(MachineInput in, int pos, int anchor)
| 213 | // It reports whether a match was found. |
| 214 | // If so, matchcap holds the submatch information. |
| 215 | boolean match(MachineInput in, int pos, int anchor) { |
| 216 | int startCond = re2.cond; |
| 217 | if (startCond == Utils.EMPTY_ALL) { // impossible |
| 218 | return false; |
| 219 | } |
| 220 | if ((anchor == RE2.ANCHOR_START || anchor == RE2.ANCHOR_BOTH) && pos != 0) { |
| 221 | return false; |
| 222 | } |
| 223 | matched = false; |
| 224 | Arrays.fill(matchcap, 0, prog.numCap, -1); |
| 225 | Queue runq = q0, nextq = q1; |
| 226 | int r = in.step(pos); |
| 227 | int rune = r >> 3; |
| 228 | int width = r & 7; |
| 229 | int rune1 = -1; |
| 230 | int width1 = 0; |
| 231 | if (r != MachineInput.EOF) { |
| 232 | r = in.step(pos + width); |
| 233 | rune1 = r >> 3; |
| 234 | width1 = r & 7; |
| 235 | } |
| 236 | int flag; // bitmask of EMPTY_* flags |
| 237 | if (pos == 0) { |
| 238 | flag = Utils.emptyOpContext(-1, rune); |
| 239 | } else { |
| 240 | flag = in.context(pos); |
| 241 | } |
| 242 | for (; ; ) { |
| 243 | |
| 244 | if (runq.isEmpty()) { |
| 245 | if ((startCond & Utils.EMPTY_BEGIN_TEXT) != 0 && pos != 0) { |
| 246 | // Anchored match, past beginning of text. |
| 247 | break; |
| 248 | } |
| 249 | if (matched) { |
| 250 | // Have match; finished exploring alternatives. |
| 251 | break; |
| 252 | } |
| 253 | if (!re2.prefix.isEmpty() && rune1 != re2.prefixRune && in.canCheckPrefix()) { |
| 254 | // Match requires literal prefix; fast search for it. |
| 255 | int advance = in.index(re2, pos); |
| 256 | if (advance < 0) { |
| 257 | break; |
| 258 | } |
| 259 | pos += advance; |
| 260 | r = in.step(pos); |
| 261 | rune = r >> 3; |
| 262 | width = r & 7; |
| 263 | r = in.step(pos + width); |
| 264 | rune1 = r >> 3; |
| 265 | width1 = r & 7; |
| 266 | } |
| 267 | } |
| 268 | if (!matched && (pos == 0 || anchor == RE2.UNANCHORED)) { |
| 269 | // If we are anchoring at begin then only add threads that begin |
| 270 | // at |pos| = 0. |
| 271 | if (ncap > 0) { |
| 272 | matchcap[0] = pos; |
no test coverage detected