refactor: remove usage of locale dependent std::isspace#14585
Merged
maflcko merged 1 commit intobitcoin:masterfrom Oct 28, 2018
Merged
refactor: remove usage of locale dependent std::isspace#14585maflcko merged 1 commit intobitcoin:masterfrom
maflcko merged 1 commit intobitcoin:masterfrom
Conversation
cc9c10c to
873e114
Compare
Contributor
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
55f25ff to
44022c4
Compare
…..) (uint256), DecodeBase58(...), ParseMoney(...) and ParseHex(...)
44022c4 to
15db77f
Compare
Member
|
utACK 15db77f |
Member
|
utACK 15db77f |
Empact
reviewed
Oct 27, 2018
| * @param[in] c character to test | ||
| * @return true if the argument is a whitespace character; otherwise false | ||
| */ | ||
| constexpr inline bool IsSpace(char c) noexcept { |
Contributor
There was a problem hiding this comment.
nit: constexpr implies inline
https://en.cppreference.com/w/cpp/language/constexpr
Empact
reviewed
Oct 27, 2018
| * tab ('\t'), and vertical tab ('\v'). | ||
| * | ||
| * This function is locale independent. Under the C locale this function gives the | ||
| * same result as std::isspace. |
Contributor
There was a problem hiding this comment.
nit: Could be more clear: ", giving the same result as std::isspace does under the C locale."
Contributor
|
Could include a test comparing its output to |
Contributor
|
utACK 15db77f |
Member
|
ACK 15db77f Tested the same poc, other interesting locales: LC_ALL=it_IT.ISO8859-15 ./poc
0 0 1
LC_ALL=uk_UA.KOI8-U ./poc
0 1 0
LC_ALL=hu_HU.ISO8859-2 ./poc
0 0 1 |
pull bot
pushed a commit
to jaschadub/bitcoin
that referenced
this pull request
Oct 28, 2018
…isspace 15db77f Don't rely on locale dependent functions in base_blob<BITS>::SetHex(...) (uint256), DecodeBase58(...), ParseMoney(...) and ParseHex(...) (practicalswift) Pull request description: Don't rely on locale dependent function `std::isspace` in `base_blob<BITS>::SetHex(...)` (uint256), `DecodeBase58(...)`, `ParseMoney(...)` and `ParseHex(...)`. Rationale: ``` $ uname -s Darwin $ cat poc.cpp #include <iostream> #include <locale> int main(void) { setlocale(LC_ALL, ""); std::cout << std::isspace(133) << ' ' << std::isspace(154) << ' ' << std::isspace(160); std::cout << '\n'; } $ clang++ -o poc poc.cpp $ ./poc 1 0 1 $ LC_ALL=en_US ./poc 1 0 1 $ LC_ALL=C ./poc 0 0 0 $ LC_ALL=ru_RU.KOI8-R ./poc # an "interesting" locale 0 1 0 ``` Tree-SHA512: 4eafb267342b8a777da6cca07c353afd1f90f3fc1d91e01f526f1b384a2b97c1da25b7bd7dfc300655182a4eaec6a4bea855a45723ab53c750a734b60e1e3c9f
PastaPastaPasta
pushed a commit
to PastaPastaPasta/dash
that referenced
this pull request
Aug 16, 2021
…isspace 15db77f Don't rely on locale dependent functions in base_blob<BITS>::SetHex(...) (uint256), DecodeBase58(...), ParseMoney(...) and ParseHex(...) (practicalswift) Pull request description: Don't rely on locale dependent function `std::isspace` in `base_blob<BITS>::SetHex(...)` (uint256), `DecodeBase58(...)`, `ParseMoney(...)` and `ParseHex(...)`. Rationale: ``` $ uname -s Darwin $ cat poc.cpp #include <iostream> #include <locale> int main(void) { setlocale(LC_ALL, ""); std::cout << std::isspace(133) << ' ' << std::isspace(154) << ' ' << std::isspace(160); std::cout << '\n'; } $ clang++ -o poc poc.cpp $ ./poc 1 0 1 $ LC_ALL=en_US ./poc 1 0 1 $ LC_ALL=C ./poc 0 0 0 $ LC_ALL=ru_RU.KOI8-R ./poc # an "interesting" locale 0 1 0 ``` Tree-SHA512: 4eafb267342b8a777da6cca07c353afd1f90f3fc1d91e01f526f1b384a2b97c1da25b7bd7dfc300655182a4eaec6a4bea855a45723ab53c750a734b60e1e3c9f
dzutto
pushed a commit
to dzutto/dash
that referenced
this pull request
Sep 9, 2021
…isspace 15db77f Don't rely on locale dependent functions in base_blob<BITS>::SetHex(...) (uint256), DecodeBase58(...), ParseMoney(...) and ParseHex(...) (practicalswift) Pull request description: Don't rely on locale dependent function `std::isspace` in `base_blob<BITS>::SetHex(...)` (uint256), `DecodeBase58(...)`, `ParseMoney(...)` and `ParseHex(...)`. Rationale: ``` $ uname -s Darwin $ cat poc.cpp #include <iostream> #include <locale> int main(void) { setlocale(LC_ALL, ""); std::cout << std::isspace(133) << ' ' << std::isspace(154) << ' ' << std::isspace(160); std::cout << '\n'; } $ clang++ -o poc poc.cpp $ ./poc 1 0 1 $ LC_ALL=en_US ./poc 1 0 1 $ LC_ALL=C ./poc 0 0 0 $ LC_ALL=ru_RU.KOI8-R ./poc # an "interesting" locale 0 1 0 ``` Tree-SHA512: 4eafb267342b8a777da6cca07c353afd1f90f3fc1d91e01f526f1b384a2b97c1da25b7bd7dfc300655182a4eaec6a4bea855a45723ab53c750a734b60e1e3c9f
UdjinM6
added a commit
to dashpay/dash
that referenced
this pull request
Sep 9, 2021
Merge bitcoin bitcoin#14585, bitcoin#14599: Use functions guaranteed to be locale independent
gades
pushed a commit
to cosanta/cosanta-core
that referenced
this pull request
May 9, 2022
…isspace 15db77f Don't rely on locale dependent functions in base_blob<BITS>::SetHex(...) (uint256), DecodeBase58(...), ParseMoney(...) and ParseHex(...) (practicalswift) Pull request description: Don't rely on locale dependent function `std::isspace` in `base_blob<BITS>::SetHex(...)` (uint256), `DecodeBase58(...)`, `ParseMoney(...)` and `ParseHex(...)`. Rationale: ``` $ uname -s Darwin $ cat poc.cpp #include <iostream> #include <locale> int main(void) { setlocale(LC_ALL, ""); std::cout << std::isspace(133) << ' ' << std::isspace(154) << ' ' << std::isspace(160); std::cout << '\n'; } $ clang++ -o poc poc.cpp $ ./poc 1 0 1 $ LC_ALL=en_US ./poc 1 0 1 $ LC_ALL=C ./poc 0 0 0 $ LC_ALL=ru_RU.KOI8-R ./poc # an "interesting" locale 0 1 0 ``` Tree-SHA512: 4eafb267342b8a777da6cca07c353afd1f90f3fc1d91e01f526f1b384a2b97c1da25b7bd7dfc300655182a4eaec6a4bea855a45723ab53c750a734b60e1e3c9f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Don't rely on locale dependent function
std::isspaceinbase_blob<BITS>::SetHex(...)(uint256),DecodeBase58(...),ParseMoney(...)andParseHex(...).Rationale: