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

Function StringPieceToRune

extern/re2/re2/parse.cc:1391–1413  ·  view source on GitHub ↗

Removes the next Rune from the StringPiece and stores it in *r. Returns number of bytes removed from sp. Behaves as though there is a terminating NUL at the end of sp. Argument order is backwards from usual Google style but consistent with chartorune.

Source from the content-addressed store, hash-verified

1389// Argument order is backwards from usual Google style
1390// but consistent with chartorune.
1391static int StringPieceToRune(Rune *r, StringPiece *sp, RegexpStatus* status) {
1392 // fullrune() takes int, not size_t. However, it just looks
1393 // at the leading byte and treats any length >= 4 the same.
1394 if (fullrune(sp->data(), static_cast<int>(std::min(size_t{4}, sp->size())))) {
1395 int n = chartorune(r, sp->data());
1396 // Some copies of chartorune have a bug that accepts
1397 // encodings of values in (10FFFF, 1FFFFF] as valid.
1398 // Those values break the character class algorithm,
1399 // which assumes Runemax is the largest rune.
1400 if (*r > Runemax) {
1401 n = 1;
1402 *r = Runeerror;
1403 }
1404 if (!(n == 1 && *r == Runeerror)) { // no decoding error
1405 sp->remove_prefix(n);
1406 return n;
1407 }
1408 }
1409
1410 status->set_code(kRegexpBadUTF8);
1411 status->set_error_arg(StringPiece());
1412 return -1;
1413}
1414
1415// Return whether name is valid UTF-8.
1416// If not, set status to kRegexpBadUTF8.

Callers 7

IsValidUTF8Function · 0.85
ParseEscapeFunction · 0.85
ParseUnicodeGroupFunction · 0.85
ParseCCCharacterMethod · 0.85
ParseCharClassMethod · 0.85
ParsePerlFlagsMethod · 0.85
ParseMethod · 0.85

Calls 9

fullruneFunction · 0.85
minClass · 0.85
chartoruneFunction · 0.85
StringPieceClass · 0.85
remove_prefixMethod · 0.80
set_codeMethod · 0.80
set_error_argMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected