summaryrefslogtreecommitdiffstats
path: root/util.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 /util.c
parentb490dc534eedcc9878d4962e6d02baf4217a712f (diff)
downloadbfs-82f7f9ee1849947ed6de227279e623d8fc3a1ee1.tar.xz
regex: Rework error handling
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/util.c b/util.c
index 1b363cd..21921e8 100644
--- a/util.c
+++ b/util.c
@@ -263,15 +263,14 @@ static int xrpregex(nl_item item, const char *response) {
return -1;
}
- int err;
- struct bfs_regex *regex = bfs_regcomp(pattern, BFS_REGEX_POSIX_EXTENDED, 0, &err);
- if (!regex) {
- return -1;
+ struct bfs_regex *regex;
+ int ret = bfs_regcomp(&regex, pattern, BFS_REGEX_POSIX_EXTENDED, 0);
+ if (ret == 0) {
+ ret = bfs_regexec(regex, response, 0);
}
- int ret = bfs_regexec(regex, response, 0, &err);
bfs_regfree(regex);
- return err ? -1 : ret;
+ return ret;
}
/** Check if a response is affirmative or negative. */