nfaCheckFinalState: define return value

Make nfaCheckFinalState return MO_HALT_MATCHING when the user instructs
us (via the callback return value) to halt matching. In the caller,
check this value and stop matching if told.
This commit is contained in:
Justin Viiret
2016-01-11 15:19:09 +11:00
committed by Matthew Barr
parent 843ca0e7cc
commit 621dfbebb7
4 changed files with 35 additions and 21 deletions

View File

@@ -168,8 +168,12 @@ void roseCheckNfaEod(const struct RoseEngine *t, char *state,
nfaExpandState(nfa, fstate, sstate, offset, key);
}
nfaCheckFinalState(nfa, fstate, sstate, offset, scratch->tctxt.cb,
scratch->tctxt.cb_som, scratch->tctxt.userCtx);
if (nfaCheckFinalState(nfa, fstate, sstate, offset, scratch->tctxt.cb,
scratch->tctxt.cb_som,
scratch->tctxt.userCtx) == MO_HALT_MATCHING) {
DEBUG_PRINTF("user instructed us to stop\n");
return;
}
}
}
@@ -213,8 +217,13 @@ void roseCheckEodSuffixes(const struct RoseEngine *t, char *state, u64a offset,
* history buffer. */
char rv = nfaQueueExecRose(q->nfa, q, MO_INVALID_IDX);
if (rv) { /* nfa is still alive */
nfaCheckFinalState(nfa, fstate, sstate, offset, scratch->tctxt.cb,
scratch->tctxt.cb_som, scratch->tctxt.userCtx);
if (nfaCheckFinalState(nfa, fstate, sstate, offset,
scratch->tctxt.cb, scratch->tctxt.cb_som,
scratch->tctxt.userCtx) ==
MO_HALT_MATCHING) {
DEBUG_PRINTF("user instructed us to stop\n");
return;
}
}
}
}