summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-22 14:13:26 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-22 14:13:26 -0500
commit275fbdbe040dc07b2705c92d4cd24ad3f3c7d069 (patch)
tree0fd997ea04f5ef16c22941d2aabbc01d900073fe /parse.c
parent59f46665aa10eed0776e93dc5f67368a3b8b27e3 (diff)
downloadbfs-275fbdbe040dc07b2705c92d4cd24ad3f3c7d069.tar.xz
Implement -D stat.
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 8376378..fb0170b 100644
--- a/parse.c
+++ b/parse.c
@@ -336,6 +336,39 @@ static struct expr *parse_test_sdata(struct parser_state *state, const char *tes
}
/**
+ * Parse -D FLAG.
+ */
+static struct expr *parse_debug(struct parser_state *state, const char *option) {
+ struct cmdline *cmdline = state->cmdline;
+
+ const char *arg = state->argv[state->i];
+ if (!arg) {
+ pretty_error(cmdline->stderr_colors,
+ "error: %s needs a flag.\n", option);
+ return NULL;
+ }
+
+ ++state->i;
+
+ if (strcmp(arg, "help") == 0) {
+ printf("Supported debug flags:\n\n");
+
+ printf(" help: This message.\n");
+ printf(" stat: Trace all stat() calls.\n");
+
+ state->just_info = true;
+ return NULL;
+ } else if (strcmp(arg, "stat") == 0) {
+ cmdline->debug |= DEBUG_STAT;
+ } else {
+ pretty_warning(cmdline->stderr_colors,
+ "warning: Unrecognized debug flag '%s'.\n\n", arg);
+ }
+
+ return new_positional_option(state);
+}
+
+/**
* Parse -[acm]{min,time}.
*/
static struct expr *parse_acmtime(struct parser_state *state, const char *option, enum timefield field, enum timeunit unit) {
@@ -670,6 +703,12 @@ static struct expr *parse_literal(struct parser_state *state) {
}
switch (arg[1]) {
+ case 'D':
+ if (strcmp(arg, "-D") == 0) {
+ return parse_debug(state, arg);
+ }
+ break;
+
case 'P':
if (strcmp(arg, "-P") == 0) {
cmdline->flags &= ~(BFTW_FOLLOW | BFTW_DETECT_CYCLES);
@@ -1128,6 +1167,7 @@ struct cmdline *parse_cmdline(int argc, char *argv[]) {
cmdline->mindepth = 0;
cmdline->maxdepth = INT_MAX;
cmdline->flags = BFTW_RECOVER;
+ cmdline->debug = 0;
cmdline->expr = &expr_true;
cmdline->colors = parse_colors(getenv("LS_COLORS"));