Don’t depend on locale when trimming strings.
Add TrimString(…)
tests.
Add boost::algorithm::trim
and boost::trim
to list of locale dependent functions we want to avoid.
Don’t depend on locale when trimming strings.
Add TrimString(…)
tests.
Add boost::algorithm::trim
and boost::trim
to list of locale dependent functions we want to avoid.
766@@ -766,8 +767,6 @@ static std::string readStdin()
767 if (ferror(stdin))
768 throw std::runtime_error("error reading stdin");
769
770- boost::algorithm::trim_right(ret);
What is the motivation for locale independent trimming?
See the developer notes:
“Avoid using locale dependent functions if possible. You can use the provided lint-locale-dependence.sh
to check for accidental use of locale dependent functions.
Rationale: Unnecessary locale dependence can cause bugs that are very tricky to isolate and fix.”
792@@ -794,7 +793,7 @@ static int CommandLineRawTx(int argc, char* argv[])
793 // param: hex-encoded bitcoin transaction
794 std::string strHexTx(argv[1]);
795 if (strHexTx == "-") // "-" implies standard input
796- strHexTx = readStdin();
797+ strHexTx = TrimString(readStdin());