X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=string.c;h=c35285153fdadf031fafb544aea4affdf066a86d;hp=f8b64b77c08d0c109c62129bdfeac04b775b3d6b;hb=4bdc5ed1cffdfae4f594d4a35b3ac44e220ad543;hpb=9a67f9e1e37589b548fc1823a21ffdf0b6faf4ea diff --git a/string.c b/string.c index f8b64b77..c3528515 100644 --- a/string.c +++ b/string.c @@ -562,10 +562,18 @@ int para_atoi64(const char *str, int64_t *value) tmp = strtoll(str, &endptr, 10); if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN)) return -E_ATOI_OVERFLOW; - if (errno != 0 && tmp == 0) /* other error */ - return -E_STRTOLL; + /* + * If there were no digits at all, strtoll() stores the original value + * of str in *endptr. + */ if (endptr == str) return -E_ATOI_NO_DIGITS; + /* + * The implementation may also set errno and return 0 in case no + * conversion was performed. + */ + if (errno != 0 && tmp == 0) + return -E_ATOI_NO_DIGITS; if (*endptr != '\0') /* Further characters after number */ return -E_ATOI_JUNK_AT_END; *value = tmp;