summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-02-21 15:25:27 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-02-21 16:12:07 -0500
commit9754c1ab7ceebd41ffda5f8004e562f18006dc6c (patch)
treebe623cc6de520ed5578458e58a9d774c75b0f296 /parse.c
parent5a3b68d37cdc1e60802a5963340be5c5705d1f5d (diff)
downloadbfs-9754c1ab7ceebd41ffda5f8004e562f18006dc6c.tar.xz
regex: Wrap the POSIX API in a facade
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/parse.c b/parse.c
index 38f63ce..066784c 100644
--- a/parse.c
+++ b/parse.c
@@ -105,11 +105,7 @@ void free_expr(struct expr *expr) {
return;
}
- if (expr->regex) {
- regfree(expr->regex);
- free(expr->regex);
- }
-
+ bfs_regfree(expr->regex);
bfs_printf_free(expr->printf);
bfs_exec_free(expr->execbuf);
@@ -2273,14 +2269,9 @@ static struct expr *parse_regex(struct parser_state *state, int flags, int arg2)
goto fail;
}
- expr->regex = malloc(sizeof(regex_t));
+ int err;
+ expr->regex = bfs_regcomp(expr->sdata, state->regex_type, flags, &err);
if (!expr->regex) {
- parse_perror(state, "malloc()");
- goto fail;
- }
-
- int err = bfs_regcomp(expr->regex, expr->sdata, flags, state->regex_type);
- if (err != 0) {
char *str = bfs_regerror(err, NULL);
if (str) {
parse_error(state, "${blu}%s${rs} ${bld}%s${rs}: %s.\n", expr->argv[0], expr->argv[1], str);
@@ -3134,7 +3125,7 @@ static const struct table_entry parse_table[] = {
{"-iname", T_TEST, parse_name, true},
{"-inum", T_TEST, parse_inum},
{"-ipath", T_TEST, parse_path, true},
- {"-iregex", T_TEST, parse_regex, REG_ICASE},
+ {"-iregex", T_TEST, parse_regex, BFS_REGEX_ICASE},
{"-iwholename", T_TEST, parse_path, true},
{"-links", T_TEST, parse_links},
{"-lname", T_TEST, parse_lname, false},