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

Function ParseCCName

extern/re2/re2/parse.cc:1820–1852  ·  view source on GitHub ↗

Parses a character class name like [:alnum:]. Sets *s to span the remainder of the string. Adds the ranges corresponding to the class to ranges.

Source from the content-addressed store, hash-verified

1818// Sets *s to span the remainder of the string.
1819// Adds the ranges corresponding to the class to ranges.
1820static ParseStatus ParseCCName(StringPiece* s, Regexp::ParseFlags parse_flags,
1821 CharClassBuilder *cc,
1822 RegexpStatus* status) {
1823 // Check begins with [:
1824 const char* p = s->data();
1825 const char* ep = s->data() + s->size();
1826 if (ep - p < 2 || p[0] != '[' || p[1] != ':')
1827 return kParseNothing;
1828
1829 // Look for closing :].
1830 const char* q;
1831 for (q = p+2; q <= ep-2 && (*q != ':' || *(q+1) != ']'); q++)
1832 ;
1833
1834 // If no closing :], then ignore.
1835 if (q > ep-2)
1836 return kParseNothing;
1837
1838 // Got it. Check that it's valid.
1839 q += 2;
1840 StringPiece name(p, static_cast<size_t>(q - p));
1841
1842 const UGroup *g = LookupPosixGroup(name);
1843 if (g == NULL) {
1844 status->set_code(kRegexpBadCharRange);
1845 status->set_error_arg(name);
1846 return kParseError;
1847 }
1848
1849 s->remove_prefix(name.size());
1850 AddUGroup(cc, g, g->sign, parse_flags);
1851 return kParseOk;
1852}
1853
1854// Parses a character inside a character class.
1855// There are fewer special characters here than in the rest of the regexp.

Callers 1

ParseCharClassMethod · 0.85

Calls 7

LookupPosixGroupFunction · 0.85
AddUGroupFunction · 0.85
set_codeMethod · 0.80
set_error_argMethod · 0.80
remove_prefixMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected