diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-09-15 13:05:17 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-09-15 13:05:17 -0700 |
commit | aba19be251eb1cccbf2d0db1b17aed729c56f6aa (patch) | |
tree | b8fea97bdb4555f153371f7a78edc6ff8ba9dd1d | |
parent | 23af2e9ad0e190331fa1ef588c50b08c70faeaff (diff) | |
download | txr-aba19be251eb1cccbf2d0db1b17aed729c56f6aa.tar.gz txr-aba19be251eb1cccbf2d0db1b17aed729c56f6aa.tar.bz2 txr-aba19be251eb1cccbf2d0db1b17aed729c56f6aa.zip |
regex: bugfix: not taking full advantage of REGM_MATCH_DONE.
* regex.c (nfa_has_transitions): The logical disjunction here
is wrong. We would like to test whether a state has
transitions if it is not an epsilon state. The code which uses
this macro doesn't care about epsilon states, even though they
have transitions; those are squeezed out by transitively
closure. The wrong condition here makes the code think that
a NFA set has transitions when it does not, preventing the
result code REGM_MATCH_DONE to be produced which can spare
a character from being consumed from a stream.
-rw-r--r-- | regex.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -234,8 +234,8 @@ union nfa_state { #define nfa_accept_state_p(s) ((s)->a.kind == nfa_accept) #define nfa_empty_state_p(s) ((s)->a.kind == nfa_accept || \ (s)->a.kind == nfa_empty) -#define nfa_has_transitions(s) ((s)->a.kind != nfa_empty || \ - (s)->e.trans0 || (s)->e.trans1) +#define nfa_has_transitions(s) ((s)->a.kind != nfa_empty && \ + ((s)->e.trans0 || (s)->e.trans1)) struct nfa_machine { int is_nfa; /* common member */ |