// 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, TokCondition condition) { L tok = javaTok(s); jreplace_dyn_allowNull(tok, in, replacer, condition); ret join(tok); } sbool jreplace_dyn_allowNull(LS tok, S in, TokReplacer replacer, TokCondition condition) { ret jreplace_dyn_allowNull(tok, in, replacer, condition, false, true); } sbool jreplace_dyn_allowNull(LS tok, S in, TokReplacer replacer, TokCondition 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(); 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 tok.set(i, expansion); if (reTok) { // would this ever be false?? int n = l(tok); reTok(tok, i, end); i += l(tok)-n; // adjust for replacement } set anyChange; } } throw fail("woot? 10000! " + quote(in) + " => " + quote(out)); }