mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
refactor: Remove unused ParsePrechecks from ParseIntegral
Also:
* Remove redundant {} from return statement
* Add missing failing c-string test case and "-" and "+" strings
* Add missing failing test cases for non-int32_t integral types
This commit is contained in:
@@ -281,16 +281,11 @@ std::string DecodeBase32(const std::string& str, bool* pf_invalid)
|
||||
return std::string((const char*)vchRet.data(), vchRet.size());
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool ParsePrechecks(const std::string&);
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
bool ParseIntegral(const std::string& str, T* out)
|
||||
{
|
||||
static_assert(std::is_integral<T>::value);
|
||||
if (!ParsePrechecks(str)) {
|
||||
return false;
|
||||
}
|
||||
// Replicate the exact behavior of strtol/strtoll/strtoul/strtoull when
|
||||
// handling leading +/- for backwards compatibility.
|
||||
if (str.length() >= 2 && str[0] == '+' && str[1] == '-') {
|
||||
|
||||
Reference in New Issue
Block a user