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 214023b85214bfcbd07d29588bdc850b760c71a0..662bedbe21f5a00798d025dbd9f94acddc647918 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
index b642589e36b9e44dbc886704568f7c8e341f066b..bf6955a7783fb28017e7eaae50aa697dc32c9230 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
     {