X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=string.c;h=c35285153fdadf031fafb544aea4affdf066a86d;hp=f8b64b77c08d0c109c62129bdfeac04b775b3d6b;hb=9081daa84546dc48c0c521cb2081ef20c896e019;hpb=ca006af72cef95b0aba3cad799badde47010a621 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;