From 07fc8fc5273070fa4ac99d456c484f96c2ae7341 Mon Sep 17 00:00:00 2001 From: Minghui Liu Date: Tue, 20 Mar 2018 17:40:34 -0700 Subject: Fix atolx not integer error when used with suffix *d --- lib/lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index a6f9f987..991213bc 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -301,12 +301,11 @@ long long atolx(char *numstr) val = xstrtol(numstr, &c, 0); if (c != numstr && *c && (end = strchr(suffixes, tolower(*c)))) { int shift = end-suffixes-2; - ++c; if (shift==-1) val *= 2; else if (!shift) val *= 512; else if (shift>0) { - if (toupper(*c)=='d') while (shift--) val *= 1000; + if (*c && toupper(*c++)=='d') while (shift--) val *= 1000; else val *= 1LL<<(shift*10); } } -- cgit v1.2.3