summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-12 15:19:09 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-12 15:19:09 -0500
commit3d167f2a35fc94ed7521909b8c7ef126aaa4bed6 (patch)
tree8b14a84684ef6f1b19ea872dafe078e3b7d5a26f
parent25648b2999b918dd1ebd9faa1f8dbff705a7a46c (diff)
downloadbfs-3d167f2a35fc94ed7521909b8c7ef126aaa4bed6.tar.xz
Use 'cmdline' instead of 'cl'.
-rw-r--r--bfs.h4
-rw-r--r--eval.c34
2 files changed, 19 insertions, 19 deletions
diff --git a/bfs.h b/bfs.h
index 82edd98..f4e2d24 100644
--- a/bfs.h
+++ b/bfs.h
@@ -138,12 +138,12 @@ struct cmdline *parse_cmdline(int argc, char *argv[]);
/**
* Evaluate the command line.
*/
-int eval_cmdline(const struct cmdline *cl);
+int eval_cmdline(const struct cmdline *cmdline);
/**
* Free the parsed command line.
*/
-void free_cmdline(struct cmdline *cl);
+void free_cmdline(struct cmdline *cmdline);
// Predicate evaluation functions
bool eval_true(const struct expr *expr, struct eval_state *state);
diff --git a/eval.c b/eval.c
index 0698857..a045d39 100644
--- a/eval.c
+++ b/eval.c
@@ -26,7 +26,7 @@ struct eval_state {
/** Data about the current file. */
struct BFTW *ftwbuf;
/** The parsed command line. */
- const struct cmdline *cl;
+ const struct cmdline *cmdline;
/** The bftw() callback return value. */
enum bftw_action action;
/** The eval_cmdline() return value. */
@@ -197,7 +197,7 @@ bool eval_delete(const struct expr *expr, struct eval_state *state) {
}
if (unlinkat(ftwbuf->at_fd, ftwbuf->at_path, flag) != 0) {
- print_error(state->cl->colors, ftwbuf->path, errno);
+ print_error(state->cmdline->colors, ftwbuf->path, errno);
state->action = BFTW_STOP;
}
@@ -321,7 +321,7 @@ bool eval_path(const struct expr *expr, struct eval_state *state) {
* -print action.
*/
bool eval_print(const struct expr *expr, struct eval_state *state) {
- struct color_table *colors = state->cl->colors;
+ struct color_table *colors = state->cmdline->colors;
if (colors) {
fill_statbuf(state);
}
@@ -420,7 +420,7 @@ static int infer_nopenfd() {
*/
struct callback_args {
/** The parsed command line. */
- const struct cmdline *cl;
+ const struct cmdline *cmdline;
/** Eventual return value from eval_cmdline(). */
int ret;
};
@@ -431,36 +431,36 @@ struct callback_args {
static enum bftw_action cmdline_callback(struct BFTW *ftwbuf, void *ptr) {
struct callback_args *args = ptr;
- const struct cmdline *cl = args->cl;
+ const struct cmdline *cmdline = args->cmdline;
if (ftwbuf->typeflag == BFTW_ERROR) {
- print_error(cl->colors, ftwbuf->path, ftwbuf->error);
+ print_error(cmdline->colors, ftwbuf->path, ftwbuf->error);
return BFTW_SKIP_SUBTREE;
}
struct eval_state state = {
.ftwbuf = ftwbuf,
- .cl = cl,
+ .cmdline = cmdline,
.action = BFTW_CONTINUE,
.ret = args->ret,
};
- if (ftwbuf->depth >= cl->maxdepth) {
+ if (ftwbuf->depth >= cmdline->maxdepth) {
state.action = BFTW_SKIP_SUBTREE;
}
// In -depth mode, only handle directories on the BFTW_POST visit
enum bftw_visit expected_visit = BFTW_PRE;
- if ((cl->flags & BFTW_DEPTH)
+ if ((cmdline->flags & BFTW_DEPTH)
&& ftwbuf->typeflag == BFTW_DIR
- && ftwbuf->depth < cl->maxdepth) {
+ && ftwbuf->depth < cmdline->maxdepth) {
expected_visit = BFTW_POST;
}
if (ftwbuf->visit == expected_visit
- && ftwbuf->depth >= cl->mindepth
- && ftwbuf->depth <= cl->maxdepth) {
- cl->expr->eval(cl->expr, &state);
+ && ftwbuf->depth >= cmdline->mindepth
+ && ftwbuf->depth <= cmdline->maxdepth) {
+ cmdline->expr->eval(cmdline->expr, &state);
}
args->ret = state.ret;
@@ -470,16 +470,16 @@ static enum bftw_action cmdline_callback(struct BFTW *ftwbuf, void *ptr) {
/**
* Evaluate the command line.
*/
-int eval_cmdline(const struct cmdline *cl) {
+int eval_cmdline(const struct cmdline *cmdline) {
int nopenfd = infer_nopenfd();
struct callback_args args = {
- .cl = cl,
+ .cmdline = cmdline,
.ret = 0,
};
- for (size_t i = 0; i < cl->nroots; ++i) {
- if (bftw(cl->roots[i], cmdline_callback, nopenfd, cl->flags, &args) != 0) {
+ for (size_t i = 0; i < cmdline->nroots; ++i) {
+ if (bftw(cmdline->roots[i], cmdline_callback, nopenfd, cmdline->flags, &args) != 0) {
args.ret = -1;
perror("bftw()");
}