]> Savannah Git Hosting - gnulib.git/commitdiff
strtod: port errno handling to z/OS
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 18 Aug 2016 00:38:05 +0000 (17:38 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 18 Aug 2016 00:44:56 +0000 (17:44 -0700)
* lib/strtod.c (strtod): Save and restore errno more reliably.

ChangeLog
lib/strtod.c

index d5883cf3cffc13709fc9a2dc6b8afecc412ad9f9..ff668a4d6dd2fcb1ce5985bdb124861f6c569c32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       strtod: port errno handling to z/OS
+       * lib/strtod.c (strtod): Save and restore errno more reliably.
+
 2016-08-17  Daniel Richard G.  <skunk@iSKUNK.ORG>
 
        strtod: port to z/OS
index 34c6c4237ebd4178498187d809ffbd1a6276d07a..7101d2904159af07fe725ef454d632500c556d2c 100644 (file)
@@ -215,7 +215,7 @@ strtod (const char *nptr, char **endptr)
   const char *s = nptr;
   const char *end;
   char *endbuf;
-  int saved_errno;
+  int saved_errno = errno;
 
   /* Eat whitespace.  */
   while (locale_isspace (*s))
@@ -226,7 +226,6 @@ strtod (const char *nptr, char **endptr)
   if (*s == '-' || *s == '+')
     ++s;
 
-  saved_errno = errno;
   num = underlying_strtod (s, &endbuf);
   end = endbuf;
 
@@ -243,7 +242,7 @@ strtod (const char *nptr, char **endptr)
               end = s + 1;
 
               /* strtod() on z/OS returns ERANGE for "0x".  */
-              errno = 0;
+              errno = saved_errno;
             }
           else if (end <= s + 2)
             {