Warning: session_start(): open(/var/lib/php/sessions/sess_u5up164eihp81903qq3p7t0nns, 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
static bool flexMatch_debug;
static bool flexMatch(S pat, S s) {
ret flexMatch(pat, s, null);
}
static bool flexMatch(S pat, S s, Matches m) {
L tokpat = codeTokens(javaTok(pat));
L tokfull = joinBrackets(javaTok(unnull(s))); // shouldn't joinBrackets be done for the pattern?
L tok = codeTokens(tokfull);
new BitSet bla;
if (!flexMatch_impl(tokpat, 0, tok, 0, bla)) ret false;
if (m != null) {
new L l;
for (int i = 1; i < l(tokfull); i += 2) {
if (bla.get(i/2)) {
int j = i;
while (j < l(tokfull) && bla.get(j/2)) j += 2;
l.add(join(subList(tokfull, i, j-1)));
i = j-2;
}
}
m.m = toStringArray(l);
}
ret true;
}
static bool flexMatch_impl(L pat, int ipat, L tok, int itok, BitSet bla) {
if (flexMatch_debug)
print("flexMatch " + structure(subList(pat, ipat)) + " " + structure(subList(tok, itok)) + " " + structure(bla));
if (ipat >= l(pat))
ret itok >= l(tok);
S t = pat.get(ipat);
if (eq(t, "*"))
if (itok >= l(tok)) // nothing to consume - just advance in pattern
ret flexMatch_impl(pat, ipat+1, tok, itok, bla);
else { // something to consume - try both continuing and ending to fill "*"
bla.set(itok);
if (flexMatch_impl(pat, ipat, tok, itok+1, bla)
|| flexMatch_impl(pat, ipat+1, tok, itok+1, bla))
ret true; // success, leave mark
bla.clear(itok); // fail, undo marking
ret false;
}
if (itok >= l(tok)) {
if (flexMatch_debug)
print("too much pattern");
ret false;
}
if (neq(tok.get(itok), t)) {
if (flexMatch_debug)
print("mismatch");
ret false;
}
// ok, consume and proceed
ret flexMatch_impl(pat, ipat+1, tok, itok+1, bla);
}