// goes over input only once (doesn't start again at 1 like jreplace_dyn) static S jreplace_dyn_allowNull(S s, S in, TokReplacer replacer, ITokCondition condition default null) { L tok = javaTok(s); jreplace_dyn_allowNull(tok, in, replacer, condition); ret join(tok); } sbool jreplace_dyn_allowNull(LS tok, S in, TokReplacer replacer, ITokCondition condition default null) { ret jreplace_dyn_allowNull(tok, in, replacer, condition, false, true); } sbool jreplace_dyn_allowNull(LS tok, S in, TokReplacer replacer, ITokCondition condition, bool ignoreCase, bool reTok) { LS tokin = javaTok(in); jfind_preprocess(tokin); S[] toks = toStringArray(codeTokensOnly(tokin)); bool anyChange; int i = 0; for safety to 10000: { ping(); ifdef jreplace_dyn_allowNull_debug printVars jreplace_dyn_allowNull_debug(+i, n := l(tok)); endifdef i = findCodeTokens(tok, i, ignoreCase, toks, condition); if (i < 0) ret anyChange; int start = i, end = i+l(tokin)-2; i = end+2; S expansion = replacer.get(tok, start, end); if (expansion != null) { clearAllTokens(tok, start, end); // C to C ifdef jreplace_dyn_allowNull_debug printVars jreplace_dyn_allowNull_debug(+i, +start, +end, n := l(tok)); endifdef tok.set(start, expansion); if (reTok) { // would this ever be false?? int n = l(tok); reTok(tok, start, end); i += l(tok)-n; // adjust for replacement } set anyChange; } } throw fail("woot? 10000! " + quote(in) + " => " + replacer); }