summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-10-04 13:46:35 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-10-05 15:39:22 -0400
commit98a3dd364739136329fe2b8f9cdeecf776fb17c9 (patch)
treed571ed17227849679b397e0cfd6c95a51c41c524 /eval.c
parentb3312002a5d96cd486156a711d3c1861c150b7c6 (diff)
downloadbfs-98a3dd364739136329fe2b8f9cdeecf776fb17c9.tar.xz
diag: New bfs_perror() function
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 551f069..246a60c 100644
--- a/eval.c
+++ b/eval.c
@@ -799,7 +799,7 @@ bool eval_regex(const struct expr *expr, struct eval_state *state) {
eval_error(state, "%s.\n", str);
free(str);
} else {
- perror("xregerror()");
+ eval_error(state, "xregerror(): %m.\n");
}
*state->ret = EXIT_FAILURE;
@@ -915,11 +915,11 @@ bool eval_xtype(const struct expr *expr, struct eval_state *state) {
/**
* Call clock_gettime(), if available.
*/
-static int eval_gettime(struct timespec *ts) {
+static int eval_gettime(struct eval_state *state, struct timespec *ts) {
#ifdef BFS_CLOCK
int ret = clock_gettime(BFS_CLOCK, ts);
if (ret != 0) {
- perror("clock_gettime()");
+ bfs_warning(state->ctx, "%pP: clock_gettime(): %m.\n", state->ftwbuf);
}
return ret;
#else
@@ -949,7 +949,7 @@ static bool eval_expr(struct expr *expr, struct eval_state *state) {
struct timespec start, end;
bool time = state->ctx->debug & DEBUG_RATES;
if (time) {
- if (eval_gettime(&start) != 0) {
+ if (eval_gettime(state, &start) != 0) {
time = false;
}
}
@@ -959,7 +959,7 @@ static bool eval_expr(struct expr *expr, struct eval_state *state) {
bool ret = expr->eval(expr, state);
if (time) {
- if (eval_gettime(&end) == 0) {
+ if (eval_gettime(state, &end) == 0) {
add_elapsed(expr, &start, &end);
}
}
@@ -1381,7 +1381,7 @@ int bfs_eval(const struct bfs_ctx *ctx) {
if (bftw(&bftw_args) != 0) {
args.ret = EXIT_FAILURE;
- perror("bftw()");
+ bfs_perror(ctx, "bftw()");
}
if (eval_exec_finish(ctx->expr, ctx) != 0) {