From: Pádraig Brady Date: Thu, 21 Apr 2016 11:20:58 +0000 (+0100) Subject: xstrtod: reinstate setting of *result upon ERANGE X-Git-Tag: v1.0~6757 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d92a0d9248948b152662f97b07c06a1279d4f6f6;p=gnulib.git xstrtod: reinstate setting of *result upon ERANGE * lib/xstrtod.c (XSTRTOD): The user may decide to use the returned limits upon ERANGE, so allow and document that. --- diff --git a/ChangeLog b/ChangeLog index f20316115d..2589371d21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-04-21 Pádraig Brady + + xstrtod: reinstate setting of *result upon ERANGE + * lib/xstrtod.c (XSTRTOD): The user may decide to use + the returned limits upon ERANGE, so allow and document that. + 2016-04-20 Tino Calancha (tiny change) xstrtod: modify *result only if no errors diff --git a/lib/xstrtod.c b/lib/xstrtod.c index 1320ab6a22..0d136cbae2 100644 --- a/lib/xstrtod.c +++ b/lib/xstrtod.c @@ -36,10 +36,9 @@ /* An interface to a string-to-floating-point conversion function that encapsulates all the error checking one should usually perform. - Like strtod/strtold, but upon successful - conversion put the result in *RESULT and return true. Return - false and don't modify *RESULT upon any failure. CONVERT - specifies the conversion function, e.g., strtod itself. */ + Like strtod/strtold, but stores the conversion in *RESULT, + and returns true upon successful conversion. + CONVERT specifies the conversion function, e.g., strtod itself. */ bool XSTRTOD (char const *str, char const **ptr, DOUBLE *result, @@ -58,7 +57,8 @@ XSTRTOD (char const *str, char const **ptr, DOUBLE *result, else { /* Allow underflow (in which case CONVERT returns zero), - but flag overflow as an error. */ + but flag overflow as an error. The user can decide + to use the limits in RESULT upon ERANGE. */ if (val != 0 && errno == ERANGE) ok = false; } @@ -66,7 +66,6 @@ XSTRTOD (char const *str, char const **ptr, DOUBLE *result, if (ptr != NULL) *ptr = terminator; - if (ok) - *result = val; + *result = val; return ok; }