aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 6e88fd25..d011af02 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -290,17 +290,18 @@ long long xstrtol(char *str, char **end, int base)
return l;
}
-// atol() with the kilo/mega/giga/tera/peta/exa extensions.
+// atol() with the kilo/mega/giga/tera/peta/exa extensions, plus word and block.
// (zetta and yotta don't fit in 64 bits.)
long long atolx(char *numstr)
{
- char *c = numstr, *suffixes="cbkmgtpe", *end;
+ char *c = numstr, *suffixes="cwbkmgtpe", *end;
long long val;
val = xstrtol(numstr, &c, 0);
if (c != numstr && *c && (end = strchr(suffixes, tolower(*c)))) {
- int shift = end-suffixes-1;
+ int shift = end-suffixes-2;
+ if (shift==-1) val *= 2;
if (!shift) val *= 512;
else if (shift>0) {
if (toupper(*++c)=='d') while (shift--) val *= 1000;