From: NeilBrown Date: Mon, 12 Jun 2023 01:26:41 +0000 (+1000) Subject: rexel: remove abort() calls not in #ifdef DEBUG X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=be92c682c7681c13af0fbfd77532fbafe925e4c2;p=edlib.git rexel: remove abort() calls not in #ifdef DEBUG if DEBUG is set, it is OK to abort. If not, don't. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index da7aca31..ab325840 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -9,10 +9,10 @@ the file. ### Trivial -- [ ] give every pane a link to root/editor main and use that +- [X] give every pane a link to root/editor main and use that instead of statics. Then maybe times_up() can use pane_too_long() - [ ] mark DEF_CMD structs as const -- [ ] rexel: don't abort if something looks wrong, just fail. +- [X] rexel: don't abort if something looks wrong, just fail. ### Small @@ -186,7 +186,7 @@ Module features ### rexel -- [ ] don't abort if something looks wrong, just fail. +- [X] don't abort if something looks wrong, just fail. - [ ] move to separate git repo and document well. - [ ] review return code of rxl_advance(). What should be returned if a flag allowed a match, but the char didn't. diff --git a/rexel.c b/rexel.c index 6486073f..730917ad 100644 --- a/rexel.c +++ b/rexel.c @@ -642,7 +642,8 @@ static int advance_one(struct match_state *st safe, int i, advance = -2; } else /* Nothing else is possible here */ - abort(); + /* abort(); */ + advance = -2; if (advance < 0) /* no match on this path */ ; @@ -1125,7 +1126,7 @@ static wint_t cvt_hex(const char *s safe, int len) else if (*s <= 'f') rv += *s - 'a' + 10; else - abort(); + return WERR; s++; len--; } @@ -1774,8 +1775,13 @@ static bool parse_piece(struct parse_state *st safe) start = newstart; max -= 1; } - if (last != st->next) + if (last != st->next) { + #ifdef DEBUG abort(); + #else + return False; + #endif + } } return True; } @@ -2062,8 +2068,14 @@ unsigned short *rxl_parse(const char *patn safe, int *lenp, int nocase) st.capture = 0; if (nocase) add_cmd(&st, REC_IGNCASE); - if (!parse_re(&st, DoCapture)) + if (!parse_re(&st, DoCapture)) { + #ifdef DEBUG abort(); + #else + free(st.rxl); + return NULL; + #endif + } add_cmd(&st, REC_MATCH); return st.rxl; }