cvs commit: src/lib/libc/stdio vfscanf.c

David Schultz das at FreeBSD.org
Sat Jun 28 02:04:22 PDT 2003


On Sat, Jun 28, 2003, David Schultz wrote:
> das         2003/06/28 02:03:05 PDT
> 
>   FreeBSD src repository
> 
>   Modified files:
>     lib/libc/stdio       vfscanf.c 
>   Log:
>   Revamp scanf's floating-point-parsing algorithm to support
>   [+|-]Inf, [+|-]NaN, nan(...), and hexidecimal FP constants.
>   While here, add %a and %A, which are aliases for %e, and
>   add support for long doubles.

The new code should correctly parse any well-formed floating point
number, but if you notice any problems, set (extern int) scanfdebug
to 1.  This will cause scanf() to dump core if it notices that
strtod() disagrees with it about how long the number is.  The two
are known to disagree in exactly one case, namely, the 'nan(...)'
form.  POSIX allows any alphanumeric string to appear in the
parentheses, but strtod() only accepts hexadecimal as it should.
Fortunately, we get correct behavior anyway, since the interpretation
of such a sequence is implementation-defined.


More information about the cvs-all mailing list