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

Method ParseCCRange

extern/re2/re2/parse.cc:1881–1902  ·  view source on GitHub ↗

Parses a character class character, or, if the character is followed by a hyphen, parses a character class range. For single characters, rr->lo == rr->hi. Sets *s to span the remainder of the string. Sets *rp to the character.

Source from the content-addressed store, hash-verified

1879// Sets *s to span the remainder of the string.
1880// Sets *rp to the character.
1881bool Regexp::ParseState::ParseCCRange(StringPiece* s, RuneRange* rr,
1882 const StringPiece& whole_class,
1883 RegexpStatus* status) {
1884 StringPiece os = *s;
1885 if (!ParseCCCharacter(s, &rr->lo, whole_class, status))
1886 return false;
1887 // [a-] means (a|-), so check for final ].
1888 if (s->size() >= 2 && (*s)[0] == '-' && (*s)[1] != ']') {
1889 s->remove_prefix(1); // '-'
1890 if (!ParseCCCharacter(s, &rr->hi, whole_class, status))
1891 return false;
1892 if (rr->hi < rr->lo) {
1893 status->set_code(kRegexpBadCharRange);
1894 status->set_error_arg(
1895 StringPiece(os.data(), static_cast<size_t>(s->data() - os.data())));
1896 return false;
1897 }
1898 } else {
1899 rr->hi = rr->lo;
1900 }
1901 return true;
1902}
1903
1904// Parses a possibly-negated character class expression like [^abx-z[:digit:]].
1905// Sets *s to span the remainder of the string.

Callers

nothing calls this directly

Calls 6

StringPieceClass · 0.85
remove_prefixMethod · 0.80
set_codeMethod · 0.80
set_error_argMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected