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 | 1768b2d01677c54d1d0f69abae1002ad32345e80 (patch) | |
tree | b8fea97bdb4555f153371f7a78edc6ff8ba9dd1d | |
parent | 7f20e18a3cc86e456d5810100b902dd33645e786 (diff) | |
download | txr-1768b2d01677c54d1d0f69abae1002ad32345e80.tar.gz txr-1768b2d01677c54d1d0f69abae1002ad32345e80.tar.bz2 txr-1768b2d01677c54d1d0f69abae1002ad32345e80.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 */ |