Filter literally-zero-size directories out of the display, since
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 1 Nov 2008 10:53:33 +0000 (10:53 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 1 Nov 2008 10:53:33 +0000 (10:53 +0000)
they typically arise from --exclude-path.

git-svn-id: svn://svn.tartarus.org/sgt/agedu@8238 cda61777-01e9-0310-a592-d414129be87e

agedu.c
html.c

diff --git a/agedu.c b/agedu.c
index c258919..a5de3fe 100644 (file)
--- a/agedu.c
+++ b/agedu.c
@@ -153,6 +153,9 @@ static void text_query(const void *mappedfile, const char *querydir,
     s1 = index_query(mappedfile, xi1, t);
     s2 = index_query(mappedfile, xi2, t);
 
+    if (s1 == s2)
+       return;                        /* no space taken up => no display */
+
     /* Display in units of 2 512-byte blocks = 1Kb */
     printf("%-11llu %s\n", (s2 - s1) / 2, querydir);
 
diff --git a/html.c b/html.c
index 76ecd83..0a57cb1 100644 (file)
--- a/html.c
+++ b/html.c
@@ -321,11 +321,20 @@ static void write_report_line(struct html *ctx, struct vector *vec)
     int i;
 
     /*
-     * Prevent divisions by zero.
+     * A line with literally zero space usage should not be
+     * printed at all if it's a link to a subdirectory (since it
+     * probably means the whole thing was excluded by some
+     * --exclude-path wildcard). If it's [files] or the top-level
+     * line, though, we must always print _something_, and in that
+     * case we must fiddle about to prevent divisions by zero in
+     * the code below.
      */
+    if (!vec->sizes[MAXCOLOUR] && vec->want_href)
+       return;
     divisor = ctx->totalsize;
-    if (!divisor)
+    if (!divisor) {
        divisor = 1;
+    }
 
     /*
      * Find the total size of this subdirectory.