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 /util.c | |
parent | b490dc534eedcc9878d4962e6d02baf4217a712f (diff) | |
download | bfs-82f7f9ee1849947ed6de227279e623d8fc3a1ee1.tar.xz |
regex: Rework error handling
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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(®ex, 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. */ |