diff --git a/src/nfa/limex_common_impl.h b/src/nfa/limex_common_impl.h index 5bd5187b..e441945d 100644 --- a/src/nfa/limex_common_impl.h +++ b/src/nfa/limex_common_impl.h @@ -115,8 +115,7 @@ void SQUASH_UNTUG_BR_FN(const IMPL_NFA_T *limex, static really_inline char PROCESS_ACCEPTS_IMPL_FN(const IMPL_NFA_T *limex, const STATE_T *s, - STATE_T *squash, const ENG_STATE_T *squashMasks, - const STATE_T *acceptMask, + STATE_T *squash, const STATE_T *acceptMask, const struct NFAAccept *acceptTable, u64a offset, NfaCallback callback, void *context) { assert(s); @@ -151,10 +150,9 @@ char PROCESS_ACCEPTS_IMPL_FN(const IMPL_NFA_T *limex, const STATE_T *s, return 1; } if (squash != NULL && a->squash != MO_INVALID_IDX) { - assert(squashMasks); - assert(a->squash < limex->squashCount); - const ENG_STATE_T *sq = &squashMasks[a->squash]; - DEBUG_PRINTF("squash mask %u @ %p\n", a->squash, sq); + DEBUG_PRINTF("applying squash mask at offset %u\n", a->squash); + const ENG_STATE_T *sq = + (const ENG_STATE_T *)((const char *)limex + a->squash); *squash = AND_STATE(*squash, LOAD_FROM_ENG(sq)); } } @@ -171,11 +169,8 @@ char PROCESS_ACCEPTS_FN(const IMPL_NFA_T *limex, STATE_T *s, NfaCallback callback, void *context) { // We have squash masks we might have to apply after firing reports. STATE_T squash = ONES_STATE; - const ENG_STATE_T *squashMasks = (const ENG_STATE_T *) - ((const char *)limex + limex->squashOffset); - - return PROCESS_ACCEPTS_IMPL_FN(limex, s, &squash, squashMasks, acceptMask, - acceptTable, offset, callback, context); + return PROCESS_ACCEPTS_IMPL_FN(limex, s, &squash, acceptMask, acceptTable, + offset, callback, context); *s = AND_STATE(*s, squash); } @@ -187,10 +182,8 @@ char PROCESS_ACCEPTS_NOSQUASH_FN(const IMPL_NFA_T *limex, const STATE_T *s, u64a offset, NfaCallback callback, void *context) { STATE_T *squash = NULL; - const ENG_STATE_T *squashMasks = NULL; - - return PROCESS_ACCEPTS_IMPL_FN(limex, s, squash, squashMasks, acceptMask, - acceptTable, offset, callback, context); + return PROCESS_ACCEPTS_IMPL_FN(limex, s, squash, acceptMask, acceptTable, + offset, callback, context); } // Run EOD accepts. Note that repeat_ctrl and repeat_state may be NULL if this diff --git a/src/nfa/limex_compile.cpp b/src/nfa/limex_compile.cpp index 89eaf10a..53a003e3 100644 --- a/src/nfa/limex_compile.cpp +++ b/src/nfa/limex_compile.cpp @@ -2020,12 +2020,13 @@ struct Factory { maskSetBits(limex->accept, acceptMask); maskSetBits(limex->acceptAtEOD, acceptEodMask); - // Transforms the index into the report list into an offset relative to - // the base of the limex. - auto report_offset_fn = [&](NFAAccept a) { + // Transforms the indices (report list, squash mask) into offsets + // relative to the base of the limex. + auto transform_offset_fn = [&](NFAAccept a) { if (!a.single_report) { a.reports = reportListOffset + a.reports * sizeof(ReportID); } + a.squash = squashOffset + a.squash * sizeof(tableRow_t); return a; }; @@ -2036,7 +2037,7 @@ struct Factory { NFAAccept *acceptsTable = (NFAAccept *)(limex_base + acceptsOffset); assert(ISALIGNED(acceptsTable)); transform(accepts.begin(), accepts.end(), acceptsTable, - report_offset_fn); + transform_offset_fn); // Write eod accept table. limex->acceptEodOffset = acceptsEodOffset; @@ -2045,7 +2046,7 @@ struct Factory { NFAAccept *acceptsEodTable = (NFAAccept *)(limex_base + acceptsEodOffset); assert(ISALIGNED(acceptsEodTable)); transform(acceptsEod.begin(), acceptsEod.end(), acceptsEodTable, - report_offset_fn); + transform_offset_fn); // Write squash mask table. limex->squashCount = verify_u32(squash.size()); diff --git a/src/nfa/limex_internal.h b/src/nfa/limex_internal.h index 0d46732f..723803c1 100644 --- a/src/nfa/limex_internal.h +++ b/src/nfa/limex_internal.h @@ -192,7 +192,7 @@ struct NFAAccept { */ u32 reports; - u32 squash; //!< Offset into squash masks, or MO_INVALID_IDX. + u32 squash; //!< Offset (from LimEx) into squash masks, or MO_INVALID_IDX. }; #endif