]> git.neil.brown.name Git - edlib.git/commitdiff
rexel: remove abort() calls not in #ifdef DEBUG
authorNeilBrown <neil@brown.name>
Mon, 12 Jun 2023 01:26:41 +0000 (11:26 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 07:51:40 +0000 (17:51 +1000)
if DEBUG is set, it is OK to abort.  If not, don't.

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
rexel.c

index da7aca315e2f6f89d9c5fe08f4d3161271ff3c1e..ab325840899333c67f9c19f93961dff20f2f7566 100644 (file)
@@ -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 6486073f00c1aeff254efd3ad697a2149e75e4a4..730917ad9aa254c59e0d9f771d426f74dcffcb3c 100644 (file)
--- 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;
 }