Bit-state search.
| 354 | |
| 355 | // Bit-state search. |
| 356 | bool Prog::SearchBitState(const StringPiece& text, |
| 357 | const StringPiece& context, |
| 358 | Anchor anchor, |
| 359 | MatchKind kind, |
| 360 | StringPiece* match, |
| 361 | int nmatch) { |
| 362 | // If full match, we ask for an anchored longest match |
| 363 | // and then check that match[0] == text. |
| 364 | // So make sure match[0] exists. |
| 365 | StringPiece sp0; |
| 366 | if (kind == kFullMatch) { |
| 367 | anchor = kAnchored; |
| 368 | if (nmatch < 1) { |
| 369 | match = &sp0; |
| 370 | nmatch = 1; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | // Run the search. |
| 375 | BitState b(this); |
| 376 | bool anchored = anchor == kAnchored; |
| 377 | bool longest = kind != kFirstMatch; |
| 378 | if (!b.Search(text, context, anchored, longest, match, nmatch)) |
| 379 | return false; |
| 380 | if (kind == kFullMatch && match[0].end() != text.end()) |
| 381 | return false; |
| 382 | return true; |
| 383 | } |
| 384 | |
| 385 | } // namespace re2 |