diff options
author | Rob Landley <rob@landley.net> | 2012-06-30 16:31:37 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-06-30 16:31:37 -0500 |
commit | b8ef889cbfaeb69957ea76564543da38dfd65c47 (patch) | |
tree | 1c8f40e1e67c7fdc5b213354072bd975471a41be /lib/lib.c | |
parent | 39c32605072bab8966ff4425f37a158f060bacd2 (diff) | |
download | toybox-b8ef889cbfaeb69957ea76564543da38dfd65c47.tar.gz |
Add NOP b (byte) suffix to atolx() since od needs it.
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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); } |