From 4030e4564f849cb4b6f04a8f14990ec4b878f6b6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 27 Jan 2024 17:54:50 -0600 Subject: [PATCH] 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. --- lib/lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/lib.c b/lib/lib.c index a27c7bbfc..6a4a77dde 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -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++;