bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sscanf broken?


From: matt farnsworth
Subject: sscanf broken?
Date: Wed, 12 Sep 2001 03:22:23 -0700

I expected 'sscanf(src,form,*to...)' to parse like a weak regex; but it
doesn't!

consider
 sscanf("URL http://svr.any.srv mode/1.1\n", 
        "URL http://%s mode/%d.%d", 
        &host, &maj, &min); == 3 // ok
but 
 sscanf("URL http://svr.any.srv/resource mode/1.1\n", 
        "URL http://%s/%s mode/%d.%d", 
        &host, &res, &maj, &min); == 1 // FAIL
and 
   sscanf("URL http://svr.any.srv /resource mode/1.1\n", 
        "URL http://%s /%s mode/%d.%d", 
        &host, &res, &maj, &min); == 4 // ok, but wrong params

thus shown
   sscanf requires %s to terminate with a <space>
but I expected
   %s<non-s-char> ==> {break on non-s-char}
as in
   when 'scan'ing for end of %s the first occurance of <char-after-%s>
terminates %s
thus 
   '/' was the intended delimiter, but sscanf walked until the first
space 
    eg. $1=//svr.any.srv/resource

Is this really standard behaviour?  Does this suck?
I have Mandrake 7.2 and I think glibc.2.1.3 (but can't find a test for
it )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]