From 010dd2a29b8862d32c86ac099e15197402a8ca31 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 1 Nov 2008 10:53:33 +0000 Subject: [PATCH] Filter literally-zero-size directories out of the display, since they typically arise from --exclude-path. git-svn-id: svn://svn.tartarus.org/sgt/agedu@8238 cda61777-01e9-0310-a592-d414129be87e --- agedu.c | 3 +++ html.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/agedu.c b/agedu.c index c258919..a5de3fe 100644 --- 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 --- 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. -- 2.11.0