diff --git a/bazel/re2.patch b/bazel/re2.patch index c3b46ea9c3..861df109b8 100644 --- a/bazel/re2.patch +++ b/bazel/re2.patch @@ -27,14 +27,14 @@ index 00330b6..8d44eba 100644 + ], visibility = ["//visibility:public"], ) - + diff --git a/WORKSPACE b/WORKSPACE index b35619c..908e100 100644 --- WORKSPACE +++ WORKSPACE @@ -5,3 +5,11 @@ # Bazel (http://bazel.io/) WORKSPACE file for RE2. - + workspace(name = "com_googlesource_code_re2") + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") @@ -49,7 +49,7 @@ index 877e548..2b742dd 100644 --- re2/bitstate.cc +++ re2/bitstate.cc @@ -42,9 +42,9 @@ class BitState { - + // The usual Search prototype. // Can only call Search once per BitState. - bool Search(const StringPiece& text, const StringPiece& context, @@ -57,11 +57,11 @@ index 877e548..2b742dd 100644 bool anchored, bool longest, - StringPiece* submatch, int nsubmatch); + absl::string_view* submatch, int nsubmatch); - + private: inline bool ShouldVisit(int id, const char* p); @@ -54,12 +54,12 @@ class BitState { - + // Search parameters Prog* prog_; // program being run - StringPiece text_; // text being searched @@ -74,7 +74,7 @@ index 877e548..2b742dd 100644 - StringPiece* submatch_; // submatches to fill in + absl::string_view* submatch_; // submatches to fill in int nsubmatch_; // # of submatches to fill in - + // Search state @@ -257,7 +257,7 @@ bool BitState::TrySearch(int id0, const char* p0) { (longest_ && p > submatch_[0].data() + submatch_[0].size())) { @@ -84,10 +84,10 @@ index 877e548..2b742dd 100644 + absl::string_view(cap_[2 * i], static_cast(cap_[2 * i + 1] - cap_[2 * i])); } - + @@ -285,9 +285,9 @@ bool BitState::TrySearch(int id0, const char* p0) { } - + // Search text (within context) for prog_. -bool BitState::Search(const StringPiece& text, const StringPiece& context, +bool BitState::Search(const absl::string_view& text, const absl::string_view& context, @@ -103,12 +103,12 @@ index 877e548..2b742dd 100644 for (int i = 0; i < nsubmatch_; i++) - submatch_[i] = StringPiece(); + submatch_[i] = absl::string_view(); - + // Allocate scratch space. int nvisited = prog_->list_count() * static_cast(text.size()+1); @@ -353,16 +353,16 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context, } - + // Bit-state search. -bool Prog::SearchBitState(const StringPiece& text, - const StringPiece& context, @@ -150,7 +150,7 @@ index d47c7d5..f81d00c 100644 #include "re2/sparse_set.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + // Silence "zero-sized array in struct/union" warning for DFA::State::next_. #ifdef _MSC_VER @@ -88,7 +88,7 @@ class DFA { @@ -161,9 +161,9 @@ index d47c7d5..f81d00c 100644 + bool Search(const absl::string_view& text, const absl::string_view& context, bool anchored, bool want_earliest_match, bool run_forward, bool* failed, const char** ep, SparseSet* matches); - + @@ -238,7 +238,7 @@ class DFA { - + // Search parameters struct SearchParams { - SearchParams(const StringPiece& text, const StringPiece& context, @@ -174,7 +174,7 @@ index d47c7d5..f81d00c 100644 @@ -252,8 +252,8 @@ class DFA { ep(NULL), matches(NULL) {} - + - StringPiece text; - StringPiece context; + absl::string_view text; @@ -190,12 +190,12 @@ index d47c7d5..f81d00c 100644 - const StringPiece& context = params->context; + const absl::string_view& text = params->text; + const absl::string_view& context = params->context; - + // Sanity check: make sure that text lies within context. if (BeginPtr(text) < BeginPtr(context) || EndPtr(text) > EndPtr(context)) { @@ -1728,8 +1728,8 @@ bool DFA::AnalyzeSearchHelper(SearchParams* params, StartInfo* info, } - + // The actual DFA search: calls AnalyzeSearch and then FastSearchLoop. -bool DFA::Search(const StringPiece& text, - const StringPiece& context, @@ -214,7 +214,7 @@ index d47c7d5..f81d00c 100644 + Anchor anchor, MatchKind kind, absl::string_view* match0, bool* failed, SparseSet* matches) { *failed = false; - + - StringPiece context = const_context; + absl::string_view context = const_context; if (context.data() == NULL) @@ -243,7 +243,7 @@ index d47c7d5..f81d00c 100644 if (!AnalyzeSearch(¶ms) || params.start == NULL || @@ -1993,7 +1993,7 @@ bool DFA::PossibleMatchRange(std::string* min, std::string* max, int maxlen) { - + // Pick out start state for anchored search at beginning of text. RWLocker l(&cache_mutex_); - SearchParams params(StringPiece(), StringPiece(), &l); @@ -258,7 +258,7 @@ index 5df9745..e888e6e 100644 @@ -46,7 +46,7 @@ FilteredRE2& FilteredRE2::operator=(FilteredRE2&& other) { return *this; } - + -RE2::ErrorCode FilteredRE2::Add(const StringPiece& pattern, +RE2::ErrorCode FilteredRE2::Add(const absl::string_view& pattern, const RE2::Options& options, int* id) { @@ -267,7 +267,7 @@ index 5df9745..e888e6e 100644 @@ -85,14 +85,14 @@ void FilteredRE2::Compile(std::vector* atoms) { compiled_ = true; } - + -int FilteredRE2::SlowFirstMatch(const StringPiece& text) const { +int FilteredRE2::SlowFirstMatch(const absl::string_view& text) const { for (size_t i = 0; i < re2_vec_.size(); i++) @@ -275,7 +275,7 @@ index 5df9745..e888e6e 100644 return static_cast(i); return -1; } - + -int FilteredRE2::FirstMatch(const StringPiece& text, +int FilteredRE2::FirstMatch(const absl::string_view& text, const std::vector& atoms) const { @@ -283,7 +283,7 @@ index 5df9745..e888e6e 100644 LOG(DFATAL) << "FirstMatch called before Compile."; @@ -107,7 +107,7 @@ int FilteredRE2::FirstMatch(const StringPiece& text, } - + bool FilteredRE2::AllMatches( - const StringPiece& text, + const absl::string_view& text, @@ -302,28 +302,28 @@ index dd618c7..5d55a78 100644 + RE2::ErrorCode Add(const absl::string_view& pattern, const RE2::Options& options, int* id); - + @@ -63,17 +63,17 @@ class FilteredRE2 { // Returns -1 on no match. Can be called prior to Compile. // Does not do any filtering: simply tries to Match the // regexps in a loop. - int SlowFirstMatch(const StringPiece& text) const; + int SlowFirstMatch(const absl::string_view& text) const; - + // Returns the index of the first matching regexp. // Returns -1 on no match. Compile has to be called before // calling this. - int FirstMatch(const StringPiece& text, + int FirstMatch(const absl::string_view& text, const std::vector& atoms) const; - + // Returns the indices of all matching regexps, after first clearing // matched_regexps. - bool AllMatches(const StringPiece& text, + bool AllMatches(const absl::string_view& text, const std::vector& atoms, std::vector* matching_regexps) const; - + diff --git a/re2/nfa.cc b/re2/nfa.cc index c7339f8..defb31e 100644 --- re2/nfa.cc @@ -337,7 +337,7 @@ index c7339f8..defb31e 100644 bool anchored, bool longest, - StringPiece* submatch, int nsubmatch); + absl::string_view* submatch, int nsubmatch); - + private: struct Thread { @@ -92,7 +92,7 @@ class NFA { @@ -347,7 +347,7 @@ index c7339f8..defb31e 100644 - void AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context, + void AddToThreadq(Threadq* q, int id0, int c, const absl::string_view& context, const char* p, Thread* t0); - + // Run runq on byte c, appending new states to nextq. @@ -102,7 +102,7 @@ class NFA { // p-1 will be used when processing Match instructions. @@ -356,7 +356,7 @@ index c7339f8..defb31e 100644 - int Step(Threadq* runq, Threadq* nextq, int c, const StringPiece& context, + int Step(Threadq* runq, Threadq* nextq, int c, const absl::string_view& context, const char* p); - + // Returns text version of capture information, for debugging. @@ -192,7 +192,7 @@ void NFA::Decref(Thread* t) { // Enqueues only the ByteRange instructions that match byte c. @@ -375,11 +375,11 @@ index c7339f8..defb31e 100644 +int NFA::Step(Threadq* runq, Threadq* nextq, int c, const absl::string_view& context, const char* p) { nextq->clear(); - + @@ -445,13 +445,13 @@ std::string NFA::FormatCapture(const char** capture) { return s; } - + -bool NFA::Search(const StringPiece& text, const StringPiece& const_context, +bool NFA::Search(const absl::string_view& text, const absl::string_view& const_context, bool anchored, bool longest, @@ -387,12 +387,12 @@ index c7339f8..defb31e 100644 + absl::string_view* submatch, int nsubmatch) { if (start_ == 0) return false; - + - StringPiece context = const_context; + absl::string_view context = const_context; if (context.data() == NULL) context = text; - + @@ -617,7 +617,7 @@ bool NFA::Search(const StringPiece& text, const StringPiece& const_context, if (matched_) { for (int i = 0; i < nsubmatch; i++) @@ -404,7 +404,7 @@ index c7339f8..defb31e 100644 fprintf(stderr, "match (%td,%td)\n", @@ -629,14 +629,14 @@ bool NFA::Search(const StringPiece& text, const StringPiece& const_context, } - + bool -Prog::SearchNFA(const StringPiece& text, const StringPiece& context, +Prog::SearchNFA(const absl::string_view& text, const absl::string_view& context, @@ -413,7 +413,7 @@ index c7339f8..defb31e 100644 + absl::string_view* match, int nmatch) { if (ExtraDebug) Dump(); - + NFA nfa(this); - StringPiece sp; + absl::string_view sp; @@ -430,13 +430,13 @@ index 2639746..dd6a38b 100644 #include "re2/sparse_set.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + // Silence "zero-sized array in struct/union" warning for OneState::action. #ifdef _MSC_VER @@ -189,7 +189,7 @@ void OnePass_Checks() { "kMaxCap disagrees with kMaxOnePassCapture"); } - + -static bool Satisfy(uint32_t cond, const StringPiece& context, const char* p) { +static bool Satisfy(uint32_t cond, const absl::string_view& context, const char* p) { uint32_t satisfied = Prog::EmptyFlags(context, p); @@ -445,7 +445,7 @@ index 2639746..dd6a38b 100644 @@ -211,10 +211,10 @@ static inline OneState* IndexToNode(uint8_t* nodes, int statesize, return reinterpret_cast(nodes + statesize*nodeindex); } - + -bool Prog::SearchOnePass(const StringPiece& text, - const StringPiece& const_context, +bool Prog::SearchOnePass(const absl::string_view& text, @@ -459,7 +459,7 @@ index 2639746..dd6a38b 100644 @@ -234,7 +234,7 @@ bool Prog::SearchOnePass(const StringPiece& text, for (int i = 0; i < ncap; i++) matchcap[i] = NULL; - + - StringPiece context = const_context; + absl::string_view context = const_context; if (context.data() == NULL) @@ -488,44 +488,44 @@ index 85f16f0..3a79c99 100644 #include "re2/unicode_groups.h" #include "re2/walker-inl.h" @@ -70,7 +70,7 @@ void Regexp::FUZZING_ONLY_set_maximum_repeat_count(int i) { - + class Regexp::ParseState { public: - ParseState(ParseFlags flags, const StringPiece& whole_regexp, + ParseState(ParseFlags flags, const absl::string_view& whole_regexp, RegexpStatus* status); ~ParseState(); - + @@ -107,18 +107,18 @@ class Regexp::ParseState { // Pushes a repeat operator regexp onto the stack. // A valid argument for the operator must already be on the stack. // s is the name of the operator, for use in error messages. - bool PushRepeatOp(RegexpOp op, const StringPiece& s, bool nongreedy); + bool PushRepeatOp(RegexpOp op, const absl::string_view& s, bool nongreedy); - + // Pushes a repetition regexp onto the stack. // A valid argument for the operator must already be on the stack. - bool PushRepetition(int min, int max, const StringPiece& s, bool nongreedy); + bool PushRepetition(int min, int max, const absl::string_view& s, bool nongreedy); - + // Checks whether a particular regexp op is a marker. bool IsMarker(RegexpOp op); - + // Processes a left parenthesis in the input. // Pushes a marker onto the stack. - bool DoLeftParen(const StringPiece& name); + bool DoLeftParen(const absl::string_view& name); bool DoLeftParenNoCapture(); - + // Processes a vertical bar in the input. @@ -142,23 +142,23 @@ class Regexp::ParseState { - + // Parse a character class into *out_re. // Removes parsed text from s. - bool ParseCharClass(StringPiece* s, Regexp** out_re, + bool ParseCharClass(absl::string_view* s, Regexp** out_re, RegexpStatus* status); - + // Parse a character class character into *rp. // Removes parsed text from s. - bool ParseCCCharacter(StringPiece* s, Rune *rp, @@ -533,7 +533,7 @@ index 85f16f0..3a79c99 100644 + bool ParseCCCharacter(absl::string_view* s, Rune *rp, + const absl::string_view& whole_class, RegexpStatus* status); - + // Parse a character class range into rr. // Removes parsed text from s. - bool ParseCCRange(StringPiece* s, RuneRange* rr, @@ -541,15 +541,15 @@ index 85f16f0..3a79c99 100644 + bool ParseCCRange(absl::string_view* s, RuneRange* rr, + const absl::string_view& whole_class, RegexpStatus* status); - + // Parse a Perl flag set or non-capturing group from s. - bool ParsePerlFlags(StringPiece* s); + bool ParsePerlFlags(absl::string_view* s); - - + + // Finishes the current concatenation, @@ -177,7 +177,7 @@ class Regexp::ParseState { - + private: ParseFlags flags_; - StringPiece whole_regexp_; @@ -559,7 +559,7 @@ index 85f16f0..3a79c99 100644 int ncap_; // number of capturing parens seen @@ -192,7 +192,7 @@ const RegexpOp kLeftParen = static_cast(kMaxRegexpOp+1); const RegexpOp kVerticalBar = static_cast(kMaxRegexpOp+2); - + Regexp::ParseState::ParseState(ParseFlags flags, - const StringPiece& whole_regexp, + const absl::string_view& whole_regexp, @@ -585,7 +585,7 @@ index 85f16f0..3a79c99 100644 if ((max != -1 && max < min) || min > maximum_repeat_count || @@ -609,7 +609,7 @@ bool Regexp::ParseState::IsMarker(RegexpOp op) { - + // Processes a left parenthesis in the input. // Pushes a marker onto the stack. -bool Regexp::ParseState::DoLeftParen(const StringPiece& name) { @@ -594,7 +594,7 @@ index 85f16f0..3a79c99 100644 re->cap_ = ++ncap_; if (name.data() != NULL) @@ -1325,7 +1325,7 @@ bool Regexp::ParseState::MaybeConcatString(int r, ParseFlags flags) { - + // Parses a decimal integer, storing it in *np. // Sets *s to span the remainder of the string. -static bool ParseInteger(StringPiece* s, int* np) { @@ -619,7 +619,7 @@ index 85f16f0..3a79c99 100644 @@ -1385,12 +1385,12 @@ static bool MaybeParseRepetition(StringPiece* sp, int* lo, int* hi) { return true; } - + -// Removes the next Rune from the StringPiece and stores it in *r. +// Removes the next Rune from the absl::string_view and stores it in *r. // Returns number of bytes removed from sp. @@ -632,7 +632,7 @@ index 85f16f0..3a79c99 100644 // at the leading byte and treats any length >= 4 the same. if (fullrune(sp->data(), static_cast(std::min(size_t{4}, sp->size())))) { @@ -1411,18 +1411,18 @@ static int StringPieceToRune(Rune *r, StringPiece *sp, RegexpStatus* status) { - + if (status != NULL) { status->set_code(kRegexpBadUTF8); - status->set_error_arg(StringPiece()); @@ -640,7 +640,7 @@ index 85f16f0..3a79c99 100644 } return -1; } - + // Returns whether name is valid UTF-8. // If not, sets status to kRegexpBadUTF8. -static bool IsValidUTF8(const StringPiece& s, RegexpStatus* status) { @@ -726,10 +726,10 @@ index 85f16f0..3a79c99 100644 + absl::string_view(begin, static_cast(s->data() - begin))); return false; } - + @@ -1623,21 +1623,21 @@ void CharClassBuilder::AddRangeFlags( } - + // Look for a group with the given name. -static const UGroup* LookupGroup(const StringPiece& name, +static const UGroup* LookupGroup(const absl::string_view& name, @@ -741,21 +741,21 @@ index 85f16f0..3a79c99 100644 return &groups[i]; return NULL; } - + // Look for a POSIX group with the given name (e.g., "[:^alpha:]") -static const UGroup* LookupPosixGroup(const StringPiece& name) { +static const UGroup* LookupPosixGroup(const absl::string_view& name) { return LookupGroup(name, posix_groups, num_posix_groups); } - + -static const UGroup* LookupPerlGroup(const StringPiece& name) { +static const UGroup* LookupPerlGroup(const absl::string_view& name) { return LookupGroup(name, perl_groups, num_perl_groups); } - + @@ -1648,9 +1648,9 @@ static URange32 any32[] = { { 65536, Runemax } }; static UGroup anygroup = { "Any", +1, any16, 1, any32, 1 }; - + // Look for a Unicode group with the given name (e.g., "Han") -static const UGroup* LookupUnicodeGroup(const StringPiece& name) { +static const UGroup* LookupUnicodeGroup(const absl::string_view& name) { @@ -786,7 +786,7 @@ index 85f16f0..3a79c99 100644 if (g == NULL) return NULL; @@ -1731,7 +1731,7 @@ enum ParseStatus { - + // Maybe parses a Unicode character group like \p{Han} or \P{Han} // (the latter is a negated group). -ParseStatus ParseUnicodeGroup(StringPiece* s, Regexp::ParseFlags parse_flags, @@ -803,7 +803,7 @@ index 85f16f0..3a79c99 100644 + absl::string_view seq = *s; // \p{Han} or \pL + absl::string_view name; // Han or L s->remove_prefix(2); // '\\', 'p' - + - if (!StringPieceToRune(&c, s, status)) + if (!StringViewToRune(&c, s, status)) return kParseError; @@ -829,11 +829,11 @@ index 85f16f0..3a79c99 100644 if (!IsValidUTF8(name, status)) return kParseError; } - + // Chop seq where s now begins. - seq = StringPiece(seq.data(), static_cast(s->data() - seq.data())); + seq = absl::string_view(seq.data(), static_cast(s->data() - seq.data())); - + if (!name.empty() && name[0] == '^') { sign = -sign; @@ -1821,7 +1821,7 @@ ParseStatus ParseUnicodeGroup(StringPiece* s, Regexp::ParseFlags parse_flags, @@ -846,12 +846,12 @@ index 85f16f0..3a79c99 100644 RegexpStatus* status) { // Check begins with [: @@ -1841,7 +1841,7 @@ static ParseStatus ParseCCName(StringPiece* s, Regexp::ParseFlags parse_flags, - + // Got it. Check that it's valid. q += 2; - StringPiece name(p, static_cast(q - p)); + absl::string_view name(p, static_cast(q - p)); - + const UGroup *g = LookupPosixGroup(name); if (g == NULL) { @@ -1859,8 +1859,8 @@ static ParseStatus ParseCCName(StringPiece* s, Regexp::ParseFlags parse_flags, @@ -867,12 +867,12 @@ index 85f16f0..3a79c99 100644 status->set_code(kRegexpMissingBracket); @@ -1874,7 +1874,7 @@ bool Regexp::ParseState::ParseCCCharacter(StringPiece* s, Rune *rp, return ParseEscape(s, rp, status, rune_max_); - + // Otherwise take the next rune. - return StringPieceToRune(rp, s, status) >= 0; + return StringViewToRune(rp, s, status) >= 0; } - + // Parses a character class character, or, if the character @@ -1882,10 +1882,10 @@ bool Regexp::ParseState::ParseCCCharacter(StringPiece* s, Rune *rp, // For single characters, rr->lo == rr->hi. @@ -937,13 +937,13 @@ index 85f16f0..3a79c99 100644 } @@ -2016,7 +2016,7 @@ bool Regexp::ParseState::ParseCharClass(StringPiece* s, } - + // Returns whether name is a valid capture name. -static bool IsValidCaptureName(const StringPiece& name) { +static bool IsValidCaptureName(const absl::string_view& name) { if (name.empty()) return false; - + @@ -2030,17 +2030,17 @@ static bool IsValidCaptureName(const StringPiece& name) { // if they start doing that for capture names, we won't follow suit. static const CharClass* const cc = []() { @@ -955,7 +955,7 @@ index 85f16f0..3a79c99 100644 +1, Regexp::NoParseFlags); return ccb.GetCharClass(); }(); - + - StringPiece t = name; + absl::string_view t = name; Rune r; @@ -973,7 +973,7 @@ index 85f16f0..3a79c99 100644 - StringPiece t = *s; +bool Regexp::ParseState::ParsePerlFlags(absl::string_view* s) { + absl::string_view t = *s; - + // Caller is supposed to check this. if (!(flags_ & PerlX) || t.size() < 2 || t[0] != '(' || t[1] != '?') { @@ -2084,7 +2084,7 @@ bool Regexp::ParseState::ParsePerlFlags(StringPiece* s) { @@ -987,7 +987,7 @@ index 85f16f0..3a79c99 100644 status_->set_code(kRegexpBadNamedCapture); @@ -2093,8 +2093,8 @@ bool Regexp::ParseState::ParsePerlFlags(StringPiece* s) { } - + // t is "P...", t[end] == '>' - StringPiece capture(t.data()-2, end+3); // "(?P" - StringPiece name(t.data()+2, end-2); // "name" @@ -1013,7 +1013,7 @@ index 85f16f0..3a79c99 100644 + absl::string_view(s->data(), static_cast(t.data() - s->data()))); return false; } - + @@ -2201,7 +2201,7 @@ BadPerlOp: // into UTF8 encoding in string. // Can't use EncodingUtils::EncodeLatin1AsUTF8 because it is @@ -1021,7 +1021,7 @@ index 85f16f0..3a79c99 100644 -void ConvertLatin1ToUTF8(const StringPiece& latin1, std::string* utf) { +void ConvertLatin1ToUTF8(const absl::string_view& latin1, std::string* utf) { char buf[UTFmax]; - + utf->clear(); @@ -2216,7 +2216,7 @@ void ConvertLatin1ToUTF8(const StringPiece& latin1, std::string* utf) { // returning the corresponding Regexp tree. @@ -1034,11 +1034,11 @@ index 85f16f0..3a79c99 100644 RegexpStatus xstatus; @@ -2224,7 +2224,7 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags, status = &xstatus; - + ParseState ps(global_flags, s, status); - StringPiece t = s; + absl::string_view t = s; - + // Convert regexp to UTF-8 (easier on the rest of the parser). if (global_flags & Latin1) { @@ -2238,7 +2238,7 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags, @@ -1053,7 +1053,7 @@ index 85f16f0..3a79c99 100644 @@ -2246,13 +2246,13 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags, return ps.DoFinish(); } - + - StringPiece lastunary = StringPiece(); + absl::string_view lastunary = absl::string_view(); while (!t.empty()) { @@ -1102,7 +1102,7 @@ index 85f16f0..3a79c99 100644 if (!ps.PushRepeatOp(op, opstr, nongreedy)) return NULL; @@ -2356,7 +2356,7 @@ Regexp* Regexp::Parse(const StringPiece& s, ParseFlags global_flags, - + case '{': { // Counted repetition. int lo, hi; - StringPiece opstr = t; @@ -1145,29 +1145,29 @@ index 55dc105..0a9c7d4 100644 #include "re2/bitmap256.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + namespace re2 { - + @@ -284,7 +284,7 @@ void Prog::Optimize() { } } - + -uint32_t Prog::EmptyFlags(const StringPiece& text, const char* p) { +uint32_t Prog::EmptyFlags(const absl::string_view& text, const char* p) { int flags = 0; - + // ^ and \A diff --git a/re2/prog.h b/re2/prog.h index 4af012a..62091d5 100644 --- re2/prog.h +++ re2/prog.h @@ -249,7 +249,7 @@ class Prog { - + // Returns the set of kEmpty flags that are in effect at // position p within context. - static uint32_t EmptyFlags(const StringPiece& context, const char* p); + static uint32_t EmptyFlags(const absl::string_view& context, const char* p); - + // Returns whether byte c is a word character: ASCII only. // Used by the implementation of \b and \B. @@ -274,15 +274,15 @@ class Prog { @@ -1179,14 +1179,14 @@ index 4af012a..62091d5 100644 // string, but note that on return, it will not be possible to distinguish // submatches that matched that empty string from submatches that didn't // match anything. Either way, match[i] == NULL. - + // Search using NFA: can find submatches but kind of slow. - bool SearchNFA(const StringPiece& text, const StringPiece& context, + bool SearchNFA(const absl::string_view& text, const absl::string_view& context, Anchor anchor, MatchKind kind, - StringPiece* match, int nmatch); + absl::string_view* match, int nmatch); - + // Search using DFA: much faster than NFA but only finds // end of match and can use a lot more memory. @@ -290,8 +290,8 @@ class Prog { @@ -1198,7 +1198,7 @@ index 4af012a..62091d5 100644 + bool SearchDFA(const absl::string_view& text, const absl::string_view& context, + Anchor anchor, MatchKind kind, absl::string_view* match0, bool* failed, SparseSet* matches); - + // The callback issued after building each DFA state with BuildEntireDFA(). @@ -321,16 +321,16 @@ class Prog { // but much faster than NFA (competitive with PCRE) @@ -1209,7 +1209,7 @@ index 4af012a..62091d5 100644 Anchor anchor, MatchKind kind, - StringPiece* match, int nmatch); + absl::string_view* match, int nmatch); - + // Bit-state backtracking. Fast on small cases but uses memory // proportional to the product of the list count and the text size. bool CanBitState() { return list_heads_.data() != NULL; } @@ -1218,9 +1218,9 @@ index 4af012a..62091d5 100644 Anchor anchor, MatchKind kind, - StringPiece* match, int nmatch); + absl::string_view* match, int nmatch); - + static const int kMaxOnePassCapture = 5; // $0 through $4 - + @@ -340,10 +340,10 @@ class Prog { // It is also recursive, so can't use in production (will overflow stacks). // The name "Unsafe" here is supposed to be a flag that @@ -1232,7 +1232,7 @@ index 4af012a..62091d5 100644 Anchor anchor, MatchKind kind, - StringPiece* match, int nmatch); + absl::string_view* match, int nmatch); - + // Computes range for any strings matching regexp. The min and max can in // some cases be arbitrarily precise, so the caller gets to specify the @@ -456,10 +456,10 @@ class Prog { @@ -1247,7 +1247,7 @@ index 4af012a..62091d5 100644 +static inline const char* EndPtr(const absl::string_view& s) { return s.data() + s.size(); } - + diff --git a/re2/re2.cc b/re2/re2.cc index c027133..e79c68d 100644 --- re2/re2.cc @@ -1255,7 +1255,7 @@ index c027133..e79c68d 100644 @@ -103,7 +103,7 @@ static RE2::ErrorCode RegexpErrorToRE2(re2::RegexpStatusCode code) { return RE2::ErrorInternal; } - + -static std::string trunc(const StringPiece& pattern) { +static std::string trunc(const absl::string_view& pattern) { if (pattern.size() < 100) @@ -1264,42 +1264,42 @@ index c027133..e79c68d 100644 @@ -118,11 +118,11 @@ RE2::RE2(const std::string& pattern) { Init(pattern, DefaultOptions); } - + -RE2::RE2(const StringPiece& pattern) { +RE2::RE2(const absl::string_view& pattern) { Init(pattern, DefaultOptions); } - + -RE2::RE2(const StringPiece& pattern, const Options& options) { +RE2::RE2(const absl::string_view& pattern, const Options& options) { Init(pattern, options); } - + @@ -170,7 +170,7 @@ int RE2::Options::ParseFlags() const { return flags; } - + -void RE2::Init(const StringPiece& pattern, const Options& options) { +void RE2::Init(const absl::string_view& pattern, const Options& options) { static std::once_flag empty_once; std::call_once(empty_once, []() { empty_string = new std::string; @@ -370,17 +370,17 @@ const std::map& RE2::CapturingGroupNames() const { - + /***** Convenience interfaces *****/ - + -bool RE2::FullMatchN(const StringPiece& text, const RE2& re, +bool RE2::FullMatchN(const absl::string_view& text, const RE2& re, const Arg* const args[], int n) { return re.DoMatch(text, ANCHOR_BOTH, NULL, args, n); } - + -bool RE2::PartialMatchN(const StringPiece& text, const RE2& re, +bool RE2::PartialMatchN(const absl::string_view& text, const RE2& re, const Arg* const args[], int n) { return re.DoMatch(text, UNANCHORED, NULL, args, n); } - + -bool RE2::ConsumeN(StringPiece* input, const RE2& re, +bool RE2::ConsumeN(absl::string_view* input, const RE2& re, const Arg* const args[], int n) { @@ -1308,14 +1308,14 @@ index c027133..e79c68d 100644 @@ -391,7 +391,7 @@ bool RE2::ConsumeN(StringPiece* input, const RE2& re, } } - + -bool RE2::FindAndConsumeN(StringPiece* input, const RE2& re, +bool RE2::FindAndConsumeN(absl::string_view* input, const RE2& re, const Arg* const args[], int n) { size_t consumed; if (re.DoMatch(*input, UNANCHORED, &consumed, args, n)) { @@ -404,8 +404,8 @@ bool RE2::FindAndConsumeN(StringPiece* input, const RE2& re, - + bool RE2::Replace(std::string* str, const RE2& re, - const StringPiece& rewrite) { @@ -1326,7 +1326,7 @@ index c027133..e79c68d 100644 if (nvec > 1 + re.NumberOfCapturingGroups()) return false; @@ -426,8 +426,8 @@ bool RE2::Replace(std::string* str, - + int RE2::GlobalReplace(std::string* str, const RE2& re, - const StringPiece& rewrite) { @@ -1339,7 +1339,7 @@ index c027133..e79c68d 100644 @@ -497,11 +497,11 @@ int RE2::GlobalReplace(std::string* str, return count; } - + -bool RE2::Extract(const StringPiece& text, +bool RE2::Extract(const absl::string_view& text, const RE2& re, @@ -1354,16 +1354,16 @@ index c027133..e79c68d 100644 @@ -514,7 +514,7 @@ bool RE2::Extract(const StringPiece& text, return re.Rewrite(out, rewrite, vec, nvec); } - + -std::string RE2::QuoteMeta(const StringPiece& unquoted) { +std::string RE2::QuoteMeta(const absl::string_view& unquoted) { std::string result; result.reserve(unquoted.size() << 1); - + @@ -613,11 +613,11 @@ static int ascii_strcasecmp(const char* a, const char* b, size_t len) { - + /***** Actual matching and rewriting code *****/ - + -bool RE2::Match(const StringPiece& text, +bool RE2::Match(const absl::string_view& text, size_t startpos, @@ -1377,14 +1377,14 @@ index c027133..e79c68d 100644 @@ -634,7 +634,7 @@ bool RE2::Match(const StringPiece& text, return false; } - + - StringPiece subtext = text; + absl::string_view subtext = text; subtext.remove_prefix(startpos); subtext.remove_suffix(text.size() - endpos); - + @@ -642,8 +642,8 @@ bool RE2::Match(const StringPiece& text, - + // Don't ask for the location if we won't use it. // SearchDFA can do extra optimizations in that case. - StringPiece match; @@ -1393,7 +1393,7 @@ index c027133..e79c68d 100644 + absl::string_view* matchp = &match; if (nsubmatch == 0) matchp = NULL; - + @@ -827,7 +827,7 @@ bool RE2::Match(const StringPiece& text, if (ncap == 1) submatch[0] = match; @@ -1404,20 +1404,20 @@ index c027133..e79c68d 100644 // DFA ran out of memory or was skipped: // need to search in entire original text. @@ -865,17 +865,17 @@ bool RE2::Match(const StringPiece& text, - + // Adjust overall match for required prefix that we stripped off. if (prefixlen > 0 && nsubmatch > 0) - submatch[0] = StringPiece(submatch[0].data() - prefixlen, + submatch[0] = absl::string_view(submatch[0].data() - prefixlen, submatch[0].size() + prefixlen); - + // Zero submatches that don't exist in the regexp. for (int i = ncap; i < nsubmatch; i++) - submatch[i] = StringPiece(); + submatch[i] = absl::string_view(); return true; } - + -// Internal matcher - like Match() but takes Args not StringPieces. -bool RE2::DoMatch(const StringPiece& text, +// Internal matcher - like Match() but takes Args not absl::string_views. @@ -1428,14 +1428,14 @@ index c027133..e79c68d 100644 @@ -898,14 +898,14 @@ bool RE2::DoMatch(const StringPiece& text, else nvec = n+1; - + - StringPiece* vec; - StringPiece stkvec[kVecSize]; - StringPiece* heapvec = NULL; + absl::string_view* vec; + absl::string_view stkvec[kVecSize]; + absl::string_view* heapvec = NULL; - + if (nvec <= static_cast(arraysize(stkvec))) { vec = stkvec; } else { @@ -1443,9 +1443,9 @@ index c027133..e79c68d 100644 + vec = new absl::string_view[nvec]; heapvec = vec; } - + @@ -925,7 +925,7 @@ bool RE2::DoMatch(const StringPiece& text, - + // If we got here, we must have matched the whole pattern. for (int i = 0; i < n; i++) { - const StringPiece& s = vec[i+1]; @@ -1454,7 +1454,7 @@ index c027133..e79c68d 100644 // TODO: Should we indicate what the error was? delete[] heapvec; @@ -939,7 +939,7 @@ bool RE2::DoMatch(const StringPiece& text, - + // Checks that the rewrite string is well-formed with respect to this // regular expression. -bool RE2::CheckRewriteString(const StringPiece& rewrite, @@ -1463,7 +1463,7 @@ index c027133..e79c68d 100644 int max_token = -1; for (const char *s = rewrite.data(), *end = s + rewrite.size(); @@ -979,7 +979,7 @@ bool RE2::CheckRewriteString(const StringPiece& rewrite, - + // Returns the maximum submatch needed for the rewrite to be done by Replace(). // E.g. if rewrite == "foo \\2,\\1", returns 2. -int RE2::MaxSubmatch(const StringPiece& rewrite) { @@ -1493,7 +1493,7 @@ index c027133..e79c68d 100644 } else if (c == '\\') { @@ -1051,9 +1051,9 @@ bool Parse(const char* str, size_t n, std::string* dest) { } - + template <> -bool Parse(const char* str, size_t n, StringPiece* dest) { +bool Parse(const char* str, size_t n, absl::string_view* dest) { @@ -1502,7 +1502,7 @@ index c027133..e79c68d 100644 + *dest = absl::string_view(str, n); return true; } - + diff --git a/re2/re2.h b/re2/re2.h index 7fd2245..6193969 100644 --- re2/re2.h @@ -1534,14 +1534,14 @@ index 7fd2245..6193969 100644 @@ -215,7 +215,7 @@ #include #endif - + -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + namespace re2 { class Prog; @@ -273,13 +273,13 @@ class RE2 { - + // Need to have the const char* and const std::string& forms for implicit // conversions when passing string literals to FullMatch and PartialMatch. - // Otherwise the StringPiece form would be sufficient. @@ -1555,7 +1555,7 @@ index 7fd2245..6193969 100644 + RE2(const absl::string_view& pattern); + RE2(const absl::string_view& pattern, const Options& options); ~RE2(); - + // Returns whether RE2 was created properly. @@ -324,13 +324,13 @@ class RE2 { // the functions whose names are the prefix before the 'N'. It is sometimes @@ -1573,7 +1573,7 @@ index 7fd2245..6193969 100644 - static bool FindAndConsumeN(StringPiece* input, const RE2& re, + static bool FindAndConsumeN(absl::string_view* input, const RE2& re, const Arg* const args[], int n); - + #ifndef SWIG @@ -364,7 +364,7 @@ class RE2 { // The provided pointer arguments can be pointers to any scalar numeric @@ -1592,7 +1592,7 @@ index 7fd2245..6193969 100644 + static bool FullMatch(const absl::string_view& text, const RE2& re, A&&... a) { return Apply(FullMatchN, text, re, Arg(std::forward(a))...); } - + @@ -400,7 +400,7 @@ class RE2 { // number of sub-patterns, the "i"th captured sub-pattern is // ignored. @@ -1601,7 +1601,7 @@ index 7fd2245..6193969 100644 + static bool PartialMatch(const absl::string_view& text, const RE2& re, A&&... a) { return Apply(PartialMatchN, text, re, Arg(std::forward(a))...); } - + @@ -418,7 +418,7 @@ class RE2 { // number of sub-patterns, the "i"th captured sub-pattern is // ignored. @@ -1610,7 +1610,7 @@ index 7fd2245..6193969 100644 + static bool Consume(absl::string_view* input, const RE2& re, A&&... a) { return Apply(ConsumeN, input, re, Arg(std::forward(a))...); } - + @@ -436,7 +436,7 @@ class RE2 { // number of sub-patterns, the "i"th captured sub-pattern is // ignored. @@ -1626,7 +1626,7 @@ index 7fd2245..6193969 100644 const RE2& re, - const StringPiece& rewrite); + const absl::string_view& rewrite); - + // Like Replace(), except replaces successive non-overlapping occurrences // of the pattern in the string with the rewrite. E.g. @@ -473,7 +473,7 @@ class RE2 { @@ -1635,7 +1635,7 @@ index 7fd2245..6193969 100644 const RE2& re, - const StringPiece& rewrite); + const absl::string_view& rewrite); - + // Like Replace, except that if the pattern matches, "rewrite" // is copied into "out" with substitutions. The non-matching @@ -483,9 +483,9 @@ class RE2 { @@ -1648,7 +1648,7 @@ index 7fd2245..6193969 100644 - const StringPiece& rewrite, + const absl::string_view& rewrite, std::string* out); - + // Escapes all potentially meaningful regexp characters in @@ -494,7 +494,7 @@ class RE2 { // 1.5-2.0? @@ -1656,7 +1656,7 @@ index 7fd2245..6193969 100644 // 1\.5\-2\.0\? - static std::string QuoteMeta(const StringPiece& unquoted); + static std::string QuoteMeta(const absl::string_view& unquoted); - + // Computes range for any strings matching regexp. The min and max can in // some cases be arbitrarily precise, so the caller gets to specify the @@ -555,15 +555,15 @@ class RE2 { @@ -1676,7 +1676,7 @@ index 7fd2245..6193969 100644 - StringPiece* submatch, + absl::string_view* submatch, int nsubmatch) const; - + // Check that the given rewrite string is suitable for use with this @@ -574,12 +574,12 @@ class RE2 { // '\' followed by anything other than a digit or '\'. @@ -1685,12 +1685,12 @@ index 7fd2245..6193969 100644 - bool CheckRewriteString(const StringPiece& rewrite, + bool CheckRewriteString(const absl::string_view& rewrite, std::string* error) const; - + // Returns the maximum submatch needed for the rewrite to be done by // Replace(). E.g. if rewrite == "foo \\2,\\1", returns 2. - static int MaxSubmatch(const StringPiece& rewrite); + static int MaxSubmatch(const absl::string_view& rewrite); - + // Append the "rewrite" string, with backslash subsitutions from "vec", // to string "out". @@ -587,8 +587,8 @@ class RE2 { @@ -1702,15 +1702,15 @@ index 7fd2245..6193969 100644 + const absl::string_view& rewrite, + const absl::string_view* vec, int veclen) const; - + // Constructor options @@ -743,9 +743,9 @@ class RE2 { static Arg Octal(T* ptr); - + private: - void Init(const StringPiece& pattern, const Options& options); + void Init(const absl::string_view& pattern, const Options& options); - + - bool DoMatch(const StringPiece& text, + bool DoMatch(const absl::string_view& text, Anchor re_anchor, @@ -1736,7 +1736,7 @@ index 2e1bfac..84cb68c 100644 -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" #include "re2/walker-inl.h" - + namespace re2 { diff --git a/re2/regexp.h b/re2/regexp.h index b6446f9..c461741 100644 @@ -1748,12 +1748,12 @@ index b6446f9..c461741 100644 #include "util/utf.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + namespace re2 { - + @@ -195,10 +195,10 @@ class RegexpStatus { ~RegexpStatus() { delete tmp_; } - + void set_code(RegexpStatusCode code) { code_ = code; } - void set_error_arg(const StringPiece& error_arg) { error_arg_ = error_arg; } + void set_error_arg(const absl::string_view& error_arg) { error_arg_ = error_arg; } @@ -1762,16 +1762,16 @@ index b6446f9..c461741 100644 - const StringPiece& error_arg() const { return error_arg_; } + const absl::string_view& error_arg() const { return error_arg_; } bool ok() const { return code() == kRegexpSuccess; } - + // Copies state from status. @@ -214,7 +214,7 @@ class RegexpStatus { - + private: RegexpStatusCode code_; // Kind of error - StringPiece error_arg_; // Piece of regexp containing syntax error. + absl::string_view error_arg_; // Piece of regexp containing syntax error. std::string* tmp_; // Temporary storage, possibly where error_arg_ is. - + RegexpStatus(const RegexpStatus&) = delete; @@ -352,7 +352,7 @@ class Regexp { // Parses string s to produce regular expression, returned. @@ -1780,7 +1780,7 @@ index b6446f9..c461741 100644 - static Regexp* Parse(const StringPiece& s, ParseFlags flags, + static Regexp* Parse(const absl::string_view& s, ParseFlags flags, RegexpStatus* status); - + // Returns a _new_ simplified version of the current regexp. @@ -369,7 +369,7 @@ class Regexp { // Parses the regexp src and then simplifies it and sets *dst to the @@ -1789,16 +1789,16 @@ index b6446f9..c461741 100644 - static bool SimplifyRegexp(const StringPiece& src, ParseFlags flags, + static bool SimplifyRegexp(const absl::string_view& src, ParseFlags flags, std::string* dst, RegexpStatus* status); - + // Returns the number of capturing groups in the regexp. @@ -467,7 +467,7 @@ class Regexp { class ParseState; - + friend class ParseState; - friend bool ParseCharClass(StringPiece* s, Regexp** out_re, + friend bool ParseCharClass(absl::string_view* s, Regexp** out_re, RegexpStatus* status); - + // Helper for testing [sic]. diff --git a/re2/set.cc b/re2/set.cc index 1870566..f0d550a 100644 @@ -1810,13 +1810,13 @@ index 1870566..f0d550a 100644 #include "re2/regexp.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + namespace re2 { - + @@ -52,7 +52,7 @@ RE2::Set& RE2::Set::operator=(Set&& other) { return *this; } - + -int RE2::Set::Add(const StringPiece& pattern, std::string* error) { +int RE2::Set::Add(const absl::string_view& pattern, std::string* error) { if (compiled_) { @@ -1825,12 +1825,12 @@ index 1870566..f0d550a 100644 @@ -121,11 +121,11 @@ bool RE2::Set::Compile() { return prog_ != nullptr; } - + -bool RE2::Set::Match(const StringPiece& text, std::vector* v) const { +bool RE2::Set::Match(const absl::string_view& text, std::vector* v) const { return Match(text, v, NULL); } - + -bool RE2::Set::Match(const StringPiece& text, std::vector* v, +bool RE2::Set::Match(const absl::string_view& text, std::vector* v, ErrorInfo* error_info) const { @@ -1846,7 +1846,7 @@ index 8d64f30..3fedcba 100644 // the error message from the parser. - int Add(const StringPiece& pattern, std::string* error); + int Add(const absl::string_view& pattern, std::string* error); - + // Compiles the set in preparation for matching. // Returns false if the compiler runs out of memory. @@ -61,12 +61,12 @@ class RE2::Set { @@ -1855,14 +1855,14 @@ index 8d64f30..3fedcba 100644 // Callers must not expect v to be sorted. - bool Match(const StringPiece& text, std::vector* v) const; + bool Match(const absl::string_view& text, std::vector* v) const; - + // As above, but populates error_info (if not NULL) when none of the regexps // in the set matched. This can inform callers when DFA execution fails, for // example, because they might wish to handle that case differently. - bool Match(const StringPiece& text, std::vector* v, + bool Match(const absl::string_view& text, std::vector* v, ErrorInfo* error_info) const; - + private: diff --git a/re2/simplify.cc b/re2/simplify.cc index 663d5fc..0266c43 100644 @@ -1884,17 +1884,17 @@ index 920a453..00419c3 100644 @@ -55,9 +55,9 @@ class Backtracker { public: explicit Backtracker(Prog* prog); - + - bool Search(const StringPiece& text, const StringPiece& context, + bool Search(const absl::string_view& text, const absl::string_view& context, bool anchored, bool longest, - StringPiece* submatch, int nsubmatch); + absl::string_view* submatch, int nsubmatch); - + private: // Explores from instruction id at string position p looking for a match. @@ -70,12 +70,12 @@ class Backtracker { - + // Search parameters Prog* prog_; // program being run - StringPiece text_; // text being searched @@ -1907,11 +1907,11 @@ index 920a453..00419c3 100644 - StringPiece *submatch_; // submatches to fill in + absl::string_view *submatch_; // submatches to fill in int nsubmatch_; // # of submatches to fill in - + // Search state @@ -96,9 +96,9 @@ Backtracker::Backtracker(Prog* prog) } - + // Runs a backtracking search. -bool Backtracker::Search(const StringPiece& text, const StringPiece& context, +bool Backtracker::Search(const absl::string_view& text, const absl::string_view& context, @@ -1922,7 +1922,7 @@ index 920a453..00419c3 100644 context_ = context; if (context_.data() == NULL) @@ -117,12 +117,12 @@ bool Backtracker::Search(const StringPiece& text, const StringPiece& context, - + // We use submatch_[0] for our own bookkeeping, // so it had better exist. - StringPiece sp0; @@ -1933,7 +1933,7 @@ index 920a453..00419c3 100644 } - submatch_[0] = StringPiece(); + submatch_[0] = absl::string_view(); - + // Allocate new visited_ bitmap -- size is proportional // to text, so have to reallocate on each call to Search. @@ -232,7 +232,7 @@ bool Backtracker::Try(int id, const char* p) { @@ -1947,7 +1947,7 @@ index 920a453..00419c3 100644 return true; @@ -243,16 +243,16 @@ bool Backtracker::Try(int id, const char* p) { } - + // Runs a backtracking search. -bool Prog::UnsafeSearchBacktrack(const StringPiece& text, - const StringPiece& context, @@ -1973,7 +1973,7 @@ index 4718830..a564be7 100644 @@ -156,7 +156,7 @@ TEST(TestRegexpCompileToProg, Simple) { EXPECT_EQ(failed, 0); } - + -static void DumpByteMap(StringPiece pattern, Regexp::ParseFlags flags, +static void DumpByteMap(absl::string_view pattern, Regexp::ParseFlags flags, std::string* bytemap) { @@ -1982,7 +1982,7 @@ index 4718830..a564be7 100644 @@ -257,7 +257,7 @@ TEST(TestCompile, InsufficientMemory) { re->Decref(); } - + -static void Dump(StringPiece pattern, Regexp::ParseFlags flags, +static void Dump(absl::string_view pattern, Regexp::ParseFlags flags, std::string* forward, std::string* reverse) { @@ -2007,7 +2007,7 @@ index 842daaf..4f673fc 100644 ASSERT_FALSE(failed); ASSERT_FALSE(matched); @@ -201,16 +201,16 @@ TEST(SingleThreaded, SearchDFA) { - + // Helper function: searches for match, which should match, // and no_match, which should not. -static void DoSearch(Prog* prog, const StringPiece& match, @@ -2047,16 +2047,16 @@ index cad0910..75e0b97 100644 -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" #include "re2/regexp.h" - + namespace re2 { diff --git a/re2/testing/exhaustive_tester.cc b/re2/testing/exhaustive_tester.cc index b0409c3..1cac2f5 100644 --- re2/testing/exhaustive_tester.cc +++ re2/testing/exhaustive_tester.cc @@ -33,7 +33,7 @@ DEFINE_FLAG(int, max_bad_regexp_inputs, 1, - + namespace re2 { - + -static char* escape(const StringPiece& sp) { +static char* escape(const absl::string_view& sp) { static char buf[512]; @@ -2065,7 +2065,7 @@ index b0409c3..1cac2f5 100644 @@ -55,7 +55,7 @@ static char* escape(const StringPiece& sp) { return buf; } - + -static void PrintResult(const RE2& re, const StringPiece& input, RE2::Anchor anchor, StringPiece *m, int n) { +static void PrintResult(const RE2& re, const absl::string_view& input, RE2::Anchor anchor, absl::string_view *m, int n) { if (!re.Match(input, 0, input.size(), anchor, m, n)) { @@ -2077,7 +2077,7 @@ index b0409c3..1cac2f5 100644 int ngroup = re.NumberOfCapturingGroups()+1; - StringPiece* group = new StringPiece[ngroup]; + absl::string_view* group = new absl::string_view[ngroup]; - + strgen_.Reset(); while (strgen_.HasNext()) { - StringPiece input = strgen_.Next(); @@ -2090,7 +2090,7 @@ index 0ec90ae..d369ad2 100644 --- re2/testing/possible_match_test.cc +++ re2/testing/possible_match_test.cc @@ -218,7 +218,7 @@ void PossibleMatchTester::HandleRegexp(const std::string& regexp) { - + strgen_.Reset(); while (strgen_.HasNext()) { - const StringPiece& s = strgen_.Next(); @@ -2104,53 +2104,53 @@ index b1f7d73..833b0b5 100644 +++ re2/testing/re2_test.cc @@ -238,7 +238,7 @@ TEST(RE2, Consume) { std::string word; - + std::string s(" aaa b!@#$@#$cccc"); - StringPiece input(s); + absl::string_view input(s); - + ASSERT_TRUE(RE2::Consume(&input, r, &word)); ASSERT_EQ(word, "aaa") << " input: " << input; @@ -249,7 +249,7 @@ TEST(RE2, Consume) { - + TEST(RE2, ConsumeN) { const std::string s(" one two three 4"); - StringPiece input(s); + absl::string_view input(s); - + RE2::Arg argv[2]; const RE2::Arg* const args[2] = { &argv[0], &argv[1] }; @@ -276,7 +276,7 @@ TEST(RE2, FindAndConsume) { std::string word; - + std::string s(" aaa b!@#$@#$cccc"); - StringPiece input(s); + absl::string_view input(s); - + ASSERT_TRUE(RE2::FindAndConsume(&input, r, &word)); ASSERT_EQ(word, "aaa"); @@ -296,7 +296,7 @@ TEST(RE2, FindAndConsume) { - + TEST(RE2, FindAndConsumeN) { const std::string s(" one two three 4"); - StringPiece input(s); + absl::string_view input(s); - + RE2::Arg argv[2]; const RE2::Arg* const args[2] = { &argv[0], &argv[1] }; @@ -345,10 +345,10 @@ TEST(RE2, MatchNumberPeculiarity) { - + TEST(RE2, Match) { RE2 re("((\\w+):([0-9]+))"); // extracts host and port - StringPiece group[4]; + absl::string_view group[4]; - + // No match. - StringPiece s = "zyzzyva"; + absl::string_view s = "zyzzyva"; ASSERT_FALSE( re.Match(s, 0, s.size(), RE2::UNANCHORED, group, arraysize(group))); - + @@ -542,7 +542,7 @@ TEST(EmptyCharset, BitstateAssumptions) { "((((()))))" "([^\\S\\s]|[^\\S\\s])?", "((((()))))" "(([^\\S\\s]|[^\\S\\s])|)" @@ -2163,7 +2163,7 @@ index b1f7d73..833b0b5 100644 @@ -677,10 +677,10 @@ TEST(RE2, FullMatchStringArg) { ASSERT_EQ(s, std::string("ell")); } - + -TEST(RE2, FullMatchStringPieceArg) { +TEST(RE2, FullMatchStringViewArg) { int i; @@ -2185,7 +2185,7 @@ index b1f7d73..833b0b5 100644 ASSERT_TRUE(RE2::FullMatch("123.4567890123456", "(.*)", (double*)NULL)); @@ -777,7 +777,7 @@ TEST(RE2, NULTerminated) { v[pagesize - 1] = '1'; - + x = 0; - ASSERT_TRUE(RE2::FullMatch(StringPiece(v + pagesize - 1, 1), "(.*)", &x)); + ASSERT_TRUE(RE2::FullMatch(absl::string_view(v + pagesize - 1, 1), "(.*)", &x)); @@ -2203,7 +2203,7 @@ index b1f7d73..833b0b5 100644 EXPECT_TRUE(RE2::PartialMatch(text, "(?i)([wand]{5})", &result)); EXPECT_TRUE(RE2::FindAndConsume(&sp, "(?i)([wand]{5})", &result)); } - + -// RE2 should permit implicit conversions from string, StringPiece, const char*, +// RE2 should permit implicit conversions from string, absl::string_view, const char*, // and C string literals. @@ -2231,30 +2231,30 @@ index b1f7d73..833b0b5 100644 + absl::string_view s = "xxxxxxxxxxxxxxxxxxxxxxxxxx_________x"; EXPECT_FALSE(re.Match(s, 0, s.size(), RE2::UNANCHORED, NULL, 0)); } - + @@ -1450,10 +1450,10 @@ TEST(RE2, NullVsEmptyString) { RE2 re(".*"); EXPECT_TRUE(re.ok()); - + - StringPiece null; + absl::string_view null; EXPECT_TRUE(RE2::FullMatch(null, re)); - + - StringPiece empty(""); + absl::string_view empty(""); EXPECT_TRUE(RE2::FullMatch(empty, re)); } - + @@ -1465,12 +1465,12 @@ TEST(RE2, NullVsEmptyStringSubmatches) { EXPECT_TRUE(re.ok()); - + // matches[0] is overall match, [1] is (), [2] is (foo), [3] is nonexistent. - StringPiece matches[4]; + absl::string_view matches[4]; - + for (size_t i = 0; i < arraysize(matches); i++) matches[i] = "bar"; - + - StringPiece null; + absl::string_view null; EXPECT_TRUE(re.Match(null, 0, null.size(), RE2::UNANCHORED, @@ -2263,7 +2263,7 @@ index b1f7d73..833b0b5 100644 @@ -1481,7 +1481,7 @@ TEST(RE2, NullVsEmptyStringSubmatches) { for (size_t i = 0; i < arraysize(matches); i++) matches[i] = "bar"; - + - StringPiece empty(""); + absl::string_view empty(""); EXPECT_TRUE(re.Match(empty, 0, empty.size(), RE2::UNANCHORED, @@ -2280,20 +2280,20 @@ index b1f7d73..833b0b5 100644 } @@ -1615,7 +1615,7 @@ TEST(RE2, Bug26356109) { ASSERT_TRUE(re.ok()); - + std::string s = "abc"; - StringPiece m; + absl::string_view m; - + ASSERT_TRUE(re.Match(s, 0, s.size(), RE2::UNANCHORED, &m, 1)); ASSERT_EQ(m, s) << " (UNANCHORED) got m='" << m << "', want '" << s << "'"; @@ -1645,7 +1645,7 @@ TEST(RE2, Issue310) { // (?:|a)* matched more text than (?:|a)+ did. - + std::string s = "aaa"; - StringPiece m; + absl::string_view m; - + RE2 star("(?:|a)*"); ASSERT_TRUE(star.Match(s, 0, s.size(), RE2::UNANCHORED, &m, 1)); diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc @@ -2312,7 +2312,7 @@ index 3eeb098..e13d282 100644 @@ -73,7 +73,7 @@ void MemoryUsage() { mc.HeapGrowth(), mc.PeakHeapGrowth()); mc.Reset(); - + - StringPiece sp[4]; + absl::string_view sp[4]; CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); @@ -2320,20 +2320,20 @@ index 3eeb098..e13d282 100644 mc.HeapGrowth(), mc.PeakHeapGrowth()); @@ -128,7 +128,7 @@ int NumCPUs() { // and not interesting. - + typedef void SearchImpl(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, bool expect_match); - + SearchImpl SearchDFA, SearchNFA, SearchOnePass, SearchBitState, SearchPCRE, @@ -136,7 +136,7 @@ SearchImpl SearchDFA, SearchNFA, SearchOnePass, SearchBitState, SearchPCRE, SearchCachedBitState, SearchCachedPCRE, SearchCachedRE2; - + typedef void ParseImpl(benchmark::State& state, const char* regexp, - const StringPiece& text); + const absl::string_view& text); - + ParseImpl Parse1NFA, Parse1OnePass, Parse1BitState, Parse1PCRE, Parse1RE2, Parse1Backtrack, Parse1CachedNFA, Parse1CachedOnePass, Parse1CachedBitState, @@ -318,8 +318,8 @@ void FindAndConsume(benchmark::State& state) { @@ -2349,7 +2349,7 @@ index 3eeb098..e13d282 100644 } @@ -442,7 +442,7 @@ BENCHMARK_RANGE(Search_AltMatch_CachedRE2, 8, 16<<20)->ThreadRange(1, NumCP // Benchmark: use regexp to find phone number. - + void SearchDigits(benchmark::State& state, SearchImpl* search) { - StringPiece s("650-253-0001"); + absl::string_view s("650-253-0001"); @@ -2357,7 +2357,7 @@ index 3eeb098..e13d282 100644 state.SetItemsProcessed(state.iterations()); } @@ -467,7 +467,7 @@ BENCHMARK(Search_Digits_BitState)->ThreadRange(1, NumCPUs()); - + void Parse3Digits(benchmark::State& state, void (*parse3)(benchmark::State&, const char*, - const StringPiece&)) { @@ -2366,7 +2366,7 @@ index 3eeb098..e13d282 100644 state.SetItemsProcessed(state.iterations()); } @@ -506,7 +506,7 @@ BENCHMARK(Parse_CachedDigits_BitState)->ThreadRange(1, NumCPUs()); - + void Parse3DigitDs(benchmark::State& state, void (*parse3)(benchmark::State&, const char*, - const StringPiece&)) { @@ -2375,7 +2375,7 @@ index 3eeb098..e13d282 100644 state.SetItemsProcessed(state.iterations()); } @@ -547,7 +547,7 @@ BENCHMARK(Parse_CachedDigitDs_BitState)->ThreadRange(1, NumCPUs()); - + void Parse1Split(benchmark::State& state, void (*parse1)(benchmark::State&, const char*, - const StringPiece&)) { @@ -2384,7 +2384,7 @@ index 3eeb098..e13d282 100644 state.SetItemsProcessed(state.iterations()); } @@ -584,7 +584,7 @@ BENCHMARK(Parse_CachedSplit_BitState)->ThreadRange(1, NumCPUs()); - + void Parse1SplitHard(benchmark::State& state, void (*run)(benchmark::State&, const char*, - const StringPiece&)) { @@ -2393,7 +2393,7 @@ index 3eeb098..e13d282 100644 state.SetItemsProcessed(state.iterations()); } @@ -619,7 +619,7 @@ BENCHMARK(Parse_CachedSplitHard_Backtrack)->ThreadRange(1, NumCPUs()); - + void Parse1SplitBig1(benchmark::State& state, void (*run)(benchmark::State&, const char*, - const StringPiece&)) { @@ -2402,7 +2402,7 @@ index 3eeb098..e13d282 100644 s.append(100000, 'x'); s.append("650-253-0001"); @@ -639,7 +639,7 @@ BENCHMARK(Parse_CachedSplitBig1_RE2)->ThreadRange(1, NumCPUs()); - + void Parse1SplitBig2(benchmark::State& state, void (*run)(benchmark::State&, const char*, - const StringPiece&)) { @@ -2412,7 +2412,7 @@ index 3eeb098..e13d282 100644 s.append(100000, '0'); @@ -859,7 +859,7 @@ DO24(MY_BENCHMARK_WITH_ARG, CacheFillDFA) // Anchored says whether to run an anchored search. - + void SearchDFA(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2430,7 +2430,7 @@ index 3eeb098..e13d282 100644 CHECK(!failed); @@ -877,14 +877,14 @@ void SearchDFA(benchmark::State& state, const char* regexp, } - + void SearchNFA(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2447,7 +2447,7 @@ index 3eeb098..e13d282 100644 delete prog; @@ -893,7 +893,7 @@ void SearchNFA(benchmark::State& state, const char* regexp, } - + void SearchOnePass(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2456,7 +2456,7 @@ index 3eeb098..e13d282 100644 Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); @@ -909,7 +909,7 @@ void SearchOnePass(benchmark::State& state, const char* regexp, } - + void SearchBitState(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2465,7 +2465,7 @@ index 3eeb098..e13d282 100644 Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); @@ -925,7 +925,7 @@ void SearchBitState(benchmark::State& state, const char* regexp, } - + void SearchPCRE(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2474,7 +2474,7 @@ index 3eeb098..e13d282 100644 PCRE re(regexp, PCRE::UTF8); @@ -938,7 +938,7 @@ void SearchPCRE(benchmark::State& state, const char* regexp, } - + void SearchRE2(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2483,7 +2483,7 @@ index 3eeb098..e13d282 100644 RE2 re(regexp); @@ -999,12 +999,12 @@ RE2* GetCachedRE2(const char* regexp) { } - + void SearchCachedDFA(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2498,7 +2498,7 @@ index 3eeb098..e13d282 100644 CHECK(!failed); @@ -1012,18 +1012,18 @@ void SearchCachedDFA(benchmark::State& state, const char* regexp, } - + void SearchCachedNFA(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2511,7 +2511,7 @@ index 3eeb098..e13d282 100644 expect_match); } } - + void SearchCachedOnePass(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2520,7 +2520,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->IsOnePass()); @@ -1034,7 +1034,7 @@ void SearchCachedOnePass(benchmark::State& state, const char* regexp, } - + void SearchCachedBitState(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2529,7 +2529,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->CanBitState()); @@ -1045,7 +1045,7 @@ void SearchCachedBitState(benchmark::State& state, const char* regexp, } - + void SearchCachedPCRE(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2538,7 +2538,7 @@ index 3eeb098..e13d282 100644 for (auto _ : state) { @@ -1057,7 +1057,7 @@ void SearchCachedPCRE(benchmark::State& state, const char* regexp, } - + void SearchCachedRE2(benchmark::State& state, const char* regexp, - const StringPiece& text, Prog::Anchor anchor, + const absl::string_view& text, Prog::Anchor anchor, @@ -2547,7 +2547,7 @@ index 3eeb098..e13d282 100644 for (auto _ : state) { @@ -1072,14 +1072,14 @@ void SearchCachedRE2(benchmark::State& state, const char* regexp, // extracting three submatches. Expects match always. - + void Parse3NFA(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2565,7 +2565,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1087,14 +1087,14 @@ void Parse3NFA(benchmark::State& state, const char* regexp, } - + void Parse3OnePass(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2582,7 +2582,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1102,14 +1102,14 @@ void Parse3OnePass(benchmark::State& state, const char* regexp, } - + void Parse3BitState(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2599,7 +2599,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1117,13 +1117,13 @@ void Parse3BitState(benchmark::State& state, const char* regexp, } - + void Parse3Backtrack(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2615,7 +2615,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1131,77 +1131,77 @@ void Parse3Backtrack(benchmark::State& state, const char* regexp, } - + void Parse3PCRE(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2627,7 +2627,7 @@ index 3eeb098..e13d282 100644 CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); } } - + void Parse3RE2(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2639,7 +2639,7 @@ index 3eeb098..e13d282 100644 CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); } } - + void Parse3CachedNFA(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2652,7 +2652,7 @@ index 3eeb098..e13d282 100644 Prog::kFullMatch, sp, 4)); } } - + void Parse3CachedOnePass(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2664,7 +2664,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); } } - + void Parse3CachedBitState(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2676,7 +2676,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); } } - + void Parse3CachedBacktrack(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2687,7 +2687,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); } } - + void Parse3CachedPCRE(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2698,7 +2698,7 @@ index 3eeb098..e13d282 100644 CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); } } - + void Parse3CachedRE2(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2710,7 +2710,7 @@ index 3eeb098..e13d282 100644 } @@ -1211,14 +1211,14 @@ void Parse3CachedRE2(benchmark::State& state, const char* regexp, // extracting three submatches. Expects match always. - + void Parse1NFA(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2728,7 +2728,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1226,14 +1226,14 @@ void Parse1NFA(benchmark::State& state, const char* regexp, } - + void Parse1OnePass(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2745,7 +2745,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1241,14 +1241,14 @@ void Parse1OnePass(benchmark::State& state, const char* regexp, } - + void Parse1BitState(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2762,7 +2762,7 @@ index 3eeb098..e13d282 100644 re->Decref(); @@ -1256,114 +1256,114 @@ void Parse1BitState(benchmark::State& state, const char* regexp, } - + void Parse1PCRE(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2774,7 +2774,7 @@ index 3eeb098..e13d282 100644 CHECK(PCRE::FullMatch(text, re, &sp1)); } } - + void Parse1RE2(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2786,7 +2786,7 @@ index 3eeb098..e13d282 100644 CHECK(RE2::FullMatch(text, re, &sp1)); } } - + void Parse1CachedNFA(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2799,7 +2799,7 @@ index 3eeb098..e13d282 100644 Prog::kFullMatch, sp, 2)); } } - + void Parse1CachedOnePass(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2811,7 +2811,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); } } - + void Parse1CachedBitState(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2823,7 +2823,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); } } - + void Parse1CachedBacktrack(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2834,7 +2834,7 @@ index 3eeb098..e13d282 100644 CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); } } - + void Parse1CachedPCRE(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2845,7 +2845,7 @@ index 3eeb098..e13d282 100644 CHECK(PCRE::FullMatch(text, re, &sp1)); } } - + void Parse1CachedRE2(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2856,7 +2856,7 @@ index 3eeb098..e13d282 100644 CHECK(RE2::FullMatch(text, re, &sp1)); } } - + void SearchParse2CachedPCRE(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2867,7 +2867,7 @@ index 3eeb098..e13d282 100644 CHECK(PCRE::PartialMatch(text, re, &sp1, &sp2)); } } - + void SearchParse2CachedRE2(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2878,7 +2878,7 @@ index 3eeb098..e13d282 100644 CHECK(RE2::PartialMatch(text, re, &sp1, &sp2)); } } - + void SearchParse1CachedPCRE(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2889,7 +2889,7 @@ index 3eeb098..e13d282 100644 CHECK(PCRE::PartialMatch(text, re, &sp1)); } } - + void SearchParse1CachedRE2(benchmark::State& state, const char* regexp, - const StringPiece& text) { + const absl::string_view& text) { @@ -2902,7 +2902,7 @@ index 3eeb098..e13d282 100644 } @@ -1409,7 +1409,7 @@ static std::string http_text = "alksdjfhasdlkfhasdlkjfhasdljkfhadsjklf HTTP/1.1"; - + void HTTPPartialMatchPCRE(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2911,7 +2911,7 @@ index 3eeb098..e13d282 100644 PCRE::PartialMatch(http_text, re, &a); @@ -1417,7 +1417,7 @@ void HTTPPartialMatchPCRE(benchmark::State& state) { } - + void HTTPPartialMatchRE2(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2920,7 +2920,7 @@ index 3eeb098..e13d282 100644 RE2::PartialMatch(http_text, re, &a); @@ -1433,7 +1433,7 @@ static std::string smallhttp_text = "GET /abc HTTP/1.1"; - + void SmallHTTPPartialMatchPCRE(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2929,7 +2929,7 @@ index 3eeb098..e13d282 100644 PCRE::PartialMatch(smallhttp_text, re, &a); @@ -1441,7 +1441,7 @@ void SmallHTTPPartialMatchPCRE(benchmark::State& state) { } - + void SmallHTTPPartialMatchRE2(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2938,7 +2938,7 @@ index 3eeb098..e13d282 100644 RE2::PartialMatch(smallhttp_text, re, &a); @@ -1454,7 +1454,7 @@ BENCHMARK(SmallHTTPPartialMatchPCRE)->ThreadRange(1, NumCPUs()); BENCHMARK(SmallHTTPPartialMatchRE2)->ThreadRange(1, NumCPUs()); - + void DotMatchPCRE(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2947,7 +2947,7 @@ index 3eeb098..e13d282 100644 PCRE::PartialMatch(http_text, re, &a); @@ -1462,7 +1462,7 @@ void DotMatchPCRE(benchmark::State& state) { } - + void DotMatchRE2(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2956,7 +2956,7 @@ index 3eeb098..e13d282 100644 RE2::PartialMatch(http_text, re, &a); @@ -1475,7 +1475,7 @@ BENCHMARK(DotMatchPCRE)->ThreadRange(1, NumCPUs()); BENCHMARK(DotMatchRE2)->ThreadRange(1, NumCPUs()); - + void ASCIIMatchPCRE(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2965,7 +2965,7 @@ index 3eeb098..e13d282 100644 PCRE::PartialMatch(http_text, re, &a); @@ -1483,7 +1483,7 @@ void ASCIIMatchPCRE(benchmark::State& state) { } - + void ASCIIMatchRE2(benchmark::State& state) { - StringPiece a; + absl::string_view a; @@ -2978,24 +2978,24 @@ index 3eeda25..e4f8279 100644 +++ re2/testing/regexp_generator.cc @@ -238,7 +238,7 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { } - + // Split s into an vector of strings, one for each UTF-8 character. -std::vector Explode(const StringPiece& s) { +std::vector Explode(const absl::string_view& s) { std::vector v; - + for (const char *q = s.data(); q < s.data() + s.size(); ) { @@ -253,7 +253,7 @@ std::vector Explode(const StringPiece& s) { - + // Split string everywhere a substring is found, returning // vector of pieces. -std::vector Split(const StringPiece& sep, const StringPiece& s) { +std::vector Split(const absl::string_view& sep, const absl::string_view& s) { std::vector v; - + if (sep.empty()) @@ -261,7 +261,7 @@ std::vector Split(const StringPiece& sep, const StringPiece& s) { - + const char *p = s.data(); for (const char *q = s.data(); q + sep.size() <= s.data() + s.size(); q++) { - if (StringPiece(q, sep.size()) == sep) { @@ -3009,27 +3009,27 @@ index 7d72aff..a0ced6f 100644 +++ re2/testing/regexp_generator.h @@ -14,7 +14,7 @@ #include - + #include "util/util.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + namespace re2 { - + @@ -66,11 +66,11 @@ class RegexpGenerator { // Helpers for preparing arguments to RegexpGenerator constructor. - + // Returns one string for each character in s. -std::vector Explode(const StringPiece& s); +std::vector Explode(const absl::string_view& s); - + // Splits string everywhere sep is found, returning // vector of pieces. -std::vector Split(const StringPiece& sep, const StringPiece& s); +std::vector Split(const absl::string_view& sep, const absl::string_view& s); - + } // namespace re2 - + diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc index 44837fe..c635493 100644 --- re2/testing/string_generator.cc @@ -3054,25 +3054,25 @@ index 73fbb51..0fcc572 100644 +++ re2/testing/string_generator.h @@ -15,7 +15,7 @@ #include - + #include "util/util.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + namespace re2 { - + @@ -24,7 +24,7 @@ class StringGenerator { StringGenerator(int maxlen, const std::vector& alphabet); ~StringGenerator() {} - + - const StringPiece& Next(); + const absl::string_view& Next(); bool HasNext() { return hasnext_; } - + // Resets generator to start sequence over. @@ -45,11 +45,11 @@ class StringGenerator { std::vector alphabet_; // Alphabet, one string per letter. - + // Iteration state. - StringPiece sp_; // Last StringPiece returned by Next(). - std::string s_; // String data in last StringPiece returned by Next(). @@ -3103,13 +3103,13 @@ index b0c22f2..a9b5585 100644 --- re2/testing/tester.cc +++ re2/testing/tester.cc @@ -97,7 +97,7 @@ struct TestInstance::Result { - + void ClearSubmatch() { for (int i = 0; i < kMaxSubmatch; i++) - submatch[i] = StringPiece(); + submatch[i] = absl::string_view(); } - + bool skipped; // test skipped: wasn't applicable @@ -105,15 +105,15 @@ struct TestInstance::Result { bool untrusted; // don't really trust the answer @@ -3118,9 +3118,9 @@ index b0c22f2..a9b5585 100644 - StringPiece submatch[kMaxSubmatch]; + absl::string_view submatch[kMaxSubmatch]; }; - + typedef TestInstance::Result Result; - + // Formats a single capture range s in text in the form (a,b) // where a and b are the starting and ending offsets of s in text. -static std::string FormatCapture(const StringPiece& text, @@ -3132,7 +3132,7 @@ index b0c22f2..a9b5585 100644 return StringPrintf("(%td,%td)", @@ -122,7 +122,7 @@ static std::string FormatCapture(const StringPiece& text, } - + // Returns whether text contains non-ASCII (>= 0x80) bytes. -static bool NonASCII(const StringPiece& text) { +static bool NonASCII(const absl::string_view& text) { @@ -3140,7 +3140,7 @@ index b0c22f2..a9b5585 100644 if ((uint8_t)text[i] >= 0x80) return true; @@ -182,7 +182,7 @@ static std::string FormatMode(Regexp::ParseFlags flags) { - + // Constructs and saves all the matching engines that // will be required for the given tests. -TestInstance::TestInstance(const StringPiece& regexp_str, Prog::MatchKind kind, @@ -3162,12 +3162,12 @@ index b0c22f2..a9b5585 100644 @@ -314,8 +314,8 @@ void TestInstance::RunSearch(Engine type, if (nsubmatch > kMaxSubmatch) nsubmatch = kMaxSubmatch; - + - StringPiece text = orig_text; - StringPiece context = orig_context; + absl::string_view text = orig_text; + absl::string_view context = orig_context; - + switch (type) { default: @@ -438,19 +438,19 @@ void TestInstance::RunSearch(Engine type, @@ -3185,7 +3185,7 @@ index b0c22f2..a9b5585 100644 result->skipped = true; break; } - + // PCRE 8.34 or so started allowing vertical tab to match \s, // following a change made in Perl 5.18. RE2 does not. - if ((regexp_str_.find("\\s") != StringPiece::npos || @@ -3199,7 +3199,7 @@ index b0c22f2..a9b5585 100644 } @@ -513,7 +513,7 @@ static bool ResultOkay(const Result& r, const Result& correct) { } - + // Runs a single test. -bool TestInstance::RunCase(const StringPiece& text, const StringPiece& context, +bool TestInstance::RunCase(const absl::string_view& text, const absl::string_view& context, @@ -3208,7 +3208,7 @@ index b0c22f2..a9b5585 100644 Result correct; @@ -595,7 +595,7 @@ bool TestInstance::RunCase(const StringPiece& text, const StringPiece& context, } - + void TestInstance::LogMatch(const char* prefix, Engine e, - const StringPiece& text, const StringPiece& context, + const absl::string_view& text, const absl::string_view& context, @@ -3217,7 +3217,7 @@ index b0c22f2..a9b5585 100644 << EngineName(e) @@ -624,7 +624,7 @@ static Prog::MatchKind kinds[] = { }; - + // Test all possible match kinds and parse modes. -Tester::Tester(const StringPiece& regexp) { +Tester::Tester(const absl::string_view& regexp) { @@ -3227,7 +3227,7 @@ index b0c22f2..a9b5585 100644 @@ -641,7 +641,7 @@ Tester::~Tester() { delete v_[i]; } - + -bool Tester::TestCase(const StringPiece& text, const StringPiece& context, +bool Tester::TestCase(const absl::string_view& text, const absl::string_view& context, Prog::Anchor anchor) { @@ -3236,7 +3236,7 @@ index b0c22f2..a9b5585 100644 @@ -654,10 +654,10 @@ static Prog::Anchor anchors[] = { Prog::kUnanchored }; - + -bool Tester::TestInput(const StringPiece& text) { +bool Tester::TestInput(const absl::string_view& text) { bool okay = TestInputInContext(text, text); @@ -3249,7 +3249,7 @@ index b0c22f2..a9b5585 100644 @@ -668,16 +668,16 @@ bool Tester::TestInput(const StringPiece& text) { return okay; } - + -bool Tester::TestInputInContext(const StringPiece& text, - const StringPiece& context) { +bool Tester::TestInputInContext(const absl::string_view& text, @@ -3259,7 +3259,7 @@ index b0c22f2..a9b5585 100644 okay &= TestCase(text, context, anchors[i]); return okay; } - + -bool TestRegexpOnText(const StringPiece& regexp, - const StringPiece& text) { +bool TestRegexpOnText(const absl::string_view& regexp, @@ -3272,9 +3272,9 @@ index 47d0c43..03f0ccb 100644 --- re2/testing/tester.h +++ re2/testing/tester.h @@ -10,7 +10,7 @@ - + #include - + -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" #include "re2/prog.h" @@ -3283,20 +3283,20 @@ index 47d0c43..03f0ccb 100644 @@ -51,7 +51,7 @@ class TestInstance { public: struct Result; - + - TestInstance(const StringPiece& regexp, Prog::MatchKind kind, + TestInstance(const absl::string_view& regexp, Prog::MatchKind kind, Regexp::ParseFlags flags); ~TestInstance(); Regexp::ParseFlags flags() { return flags_; } @@ -59,20 +59,20 @@ class TestInstance { - + // Runs a single test case: search in text, which is in context, // using the given anchoring. - bool RunCase(const StringPiece& text, const StringPiece& context, + bool RunCase(const absl::string_view& text, const absl::string_view& context, Prog::Anchor anchor); - + private: // Runs a single search using the named engine type. void RunSearch(Engine type, @@ -3304,12 +3304,12 @@ index 47d0c43..03f0ccb 100644 + const absl::string_view& text, const absl::string_view& context, Prog::Anchor anchor, Result *result); - + - void LogMatch(const char* prefix, Engine e, const StringPiece& text, - const StringPiece& context, Prog::Anchor anchor); + void LogMatch(const char* prefix, Engine e, const absl::string_view& text, + const absl::string_view& context, Prog::Anchor anchor); - + - const StringPiece regexp_str_; // regexp being tested + const absl::string_view regexp_str_; // regexp being tested Prog::MatchKind kind_; // kind of match @@ -3322,42 +3322,42 @@ index 47d0c43..03f0ccb 100644 - explicit Tester(const StringPiece& regexp); + explicit Tester(const absl::string_view& regexp); ~Tester(); - + bool error() { return error_; } - + // Runs a single test case: search in text, which is in context, // using the given anchoring. - bool TestCase(const StringPiece& text, const StringPiece& context, + bool TestCase(const absl::string_view& text, const absl::string_view& context, Prog::Anchor anchor); - + // Run TestCase(text, text, anchor) for all anchoring modes. - bool TestInput(const StringPiece& text); + bool TestInput(const absl::string_view& text); - + // Run TestCase(text, context, anchor) for all anchoring modes. - bool TestInputInContext(const StringPiece& text, const StringPiece& context); + bool TestInputInContext(const absl::string_view& text, const absl::string_view& context); - + private: bool error_; @@ -116,7 +116,7 @@ class Tester { }; - + // Run all possible tests using regexp and text. -bool TestRegexpOnText(const StringPiece& regexp, const StringPiece& text); +bool TestRegexpOnText(const absl::string_view& regexp, const absl::string_view& text); - + } // namespace re2 - + diff --git a/util/pcre.cc b/util/pcre.cc index b689851..6be9a5d 100644 --- util/pcre.cc +++ util/pcre.cc @@ -191,7 +191,7 @@ pcre* PCRE::Compile(Anchor anchor) { - + /***** Convenience interfaces *****/ - + -bool PCRE::FullMatchFunctor::operator ()(const StringPiece& text, +bool PCRE::FullMatchFunctor::operator ()(const absl::string_view& text, const PCRE& re, @@ -3366,7 +3366,7 @@ index b689851..6be9a5d 100644 @@ -234,7 +234,7 @@ done: return re.DoMatchImpl(text, ANCHOR_BOTH, &consumed, args, n, vec, kVecSize); } - + -bool PCRE::PartialMatchFunctor::operator ()(const StringPiece& text, +bool PCRE::PartialMatchFunctor::operator ()(const absl::string_view& text, const PCRE& re, @@ -3375,7 +3375,7 @@ index b689851..6be9a5d 100644 @@ -277,7 +277,7 @@ done: return re.DoMatchImpl(text, UNANCHORED, &consumed, args, n, vec, kVecSize); } - + -bool PCRE::ConsumeFunctor::operator ()(StringPiece* input, +bool PCRE::ConsumeFunctor::operator ()(absl::string_view* input, const PCRE& pattern, @@ -3384,14 +3384,14 @@ index b689851..6be9a5d 100644 @@ -326,7 +326,7 @@ done: } } - + -bool PCRE::FindAndConsumeFunctor::operator ()(StringPiece* input, +bool PCRE::FindAndConsumeFunctor::operator ()(absl::string_view* input, const PCRE& pattern, const Arg& a0, const Arg& a1, @@ -377,7 +377,7 @@ done: - + bool PCRE::Replace(std::string *str, const PCRE& pattern, - const StringPiece& rewrite) { @@ -3400,7 +3400,7 @@ index b689851..6be9a5d 100644 int matches = pattern.TryMatch(*str, 0, UNANCHORED, true, vec, kVecSize); if (matches == 0) @@ -395,7 +395,7 @@ bool PCRE::Replace(std::string *str, - + int PCRE::GlobalReplace(std::string *str, const PCRE& pattern, - const StringPiece& rewrite) { @@ -3411,7 +3411,7 @@ index b689851..6be9a5d 100644 @@ -451,9 +451,9 @@ int PCRE::GlobalReplace(std::string *str, return count; } - + -bool PCRE::Extract(const StringPiece &text, +bool PCRE::Extract(const absl::string_view &text, const PCRE& pattern, @@ -3423,16 +3423,16 @@ index b689851..6be9a5d 100644 @@ -463,7 +463,7 @@ bool PCRE::Extract(const StringPiece &text, return pattern.Rewrite(out, rewrite, text, vec, matches); } - + -std::string PCRE::QuoteMeta(const StringPiece& unquoted) { +std::string PCRE::QuoteMeta(const absl::string_view& unquoted) { std::string result; result.reserve(unquoted.size() << 1); - + @@ -508,7 +508,7 @@ void PCRE::ClearHitLimit() { hit_limit_ = 0; } - + -int PCRE::TryMatch(const StringPiece& text, +int PCRE::TryMatch(const absl::string_view& text, size_t startpos, @@ -3441,7 +3441,7 @@ index b689851..6be9a5d 100644 @@ -604,7 +604,7 @@ int PCRE::TryMatch(const StringPiece& text, return rc; } - + -bool PCRE::DoMatchImpl(const StringPiece& text, +bool PCRE::DoMatchImpl(const absl::string_view& text, Anchor anchor, @@ -3450,7 +3450,7 @@ index b689851..6be9a5d 100644 @@ -654,7 +654,7 @@ bool PCRE::DoMatchImpl(const StringPiece& text, return true; } - + -bool PCRE::DoMatch(const StringPiece& text, +bool PCRE::DoMatch(const absl::string_view& text, Anchor anchor, @@ -3459,7 +3459,7 @@ index b689851..6be9a5d 100644 @@ -668,8 +668,8 @@ bool PCRE::DoMatch(const StringPiece& text, return b; } - + -bool PCRE::Rewrite(std::string *out, const StringPiece &rewrite, - const StringPiece &text, int *vec, int veclen) const { +bool PCRE::Rewrite(std::string *out, const absl::string_view &rewrite, @@ -3470,21 +3470,21 @@ index b689851..6be9a5d 100644 @@ -704,7 +704,7 @@ bool PCRE::Rewrite(std::string *out, const StringPiece &rewrite, return true; } - + -bool PCRE::CheckRewriteString(const StringPiece& rewrite, +bool PCRE::CheckRewriteString(const absl::string_view& rewrite, std::string* error) const { int max_token = -1; for (const char *s = rewrite.data(), *end = s + rewrite.size(); @@ -776,7 +776,7 @@ bool PCRE::Arg::parse_string(const char* str, size_t n, void* dest) { - + bool PCRE::Arg::parse_stringpiece(const char* str, size_t n, void* dest) { if (dest == NULL) return true; - *(reinterpret_cast(dest)) = StringPiece(str, n); + *(reinterpret_cast(dest)) = absl::string_view(str, n); return true; } - + diff --git a/util/pcre.h b/util/pcre.h index 896b0bd..a5eb939 100644 --- util/pcre.h @@ -3506,11 +3506,11 @@ index 896b0bd..a5eb939 100644 // int value; @@ -162,7 +162,7 @@ // will leave 64 in a, b, c, and d. - + #include "util/util.h" -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" - + #ifdef USEPCRE #include @@ -247,7 +247,7 @@ class PCRE { @@ -3564,7 +3564,7 @@ index 896b0bd..a5eb939 100644 const PCRE& pattern, - const StringPiece& rewrite); + const absl::string_view& rewrite); - + // Like Replace(), except replaces all occurrences of the pattern in // the string with the rewrite. Replacements are not subject to @@ -392,7 +392,7 @@ class PCRE { @@ -3573,7 +3573,7 @@ index 896b0bd..a5eb939 100644 const PCRE& pattern, - const StringPiece& rewrite); + const absl::string_view& rewrite); - + // Like Replace, except that if the pattern matches, "rewrite" // is copied into "out" with substitutions. The non-matching @@ -400,9 +400,9 @@ class PCRE { @@ -3586,7 +3586,7 @@ index 896b0bd..a5eb939 100644 - const StringPiece &rewrite, + const absl::string_view &rewrite, std::string *out); - + // Check that the given @p rewrite string is suitable for use with @@ -418,7 +418,7 @@ class PCRE { // @param error An error message is recorded here, iff we return false. @@ -3595,7 +3595,7 @@ index 896b0bd..a5eb939 100644 - bool CheckRewriteString(const StringPiece& rewrite, + bool CheckRewriteString(const absl::string_view& rewrite, std::string* error) const; - + // Returns a copy of 'unquoted' with all potentially meaningful @@ -428,7 +428,7 @@ class PCRE { // 1.5-2.0? @@ -3603,11 +3603,11 @@ index 896b0bd..a5eb939 100644 // 1\.5\-2\.0\? - static std::string QuoteMeta(const StringPiece& unquoted); + static std::string QuoteMeta(const absl::string_view& unquoted); - + /***** Generic matching interface (not so nice to use) *****/ - + @@ -441,7 +441,7 @@ class PCRE { - + // General matching routine. Stores the length of the match in // "*consumed" if successful. - bool DoMatch(const StringPiece& text, @@ -3634,7 +3634,7 @@ index 896b0bd..a5eb939 100644 + const absl::string_view &text, int *vec, int veclen) const; - + // internal implementation for DoMatch - bool DoMatchImpl(const StringPiece& text, + bool DoMatchImpl(const absl::string_view& text, @@ -3647,7 +3647,7 @@ index 896b0bd..a5eb939 100644 MAKE_PARSER(std::string, parse_string); - MAKE_PARSER(StringPiece, parse_stringpiece); + MAKE_PARSER(absl::string_view, parse_stringpiece); - + MAKE_PARSER(short, parse_short); MAKE_PARSER(unsigned short, parse_ushort); diff --git a/util/strutil.cc b/util/strutil.cc @@ -3668,17 +3668,16 @@ index a69908a..a449054 100644 --- util/strutil.h +++ util/strutil.h @@ -7,12 +7,12 @@ - + #include - + -#include "re2/stringpiece.h" +#include "absl/strings/string_view.h" #include "util/util.h" - + namespace re2 { - + -std::string CEscape(const StringPiece& src); +std::string CEscape(const absl::string_view& src); void PrefixSuccessor(std::string* prefix); std::string StringPrintf(const char* format, ...); -