Inserting a matched-group reference into ORed triggers leads into an infinite loop. The code uses spacer in the substituting text to prevent additional matches against the new text that is inserted by the refactoring. Matched-group references slip through this mechanism because they are not, and cannot yet be, literal matches.
In fix_or, after fix_or_internal has returned, find returns true because the matched-group reference has now been replaced by the group it referenced. subst is called in a depth-first recursion that never ends.
If the matched-group reference in the TP2 is replaced by the equivalent literal text, find instead returns false because the substituting text contains spacer.
<<<<<<<< .../test.baf
IF
See(Player1)
OR(2)
RandomNum(10,1)
RandomNum(10,2)
See(Player2)
THEN
RESPONSE #100
NoAction()
END
>>>>>>>>
COPY - ~.../test.baf~ ~.../subst.baf~
REFACTOR_TRIGGER EVALUATE_REGEXP ~\(RandomNum(10,2)\)~ ~\1~
READ_ASCII 0 buff (BUFFER_LENGTH)
PRINT ~%buff%~
Inserting a matched-group reference into
OR
ed triggers leads into an infinite loop. The code usesspacer
in the substituting text to prevent additional matches against the new text that is inserted by the refactoring. Matched-group references slip through this mechanism because they are not, and cannot yet be, literal matches.In
fix_or
, afterfix_or_internal
has returned,find
returns true because the matched-group reference has now been replaced by the group it referenced.subst
is called in a depth-first recursion that never ends.If the matched-group reference in the TP2 is replaced by the equivalent literal text,
find
instead returns false because the substituting text containsspacer
.