Page MenuHomePhabricator

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

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

Details

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.Nov 16 2024, 09:20
PiRK planned changes to this revision.Nov 16 2024, 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

Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/init.cpp
1380 ↗(On Diff #50885)
This revision is now accepted and ready to land.Nov 18 2024, 09:16