On 5/8/2025 9:27 AM, Bruce Richardson wrote:
On Wed, May 07, 2025 at 04:22:10PM +0100, Anatoly Burakov wrote:
Remove custom number parser and use C standard library instead. In order to
keep compatibility with earlier versions of the parser, we have to take
into account a few quirks:
- We do not consider "negative" numbers to be valid for anything other than
base-10 numbers, whereas C standard library does. We work around that by
forcing base-10 when parsing numbers we expect to be negative.
Is it likely to break much in the way of compatibility if we start allowing
negative non-base-10 numbers? If it simplifies our code to allow it, I'd
tend towards doing so unless there is a known case where it might cause
problems.
/Bruce
It wouldn't simplify much because we still need to use strtoll when
parsing negative numbers, because strtoull doesn't do range checks on
negative values. So it'll literally be a one line difference (use base 0
- autodetect - instead of base 10 when calling strtoll), and fewer
"invalid" tests. I can do that just for consistency sake but it's not
going to be a huge difference in terms of code.
--
Thanks,
Anatoly