Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
From: "Dave Korn" <dave.korn@artimi.com>
To: <cygwin@cygwin.com>
Cc: <newlib@sources.redhat.com>
Subject: RE: sscanf problem
Date: Mon, 4 Apr 2005 19:06:42 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
In-Reply-To: <SERRANOBPXzCZZuozJ700000037@SERRANO.CAM.ARTIMI.COM>
Message-ID: <SERRANO66UDeuXqq5z200000038@SERRANO.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 04 Apr 2005 18:06:46.0982 (UTC) FILETIME=[10F11660:01C53941]

----Original Message----
>From: Dave Korn
>Sent: 04 April 2005 18:51

> ----Original Message----
>> From: Michael Hines
>> Sent: 04 April 2005 19:43
> 
>> The following program prints
>> i=1 x=0
>> instead of
>> i=0 x=10
>> when using the latest version of cygwin1.dll.
>> 
>> 
>> #include <stdio.h>
>> int main() {
>>          int i;
>>          double x;
>>          x = 10;
>>          i = sscanf("n", "%lf", &x);
>>          printf("i=%d x=%g\n", i, x);
>>          return 0;
>> }
>> 
>> 
>> -Michael Hines
> 
> 
>   Heh, the interminable newlib-sscanf-bug strikes again!  It's mis-parsing
> the n as being the first letter of 'nan', which is a valid input to %f. 
> CV sent a patch upstream to the newlib maintainers last week but I guess
> it hasn't made it into the source yet.


  No, hang on, on checking the newlib-l archive that seems to have been
something to do with a zero exponent.  This is a separate bug: it accepts
the first one or two characters of 'nan' and says "ok, everything's still
good", and then because it's reached the end of the string it treats that as
a successful parse; it forgets to verify that it doesn't have an outstanding
half-formed NaN.  I'll post a (provisional) patch shortly.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
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/

