X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX19V644QfLJVdysArLVutsgHL7algqNWCSJuxR9WaJ VCAnwQ+rBPp5Og From: Juan Manuel Guerrero To: djgpp-workers AT delorie DOT com Subject: Re: Bug fix for strtold Date: Tue, 8 Apr 2008 19:45:42 +0200 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200804081945.44078.juan.guerrero@gmx.de> X-Y-GMX-Trusted: 0 Reply-To: djgpp-workers AT delorie DOT com Fixed as discussed. 2008-04-08 Juan Manuel Guerrero Diffs against djgpp CVS head of 2008-04-08. * src/libc/ansi/stdlib/strtod.c: Return the mantissa of a floating point number even if the exponent could not be converted. * src/libc/c99/stdlib/strtof.c: Return the mantissa of a floating point number even if the exponent could not be converted. diff -aprNU3 djgpp.orig/src/libc/ansi/stdlib/strtod.c djgpp/src/libc/ansi/stdlib/strtod.c --- djgpp.orig/src/libc/ansi/stdlib/strtod.c 2003-11-08 12:19:40 +0000 +++ djgpp/src/libc/ansi/stdlib/strtod.c 2008-04-08 19:19:00 +0000 @@ -32,9 +32,6 @@ strtod(const char *s, char **sret) e = 0; esign = 1; - if (sret) - *sret = unconst(s, char *); - while (isspace((unsigned char) *s)) s++; @@ -75,7 +72,7 @@ strtod(const char *s, char **sret) /* Handle NAN and NAN(). */ if ( ! strnicmp( "NAN", s, 3 ) ) { - _double_union_t t; + _double_union_t t; t.d = NAN; @@ -139,10 +136,11 @@ strtod(const char *s, char **sret) } if (flags == 0) - return 0; - - if (sret) - *sret = unconst(s, char *); + { + if (sret) + *sret = unconst(s, char *); + return 0.0; + } if ((*s == 'e') || (*s == 'E')) { @@ -154,9 +152,6 @@ strtod(const char *s, char **sret) s++; esign = -1; } - if ((*s < '0') || (*s > '9')) - return r * sign; - while ((*s >= '0') && (*s <= '9')) { e *= 10; diff -aprNU3 djgpp.orig/src/libc/c99/stdlib/strtof.c djgpp/src/libc/c99/stdlib/strtof.c --- djgpp.orig/src/libc/c99/stdlib/strtof.c 2003-11-08 12:19:40 +0000 +++ djgpp/src/libc/c99/stdlib/strtof.c 2008-04-08 19:25:32 +0000 @@ -34,9 +34,6 @@ strtof(const char *s, char **sret) e = 0; esign = 1; - if (sret) - *sret = unconst(s, char *); - while (isspace((unsigned char) *s)) s++; @@ -141,12 +138,12 @@ strtof(const char *s, char **sret) d *= 0.1L; } } - if (flags == 0) - return 0; - - if (sret) - *sret = unconst(s, char *); + { + if (sret) + *sret = unconst(s, char *); + return 0.0; + } if ((*s == 'e') || (*s == 'E')) { @@ -158,9 +155,6 @@ strtof(const char *s, char **sret) s++; esign = -1; } - if ((*s < '0') || (*s > '9')) - return r * sign; - while ((*s >= '0') && (*s <= '9')) { e *= 10;