From 59db194299c94c6707095797c3df0e2f67ff82b2 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sat, 14 Jan 2023 14:38:38 +0100 Subject: regexec.c - make REF into a backtracking state This way we can do the required paren restoration only when it is in use. When we match a REF type node which is potentially a reference to an unclosed paren we push the match context information, currently for "everything", but in a future patch we can teach it to be more efficient by adding a new parameter to the REF regop to track which parens it should save. This converts the backtracking changes from the previous commit, so that it is run only when specifically enabled via the define RE_PESSIMISTIC_PARENS which is by default 0. We don't make the new fields in the struct conditional as the stack frames are large and our changes don't make any real difference and it keeps things simpler to not have conditional members, especially since some of the structures have to line up with each other. If enabling RE_PESSIMISTIC_PARENS fixes a backtracking bug then it means something is sensitive to us not necessarily restoring the parens properly on failure. We make some assumptions that the paren state after a failing state will be corrected by a future successful state, or that the state of the parens is irrelevant as we will fail anyway. This can be made not true by EVAL, backrefs, and potentially some other scenarios. Thus I have left this inefficient logic in place but guarded by the flag. --- regcomp.sym | 1 + 1 file changed, 1 insertion(+) (limited to 'regcomp.sym') diff --git a/regcomp.sym b/regcomp.sym index e01844f9b0..d58f1cb54f 100644 --- a/regcomp.sym +++ b/regcomp.sym @@ -344,3 +344,4 @@ MARKPOINT next:FAIL SKIP next:FAIL CUTGROUP next:FAIL KEEPS next:FAIL +REF next:FAIL -- cgit v1.2.1