[PATCH v9 1/3] cmdline: use C standard library as number parser

Burakov, Anatoly anatoly.burakov at intel.com
Fri May 9 15:42:39 CEST 2025


On 5/9/2025 3:39 PM, 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 couple of quirks:
> 
> - We did not consider "negative" numbers to be valid for anything other
>    than base-10 numbers, whereas C standard library does. Adjust the tests
>    to match the new behavior.
> - We did not consider numbers such as "+4" to be valid, whereas C
>    standard library does. Adjust the tests to match the new behavior.
> - C standard library's strtoull does not do range checks on negative
>    numbers, so we have to parse knowingly-negative numbers as signed.

<snip>

> - C standard library does not support binary numbers, so we keep around the
>    relevant parts of the custom parser in place to support binary numbers.

Missed updating this part. Better wording:

cmdline: use C standard library as number parser

- Some C standard library versions do not support binary numbers, so we 
keep around the relevant parts of the custom parser in place to support 
binary numbers. However, since those libc versions that do support them, 
also support them being negative, allow negative binary as well.

-- 
Thanks,
Anatoly


More information about the dev mailing list