Fix strtod() flaw.
Sergei Organov
osv@javad.com
Tue Dec 27 19:00:00 GMT 2005
Hello,
strtod() bundled with eCos considers 'd' and 'D' to be synonyms for 'e'
and 'E' in floating point numbers though according to specification only
'e' and 'E' are allowed. The patch below fixes it.
diff -a -u -r1.1.1.1 strtod.cxx
--- packages/language/c/libc/stdlib/current/src/strtod.cxx 7 Dec 2005 12:06:34 -0000 1.1.1.1
+++ packages/language/c/libc/stdlib/current/src/strtod.cxx 27 Dec 2005 18:22:28 -0000
@@ -83,7 +83,7 @@
// MACROS
-#define Ise(c) ((c == 'e') || (c == 'E') || (c == 'd') || (c == 'D'))
+#define Ise(c) ((c == 'e') || (c == 'E'))
#define Issign(c) ((c == '-') || (c == '+'))
#define Val(c) ((c - '0'))
@@ -219,7 +219,7 @@
if(Ise(*nptr))
{
conv_done = 1;
- if(*++nptr != '\0') /* skip e|E|d|D */
+ if(*++nptr != '\0') /* skip e|E */
{ /* ! ([nptr]xxx[.[yyy]]e) */
while(isspace(*nptr)) nptr++; /* Ansi allows spaces after e */
diff -a -u -r1.1.1.1 ChangeLog
--- packages/language/c/libc/stdlib/current/ChangeLog 7 Dec 2005 12:06:34 -0000 1.1.1.1
+++ packages/language/c/libc/stdlib/current/ChangeLog 27 Dec 2005 18:42:26 -0000
@@ -1,3 +1,8 @@
+2005-12-27 Sergei Organov <osv@javad.com>
+
+ * src/strtod.cxx (Ise): 'd' and 'D' aren't allowed in floating
+ formats.
+
2004-08-18 Fredrik Hederstierna <fredrik@wespot.com>
2004-08-18 Jonathan Larmour <jifl@eCosCentric.com>
More information about the Ecos-patches
mailing list