mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12740 from ethereum/remove-locale-dependent-operations
Replace all locale-dependent operations with locale-agnostic counterparts
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/CommonIO.h>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
@@ -216,7 +217,7 @@ string BytesUtils::formatString(bytes const& _bytes, size_t _cutOff)
|
||||
os << "\\n";
|
||||
break;
|
||||
default:
|
||||
if (isprint(v))
|
||||
if (isPrint(static_cast<char>(v)))
|
||||
os << v;
|
||||
else
|
||||
os << "\\x" << toHex(v, HexCase::Lower);
|
||||
|
||||
@@ -762,13 +762,16 @@ string TestFileParser::Scanner::scanString()
|
||||
// TODO: use fromHex() from CommonData
|
||||
char TestFileParser::Scanner::scanHexPart()
|
||||
{
|
||||
auto toLower = [](char _c) -> char { return tolower(_c, locale::classic()); };
|
||||
auto isDigit = [](char _c) -> bool { return isdigit(_c, locale::classic()); };
|
||||
|
||||
advance(); // skip 'x'
|
||||
|
||||
int value{};
|
||||
if (isdigit(current()))
|
||||
if (isDigit(current()))
|
||||
value = current() - '0';
|
||||
else if (tolower(current()) >= 'a' && tolower(current()) <= 'f')
|
||||
value = tolower(current()) - 'a' + 10;
|
||||
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
|
||||
value = toLower(current()) - 'a' + 10;
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(TestParserError("\\x used with no following hex digits."));
|
||||
|
||||
@@ -777,10 +780,10 @@ char TestFileParser::Scanner::scanHexPart()
|
||||
return static_cast<char>(value);
|
||||
|
||||
value <<= 4;
|
||||
if (isdigit(current()))
|
||||
if (isDigit(current()))
|
||||
value |= current() - '0';
|
||||
else if (tolower(current()) >= 'a' && tolower(current()) <= 'f')
|
||||
value |= tolower(current()) - 'a' + 10;
|
||||
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
|
||||
value |= toLower(current()) - 'a' + 10;
|
||||
|
||||
advance();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user