This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: [PATCH] Fix newly exposed bug [was RE: RFC: Fix partial NaN-parsing problem [was RE: sscanf problem]]
- From: Eric Blake <ebb9 at byu dot net>
- To: Dave Korn <dave dot korn at artimi dot com>
- Cc: 'Jeff Johnston' <jjohnstn at redhat dot com>, 'Jean-Christophe Kablitz' <jckablitz at infonie dot fr>, cygwin at cygwin dot com, newlib at sources dot redhat dot com
- Date: Fri, 29 Apr 2005 06:16:39 -0600
- Subject: Re: [PATCH] Fix newly exposed bug [was RE: RFC: Fix partial NaN-parsing problem [was RE: sscanf problem]]
- References: <SERRANOwr2UAaTzvb5Y0000017b@SERRANO.CAM.ARTIMI.COM>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Dave Korn on 4/28/2005 12:41 PM:
> Heh, actually we probably have to talk about that. The k should IIUIC be
> swallowed by the %lf and the %c should fail; this is the production
> described as NAN(n-char-sequence opt) in the C language spec, strtod
> documentation (that's 7.20.1.3.3 in WG14/N843 draft, I don't have the final
> version). And we haven't even mentioned the lack of INF support yet :)
Per POSIX,
http://www.opengroup.org/onlinepubs/009695399/functions/sscanf.html,
NAN{n-char-sequence} is implementation defined - sscanf should only accept
n-char-sequences that are also generated by the same implementation's
printf and parsed by strtod. And since newlib printf does not output any
n-char-sequence versions of NaN, sscanf should not parse them. IIUC,
n-char-sequence exists to allow implementations the ability to specify
signalling NaNs or exact bit patterns within the NaN.
All this means that I think Jeff is right that
i = sscanf ("nank", "%lf%c%n", &x, &m, &n)
should succeed on newlib, but you should also remember that it is not
portable and that on non-newlib systems it might fail.
- --
Life is short - so eat dessert first!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCciWn84KuGfSFAYARAn57AKC4NQ8N9eIfdVRw4wTqzSzkyJIbPgCffhII
wOxYCH3ae9wn47EgS0sTYGs=
=L/cl
-----END PGP SIGNATURE-----
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/