Skip to content

Conversation

@Empact
Copy link
Contributor

@Empact Empact commented Feb 12, 2020

TrimString is an existing alternative. I patterned TrimRight after it.

Note TrimString and TrimRight uses " \f\n\r\t\v" as the pattern, which is consistent with the default behavior of std::isspace.
https://en.cppreference.com/w/cpp/string/byte/isspace

@Empact Empact changed the title Replace uses of boost::trim* with non-locale-dependent alternatives Replace uses of boost::trim* with locale-independent alternatives Feb 12, 2020
@Empact
Copy link
Contributor Author

Empact commented Feb 12, 2020

Oops, should have checked outstanding PRs - #17760 covers this.
See also #17760 (now closed)

@practicalswift
Copy link
Contributor

practicalswift commented Feb 12, 2020

Concept ACK

Thanks a lot for getting rid of the use of locale dependent functions! That is appreciated. Please don't hesitate to take on some of the remaining KNOWN_VIOLATIONS in subsequent pull requests. I would be happy to review :)

@Empact Empact force-pushed the 2020-02-boost-trim branch from 7cf3e02 to f4816da Compare February 12, 2020 19:46
@practicalswift
Copy link
Contributor

ACK 7cf3e02096d7991fc144ef05f5f6b7fecd475b8c modulo that the existing TrimString should be used in both places - that way TrimRight doesn't need to be introduced and maintained :)

@Empact Empact force-pushed the 2020-02-boost-trim branch from f4816da to 392553f Compare February 12, 2020 19:55
@Empact
Copy link
Contributor Author

Empact commented Feb 12, 2020

Ok, took another look and it's straightforward to see that the value goes only to DecodeHexTx which fails on non-hex digits, so I've switched that to TrimString as well.

@practicalswift
Copy link
Contributor

ACK fbc8195427cf98bf96eb76bafda39a4f38de3cd2

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 12, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

@Empact
Copy link
Contributor Author

Empact commented Feb 13, 2020

Small fixup - used clang-format-diff.py to identify a whitespace inconsistency in the last commit:

diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index c3e08106e..15b8d3215 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(util_TrimString)
     BOOST_CHECK_EQUAL(TrimString("\t \n foo \n\tbar\t \n ", "fobar"), "\t \n foo \n\tbar\t \n ");
     BOOST_CHECK_EQUAL(TrimString("foo bar"), "foo bar");
     BOOST_CHECK_EQUAL(TrimString("foo bar", "fobar"), " ");
-    BOOST_CHECK_EQUAL(TrimString(std::string( "\0 foo \0 ", 8)), std::string("\0 foo \0", 7));
+    BOOST_CHECK_EQUAL(TrimString(std::string("\0 foo \0 ", 8)), std::string("\0 foo \0", 7));
     BOOST_CHECK_EQUAL(TrimString(std::string(" foo ", 5)), std::string("foo", 3));
     BOOST_CHECK_EQUAL(TrimString(std::string("\t\t\0\0\n\n", 6)), std::string("\0\0", 2));
     BOOST_CHECK_EQUAL(TrimString(std::string("\x05\x04\x03\x02\x01\x00", 6)), std::string("\x05\x04\x03\x02\x01\x00", 6));

@practicalswift
Copy link
Contributor

ACK 44f18a552e51cdb103845b592b87dbab571f8308

@practicalswift
Copy link
Contributor

Anyone willing to review @Empact's excellent PR? Would be really nice to move forward with this one and plug another source of locale dependency.

@l2a5b1
Copy link
Contributor

l2a5b1 commented Mar 9, 2020

ACK 44f18a5 - nice! Next boost::split 🙄

@practicalswift
Copy link
Contributor

re-ACK 4c1abe60467c1adfe0230f4bee56202150c0b134

Empact and others added 3 commits May 10, 2020 22:43
Note the only use of readStdin is fed to DecodeHexTx, which fails in
IsHex on non-hex characters as recorded in p_util_hexdigit.
@practicalswift
Copy link
Contributor

re-ACK 12c0546

Nice to see the list of places where we rely on locale dependent functions shrink :)

@DrahtBot
Copy link
Contributor

DrahtBot commented May 5, 2021

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@fanquake
Copy link
Member

@Empact Any chance you'd like to rebase this? Otherwise I can pick it up.

@fanquake
Copy link
Member

fanquake commented Sep 2, 2021

I've rebased this in #22859.

@fanquake fanquake closed this Sep 2, 2021
fanquake added a commit that referenced this pull request Sep 5, 2021
…ternatives (#18130 rebased)

696c76d tests: Add TrimString(...) tests (practicalswift)
4bf18b0 Replace use of boost::trim_right with locale-independent TrimString (Ben Woosley)
9355186 Replace use of boost::trim use with locale-independent TrimString (Ben Woosley)

Pull request description:

  This is [#18130 rebased](#18130 (comment)).

  > `TrimString` is an existing alternative.

  > Note `TrimString` uses `" \f\n\r\t\v"` as the pattern, which is consistent with the default behavior of `std::isspace`. See: https://en.cppreference.com/w/cpp/string/byte/isspace

ACKs for top commit:
  jb55:
    utACK 696c76d
  practicalswift:
    ACK 696c76d
  jonatack:
    ACK 696c76d
  theStack:
    Code-review ACK 696c76d

Tree-SHA512: 6a70e3777602dfa65a60353e5c6874eb951e4a806844cd4bdaa4237cad980a4f61ec205defc05a29f9707776835975838f6cc635259c42adfe37ceb02ba9358d
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants