repos/stagit

fork of stagit, a static git page generator
Commits Files Refs README LICENSE
commit 0b0b1e436f2eef139d48e57bc26c957202d53bd3
parent 26d14000ec0afec9f60302b80842dc1994aeb6c4
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Fri,  4 Sep 2026 22:06:29 -0300

Add space in between size number and unit

Diffstat:
Mstagit.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/stagit.c b/stagit.c
@@ -1108,9 +1108,14 @@ formatsize(size_t size)
         sz /= 1024;
 
     if (i == 0)
-        snprintf(buf, sizeof(buf), "%zuB", size);
+        snprintf(buf, sizeof(buf), "%zu B", size);
     else
-        snprintf(buf, sizeof(buf), "%.1f%s", sz, units[i]);
+        if (sz < 10)
+            snprintf(buf, sizeof(buf), "%.2f %s", sz, units[i]);
+        else if (sz < 100)
+            snprintf(buf, sizeof(buf), "%.1f %s", sz, units[i]);
+        else
+            snprintf(buf, sizeof(buf), "%.0f %s", sz, units[i]);
 
     return buf;
 }
@@ -1443,7 +1448,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
                     fprintf(fp, "<a href=\"%s", relpath);
                     percentencode(fp, filepath, strlen(filepath));
                     fputs("\">", fp);
-                    fprintf(fp, "%zuL", lc);
+                    fprintf(fp, "%zu L", lc);
                 }
                 else if (!is_obj_tree) {
                     fputs("<td id=\"file-size\" class=\"num\">", fp);
@@ -1525,7 +1530,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
                 fprintf(fp, "<a href=\"%s", relpath);
                 percentencode(fp, filepath, strlen(filepath));
                 fputs("\">", fp);
-                fprintf(fp, "%zuL", lc);
+                fprintf(fp, "%zu L", lc);
             }
             else if (!is_obj_tree) {
                 fputs("<td id=\"file-size\" class=\"num\">", fp);