]> Savannah Git Hosting - gnulib.git/commitdiff
xstrtod: reinstate setting of *result upon ERANGE
authorPádraig Brady <P@draigBrady.com>
Thu, 21 Apr 2016 11:20:58 +0000 (12:20 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 21 Apr 2016 18:30:10 +0000 (19:30 +0100)
* lib/xstrtod.c (XSTRTOD): The user may decide to use
the returned limits upon ERANGE, so allow and document that.

ChangeLog
lib/xstrtod.c

index f20316115d350824b706b4870eb233b4c8970d12..2589371d2103d1743cfbf5f21700b61591f9e51e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-04-21  Pádraig Brady  <P@draigBrady.com>
+
+       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  <f92capac@gmail.com>  (tiny change)
 
        xstrtod: modify *result only if no errors
index 1320ab6a22c2a7617bfb1c13d021351cb168b371..0d136cbae2ec63ffb4f62c8c82a2f9aec425f4b9 100644 (file)
 
 /* 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;
 }