Fix "./truncate -s 1e2" to say "not integer" instead of "too large".

It's not scientific notation, it's "exabyte suffix" and then the check
for trailing 'd' meaning decimal instead of binary always incremented past
the non-null character whether or not the test matched, so the error
check at the end didn't catch a non-d second suffix.
This commit is contained in:
Rob Landley 2024-01-27 17:54:50 -06:00
parent 316a2676cc
commit 4030e4564f

View File

@ -319,8 +319,10 @@ long long atolx(char *numstr)
if (shift==-1) val *= 2;
else if (!shift) val *= 512;
else if (shift>0) {
if (*c && tolower(*c++)=='d') while (shift--) val *= 1000;
else val *= 1LL<<(shift*10);
if (*c && tolower(*c)=='d') {
c++;
while (shift--) val *= 1000;
} else val *= 1LL<<(shift*10);
}
}
while (isspace(*c)) c++;