18 points Forgret 1 day ago 10 comments
fjfaase 1 day ago | parent
You could add a c file with some unittests.
Forgret 1 day ago | parent
wahern 17 hours ago | parent
snprintf always null-terminates when the buffer length is greater than 0 and there's no error. That is, if snprintf returns >= 0 and the buffer length is > 0, the output is null-terminated.
This should be clear from your local snprintf(3) man page (e.g. https://man.openbsd.org/snprintf), but also see the C23 standard (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf) and POSIX (https://pubs.opengroup.org/onlinepubs/9799919799/).
s_gourichon 16 hours ago | parent
I had a bug:
u_printf( my_output_cb, NULL, "%d" NL, -42 );
prints:--42
I may have found an explanation. In u_parse_format(), case 'i': calls u_itoa( value, buffer, 10, false ); which outputs minus sign.
Then if ( number ) does if ( sign ) { output_cb( '-', ctx ); chars_written++; } which outputs another minus sign.
s_gourichon 7 hours ago | parent
Is it really possible to reconcile "no bloat" with "fully standard compliant"?
Maybe have a look at https://github.com/eyalroz/printf, if only for the test suite, which looks pretty comprehensive and still fails.
Maybe "key features" does not mean the same in all projects, making every project appear "unnecessarily bloated while missing key features" in every other context?