strtod(): Was not returning endptr on error conditions.
This commit is contained in:
parent
61b0ac06bf
commit
155055d564
@ -115,6 +115,8 @@ double_t strtod(FAR const char *str, FAR char **endptr)
|
||||
negative = 1; /* Fall through to increment position */
|
||||
case '+':
|
||||
p++;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
number = 0.;
|
||||
@ -151,7 +153,8 @@ double_t strtod(FAR const char *str, FAR char **endptr)
|
||||
if (num_digits == 0)
|
||||
{
|
||||
set_errno(ERANGE);
|
||||
return 0.0;
|
||||
number = 0.0;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Correct for sign */
|
||||
@ -174,6 +177,8 @@ double_t strtod(FAR const char *str, FAR char **endptr)
|
||||
negative = 1; /* Fall through to increment pos */
|
||||
case '+':
|
||||
p++;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Process string of digits */
|
||||
@ -199,7 +204,8 @@ double_t strtod(FAR const char *str, FAR char **endptr)
|
||||
exponent > __DBL_MAX_EXP__)
|
||||
{
|
||||
set_errno(ERANGE);
|
||||
return infinite;
|
||||
number = infinite;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Scale the result */
|
||||
@ -220,6 +226,7 @@ double_t strtod(FAR const char *str, FAR char **endptr)
|
||||
number *= p10;
|
||||
}
|
||||
}
|
||||
|
||||
n >>= 1;
|
||||
p10 *= p10;
|
||||
}
|
||||
@ -229,6 +236,7 @@ double_t strtod(FAR const char *str, FAR char **endptr)
|
||||
set_errno(ERANGE);
|
||||
}
|
||||
|
||||
errout:
|
||||
if (endptr)
|
||||
{
|
||||
*endptr = p;
|
||||
|
Loading…
Reference in New Issue
Block a user