summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2015-08-30 18:00:04 -0400
committerTavian Barnes <tavianator@tavianator.com>2015-08-30 18:00:04 -0400
commite614308b846478e20d548c81bc66d54b35e3292c (patch)
tree496d39f77354e2d0d12b76f4fbc7e33a4959f246
parent27ae855598129ed167699ecf787406238f4f576b (diff)
downloadbfs-e614308b846478e20d548c81bc66d54b35e3292c.tar.xz
Add support for -true and -false.
-rw-r--r--bfs.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/bfs.c b/bfs.c
index 09f4e89..d5d1dc2 100644
--- a/bfs.c
+++ b/bfs.c
@@ -174,18 +174,10 @@ static const char *skip_paths(parser_state *state) {
}
/**
- * Always true.
+ * -false test.
*/
-static bool eval_true(const char *fpath, const struct BFTW *ftwbuf, const cmdline *cl, const expression *expr, int *ret) {
- return true;
-}
-
-/**
- * -print action.
- */
-static bool eval_print(const char *fpath, const struct BFTW *ftwbuf, const cmdline *cl, const expression *expr, int *ret) {
- pretty_print(cl->colors, fpath, ftwbuf->statbuf);
- return true;
+static bool eval_false(const char *fpath, const struct BFTW *ftwbuf, const cmdline *cl, const expression *expr, int *ret) {
+ return false;
}
/**
@@ -216,6 +208,21 @@ static bool eval_nohidden(const char *fpath, const struct BFTW *ftwbuf, const cm
}
/**
+ * -print action.
+ */
+static bool eval_print(const char *fpath, const struct BFTW *ftwbuf, const cmdline *cl, const expression *expr, int *ret) {
+ pretty_print(cl->colors, fpath, ftwbuf->statbuf);
+ return true;
+}
+
+/**
+ * -true test.
+ */
+static bool eval_true(const char *fpath, const struct BFTW *ftwbuf, const cmdline *cl, const expression *expr, int *ret) {
+ return true;
+}
+
+/**
* -type test.
*/
static bool eval_type(const char *fpath, const struct BFTW *ftwbuf, const cmdline *cl, const expression *expr, int *ret) {
@@ -283,6 +290,8 @@ static expression *parse_literal(parser_state *state) {
} else if (strcmp(arg, "-nocolor") == 0) {
state->cl->color = false;
return new_expression(NULL, NULL, eval_true, 0);
+ } else if (strcmp(arg, "-false") == 0) {
+ return new_expression(NULL, NULL, eval_false, 0);
} else if (strcmp(arg, "-hidden") == 0) {
return new_expression(NULL, NULL, eval_hidden, 0);
} else if (strcmp(arg, "-nohidden") == 0) {
@@ -292,6 +301,8 @@ static expression *parse_literal(parser_state *state) {
return new_expression(NULL, NULL, eval_print, 0);
} else if (strcmp(arg, "-prune") == 0) {
return new_expression(NULL, NULL, eval_prune, 0);
+ } else if (strcmp(arg, "-true") == 0) {
+ return new_expression(NULL, NULL, eval_true, 0);
} else if (strcmp(arg, "-type") == 0) {
return parse_type(state);
} else {