summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-14 14:42:54 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-14 14:45:32 -0500
commit0d6c12cbc8370dafcfcb2c1882303ab2610175c6 (patch)
treee43350ff1e022fe904a4a10446132daf30d8e685 /eval.c
parentc40f26a15c0dce60ee365ee3f6d0779ef19cd947 (diff)
downloadbfs-0d6c12cbc8370dafcfcb2c1882303ab2610175c6.tar.xz
Refactor color handling.
The main benefit is colored warnings/errors during parsing.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index 26596f0..125342a 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
}