diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-10-23 17:01:14 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-10-23 17:01:14 +0200 |
commit | 63bdde8c402f91e7aacbc8ca9ecb65a781bc7fe2 (patch) | |
tree | 055dade788b8d54ad87c5b171ee2d251dd12b5c4 | |
parent | 37c19fb27d2a2db8cc204f3b01fe31060a2dc6ac (diff) | |
download | lr-63bdde8c402f91e7aacbc8ca9ecb65a781bc7fe2.tar.gz lr-63bdde8c402f91e7aacbc8ca9ecb65a781bc7fe2.tar.xz lr-63bdde8c402f91e7aacbc8ca9ecb65a781bc7fe2.zip |
depth-first search is now -D, -d is don't enter dirs, -1 is -maxdepth 1
-rw-r--r-- | lr.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lr.c b/lr.c index 8047bf4..c6de73d 100644 --- a/lr.c +++ b/lr.c @@ -50,7 +50,7 @@ #include <time.h> #include <unistd.h> -static int dflag; +static int Dflag; static int Hflag; static int Lflag; static int xflag; @@ -503,9 +503,9 @@ parse_or() } static struct expr * -parse_expr(char *s) +parse_expr(const char *s) { - pos = s; + pos = (char *) s; struct expr *e = parse_or(); if (*pos) parse_error("trailing garbage"); @@ -940,7 +940,7 @@ recurse(char *path, struct history *h) entries = 0; new.total = st.st_blocks/2; - if (!dflag) { + if (!Dflag) { prune = 0; r = callback(path, &st, new.level, 0, 0); if (prune) @@ -984,7 +984,7 @@ recurse(char *path, struct history *h) } path[l] = 0; - if (dflag && (r=callback(path, &st, new.level, entries, new.total))) + if (Dflag && (r=callback(path, &st, new.level, entries, new.total))) return r; return 0; @@ -1013,22 +1013,22 @@ main(int argc, char *argv[]) ordering = default_ordering; argv0 = argv[0]; - while ((c = getopt(argc, argv, "df:t:o:xLFHUl0s")) != -1) + while ((c = getopt(argc, argv, "01DFHLUdf:lo:st:x")) != -1) switch(c) { - case 'd': dflag++; break; - case 'f': format = optarg; break; - case 'o': ordering = optarg; break; - case 't': expr = chain(expr, EXPR_AND, parse_expr(optarg)); break; - case 'x': xflag++; break; + case '0': format = zero_format; break; + case '1': expr = chain(expr, EXPR_AND, parse_expr("depth == 0 || prune")); break; + case 'D': Dflag++; break; + case 'F': format = type_format; break; case 'H': Hflag++; break; case 'L': Lflag++; break; case 'U': Uflag++; break; - case '0': format = zero_format; break; + case 'd': expr = chain(expr, EXPR_AND, parse_expr("type == d && prune || print")); break; + case 'f': format = optarg; break; + case 'l': lflag++; format = long_format; break; + case 'o': ordering = optarg; break; case 's': sflag++; break; - case 'l': - lflag++; - format = long_format; break; - case 'F': format = type_format; break; + case 't': expr = chain(expr, EXPR_AND, parse_expr(optarg)); break; + case 'x': xflag++; break; default: fprintf(stderr, "Usage: %s [-oxL] PATH...\n", argv0); exit(2); |