{
if (endp) *endp = endptr;
- /* Check for the weird "feature":
- * a "-" string is apparently a valid "number" for strto[u]l[l]!
- * It returns zero and errno is 0! :( */
- if (endptr[-1] == '-')
- return ret_ERANGE();
-
/* errno is already set to ERANGE by strtoXXX if value overflowed */
if (endptr[0]) {
/* "1234abcg" or out-of-range? */
/* good number, just suspicious terminator */
errno = EINVAL;
}
+ /* Check for the weird "feature":
+ * a "-" string is apparently a valid "number" for strto[u]l[l]!
+ * It returns zero and errno is 0! :( */
+ if (endptr[-1] == '-')
+ return ret_ERANGE();
return v;
}