On 12/17/19 7:33 PM, Tao Xu wrote:
Also fun: for "0123", we use uint64_t 83, not double 123.0. But for
"0123.", we use 123.0, not 83.
Do we really want to accept octal and hexadecimal integers?
Thank you for reminding me. Octal and hexadecimal may bring more
confusion. I will use qemu_strtou64(nptr, &suffixu, 10, &valu) and add
test for input like "0123".
Note that JSON does not permit octal numbers, but ALSO does not permit
'0123' as a valid JSON number. Of course, this parser is intended for
human users rather than a JSON parser, so silently accepting it as
decimal 123 is probably okay, but it is worth remembering that decisions
are not trivial here.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org