public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* why does sscanf() does not interpret number length attributes?
@ 2003-07-02 20:34 Kay Sievers
  2003-07-02 20:55 ` Richard B. Johnson
  2003-07-02 23:00 ` Stephen Wille Padnos
  0 siblings, 2 replies; 4+ messages in thread
From: Kay Sievers @ 2003-07-02 20:34 UTC (permalink / raw)
  To: linux-kernel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-02 22:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-02 20:34 why does sscanf() does not interpret number length attributes? Kay Sievers
2003-07-02 20:55 ` Richard B. Johnson
2003-07-02 22:26   ` Kay Sievers
2003-07-02 23:00 ` Stephen Wille Padnos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox