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: <004a01c54ab6$c37b2ce0$66779b53@maison> From: "Jean-Christophe Kablitz" To: References: <4252DD31 DOT 7040409 AT redhat DOT com> Subject: Re: RFC: Fix partial NaN-parsing problem [was RE: sscanf problem] Date: Wed, 27 Apr 2005 01:22:06 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Hello, I have noticed, that, while parsing {a float_value immediately followed by 'n' or 'N'} with the "%f%c" format, the sscanf function of cygwin-1.5.16-1 behaves differently from the scanf function of cygwin-1.5.14-1. Until cygwin-1.5.14-1 (included), 'n' matches %c, while with cygwin-1.5.15-1 and cygwin-1.5-16-1, 'n' is no more assigned to %c. In the following test case, I would expect the progran to output i=2 x=1 m=a i=2 x=1 m=n that was the case until cygwin-1.5.14-1 (included). With cygwin-1.5.15-1 and cygwin-1.5-16-1, the program outputs instead i=2 x=1 m=a i=1 x=1 m=_ Maybe I have been misusing sscanf. Or there is a relationship with the NaN-parsing problem of the "newlib". Best regards. Jean-Christophe K. --- beginning of test case --- jck:/sscanf> cat ssn.c #include int main() { double x; char m; int i; x = 0.0; m = '_'; i = sscanf("1.0a", "%lf%c", &x, &m); printf("i=%d x=%g m=%c\n", i, x, m); x = 0.0; m = '_'; i = sscanf("1.0n", "%lf%c", &x, &m); printf("i=%d x=%g m=%c\n", i, x, m); return 0; } jck:/sscanf> gcc -O0 ssn.c -o ssn.exe jck:/sscanf> ./ssn.exe i=2 x=1 m=a i=1 x=1 m=_ --- end of test case --- ----- Original Message ----- From: "Jeff Johnston" To: "Dave Korn" Cc: ; Sent: Tuesday, April 05, 2005 8:47 PM Subject: Re: RFC: Fix partial NaN-parsing problem [was RE: sscanf problem] > 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/ > -- 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/