I'm trying to switch from ASM to C, but I now have crashes that never happened before (no error log). The following procedure does not run independently, but maybe you'll see something obviously wrong in my code:
Code: Select all
Procedure$ ReplaceReplacers(line$)
Define regex
Debug "RR1" ; DEBUG
regex = CreateRegularExpression(#PB_Any, "\*\*(.*?)\*\*")
ExamineRegularExpression(regex, line$)
While NextRegularExpressionMatch(regex)
Define match$ = RegularExpressionMatchString(regex)
match$ = Trim(ReplaceString(match$, "**", ""))
Define func_line$ = StringField(match$, 1, "(")
Define args_line$ = StringField(StringField(match$, 2, "("), 1, ")")
args_line$ = Trim(ReplaceString(args_line$, ", ", ","))
args_line$ = ReplaceReplacers(args_line$)
Define func.__RuntimeReplacer = GetRuntimeInteger("RH_Encounter::" + func_line$ + "()")
If func = 0
xyError::FatalError("Error at replacer " + match$ + ": '" + func_line$ + "' is not a valid function.")
EndIf
line$ = ReplaceString(line$, RegularExpressionMatchString(regex), func(args_line$), #PB_String_CaseSensitive, 1, 1)
Debug match$ ; DEBUG
Wend
FreeRegularExpression(regex)
Debug "RR2" ; DEBUG
ProcedureReturn line$
EndProcedure
Debug log looks like this:
RR1
RR2 (lag/crash here)
match$
RR2
