mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #14599: Use functions guaranteed to be locale independent (IsDigit, ToLower) in {Format,Parse}Money(...), uint256::SetHex(...), etc. Remove the use of locale dependent boost::is_space(...)
8931a95beca2b959c7ee73b154ce8a69acbe8599 Include util/strencodings.h which is required for IsSpace(...) (practicalswift) 7c9f7907615ff9c10a56ede5a8e47c91cb20fe3b Update KNOWN_VIOLATIONS: Remove fixed violations (practicalswift) 587924f0006d2eb9b8218b6abffe181bb9c27513 Use IsSpace(...) instead of boost::is_space (practicalswift) c5fd143edb85d0c181e21a429f9e29d12a611831 Use ToLower(...) instead of std::tolower (practicalswift) e70cc8983c570bbacee37a67df86b1bf959894df Use IsDigit(...) instead of std::isdigit (practicalswift) Pull request description: * Use `ToLower(...)` instead of `std::tolower`. `std::tolower` is locale dependent. * Use `IsDigit(...)` instead of `std::isdigit`. Some implementations (e.g. Microsoft in 1252 codepage) may classify single-byte characters other than `[0-9]` as digits. * Update `KNOWN_VIOLATIONS`: Remove fixed violations. * ~~Replace use of locale dependent Boost trim (`boost::trim`) with locale independent `TrimString`.~~ * Use` IsSpace(...)` instead of `boost::is_space` Tree-SHA512: defed016136b530b723fa185afdbd00410925a748856ba3afa4cee60f61a67617e30f304f2b9991a67b5fe075d9624f051e14342aee176f45fbc024d59e1aa82
This commit is contained in:
parent
6bb5dfe2d9
commit
fa67372efe
@ -20,6 +20,7 @@
|
||||
#include <netbase.h>
|
||||
#include <rpc/server.h>
|
||||
#include <rpc/client.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
@ -229,7 +230,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
|
||||
if (lastResult.isArray())
|
||||
{
|
||||
for(char argch: curarg)
|
||||
if (!std::isdigit(argch))
|
||||
if (!IsDigit(argch))
|
||||
throw std::runtime_error("Invalid result query");
|
||||
subelement = lastResult[atoi(curarg.c_str())];
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <test/test_dash.h>
|
||||
|
||||
@ -17,7 +18,7 @@ static void ResetArgs(const std::string& strArg)
|
||||
{
|
||||
std::vector<std::string> vecArg;
|
||||
if (strArg.size())
|
||||
boost::split(vecArg, strArg, boost::is_space(), boost::token_compress_on);
|
||||
boost::split(vecArg, strArg, IsSpace, boost::token_compress_on);
|
||||
|
||||
// Insert dummy executable name:
|
||||
vecArg.insert(vecArg.begin(), "testdash");
|
||||
|
@ -37,7 +37,7 @@ void base_blob<BITS>::SetHex(const char* psz)
|
||||
psz++;
|
||||
|
||||
// skip 0x
|
||||
if (psz[0] == '0' && tolower(psz[1]) == 'x')
|
||||
if (psz[0] == '0' && ToLower((unsigned char)psz[1]) == 'x')
|
||||
psz += 2;
|
||||
|
||||
// hex string to uint
|
||||
|
@ -20,7 +20,7 @@ std::string FormatMoney(const CAmount& n)
|
||||
|
||||
// Right-trim excess zeros before the decimal point:
|
||||
int nTrim = 0;
|
||||
for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i)
|
||||
for (int i = str.size()-1; (str[i] == '0' && IsDigit(str[i-2])); --i)
|
||||
++nTrim;
|
||||
if (nTrim)
|
||||
str.erase(str.size()-nTrim, nTrim);
|
||||
@ -49,7 +49,7 @@ bool ParseMoney(const char* pszIn, CAmount& nRet)
|
||||
{
|
||||
p++;
|
||||
int64_t nMult = COIN / 10;
|
||||
while (isdigit(*p) && (nMult > 0))
|
||||
while (IsDigit(*p) && (nMult > 0))
|
||||
{
|
||||
nUnits += nMult * (*p++ - '0');
|
||||
nMult /= 10;
|
||||
@ -58,7 +58,7 @@ bool ParseMoney(const char* pszIn, CAmount& nRet)
|
||||
}
|
||||
if (IsSpace(*p))
|
||||
break;
|
||||
if (!isdigit(*p))
|
||||
if (!IsDigit(*p))
|
||||
return false;
|
||||
strWhole.insert(strWhole.end(), *p);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
key.erase(is_index);
|
||||
}
|
||||
#ifdef WIN32
|
||||
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
|
||||
std::transform(key.begin(), key.end(), key.begin(), ToLower);
|
||||
if (key[0] == '/')
|
||||
key[0] = '-';
|
||||
#endif
|
||||
|
@ -6,8 +6,6 @@ KNOWN_VIOLATIONS=(
|
||||
"src/bench/string_cast.cpp.*atoi"
|
||||
"src/dash-tx.cpp.*stoul"
|
||||
"src/dash-tx.cpp.*trim_right"
|
||||
"src/dash-tx.cpp:.*atoi"
|
||||
"src/core_read.cpp.*is_digit"
|
||||
"src/dbwrapper.cpp.*stoul"
|
||||
"src/dbwrapper.cpp:.*vsnprintf"
|
||||
"src/governance/governance-validators.cpp.*isspace"
|
||||
@ -16,7 +14,6 @@ KNOWN_VIOLATIONS=(
|
||||
"src/init.cpp:.*atoi"
|
||||
"src/init.cpp:.*fprintf"
|
||||
"src/qt/rpcconsole.cpp:.*atoi"
|
||||
"src/qt/rpcconsole.cpp:.*isdigit"
|
||||
"src/rest.cpp:.*strtol"
|
||||
"src/rpc/blockchain.cpp.*atoi"
|
||||
"src/rpc/governance.cpp.*atoi"
|
||||
@ -25,20 +22,15 @@ KNOWN_VIOLATIONS=(
|
||||
"src/rpc/server.cpp.*tolower"
|
||||
"src/statsd_client.cpp:.*snprintf"
|
||||
"src/test/dbwrapper_tests.cpp:.*snprintf"
|
||||
"src/test/getarg_tests.cpp.*split"
|
||||
"src/torcontrol.cpp:.*atoi"
|
||||
"src/torcontrol.cpp:.*strtol"
|
||||
"src/uint256.cpp:.*tolower"
|
||||
"src/util/system.cpp:.*atoi"
|
||||
"src/util/system.cpp:.*tolower"
|
||||
"src/util/moneystr.cpp:.*isdigit"
|
||||
"src/util/strencodings.cpp:.*atoi"
|
||||
"src/util/strencodings.cpp:.*strtol"
|
||||
"src/util/strencodings.cpp:.*strtoll"
|
||||
"src/util/strencodings.cpp:.*strtoul"
|
||||
"src/util/strencodings.cpp:.*strtoull"
|
||||
"src/util/strencodings.h:.*atoi"
|
||||
"src/wallet/wallet.cpp:.*atoi"
|
||||
"src/util/system.cpp:.*atoi"
|
||||
"src/util/system.cpp:.*fprintf"
|
||||
)
|
||||
|
||||
REGEXP_IGNORE_EXTERNAL_DEPENDENCIES="^src/(crypto/ctaes/|leveldb/|secp256k1/|tinyformat.h|univalue/)"
|
||||
|
Loading…
Reference in New Issue
Block a user