On 21/04/16 11:59, Tino Calancha wrote:


Tino are you writing code that depends on the non modification of RESULT?
Perhaps we could just remove that comment since no code has depended
on that for the last 20 years?

Hi Pádraig,
no problem, it does not affect my code at all.

Cool, I'll apply the attached later.

thanks!
Pádraig

>From 90c39600ad0124122ccc9a74a00fa554f79ed211 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Thu, 21 Apr 2016 12:20:58 +0100
Subject: [PATCH] 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.
---
 lib/xstrtod.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/lib/xstrtod.c b/lib/xstrtod.c
index 1320ab6..0d136cb 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;
 }
-- 
2.5.5

Reply via email to