]> git.tue.mpg.de Git - adu.git/commitdiff
Honor the --limit option.
authorAndre Noll <maan@systemlinux.org>
Mon, 26 May 2008 11:55:32 +0000 (13:55 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 26 May 2008 11:55:32 +0000 (13:55 +0200)
adu.c
adu.ggo

diff --git a/adu.c b/adu.c
index 26039ce7a35a2a7fc96bfd897eec08d2ddc3febd..93305d5ee865ed458b97c5149465d9a603811ea1 100644 (file)
--- a/adu.c
+++ b/adu.c
@@ -538,7 +538,7 @@ static int global_stats_loop_function(struct osl_row *row, void *data)
                        num_dirs++;
                }
        }
-       if (gsi->count)
+       if (gsi->count > 0)
                gsi->count--;
        return 1;
 }
@@ -626,7 +626,7 @@ static int user_stats_loop_function(struct osl_row *row, void *data)
                }
 
        }
-       if (usi->count)
+       if (usi->count > 0)
                usi->count--;
        return 1;
 }
@@ -637,7 +637,7 @@ static void print_user_stats(void)
 
        FOR_EACH_USER(ui) {
                struct user_stats_info usi = {
-                       .count = 10,
+                       .count = conf.limit_arg,
                        .ui = ui
                };
                if (!ui->table)
@@ -651,7 +651,7 @@ static void print_user_stats(void)
                osl_rbtree_loop_reverse(ui->table, UT_BYTES, &usi,
                        user_stats_loop_function);
                printf("---------- dirs containing most files ------------\n");
-               usi.count = 10;
+               usi.count = conf.limit_arg,
                usi.flags = USF_PRINT_DIRNAME | USF_PRINT_FILES;
                osl_rbtree_loop_reverse(ui->table, UT_FILES, &usi,
                        user_stats_loop_function);
@@ -662,7 +662,7 @@ static int print_statistics(void)
 {
        int ret;
        struct global_stats_info gsi = {
-               .count = 10,
+               .count = conf.limit_arg,
                .flags = GSF_PRINT_DIRNAME | GSF_PRINT_BYTES | GSF_COMPUTE_SUMMARY
        };
 
@@ -671,7 +671,7 @@ static int print_statistics(void)
                global_stats_loop_function);
        if (ret < 0 && ret != -E_LOOP_COMPLETE)
                return ret;
-       gsi.count = 10;
+       gsi.count = conf.limit_arg;
 
        gsi.flags = GSF_PRINT_DIRNAME | GSF_PRINT_FILES;
        printf("---------- dirs containing most files ------------\n");
diff --git a/adu.ggo b/adu.ggo
index ab6e025a4ea2679f6dd75b4e1134df43a328569a..2a7cee97a5d55bc401503e1dfb3ccfdb3f79ce5b 100644 (file)
--- a/adu.ggo
+++ b/adu.ggo
@@ -142,10 +142,12 @@ option "limit" L
 #~~~~~~~~~~~~~~~
 "Limit output"
 int  typestr="num"
-required
+default="-1"
+optional
 dependon="select"
 details="
-       Only print num lines of output.
+       Only print num lines of output. If negative (the default),
+       print all lines.
 "
 
 option "units" U