cosmopolitan/test
Gabriel Ravier 9a5d69c842
Fix scanf x specifier with string of 0 (#793)
The C standard states that, in the context of an x conversion
specifier given to scanf:
> Matches an optionally signed hexadecimal integer, whose format is
> the same as expected for the subject sequence of the strtoul
> function with the value 16 for the base argument.
- C standard, 7.23.6.2.11. The fscanf function

Cosmopolitan fails to do this, as 0 should be parsed as a 0 by such an
invocation of strtoul. Instead, cosmopolitan errors out as though such
input is invalid, which is wrong.

This means that a program such as this:

 #include <stdio.h>
 #undef NDEBUG
 #include <assert.h>

int main()
{
    int v = 0;
    assert(sscanf("0", "%x", &v) == 1);
}

will not run correctly on cosmpolitan, instead failing the assertion.

This patch fixes this, along with the associated GitHub issue,
https://github.com/jart/cosmopolitan/issues/778
2023-04-15 06:25:35 -07:00
..
dsp Rename hidden keyword to _Hide 2022-11-08 12:55:28 -08:00
libc Fix scanf x specifier with string of 0 (#793) 2023-04-15 06:25:35 -07:00
net Allow HTTP range past EOF 2022-11-07 05:52:24 -08:00
tool Update tests and CPU detection for Blink 2023-01-18 00:56:09 -08:00
test.mk Support malloc() on bare metal 2021-02-24 00:53:24 -08:00