summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-02-24 15:56:08 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-02-24 16:28:58 -0500
commit82f7f9ee1849947ed6de227279e623d8fc3a1ee1 (patch)
tree479c64bf8d92cfdd1ccba4bd679fb534a943c6e0 /eval.c
parentb490dc534eedcc9878d4962e6d02baf4217a712f (diff)
downloadbfs-82f7f9ee1849947ed6de227279e623d8fc3a1ee1.tar.xz
regex: Rework error handling
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index e812dc6..321a8d9 100644
--- a/eval.c
+++ b/eval.c
@@ -828,10 +828,9 @@ bool eval_quit(const struct expr *expr, struct eval_state *state) {
bool eval_regex(const struct expr *expr, struct eval_state *state) {
const char *path = state->ftwbuf->path;
- int err;
- bool ret = bfs_regexec(expr->regex, path, BFS_REGEX_ANCHOR, &err);
- if (err) {
- char *str = bfs_regerror(err, expr->regex);
+ int ret = bfs_regexec(expr->regex, path, BFS_REGEX_ANCHOR);
+ if (ret < 0) {
+ char *str = bfs_regerror(expr->regex);
if (str) {
eval_error(state, "%s.\n", str);
free(str);
@@ -840,7 +839,7 @@ bool eval_regex(const struct expr *expr, struct eval_state *state) {
}
}
- return ret;
+ return ret > 0;
}
/**