From owner-cvs-src@FreeBSD.ORG Sat Jul 5 22:13:06 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E4A3137B401; Sat, 5 Jul 2003 22:13:06 -0700 (PDT) Received: from HAL9000.homeunix.com (ip114.bella-vista.sfo.interquest.net [66.199.86.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23BA243FE9; Sat, 5 Jul 2003 22:13:06 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.9) with ESMTP id h665D2K5022370; Sat, 5 Jul 2003 22:13:02 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.9/Submit) id h665D2C6022369; Sat, 5 Jul 2003 22:13:02 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Sat, 5 Jul 2003 22:13:02 -0700 From: David Schultz To: Peter Jeremy Message-ID: <20030706051302.GA22242@HAL9000.homeunix.com> Mail-Followup-To: Peter Jeremy , src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org References: <200306280903.h5S936Em045685@repoman.freebsd.org> <20030628090418.GA30292@HAL9000.homeunix.com> <20030702194602.GB21606@cirb503493.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030702194602.GB21606@cirb503493.alcatel.com.au> cc: cvs-src@FreeBSD.ORG cc: src-committers@FreeBSD.ORG cc: cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/lib/libc/stdio vfscanf.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jul 2003 05:13:07 -0000 On Thu, Jul 03, 2003, Peter Jeremy wrote: > 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. > > 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. In principle, you're right, but there are a number of problems. BDE touched on the key technical issues. Another reason not to do as you suggest is that in order to seamlessly integrate the two, someone would have to overhaul the vendor's implementations of strtod() and strtodg(). Even if I wanted to do that, the ensuing political battle would likely take hours of time, whereas the present solution required 15 minutes of coding and 30 minutes of testing and debugging. > This conversion also results in the 512 > character limit on numeric strings. This is an age-old limitation. I considered removing it, but then realized that I have yet to encounter anyone who cares. 512 characters is a BIG floating point number---much larger than the precision supported by readily available hardware.