basic/parse-util: add safe_atoux64()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-04-09 11:29:55 +02:00
parent 1b87e27999
commit ce51632a35
3 changed files with 52 additions and 3 deletions
+2 -2
View File
@@ -395,7 +395,7 @@ int safe_atoi(const char *s, int *ret_i) {
return 0;
}
int safe_atollu(const char *s, long long unsigned *ret_llu) {
int safe_atollu_full(const char *s, unsigned base, long long unsigned *ret_llu) {
char *x = NULL;
unsigned long long l;
@@ -404,7 +404,7 @@ int safe_atollu(const char *s, long long unsigned *ret_llu) {
s += strspn(s, WHITESPACE);
errno = 0;
l = strtoull(s, &x, 0);
l = strtoull(s, &x, base);
if (errno > 0)
return -errno;
if (!x || x == s || *x != 0)