strtod: Restore errno when successfully parsing Infinity or NaN.
authorBruno Haible <bruno@clisp.org>
Fri, 7 Jan 2011 20:27:23 +0000 (21:27 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 7 Jan 2011 20:27:23 +0000 (21:27 +0100)
* lib/strtod.c (strtod): After successfully parsing an Infinity or NaN,
restore the original errno.

ChangeLog
lib/strtod.c

index 214023b..662bedb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-01-07  Bruno Haible  <bruno@clisp.org>
 
+       strtod: Restore errno when successfully parsing Infinity or NaN.
+       * lib/strtod.c (strtod): After successfully parsing an Infinity or NaN,
+       restore the original errno.
+
+2011-01-07  Bruno Haible  <bruno@clisp.org>
+
        remove test: Avoid failure on HP-UX 11.
        * tests/test-remove.c (main): Allow EEXIST as alternative error code.
 
index b642589..bf6955a 100644 (file)
@@ -303,6 +303,7 @@ strtod (const char *nptr, char **endptr)
           && c_tolower (s[4]) == 'y')
         s += 5;
       num = HUGE_VAL;
+      errno = saved_errno;
     }
   else if (c_tolower (*s) == 'n'
            && c_tolower (s[1]) == 'a'
@@ -325,6 +326,7 @@ strtod (const char *nptr, char **endptr)
          to interpreting n-char-sequence as a hexadecimal number.  */
       if (s != end)
         num = NAN;
+      errno = saved_errno;
     }
   else
     {