]> Savannah Git Hosting - gnulib.git/commitdiff
strtod, strtold: Work around HP-UX 11.31/ia64 bug.
authorBruno Haible <bruno@clisp.org>
Thu, 31 Jan 2019 23:18:57 +0000 (00:18 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 31 Jan 2019 23:20:05 +0000 (00:20 +0100)
* lib/strtod.c (STRTOD): When there is an extra character after the
exponent marker 'p', reparse the number.
* doc/posix-functions/strtod.texi: Document the HP-UX 11.31 bug.
* doc/posix-functions/strtold.texi: Likewise.

ChangeLog
doc/posix-functions/strtod.texi
doc/posix-functions/strtold.texi
lib/strtod.c

index 5ab5d83cb4695884fa4e9ffa9433523ee034e71d..991db2bf2e15f6941ad0b7594e5c2bd2d1181ca8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-01-31  Bruno Haible  <bruno@clisp.org>
+
+       strtod, strtold: Work around HP-UX 11.31/ia64 bug.
+       * lib/strtod.c (STRTOD): When there is an extra character after the
+       exponent marker 'p', reparse the number.
+       * doc/posix-functions/strtod.texi: Document the HP-UX 11.31 bug.
+       * doc/posix-functions/strtold.texi: Likewise.
+
 2019-01-29  Bruno Haible  <bruno@clisp.org>
 
        strtold: Add tests.
index 72ce8bc2fa98721c97074a49fb789b50f8b28d14..ac9ed212facc2725109bea08d89097471a20e75d 100644 (file)
@@ -58,6 +58,11 @@ platforms:
 NetBSD 5.0, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1,
 Solaris 11.4, mingw, MSVC 14.
 
+@item
+In hexadecimal floats, this function allows whitespace between @samp{p}
+and the exponent on some platforms:
+HP-UX 11.31/ia64.
+
 @item
 This function returns the wrong end pointer for @samp{0x1p} on some
 platforms:
index f136c54d4727c742975eddaca31456b17ec24825..028915e2f97949b49ea79496caa75d711c48f13b 100644 (file)
@@ -57,6 +57,11 @@ glibc-2.3.2, mingw, Haiku.
 This function fails to parse C99 hexadecimal floating point on some
 platforms:
 IRIX 6.5, mingw.
+
+@item
+In hexadecimal floats, this function allows whitespace between @samp{p}
+and the exponent on some platforms:
+HP-UX 11.31/ia64.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 1d1ba2797b389bcec321d02c1bc1897984496bea..2733ff9ebafa44b4f5c45e201f6134693978735c 100644 (file)
@@ -297,7 +297,25 @@ STRTOD (const char *nptr, char **endptr)
               while (p < end && c_tolower (*p) != 'p')
                 p++;
               if (p < end && ! c_isdigit (p[1 + (p[1] == '-' || p[1] == '+')]))
-                end = p;
+                {
+                  char *dup = strdup (s);
+                  errno = saved_errno;
+                  if (!dup)
+                    {
+                      /* Not really our day, is it.  Rounding errors are
+                         better than outright failure.  */
+                      num = parse_number (s + 2, 16, 2, 4, 'p', &endbuf);
+                    }
+                  else
+                    {
+                      dup[p - s] = '\0';
+                      num = STRTOD (dup, &endbuf);
+                      saved_errno = errno;
+                      free (dup);
+                      errno = saved_errno;
+                    }
+                  end = p;
+                }
             }
         }
       else