X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=dus.c;h=b90a0bdddc0648f1fc2735e199b1a300b580550d;hb=b2fe75d8869c39badff3381fd9bde0f58b8ee7ce;hp=91cb0f02389e63b2887dc67fc05cdd11f9f0e0b6;hpb=a60dad8d8db2c660abb1f4f4ceceba8a1440fe94;p=dus.git diff --git a/dus.c b/dus.c index 91cb0f0..b90a0bd 100644 --- a/dus.c +++ b/dus.c @@ -136,6 +136,9 @@ size_sum_t atoss(const char *string) { for(c = string; *c; c++) { if(*c >= '0' && *c <= '9') { partial_total = 10 * partial_total + ((int) (*c - '0')); + } else if(*c == 'B' || *c == 'b') { + total += partial_total; + partial_total = 0; } else if(*c == 'K' || *c == 'k') { total += partial_total * 1024; partial_total = 0; @@ -149,6 +152,9 @@ size_sum_t atoss(const char *string) { fprintf(stderr, "Syntax error in %s\n", string); } } + + total += partial_total; + return total; }