mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 06:55:32 +01:00
Merge #13671: Remove the boost/algorithm/string/case_conv.hpp dependency
b193d5a443Removes the Boost case_conv.hpp dependency. (251)7a208d9fadImplements custom tolower and toupper functions. (251)e2ba043b8dImplements ParseNetwork unit test. (251) Pull request description: This pull request removes the `boost/algorithm/string/case_conv.hpp` dependency from the project. `boost/algorithm/string/case_conv.hpp` is included for the `boost::to_lower` and `boost::to_upper` template functions. We can replace the calls to these functions with straightforward alternative implementations that use the C++ Standard Library, because the functions are called with `std::string` objects that use standard 7-bit ASCII characters as argument. The refactored implementation should work without the explicit `static_cast<unsigned char>` cast and `unsigned char` lambda return type. Both have been added defensively and to be explicit. Especially in case of the former, behaviour is undefined (potentially result in a crash) if the `std::toupper` argument is not an `unsigned char`. A potential alternative, maybe even preferred, implementation to address the `boost::to_lower` function call in `ParseNetwork(std::string)` could have been: ```c++ if (net == "ipv4" || net == "IPv4") return NET_IPV4; if (net == "ipv6" || net == "IPv6") return NET_IPV6; ``` This alternative implementation would however change the external behaviour of `ParseNetwork(std::string)`. This pull requests includes a unit test to validate the implementation of `ParseNetwork(std::string)` prior and after the removal of the `case_conv.hpp` dependency. `boost/algorithm/string/case_conv.hpp` has been removed from the `EXPECTED_BOOST_INCLUDES` in `test/lint/lint-includes.sh` because it is no longer required. Tree-SHA512: d803ae709f2368a3efb223097384a722436955bce0c44a1a5cffd0abb3164be0cce85ba0e9ebd9408166df3f1a95ea0c0d29e3a2534af2fae206c0419d67fde9
This commit is contained in:
@@ -47,7 +47,6 @@ fi
|
||||
|
||||
EXPECTED_BOOST_INCLUDES=(
|
||||
boost/algorithm/string.hpp
|
||||
boost/algorithm/string/case_conv.hpp
|
||||
boost/algorithm/string/classification.hpp
|
||||
boost/algorithm/string/replace.hpp
|
||||
boost/algorithm/string/split.hpp
|
||||
|
||||
@@ -11,11 +11,9 @@ KNOWN_VIOLATIONS=(
|
||||
"src/dbwrapper.cpp:.*vsnprintf"
|
||||
"src/httprpc.cpp.*trim"
|
||||
"src/init.cpp:.*atoi"
|
||||
"src/netbase.cpp.*to_lower"
|
||||
"src/qt/rpcconsole.cpp:.*atoi"
|
||||
"src/qt/rpcconsole.cpp:.*isdigit"
|
||||
"src/rest.cpp:.*strtol"
|
||||
"src/rpc/server.cpp.*to_upper"
|
||||
"src/test/dbwrapper_tests.cpp:.*snprintf"
|
||||
"src/test/getarg_tests.cpp.*split"
|
||||
"src/torcontrol.cpp:.*atoi"
|
||||
|
||||
Reference in New Issue
Block a user