changeset 14145:a94d9a7b4aaa

strtod: Restore errno when successfully parsing Infinity or NaN. * lib/strtod.c (strtod): After successfully parsing an Infinity or NaN, restore the original errno.
author Bruno Haible <bruno@clisp.org>
date Fri, 07 Jan 2011 21:27:23 +0100
parents a0e5b3297968
children 4f164e76286e
files ChangeLog lib/strtod.c
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/strtod.c
+++ b/lib/strtod.c
@@ -303,6 +303,7 @@
           && 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 @@
          to interpreting n-char-sequence as a hexadecimal number.  */
       if (s != end)
         num = NAN;
+      errno = saved_errno;
     }
   else
     {