From de0fec8fcb2e09500b4665b07fdad6a2902d9c87 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 26 Jan 2021 17:54:23 -0800 Subject: Removed check() and replaced with err()/errx() --- match.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'match.c') diff --git a/match.c b/match.c index c57bfcf..aac0520 100644 --- a/match.c +++ b/match.c @@ -3,6 +3,7 @@ // #include +#include #include #include #include @@ -313,7 +314,8 @@ static match_t *match(def_t *defs, file_t *f, const char *str, pat_t *pat, bool } case BP_AFTER: { ssize_t backtrack = pat->args.pat->len; - check(backtrack != -1, "'<' is only allowed for fixed-length operations"); + if (backtrack == -1) + errx(EXIT_FAILURE, "'<' is only allowed for fixed-length operations"); if (str - backtrack < f->contents) return NULL; match_t *before = match(defs, f, str - backtrack, pat->args.pat, ignorecase); if (before == NULL) return NULL; @@ -426,7 +428,8 @@ static match_t *match(def_t *defs, file_t *f, const char *str, pat_t *pat, bool } case BP_REF: { def_t *def = lookup(defs, pat->args.name.len, pat->args.name.name); - check(def != NULL, "Unknown identifier: '%.*s'", (int)pat->args.name.len, pat->args.name.name); + if (def == NULL) + errx(EXIT_FAILURE, "Unknown identifier: '%.*s'", (int)pat->args.name.len, pat->args.name.name); pat_t *ref = def->pat; pat_t rec_op = { @@ -474,7 +477,8 @@ static match_t *match(def_t *defs, file_t *f, const char *str, pat_t *pat, bool --m->refcount; } - check(m, "Match should be non-null at this point"); + if (!m) + errx(EXIT_FAILURE, "Match should be non-null at this point"); // This match wrapper mainly exists for record-keeping purposes and // does not affect correctness. It also helps with visualization of // match results. -- cgit v1.2.3