Warning: session_start(): open(/var/lib/php/sessions/sess_2jua45iqb2p3ga1f3nq7ngmoo9, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// places must be sorted
static LS reTok_multi(LS tok, L places) {
if (empty(places)) ret tok;
L orig = cloneList(tok); // copy to orig
// extend & merge ranges
new L places2;
for (IntRange p : places) {
p = intRange(p.start & ~1, p.end | 1); // extend to N-to-N
if (nempty(places2) && p.start <= last(places2).end)
last(places2).end = p.end; // merge if overlapping
else
places2.add(p);
}
ifdef reTok_multi_debug
printStruct("places: ", places2);
endifdef
int iPlace = 0, n = l(orig);
IntRange p = get(places2, iPlace);
tok.clear();
int i = 0, next = p.start;
while (i < n)
if (i < next)
tok.add(orig.get(i++));
else {
int j = p.end;
S s = joinSubList(orig, i, j);
ifdef reTok_multi_debug
printStruct("retokking: ", s);
endifdef
tok.addAll(javaTok(s));
i = j;
p = get(places2, ++iPlace);
if (p == null) break;
next = p.start;
}
while (i < n)
tok.add(orig.get(i++));
ifdef reTok_multi_check
LS correct = javaTok(join(orig));
if (neq(correct, tok)) {
int n = min(l(correct), l(tok));
if (l(correct) != l(tok)) print("reTok_multi_check: size difference " + l(correct) + " / " + l(tok));
for i to n:
if (!eq(tok.get(i), correct.get(i))) {
for (int j = max(0, i-1); j < min(n, i+1); j++)
print("reTok_multi_check diff @ " + j + "/" + n + ": " + quote(correct.get(j)) + " / " + quote(tok.get(j)));
break;
}
fail("reTok_multi_check");
}
endifdef
ret tok;
}