This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/18246] scanf "%2d" can incorrectly parse "0x" same for "%2f" with "1e"


https://sourceware.org/bugzilla/show_bug.cgi?id=18246

will bradshaw <wbrad.vt at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wbrad.vt at gmail dot com

--- Comment #3 from will bradshaw <wbrad.vt at gmail dot com> ---
what is the appropriate result for:

#include <stdio.h>
int main()
{
int x,z;
int r;
char c;

r = sscanf("0x12", "%2i%c%d", &x,&c,&z);
        printf("got %d fields (x=%d,c=%c,z=%d)\n", r,x,c,z);
}

i get:

got 3 fields (x=0,c=1,z=2)

I believe I should get:

got 3 fields (x=0,c=x,z=12)

but I think the answer may also be to get 0 fields. I'm really not sure. I need
input from someone intimately familiar with scanf semantics.

Additionally it does not appear that float parsing follows width specifiers for
parsing of NaN inf or infinity. If someone has a careful definition of scanf
semantics that would also be appreciated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]