HomePhabricator

util: Introduce ToIntegral<T>(const std::string&) for locale independent…

Description

util: Introduce ToIntegral<T>(const std::string&) for locale independent parsing using std::from_chars(…) (C++17)

Summary:

util: Avoid locale dependent functions strtol/strtoll/strtoul/strtoull in ParseInt32/ParseInt64/ParseUInt32/ParseUInt64

fuzz: Assert equivalence between new and old Parse{Int,Uint}{8,32,64} functions

test: Add unit tests for ToIntegral<T>(const std::string&)

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

Remove unused ParseDouble and ParsePrechecks

This is a backport of core#20457 and core#23156

Test Plan: ninja all check-all bitcoin-fuzzers

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17147

Details

Provenance
practicalswift <practicalswift@users.noreply.github.com>Authored on Sep 18 2021, 04:30
PiRKCommitted on Nov 18 2024, 10:22
PiRKPushed on Nov 18 2024, 10:22
Reviewer
Restricted Project
Differential Revision
D17147: util: Introduce ToIntegral<T>(const std::string&) for locale independent parsing using std::from_chars(…) (C++17)
Parents
rABCadc9c8e45a53: net: use Sock::WaitMany() instead of CConnman::SocketEvents()
Branches
Unknown
Tags
Unknown