We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With the following code:
#include <stdio.h> #ifdef USE_NANOPRINTF #define NANOPRINTF_IMPLEMENTATION #define NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS 1 #define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 1 #define NANOPRINTF_USE_FLOAT_FORMAT_SPECIFIERS 1 #define NANOPRINTF_USE_LARGE_FORMAT_SPECIFIERS 1 #define NANOPRINTF_USE_BINARY_FORMAT_SPECIFIERS 1 #define NANOPRINTF_USE_WRITEBACK_FORMAT_SPECIFIERS 1 #include "nanoprintf.h" #define snprintf npf_snprintf #endif int main() { char output[100]; snprintf(output, sizeof(output), "%02.1d", 0); printf("%s\n", output); }
when compiled without USE_NANOPRINTF, I get an output of 0, whereas when using nanoprintf, 00 is output:
0
00
$ gcc test.c -o default $ gcc -DUSE_NANOPRINTF test.c -o nanoprintf $ ./default; ./nanoprintf 0 00
Nanoprintf's behavior is invalid because the C standard states that:
For d, i, o, u, x, and X conversions, if a precision is specified, the 0 flag is ignored.
The current trunk version of nanoprintf fails to do so.
The text was updated successfully, but these errors were encountered:
Thanks for the report! I'll investigate this ASAP, sorry!
Sorry, something went wrong.
With #245 and your test driver, I get:
❯ gcc test.c -o default ❯ gcc -DUSE_NANOPRINTF test.c -o npf_test ❯ ./default;./npf_test 0 0
I'll cut a new release for this after I merge it.
Released v0.3.4 with this fix. https://github.com/charlesnicholson/nanoprintf/releases/tag/v0.3.4
Thanks again! I even had it as a requirement in the implementation comments, but didn't adhere to it. Sigh.
No branches or pull requests
With the following code:
when compiled without USE_NANOPRINTF, I get an output of
0
, whereas when using nanoprintf,00
is output:$ gcc test.c -o default $ gcc -DUSE_NANOPRINTF test.c -o nanoprintf $ ./default; ./nanoprintf 0 00
Nanoprintf's behavior is invalid because the C standard states that:
The current trunk version of nanoprintf fails to do so.
The text was updated successfully, but these errors were encountered: