diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-02-24 15:56:08 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2022-02-24 16:28:58 -0500 |
commit | 82f7f9ee1849947ed6de227279e623d8fc3a1ee1 (patch) | |
tree | 479c64bf8d92cfdd1ccba4bd679fb534a943c6e0 /eval.c | |
parent | b490dc534eedcc9878d4962e6d02baf4217a712f (diff) | |
download | bfs-82f7f9ee1849947ed6de227279e623d8fc3a1ee1.tar.xz |
regex: Rework error handling
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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; } /** |