From a2a39436b65f329630df4a93ec4e30aeae403c54 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 17 Aug 2016 17:38:05 -0700 Subject: [PATCH] strtod: port errno handling to z/OS * lib/strtod.c (strtod): Save and restore errno more reliably. --- ChangeLog | 5 +++++ lib/strtod.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5883cf3cf..ff668a4d6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-08-17 Paul Eggert + + strtod: port errno handling to z/OS + * lib/strtod.c (strtod): Save and restore errno more reliably. + 2016-08-17 Daniel Richard G. strtod: port to z/OS diff --git a/lib/strtod.c b/lib/strtod.c index 34c6c4237e..7101d29041 100644 --- a/lib/strtod.c +++ b/lib/strtod.c @@ -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) { -- 2.39.5