MCPcopy Create free account
hub / github.com/google/re2j / allMatches

Method allMatches

java/com/google/re2j/RE2.java:535–570  ·  view source on GitHub ↗
(MachineInput input, int n, DeliverFunc deliver)

Source from the content-addressed store, hash-verified

533
534 // Find matches in input.
535 private void allMatches(MachineInput input, int n, DeliverFunc deliver) {
536 int end = input.endPos();
537 if (n < 0) {
538 n = end + 1;
539 }
540 for (int pos = 0, i = 0, prevMatchEnd = -1; i < n && pos <= end; ) {
541 int[] matches = doExecute(input, pos, UNANCHORED, prog.numCap);
542 if (matches == null || matches.length == 0) {
543 break;
544 }
545
546 boolean accept = true;
547 if (matches[1] == pos) {
548 // We've found an empty match.
549 if (matches[0] == prevMatchEnd) {
550 // We don't allow an empty match right
551 // after a previous match, so ignore it.
552 accept = false;
553 }
554 int r = input.step(pos);
555 if (r < 0) { // EOF
556 pos = end + 1;
557 } else {
558 pos += r & 0x7;
559 }
560 } else {
561 pos = matches[1];
562 }
563 prevMatchEnd = matches[1];
564
565 if (accept) {
566 deliver.deliver(pad(matches));
567 i++;
568 }
569 }
570 }
571
572 // Legacy Go-style interface; preserved (package-private) for better
573 // test coverage.

Callers 8

findAllUTF8Method · 0.95
findAllUTF8IndexMethod · 0.95
findAllMethod · 0.95
findAllIndexMethod · 0.95
findAllUTF8SubmatchMethod · 0.95
findAllSubmatchMethod · 0.95
findAllSubmatchIndexMethod · 0.95

Calls 5

doExecuteMethod · 0.95
padMethod · 0.95
deliverMethod · 0.65
endPosMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected