Page MenuHomePhabricator

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

Authored by PiRK on Sat, Nov 16, 09:20.

Details

Reviewers
None
Group Reviewers
Restricted Project
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

Event Timeline

PiRK requested review of this revision.Sat, Nov 16, 09:20
PiRK planned changes to this revision.Sat, Nov 16, 09:34
PiRK added inline comments.
src/test/fuzz/string.cpp
108 ↗(On Diff #50884)

I missed the braces formatting one, will fix after clang-tidy is done complaining.

it didn't complain but fix it anyway