MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / UnsafeSearchBacktrack

Method UnsafeSearchBacktrack

extern/re2/re2/testing/backtrack.cc:246–273  ·  view source on GitHub ↗

Runs a backtracking search.

Source from the content-addressed store, hash-verified

244
245// Runs a backtracking search.
246bool Prog::UnsafeSearchBacktrack(const StringPiece& text,
247 const StringPiece& context,
248 Anchor anchor,
249 MatchKind kind,
250 StringPiece* match,
251 int nmatch) {
252 // If full match, we ask for an anchored longest match
253 // and then check that match[0] == text.
254 // So make sure match[0] exists.
255 StringPiece sp0;
256 if (kind == kFullMatch) {
257 anchor = kAnchored;
258 if (nmatch < 1) {
259 match = &sp0;
260 nmatch = 1;
261 }
262 }
263
264 // Run the search.
265 Backtracker b(this);
266 bool anchored = anchor == kAnchored;
267 bool longest = kind != kFirstMatch;
268 if (!b.Search(text, context, anchored, longest, match, nmatch))
269 return false;
270 if (kind == kFullMatch && match[0].end() != text.end())
271 return false;
272 return true;
273}
274
275} // namespace re2

Callers 4

RunSearchMethod · 0.80
Parse3BacktrackFunction · 0.80
Parse3CachedBacktrackFunction · 0.80
Parse1CachedBacktrackFunction · 0.80

Calls 2

SearchMethod · 0.45
endMethod · 0.45

Tested by 1

RunSearchMethod · 0.64