}
}
- if (!is_simple &&
+ if (!is_simple && ir->ekey != INVALID_EKEY &&
unlikely(isExhausted(ci->rose, ci->exhaustionVector, ir->ekey))) {
DEBUG_PRINTF("ate exhausted match\n");
return MO_CONTINUE_MATCHING;
return MO_HALT_MATCHING;
}
- if (!is_simple && ir->ekey != END_EXHAUST) {
+ if (!is_simple && ir->ekey != INVALID_EKEY) {
markAsMatched(ci->rose, ci->exhaustionVector, ir->ekey);
return MO_CONTINUE_MATCHING;
} else {
int halt = 0;
- if (!is_simple &&
+ if (!is_simple && ir->ekey != INVALID_EKEY &&
unlikely(isExhausted(ci->rose, ci->exhaustionVector, ir->ekey))) {
DEBUG_PRINTF("ate exhausted match\n");
goto exit;
halt = ci->userCallback((unsigned int)ir->onmatch, from_offset, to_offset,
flags, ci->userContext);
- if (!is_simple) {
+ if (!is_simple && ir->ekey != INVALID_EKEY) {
markAsMatched(ci->rose, ci->exhaustionVector, ir->ekey);
}
DEBUG_PRINTF("check exhaustion -> start at %u\n", info->ekeyListOffset);
- /* END_EXHAUST terminated list */
+ /* INVALID_EKEY terminated list */
const u32 *ekeys = (const u32 *)((const char *)t + info->ekeyListOffset);
- while (*ekeys != END_EXHAUST) {
+ while (*ekeys != INVALID_EKEY) {
DEBUG_PRINTF("check %u\n", *ekeys);
if (!isExhausted(t, exhausted, *ekeys)) {
DEBUG_PRINTF("not exhausted -> alive\n");
populateCoreInfo(scratch, rose, scratch->bstate, onEvent, userCtx, data,
length, NULL, 0, 0, 0, flags);
- clearEvec(scratch->core_info.exhaustionVector, rose);
+ clearEvec(rose, scratch->core_info.exhaustionVector);
// Rose program execution (used for some report paths) depends on these
// values being initialised.
setStreamStatus(state, 0);
roseInitState(rose, state);
- clearEvec((char *)state + rose->stateOffsets.exhausted, rose);
+ clearEvec(rose, state + rose->stateOffsets.exhausted);
// SOM state multibit structures.
initSomState(rose, state);
#define EXHAUST_H
#include "rose/rose_internal.h"
+#include "util/internal_report.h"
#include "util/multibit.h"
#include "ue2common.h"
-/** \brief Sentinel value meaning no further exhaustion keys. */
-#define END_EXHAUST (~(u32)0)
-
-/** \brief Test whether the given key (\a eoff) is set in the exhaustion vector
+/** \brief Test whether the given key (\a ekey) is set in the exhaustion vector
* \a evec. */
static really_inline
-int isExhausted(const struct RoseEngine *t, const char *evec, u32 eoff) {
- DEBUG_PRINTF("checking exhaustion %p %u\n", evec, eoff);
- return eoff != END_EXHAUST &&
- mmbit_isset((const u8 *)evec, t->ekeyCount, eoff);
+int isExhausted(const struct RoseEngine *t, const char *evec, u32 ekey) {
+ DEBUG_PRINTF("checking exhaustion %p %u\n", evec, ekey);
+ assert(ekey != INVALID_EKEY);
+ assert(ekey < t->ekeyCount);
+ return mmbit_isset((const u8 *)evec, t->ekeyCount, ekey);
}
/** \brief Returns 1 if all exhaustion keys in the bitvector are on. */
return mmbit_all((const u8 *)evec, t->ekeyCount);
}
-/** \brief Mark key \a eoff on in the exhaustion vector. */
+/** \brief Mark key \a ekey on in the exhaustion vector. */
static really_inline
-void markAsMatched(const struct RoseEngine *t, char *evec, u32 eoff) {
- if (eoff != END_EXHAUST) {
- DEBUG_PRINTF("marking as exhausted key %u\n", eoff);
- mmbit_set((u8 *)evec, t->ekeyCount, eoff);
- }
+void markAsMatched(const struct RoseEngine *t, char *evec, u32 ekey) {
+ DEBUG_PRINTF("marking as exhausted key %u\n", ekey);
+ assert(ekey != INVALID_EKEY);
+ assert(ekey < t->ekeyCount);
+ mmbit_set((u8 *)evec, t->ekeyCount, ekey);
}
/** \brief Clear all keys in the exhaustion vector. */
static really_inline
-void clearEvec(char *evec, const struct RoseEngine *t) {
+void clearEvec(const struct RoseEngine *t, char *evec) {
DEBUG_PRINTF("clearing evec %p %u\n", evec, t->ekeyCount);
mmbit_clear((u8 *)evec, t->ekeyCount);
}