cosmopolitan/test
Gabriel Ravier 12e07798df
Fix printf precision/field width being limited by internal buffer size (#799)
The C standard, when defining field width and precision, never gives
any limit on the values used for them (except, I believe, that they
fit within an int). In other words, if the user gives a field width of
32145 and a precision of 9218, the implementation has to handle these
values correctly. However, when such kinds of high numbers are used
with integer conversions, cosmopolitan is limited by an internal
buffer size of 144, which means precisions and field widths have to
fit within this, which violates the standard.

This means that for example, the following program:

 #include <stdio.h>
 #include <string.h>

int main()
{
    char buf2[512] = {};

    int i = snprintf(buf2, sizeof(buf2), "%.9999u", 10);
    printf("%d %zu\n", i, strlen(buf2));
}

would, instead of printing "9999 511" (the correct output), instead
print "144 144" under cosmopolitan.

This patch fixes this.
2023-04-04 14:16:34 -04:00
..
dsp Rename hidden keyword to _Hide 2022-11-08 12:55:28 -08:00
libc Fix printf precision/field width being limited by internal buffer size (#799) 2023-04-04 14:16:34 -04: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