Mercurial > hg > toybox
changeset 149:58554af48c8b
Fix from Charlie Shepherd: at end of string, don't match the null terminator
as a yottabyte suffix. Also, the shift increment needs to be a long constant
on 64-bit platforms for the top three suffixes to mean anything.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 04 Nov 2007 15:32:59 -0600 |
parents | 88dd003ccdf4 |
children | beeab8a27a7d |
files | lib/lib.c |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/lib.c Sun Nov 04 15:31:06 2007 -0600 +++ b/lib/lib.c Sun Nov 04 15:32:59 2007 -0600 @@ -422,8 +422,10 @@ char *suffixes="kmgtpe", *end; long val = strtol(c, &c, 0); - end = strchr(suffixes, tolower(*c)); - if (end) val *= 1024<<((end-suffixes)*10); + if (*c) { + end = strchr(suffixes, tolower(*c)); + if (end) val *= 1024L<<((end-suffixes)*10); + } return val; }