Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jul 2003 05:46:02 +1000
From:      Peter Jeremy <peterjeremy@optushome.com.au>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/lib/libc/stdio vfscanf.c
Message-ID:  <20030702194602.GB21606@cirb503493.alcatel.com.au>
In-Reply-To: <20030628090418.GA30292@HAL9000.homeunix.com>
References:  <200306280903.h5S936Em045685@repoman.freebsd.org> <20030628090418.GA30292@HAL9000.homeunix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jun 28, 2003 at 02:04:19AM -0700, David Schultz wrote:
>On Sat, Jun 28, 2003, David Schultz wrote:
>>   Revamp scanf's floating-point-parsing algorithm to support
>>   [+|-]Inf, [+|-]NaN, nan(...), and hexidecimal FP constants.
...
>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.

vfscanf() does numeric conversion by calling strtoX() functions as
appropriate.  One side-effect of this is that vfscanf() needs to
replicate the number parsing code in the strtoX() functions to
convert the incoming FILE* stream into a character array as needed
by strtoX() functions.  This conversion also results in the 512
character limit on numeric strings.

It would seem cleaner to use a common underlying set of conversion
functions, similar to strtoX() but taking taking a FILE* and a width
instead of a char*.  The strtoX() functions can hand-craft the FILE
structure much as sscanf() does.

Benefits:
- Removal of functionally duplicated code (vfscanf.c:parsefloat()
  and CT_INT code in vfscanf())
- Removal of arbitrary(?) 512 char numeric conversion limit

Disadvantages:
- Additional effort to develop/maintain new code
- Some additional overhead in the strtoX() functions to build the FILE
  structure.

Comments?

Peter



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030702194602.GB21606>