mailing list of musl libc
 help / color / mirror / code / Atom feed
* fscanf question
@ 2014-08-07  9:55 林冠儒
  2014-08-07 16:09 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: 林冠儒 @ 2014-08-07  9:55 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

I use libc-testsuite and test for fscanf function.
I found that the result is different from glibc.
In this case:
     i = x = y = -1;
     i = fscanf( "tmp.txt", "%5i%2i" , &x, &y)
     printf(" i = %d, x = %d, y = %d" , i , x , y);

tmp.txt content >> "0x12 0x34"

In glibc, it will print >> "i = 2 , x = 18, y = 0"
In musl-libc will print >> "i = 1 , x = 18 , y = -1"

In this case, y's value should be "0x"
I wonder that "0x" is equal to "0" and should be counted as matched string
or not?

It would be very helpful if you email me back and tell me what's the problem
Sorry with my poor english!

[-- Attachment #2: Type: text/html, Size: 1046 bytes --]

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

* Re: fscanf question
  2014-08-07  9:55 fscanf question 林冠儒
@ 2014-08-07 16:09 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2014-08-07 16:09 UTC (permalink / raw)
  To: musl

On Thu, Aug 07, 2014 at 05:55:56PM +0800, 林冠儒 wrote:
> I use libc-testsuite and test for fscanf function.
> I found that the result is different from glibc.
> In this case:
>      i = x = y = -1;
>      i = fscanf( "tmp.txt", "%5i%2i" , &x, &y)
>      printf(" i = %d, x = %d, y = %d" , i , x , y);
> 
> tmp.txt content >> "0x12 0x34"
> 
> In glibc, it will print >> "i = 2 , x = 18, y = 0"
> In musl-libc will print >> "i = 1 , x = 18 , y = -1"
> 
> In this case, y's value should be "0x"
> I wonder that "0x" is equal to "0" and should be counted as matched string
> or not?
> 
> It would be very helpful if you email me back and tell me what's the problem
> Sorry with my poor english!

This is related to glibc bug #12701:

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

glibc is wrong here.

Rich


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

end of thread, other threads:[~2014-08-07 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-07  9:55 fscanf question 林冠儒
2014-08-07 16:09 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).