diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-14 14:42:54 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-14 14:45:32 -0500 |
commit | 0d6c12cbc8370dafcfcb2c1882303ab2610175c6 (patch) | |
tree | e43350ff1e022fe904a4a10446132daf30d8e685 /eval.c | |
parent | c40f26a15c0dce60ee365ee3f6d0779ef19cd947 (diff) | |
download | bfs-0d6c12cbc8370dafcfcb2c1882303ab2610175c6.tar.xz |
Refactor color handling.
The main benefit is colored warnings/errors during parsing.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -40,7 +40,8 @@ struct eval_state { * Report an error that occurs during evaluation. */ static void eval_error(struct eval_state *state) { - print_error(state->cmdline->colors, state->ftwbuf->path, errno); + pretty_error(state->cmdline->stderr_colors, + "'%s': %s\n", state->ftwbuf->path, strerror(errno)); state->ret = -1; } @@ -386,10 +387,11 @@ 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->cmdline->colors; + const struct color_table *colors = state->cmdline->stdout_colors; if (colors) { fill_statbuf(state); } + pretty_print(colors, state->ftwbuf); return true; } @@ -526,7 +528,7 @@ static enum bftw_action cmdline_callback(struct BFTW *ftwbuf, void *ptr) { const struct cmdline *cmdline = args->cmdline; if (ftwbuf->typeflag == BFTW_ERROR) { - print_error(cmdline->colors, ftwbuf->path, ftwbuf->error); + pretty_error(cmdline->stderr_colors, "'%s': %s\n", ftwbuf->path, strerror(ftwbuf->error)); return BFTW_SKIP_SUBTREE; } |