Its likely a more complex check for \<\> would avoid the false failure. It needs to check the previous op-code for BOW: something like mp[-1] == BOW with appropriate checking for start of buffer to avoid out-of-bounds.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think above change is better than using mp[-1] as distance between sp and mp may large than 1.
RESearch-2413-memset-1117.diff contains same change, but changed std::fill(bittab to memset(bitta. I'm plan to add another change to replace following loop:
Revert patch to RESearch-nfa-bittab-1111.diff, but with only nfa[0] = END; instead of clear whole 4K: reading from sp is valid after the loop been executed once, after sp = lp;, then sp is always lees than mp.
Committed with [03bbb3] including minor changes. Since std::fill may throw, noexcept removed from Compile. Its not unreasonable for something as complex as Compile to throw and it already reports failure with strings. Also changed unit test to point at this issue.
tagstkis moved local intoRESearch::Compile().bittabalso needs to be cleared in case of earlier return inside/* match char class */block.This moves a 4K
memsetfrom one-time creation to each search. Have you checked the performance impact?Its likely a more complex check for
\<\>would avoid the false failure. It needs to check the previous op-code forBOW: something likemp[-1] == BOWwith appropriate checking for start of buffer to avoid out-of-bounds.I think the failure is due to read saved pointer (
sporlp) beyond max written pointermp, wrap*spwith following helper also fixed the bug:I think above change is better than using
mp[-1]as distance betweenspandmpmay large than 1.RESearch-2413-memset-1117.diffcontains same change, but changedstd::fill(bittabtomemset(bitta. I'm plan to add another change to replace following loop:with
memcpy()andmemset()(negative part is only needed for/* match char class */block):std::fillis more type-safe thanmemset.Revert patch to
RESearch-nfa-bittab-1111.diff, but with onlynfa[0] = END;instead of clear whole 4K: reading fromspis valid after the loop been executed once, aftersp = lp;, thenspis always lees thanmp.Committed with [03bbb3] including minor changes. Since
std::fillmay throw,noexceptremoved fromCompile. Its not unreasonable for something as complex asCompileto throw and it already reports failure with strings. Also changed unit test to point at this issue.Related
Commit: [03bbb3]