From: Bruno Haible Date: Fri, 7 Jan 2011 20:27:23 +0000 (+0100) Subject: strtod: Restore errno when successfully parsing Infinity or NaN. X-Git-Tag: v0.1~3375 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=88418d5fd24c99aac393d3e2f564f6939e4e2fe3;p=gnulib.git strtod: Restore errno when successfully parsing Infinity or NaN. * lib/strtod.c (strtod): After successfully parsing an Infinity or NaN, restore the original errno. --- diff --git a/ChangeLog b/ChangeLog index 214023b85..662bedbe2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-01-07 Bruno Haible + 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 + remove test: Avoid failure on HP-UX 11. * tests/test-remove.c (main): Allow EEXIST as alternative error code. diff --git a/lib/strtod.c b/lib/strtod.c index b642589e3..bf6955a77 100644 --- a/lib/strtod.c +++ b/lib/strtod.c @@ -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 {