comparison lib/xstrtod.c @ 12421:e8d2c6fc33ad

Use spaces for indentation, not tabs.
author Bruno Haible <bruno@clisp.org>
date Thu, 10 Dec 2009 20:28:30 +0100
parents bbbbbf4cd1c5
children b5e42ef33b49
comparison
equal deleted inserted replaced
12420:5850b9a81029 12421:e8d2c6fc33ad
41 false and don't modify *RESULT upon any failure. CONVERT 41 false and don't modify *RESULT upon any failure. CONVERT
42 specifies the conversion function, e.g., strtod itself. */ 42 specifies the conversion function, e.g., strtod itself. */
43 43
44 bool 44 bool
45 XSTRTOD (char const *str, char const **ptr, DOUBLE *result, 45 XSTRTOD (char const *str, char const **ptr, DOUBLE *result,
46 DOUBLE (*convert) (char const *, char **)) 46 DOUBLE (*convert) (char const *, char **))
47 { 47 {
48 DOUBLE val; 48 DOUBLE val;
49 char *terminator; 49 char *terminator;
50 bool ok = true; 50 bool ok = true;
51 51
56 if (terminator == str || (ptr == NULL && *terminator != '\0')) 56 if (terminator == str || (ptr == NULL && *terminator != '\0'))
57 ok = false; 57 ok = false;
58 else 58 else
59 { 59 {
60 /* Allow underflow (in which case CONVERT returns zero), 60 /* Allow underflow (in which case CONVERT returns zero),
61 but flag overflow as an error. */ 61 but flag overflow as an error. */
62 if (val != 0 && errno == ERANGE) 62 if (val != 0 && errno == ERANGE)
63 ok = false; 63 ok = false;
64 } 64 }
65 65
66 if (ptr != NULL) 66 if (ptr != NULL)
67 *ptr = terminator; 67 *ptr = terminator;
68 68