Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <4252DD31.7040409@redhat.com> Date: Tue, 05 Apr 2005 14:47:13 -0400 From: Jeff Johnston User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 MIME-Version: 1.0 To: Dave Korn Cc: cygwin AT cygwin DOT com, newlib AT sources DOT redhat DOT com Subject: Re: RFC: Fix partial NaN-parsing problem [was RE: sscanf problem] References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Patch checked in. Thanks. -- Jeff J. Dave Korn wrote: > ----Original Message---- > >>From: Dave Korn >>Sent: 04 April 2005 19:07 > > >>----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. > > >> 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. > > > Ok, this is only provisional, because as I point out I'm not quite sure > about the corner case where we've refilled the buffer. It also has minor > formatting issues (slightly long lines in the comment, IMO). However, it > fixes the testcase, and I've got to go home for the evening, so here's my > work-in-progress; comments welcomed. > > ------------------------------------------------------ > dk AT mace /test/sscanf> cat ss.c > > #include > int main() { > int i; > double x; > x = 10; > i = sscanf("n", "%lf", &x); > printf("i=%d x=%g\n", i, x); > i = sscanf("nan", "%lf", &x); > printf("i=%d x=%g\n", i, x); > return 0; > } > > > > dk AT mace /test/sscanf> gcc -O0 -g ss.c -o ss.exe > dk AT mace /test/sscanf> ./ss.exe > i=0 x=10 > i=1 x=NaN > dk AT mace /test/sscanf> > ------------------------------------------------------ > > > > > > cheers, > DaveK -- 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/