This patch makes strto{u,}l{l,}() behave more to-spec about endptr. "If endptr is not NULL, strtoull stores the address of the first invalid character in *endptr."
@@ -929,6 +929,9 @@ long long strtoll(const char* str, char** endptr, int base)
return 0;
}
+ if (endptr)
+ *endptr = parse_ptr;
+
if (overflow) {
errno = ERANGE;
if (sign != Sign::Negative) {
@@ -1003,6 +1006,9 @@ unsigned long long strtoull(const char* str, char** endptr, int base)
return LONG_LONG_MAX;