The actual DFA search: calls AnalyzeSearch and then FastSearchLoop.
| 1725 | |
| 1726 | // The actual DFA search: calls AnalyzeSearch and then FastSearchLoop. |
| 1727 | bool DFA::Search(const StringPiece& text, |
| 1728 | const StringPiece& context, |
| 1729 | bool anchored, |
| 1730 | bool want_earliest_match, |
| 1731 | bool run_forward, |
| 1732 | bool* failed, |
| 1733 | const char** epp, |
| 1734 | SparseSet* matches) { |
| 1735 | *epp = NULL; |
| 1736 | if (!ok()) { |
| 1737 | *failed = true; |
| 1738 | return false; |
| 1739 | } |
| 1740 | *failed = false; |
| 1741 | |
| 1742 | if (ExtraDebug) { |
| 1743 | fprintf(stderr, "\nprogram:\n%s\n", prog_->DumpUnanchored().c_str()); |
| 1744 | fprintf(stderr, "text %s anchored=%d earliest=%d fwd=%d kind %d\n", |
| 1745 | std::string(text).c_str(), anchored, want_earliest_match, run_forward, kind_); |
| 1746 | } |
| 1747 | |
| 1748 | RWLocker l(&cache_mutex_); |
| 1749 | SearchParams params(text, context, &l); |
| 1750 | params.anchored = anchored; |
| 1751 | params.want_earliest_match = want_earliest_match; |
| 1752 | params.run_forward = run_forward; |
| 1753 | params.matches = matches; |
| 1754 | |
| 1755 | if (!AnalyzeSearch(¶ms)) { |
| 1756 | *failed = true; |
| 1757 | return false; |
| 1758 | } |
| 1759 | if (params.start == DeadState) |
| 1760 | return false; |
| 1761 | if (params.start == FullMatchState) { |
| 1762 | if (run_forward == want_earliest_match) |
| 1763 | *epp = text.data(); |
| 1764 | else |
| 1765 | *epp = text.data() + text.size(); |
| 1766 | return true; |
| 1767 | } |
| 1768 | if (ExtraDebug) |
| 1769 | fprintf(stderr, "start %s\n", DumpState(params.start).c_str()); |
| 1770 | bool ret = FastSearchLoop(¶ms); |
| 1771 | if (params.failed) { |
| 1772 | *failed = true; |
| 1773 | return false; |
| 1774 | } |
| 1775 | *epp = params.ep; |
| 1776 | return ret; |
| 1777 | } |
| 1778 | |
| 1779 | DFA* Prog::GetDFA(MatchKind kind) { |
| 1780 | // For a forward DFA, half the memory goes to each DFA. |
no test coverage detected