From b8ef889cbfaeb69957ea76564543da38dfd65c47 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 30 Jun 2012 16:31:37 -0500 Subject: Add NOP b (byte) suffix to atolx() since od needs it. --- lib/lib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index 1c1148c2..6cb82e24 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -499,13 +499,15 @@ char *itoa(int n) // (zetta and yotta don't fit in 64 bits.) long atolx(char *numstr) { - char *c, *suffixes="kmgtpe", *end; + char *c, *suffixes="bkmgtpe", *end; long val = strtol(numstr, &c, 0); if (*c) { end = strchr(suffixes, tolower(*c)); - if (end) val *= 1024L<<((end-suffixes)*10); - else { + if (end) { + int shift = end-suffixes; + if (shift--) val *= 1024L<<(shift*10); + } else { while (isspace(*c)) c++; if (*c) error_exit("not integer: %s", numstr); } -- cgit v1.2.3