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

Method PushRegexp

extern/re2/re2/parse.cc:237–267  ·  view source on GitHub ↗

Pushes the given regular expression onto the stack. Could check for too much memory used here.

Source from the content-addressed store, hash-verified

235// Pushes the given regular expression onto the stack.
236// Could check for too much memory used here.
237bool Regexp::ParseState::PushRegexp(Regexp* re) {
238 MaybeConcatString(-1, NoParseFlags);
239
240 // Special case: a character class of one character is just
241 // a literal. This is a common idiom for escaping
242 // single characters (e.g., [.] instead of \.), and some
243 // analysis does better with fewer character classes.
244 // Similarly, [Aa] can be rewritten as a literal A with ASCII case folding.
245 if (re->op_ == kRegexpCharClass && re->ccb_ != NULL) {
246 re->ccb_->RemoveAbove(rune_max_);
247 if (re->ccb_->size() == 1) {
248 Rune r = re->ccb_->begin()->lo;
249 re->Decref();
250 re = new Regexp(kRegexpLiteral, flags_);
251 re->rune_ = r;
252 } else if (re->ccb_->size() == 2) {
253 Rune r = re->ccb_->begin()->lo;
254 if ('A' <= r && r <= 'Z' && re->ccb_->Contains(r + 'a' - 'A')) {
255 re->Decref();
256 re = new Regexp(kRegexpLiteral, flags_ | FoldCase);
257 re->rune_ = r + 'a' - 'A';
258 }
259 }
260 }
261
262 if (!IsMarker(re->op()))
263 re->simple_ = re->ComputeSimple();
264 re->down_ = stacktop_;
265 stacktop_ = re;
266 return true;
267}
268
269// Searches the case folding tables and returns the CaseFold* that contains r.
270// If there isn't one, returns the CaseFold* with smallest f->lo bigger than r.

Callers 1

ParseMethod · 0.80

Calls 7

RemoveAboveMethod · 0.80
ComputeSimpleMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
DecrefMethod · 0.45
ContainsMethod · 0.45
opMethod · 0.45

Tested by

no test coverage detected