Page MenuHomePhabricator

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

Authored by PiRK on Sat, Nov 16, 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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

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.Mon, Nov 18, 09:16