From: Andre Noll Date: Mon, 26 May 2008 11:55:32 +0000 (+0200) Subject: Honor the --limit option. X-Git-Tag: v0.0.2~40 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=28501f00678aa1d9d3dee1c608defe3a35bb02a2;p=adu.git Honor the --limit option. --- diff --git a/adu.c b/adu.c index 26039ce..93305d5 100644 --- 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 ab6e025..2a7cee9 100644 --- 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