Added the units 'b' and 'B' for the min size specification
[dus.git] / dus.c
diff --git a/dus.c b/dus.c
index 03bd980..b90a0bd 100644 (file)
--- 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;
 }
 
@@ -258,25 +264,25 @@ void fancy_print(char *buffer, size_t buffer_size,
   if(size < 1024) {
     snprintf(buffer,
              buffer_size,
-             "% 7d -- %s\n",
+             "% 8d -- %s\n",
              ((int) size),
              filename);
   } else if(size < 1024 * 1024) {
     snprintf(buffer,
              buffer_size,
-             "% 6.1fK -- %s\n",
+             "% 7.1fK -- %s\n",
              ((double) (size))/(1024.0),
              filename);
   } else if(size < 1024 * 1024 * 1024) {
     snprintf(buffer,
              buffer_size,
-             "% 6.1fM -- %s\n",
+             "% 7.1fM -- %s\n",
              ((double) (size))/(1024.0 * 1024),
              filename);
   } else {
     snprintf(buffer,
              buffer_size,
-             "% 6.1fG -- %s\n",
+             "% 7.1fG -- %s\n",
              ((double) (size))/(1024.0 * 1024.0 * 1024.0),
              filename);
   }