# HG changeset patch # User Bruno Haible # Date 1548976737 -3600 # Node ID ecb43221748b2dd88ac0d7bff2a7fd638b8cfd48 # Parent f533980eb42fc5485f633dd756efac0a8eff2f30 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. diff -r f533980eb42f -r ecb43221748b ChangeLog --- a/ChangeLog Thu Jan 31 13:24:44 2019 -0800 +++ b/ChangeLog Fri Feb 01 00:18:57 2019 +0100 @@ -1,3 +1,11 @@ +2019-01-31 Bruno Haible + + 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 strtold: Add tests. diff -r f533980eb42f -r ecb43221748b doc/posix-functions/strtod.texi --- a/doc/posix-functions/strtod.texi Thu Jan 31 13:24:44 2019 -0800 +++ b/doc/posix-functions/strtod.texi Fri Feb 01 00:18:57 2019 +0100 @@ -59,6 +59,11 @@ 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: AIX 7.1. diff -r f533980eb42f -r ecb43221748b doc/posix-functions/strtold.texi --- a/doc/posix-functions/strtold.texi Thu Jan 31 13:24:44 2019 -0800 +++ b/doc/posix-functions/strtold.texi Fri Feb 01 00:18:57 2019 +0100 @@ -57,6 +57,11 @@ 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: diff -r f533980eb42f -r ecb43221748b lib/strtod.c --- a/lib/strtod.c Thu Jan 31 13:24:44 2019 -0800 +++ b/lib/strtod.c Fri Feb 01 00:18:57 2019 +0100 @@ -297,7 +297,25 @@ 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