// match2 matches multiple "*" (matches a single token) wildcards and zero or one "..." wildcards (matches multiple tokens) static S[] match2(L pat, L tok) { // standard case (no ...) int i = pat.indexOf("..."); if (i < 0) return match2_match(pat, tok); pat = new ArrayList(pat); // We're modifying it, so copy first pat.set(i, "*"); while (pat.size() < tok.size()) { pat.add(i, "*"); pat.add(i+1, ""); // doesn't matter } return match2_match(pat, tok); } static S[] match2_match(L pat, L tok) { L result = new ArrayList(); if (pat.size() != tok.size()) { ifdef match2_debug print("match2: Size mismatch: " + structure(pat) + " vs " + structure(tok)); endifdef return null; } for (int i = 1; i < pat.size(); i += 2) { S p = pat.get(i), t = tok.get(i); ifdef match2_debug print("match2: Checking " + p + " against " + t); endifdef if (eq(p, "*")) result.add(t); else if (!equalsIgnoreCase(unquote(p), unquote(t))) // bold change - match quoted and unquoted now. TODO: should remove return null; } return result.toArray(new S[result.size()]); }