[PATCH] nano version of sscanf does not work with %F %G and %E (capital letters) specifiers
Igor Venevtsev
igor.venevtsev@gmail.com
Tue Feb 2 10:55:00 GMT 2016
Here is test case and expected output produced by host gcc:
bash-4.3$ cat nano-sscanf-F-E-G.c && gcc nano-sscanf-F-E-G.c && ./a.out
#include <stdio.h>
float F = 0, E = 0, G = 0;
int main()
{
char *in = "356.3e+2\n";
sscanf(in, "%F\n", &F);
sscanf(in, "%E\n", &E);
sscanf(in, "%G\n", &G);
fprintf(stderr, ":%F: :%E: :%G:\n", F, E, G);
return 0;
}
void __attribute__((noreturn)) exit(int code) {
for (;;)
asm volatile ("int $0x80" : : "a"(1), "b"(code));
}
int write(int fd, char* buf, int size)
{
asm volatile ("int $0x80" : : "a"(4), "b"(fd), "c"(buf), "d"(size));
}
void __attribute__((weak)) _start()
{
exit(main());
}
:35630.000000: :3.563000E+04: :35630:
Here is an output produced by newlib configured with
--newlib-enable-nano-formatted-io knob:
bash-4.3$ gcc -m32 nano-sscanf-F-E-G.c -I i386-elf/include/ -nostdlib
i386-elf/lib/libc.a i386-elf/lib/libnosys.a -u _printf_float -u
_scanf_float && ./a.out
:F-07: :4.988623E-43: :4.98862E-43:
Please find a patch in attachment
Thanks, Igor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-newlib-libc-stdio-nano-vfscanf.c-Fix-F-G-and-E-speci.patch
Type: application/octet-stream
Size: 812 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20160202/d2be2818/attachment.obj>
More information about the Newlib
mailing list