Browse Source

Update contrib/libs/re2 to 2023-06-02

thegeorg 1 year ago
parent
commit
40e98695cc

+ 1 - 1
contrib/libs/apache/arrow/cpp/src/arrow/compute/kernels/scalar_string.cc

@@ -2725,7 +2725,7 @@ struct ExtractRegex : public ExtractRegexBase {
         result->value.reserve(group_count);
         result->value.reserve(group_count);
         for (int i = 0; i < group_count; i++) {
         for (int i = 0; i < group_count; i++) {
           result->value.push_back(
           result->value.push_back(
-              std::make_shared<ScalarType>(found_values[i].as_string()));
+              std::make_shared<ScalarType>(std::string{found_values[i]}));
         }
         }
         result->is_valid = true;
         result->is_valid = true;
       } else {
       } else {

+ 5 - 1
contrib/libs/re2/CMakeLists.darwin-x86_64.txt

@@ -20,6 +20,11 @@ target_include_directories(contrib-libs-re2 PRIVATE
 target_link_libraries(contrib-libs-re2 PUBLIC
 target_link_libraries(contrib-libs-re2 PUBLIC
   contrib-libs-cxxsupp
   contrib-libs-cxxsupp
   yutil
   yutil
+  abseil-cpp-absl-base
+  abseil-cpp-absl-container
+  abseil-cpp-absl-hash
+  abseil-cpp-absl-strings
+  abseil-cpp-absl-synchronization
 )
 )
 target_sources(contrib-libs-re2 PRIVATE
 target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
@@ -39,7 +44,6 @@ target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
-  ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/stringpiece.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc

+ 5 - 1
contrib/libs/re2/CMakeLists.linux-aarch64.txt

@@ -21,6 +21,11 @@ target_link_libraries(contrib-libs-re2 PUBLIC
   contrib-libs-linux-headers
   contrib-libs-linux-headers
   contrib-libs-cxxsupp
   contrib-libs-cxxsupp
   yutil
   yutil
+  abseil-cpp-absl-base
+  abseil-cpp-absl-container
+  abseil-cpp-absl-hash
+  abseil-cpp-absl-strings
+  abseil-cpp-absl-synchronization
 )
 )
 target_sources(contrib-libs-re2 PRIVATE
 target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
@@ -40,7 +45,6 @@ target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
-  ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/stringpiece.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc

+ 5 - 1
contrib/libs/re2/CMakeLists.linux-x86_64.txt

@@ -21,6 +21,11 @@ target_link_libraries(contrib-libs-re2 PUBLIC
   contrib-libs-linux-headers
   contrib-libs-linux-headers
   contrib-libs-cxxsupp
   contrib-libs-cxxsupp
   yutil
   yutil
+  abseil-cpp-absl-base
+  abseil-cpp-absl-container
+  abseil-cpp-absl-hash
+  abseil-cpp-absl-strings
+  abseil-cpp-absl-synchronization
 )
 )
 target_sources(contrib-libs-re2 PRIVATE
 target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
@@ -40,7 +45,6 @@ target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
-  ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/stringpiece.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc

+ 5 - 1
contrib/libs/re2/CMakeLists.windows-x86_64.txt

@@ -20,6 +20,11 @@ target_include_directories(contrib-libs-re2 PRIVATE
 target_link_libraries(contrib-libs-re2 PUBLIC
 target_link_libraries(contrib-libs-re2 PUBLIC
   contrib-libs-cxxsupp
   contrib-libs-cxxsupp
   yutil
   yutil
+  abseil-cpp-absl-base
+  abseil-cpp-absl-container
+  abseil-cpp-absl-hash
+  abseil-cpp-absl-strings
+  abseil-cpp-absl-synchronization
 )
 )
 target_sources(contrib-libs-re2 PRIVATE
 target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/bitmap256.cc
@@ -39,7 +44,6 @@ target_sources(contrib-libs-re2 PRIVATE
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/regexp.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/set.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/simplify.cc
-  ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/stringpiece.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/tostring.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_casefold.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc
   ${CMAKE_SOURCE_DIR}/contrib/libs/re2/re2/unicode_groups.cc

+ 5 - 0
contrib/libs/re2/README

@@ -10,6 +10,11 @@ make test
 make install
 make install
 make testinstall
 make testinstall
 
 
+Building RE2 requires Abseil (https://github.com/abseil/abseil-cpp)
+to be installed on your system. Building the testing for RE2 requires
+GoogleTest (https://github.com/google/googletest) and Benchmark
+(https://github.com/google/benchmark) to be installed as well.
+
 There is a fair amount of documentation (including code snippets) in
 There is a fair amount of documentation (including code snippets) in
 the re2.h header file.
 the re2.h header file.
 
 

+ 0 - 1
contrib/libs/re2/include/util/util.h

@@ -1 +0,0 @@
-#include "../../util/util.h" /* inclink generated by yamaker */

+ 4 - 4
contrib/libs/re2/re2/bitmap256.cc

@@ -6,7 +6,7 @@
 
 
 #include <stdint.h>
 #include <stdint.h>
 
 
-#include "util/util.h"
+#include "absl/base/macros.h"
 #include "util/logging.h"
 #include "util/logging.h"
 
 
 namespace re2 {
 namespace re2 {
@@ -27,15 +27,15 @@ int Bitmap256::FindNextSetBit(int c) const {
     case 1:
     case 1:
       if (words_[1] != 0)
       if (words_[1] != 0)
         return (1 * 64) + FindLSBSet(words_[1]);
         return (1 * 64) + FindLSBSet(words_[1]);
-      FALLTHROUGH_INTENDED;
+      ABSL_FALLTHROUGH_INTENDED;
     case 2:
     case 2:
       if (words_[2] != 0)
       if (words_[2] != 0)
         return (2 * 64) + FindLSBSet(words_[2]);
         return (2 * 64) + FindLSBSet(words_[2]);
-      FALLTHROUGH_INTENDED;
+      ABSL_FALLTHROUGH_INTENDED;
     case 3:
     case 3:
       if (words_[3] != 0)
       if (words_[3] != 0)
         return (3 * 64) + FindLSBSet(words_[3]);
         return (3 * 64) + FindLSBSet(words_[3]);
-      FALLTHROUGH_INTENDED;
+      ABSL_FALLTHROUGH_INTENDED;
     default:
     default:
       return -1;
       return -1;
   }
   }

+ 21 - 25
contrib/libs/re2/re2/bitstate.cc

@@ -42,9 +42,8 @@ class BitState {
 
 
   // The usual Search prototype.
   // The usual Search prototype.
   // Can only call Search once per BitState.
   // Can only call Search once per BitState.
-  bool Search(const StringPiece& text, const StringPiece& context,
-              bool anchored, bool longest,
-              StringPiece* submatch, int nsubmatch);
+  bool Search(absl::string_view text, absl::string_view context, bool anchored,
+              bool longest, absl::string_view* submatch, int nsubmatch);
 
 
  private:
  private:
   inline bool ShouldVisit(int id, const char* p);
   inline bool ShouldVisit(int id, const char* p);
@@ -53,14 +52,14 @@ class BitState {
   bool TrySearch(int id, const char* p);
   bool TrySearch(int id, const char* p);
 
 
   // Search parameters
   // Search parameters
-  Prog* prog_;              // program being run
-  StringPiece text_;        // text being searched
-  StringPiece context_;     // greater context of text being searched
-  bool anchored_;           // whether search is anchored at text.begin()
-  bool longest_;            // whether search wants leftmost-longest match
-  bool endmatch_;           // whether match must end at text.end()
-  StringPiece* submatch_;   // submatches to fill in
-  int nsubmatch_;           //   # of submatches to fill in
+  Prog* prog_;                   // program being run
+  absl::string_view text_;       // text being searched
+  absl::string_view context_;    // greater context of text being searched
+  bool anchored_;                // whether search is anchored at text.begin()
+  bool longest_;                 // whether search wants leftmost-longest match
+  bool endmatch_;                // whether match must end at text.end()
+  absl::string_view* submatch_;  // submatches to fill in
+  int nsubmatch_;                //   # of submatches to fill in
 
 
   // Search state
   // Search state
   static constexpr int kVisitedBits = 64;
   static constexpr int kVisitedBits = 64;
@@ -256,9 +255,9 @@ bool BitState::TrySearch(int id0, const char* p0) {
         if (submatch_[0].data() == NULL ||
         if (submatch_[0].data() == NULL ||
             (longest_ && p > submatch_[0].data() + submatch_[0].size())) {
             (longest_ && p > submatch_[0].data() + submatch_[0].size())) {
           for (int i = 0; i < nsubmatch_; i++)
           for (int i = 0; i < nsubmatch_; i++)
-            submatch_[i] =
-                StringPiece(cap_[2 * i],
-                            static_cast<size_t>(cap_[2 * i + 1] - cap_[2 * i]));
+            submatch_[i] = absl::string_view(
+                cap_[2 * i],
+                static_cast<size_t>(cap_[2 * i + 1] - cap_[2 * i]));
         }
         }
 
 
         // If going for first match, we're done.
         // If going for first match, we're done.
@@ -285,9 +284,9 @@ bool BitState::TrySearch(int id0, const char* p0) {
 }
 }
 
 
 // Search text (within context) for prog_.
 // Search text (within context) for prog_.
-bool BitState::Search(const StringPiece& text, const StringPiece& context,
-                      bool anchored, bool longest,
-                      StringPiece* submatch, int nsubmatch) {
+bool BitState::Search(absl::string_view text, absl::string_view context,
+                      bool anchored, bool longest, absl::string_view* submatch,
+                      int nsubmatch) {
   // Search parameters.
   // Search parameters.
   text_ = text;
   text_ = text;
   context_ = context;
   context_ = context;
@@ -303,7 +302,7 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context,
   submatch_ = submatch;
   submatch_ = submatch;
   nsubmatch_ = nsubmatch;
   nsubmatch_ = nsubmatch;
   for (int i = 0; i < nsubmatch_; i++)
   for (int i = 0; i < nsubmatch_; i++)
-    submatch_[i] = StringPiece();
+    submatch_[i] = absl::string_view();
 
 
   // Allocate scratch space.
   // Allocate scratch space.
   int nvisited = prog_->list_count() * static_cast<int>(text.size()+1);
   int nvisited = prog_->list_count() * static_cast<int>(text.size()+1);
@@ -353,16 +352,13 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context,
 }
 }
 
 
 // Bit-state search.
 // Bit-state search.
-bool Prog::SearchBitState(const StringPiece& text,
-                          const StringPiece& context,
-                          Anchor anchor,
-                          MatchKind kind,
-                          StringPiece* match,
-                          int nmatch) {
+bool Prog::SearchBitState(absl::string_view text, absl::string_view context,
+                          Anchor anchor, MatchKind kind,
+                          absl::string_view* match, int nmatch) {
   // If full match, we ask for an anchored longest match
   // If full match, we ask for an anchored longest match
   // and then check that match[0] == text.
   // and then check that match[0] == text.
   // So make sure match[0] exists.
   // So make sure match[0] exists.
-  StringPiece sp0;
+  absl::string_view sp0;
   if (kind == kFullMatch) {
   if (kind == kFullMatch) {
     anchor = kAnchored;
     anchor = kAnchored;
     if (nmatch < 1) {
     if (nmatch < 1) {

+ 5 - 4
contrib/libs/re2/re2/compile.cc

@@ -10,9 +10,10 @@
 
 
 #include <stdint.h>
 #include <stdint.h>
 #include <string.h>
 #include <string.h>
-#include <unordered_map>
 #include <utility>
 #include <utility>
 
 
+#include "absl/base/macros.h"
+#include "absl/container/flat_hash_map.h"
 #include "util/logging.h"
 #include "util/logging.h"
 #include "util/utf.h"
 #include "util/utf.h"
 #include "re2/pod_array.h"
 #include "re2/pod_array.h"
@@ -211,7 +212,7 @@ class Compiler : public Regexp::Walker<Frag> {
 
 
   int64_t max_mem_;    // Total memory budget.
   int64_t max_mem_;    // Total memory budget.
 
 
-  std::unordered_map<uint64_t, int> rune_cache_;
+  absl::flat_hash_map<uint64_t, int> rune_cache_;
   Frag rune_range_;
   Frag rune_range_;
 
 
   RE2::Anchor anchor_;  // anchor mode for RE2::Set
   RE2::Anchor anchor_;  // anchor mode for RE2::Set
@@ -478,7 +479,7 @@ static uint64_t MakeRuneCacheKey(uint8_t lo, uint8_t hi, bool foldcase,
 int Compiler::CachedRuneByteSuffix(uint8_t lo, uint8_t hi, bool foldcase,
 int Compiler::CachedRuneByteSuffix(uint8_t lo, uint8_t hi, bool foldcase,
                                    int next) {
                                    int next) {
   uint64_t key = MakeRuneCacheKey(lo, hi, foldcase, next);
   uint64_t key = MakeRuneCacheKey(lo, hi, foldcase, next);
-  std::unordered_map<uint64_t, int>::const_iterator it = rune_cache_.find(key);
+  absl::flat_hash_map<uint64_t, int>::const_iterator it = rune_cache_.find(key);
   if (it != rune_cache_.end())
   if (it != rune_cache_.end())
     return it->second;
     return it->second;
   int id = UncachedRuneByteSuffix(lo, hi, foldcase, next);
   int id = UncachedRuneByteSuffix(lo, hi, foldcase, next);
@@ -1243,7 +1244,7 @@ Prog* Compiler::CompileSet(Regexp* re, RE2::Anchor anchor, int64_t max_mem) {
   // Make sure DFA has enough memory to operate,
   // Make sure DFA has enough memory to operate,
   // since we're not going to fall back to the NFA.
   // since we're not going to fall back to the NFA.
   bool dfa_failed = false;
   bool dfa_failed = false;
-  StringPiece sp = "hello, world";
+  absl::string_view sp = "hello, world";
   prog->SearchDFA(sp, sp, Prog::kAnchored, Prog::kManyMatch,
   prog->SearchDFA(sp, sp, Prog::kAnchored, Prog::kManyMatch,
                   NULL, &dfa_failed, NULL);
                   NULL, &dfa_failed, NULL);
   if (dfa_failed) {
   if (dfa_failed) {

Some files were not shown because too many files changed in this diff