diff options
Diffstat (limited to 'lib/lib.c')
-rw-r--r-- | lib/lib.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -480,14 +480,18 @@ char *itoa(int n) // atol() with the kilo/mega/giga/tera/peta/exa extensions. // (zetta and yotta don't fit in 64 bits.) -long atolx(char *c) +long atolx(char *numstr) { - char *suffixes="kmgtpe", *end; - long val = strtol(c, &c, 0); + char *c, *suffixes="kmgtpe", *end; + long val = strtol(numstr, &c, 0); if (*c) { end = strchr(suffixes, tolower(*c)); if (end) val *= 1024L<<((end-suffixes)*10); + else { + while (isspace(*c)) c++; + if (*c) error_exit("not integer: %s", numstr); + } } return val; |