+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
/* 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,
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;
}
if (ptr != NULL)
*ptr = terminator;
- if (ok)
- *result = val;
+ *result = val;
return ok;
}