Mail Archives: djgpp-workers/2008/04/08/11:19:40
Given a string like this:
"123.456 E+12"
strtof and strtod return 0.0 and point to the first character of the string,
meanwhile strtold returns the value 123.456 and points to the space character
between mantissa and "E+12". I assume that all functions should behave
identically in this case.
2008-04-08 Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
* src/libc/ansi/stdlib/strtold.c: Do not return the mantissa of a
floating point number if the exponent conversion failed.
Index: src/libc/ansi/stdlib/strtold.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/stdlib/strtold.c,v
retrieving revision 1.10
diff -U3 -r1.10 strtold.c
--- src/libc/ansi/stdlib/strtold.c 8 Nov 2003 12:19:40 -0000 1.10
+++ src/libc/ansi/stdlib/strtold.c 8 Apr 2008 15:17:32 -0000
@@ -33,9 +33,13 @@
e = ne = 0;
esign = 1;
+ if (sret)
+ *sret = unconst(s, char *);
+
while(*s && isspace((unsigned char)*s))
s++;
+ /* Handle leading sign. */
if (*s == '+')
s++;
else if (*s == '-')
@@ -137,12 +141,12 @@
ne++;
}
}
+
if (flags == 0)
- {
- if (sret)
- *sret = unconst(s, char *);
return 0.0L;
- }
+
+ if (sret)
+ *sret = unconst(s, char *);
if ((*s == 'e') || (*s == 'E'))
{
- Raw text -