lkml.org 
[lkml]   [2003]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectwhy does sscanf() does not interpret number length attributes?
I needed a conversion from hex-string to integer and found
this mail from Linus suggesting sscanf:

http://marc.theaimsgroup.com/?l=linux-kernel&m=101414195507893&w=2

but sscanf in linux-2.5/lib/vsprintf.c interpretes length attributes
only when the type is a string. It uses simple_strtoul() and it will
read the buffer until it finds a non-(hex)digit.

int i;
char str[] ="34AFFE45XYZ";
sscanf(str, "%1x", &i);

i will be '0x34AFFE45' instead of the expected '3'.

Is this behaviour intended or is just nobody caring about?


thanks
Kay

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.044 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site