Skip to content

Commit 49d776b

Browse files
committed
Copy over the re2/ and util/ subdirectories.
This change should fix the Bazel CI workflow; the GNU make and CMake CI workflows will break now, but should be fixed by the next change. Change-Id: I417463f0283cc74412789d68d1e8d5764d564e8c Reviewed-on: https://code-review.googlesource.com/c/re2/+/61250 Reviewed-by: Alex Chernyakhovsky <[email protected]> Reviewed-by: Paul Wankadia <[email protected]>
1 parent b76a3ea commit 49d776b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1157
-2236
lines changed

re2/bitmap256.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <stdint.h>
88

9-
#include "util/util.h"
9+
#include "absl/base/macros.h"
1010
#include "util/logging.h"
1111

1212
namespace re2 {
@@ -27,15 +27,15 @@ int Bitmap256::FindNextSetBit(int c) const {
2727
case 1:
2828
if (words_[1] != 0)
2929
return (1 * 64) + FindLSBSet(words_[1]);
30-
FALLTHROUGH_INTENDED;
30+
ABSL_FALLTHROUGH_INTENDED;
3131
case 2:
3232
if (words_[2] != 0)
3333
return (2 * 64) + FindLSBSet(words_[2]);
34-
FALLTHROUGH_INTENDED;
34+
ABSL_FALLTHROUGH_INTENDED;
3535
case 3:
3636
if (words_[3] != 0)
3737
return (3 * 64) + FindLSBSet(words_[3]);
38-
FALLTHROUGH_INTENDED;
38+
ABSL_FALLTHROUGH_INTENDED;
3939
default:
4040
return -1;
4141
}

re2/bitstate.cc

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ class BitState {
4242

4343
// The usual Search prototype.
4444
// Can only call Search once per BitState.
45-
bool Search(const StringPiece& text, const StringPiece& context,
46-
bool anchored, bool longest,
47-
StringPiece* submatch, int nsubmatch);
45+
bool Search(absl::string_view text, absl::string_view context, bool anchored,
46+
bool longest, absl::string_view* submatch, int nsubmatch);
4847

4948
private:
5049
inline bool ShouldVisit(int id, const char* p);
@@ -53,14 +52,14 @@ class BitState {
5352
bool TrySearch(int id, const char* p);
5453

5554
// Search parameters
56-
Prog* prog_; // program being run
57-
StringPiece text_; // text being searched
58-
StringPiece context_; // greater context of text being searched
59-
bool anchored_; // whether search is anchored at text.begin()
60-
bool longest_; // whether search wants leftmost-longest match
61-
bool endmatch_; // whether match must end at text.end()
62-
StringPiece* submatch_; // submatches to fill in
63-
int nsubmatch_; // # of submatches to fill in
55+
Prog* prog_; // program being run
56+
absl::string_view text_; // text being searched
57+
absl::string_view context_; // greater context of text being searched
58+
bool anchored_; // whether search is anchored at text.begin()
59+
bool longest_; // whether search wants leftmost-longest match
60+
bool endmatch_; // whether match must end at text.end()
61+
absl::string_view* submatch_; // submatches to fill in
62+
int nsubmatch_; // # of submatches to fill in
6463

6564
// Search state
6665
static constexpr int kVisitedBits = 64;
@@ -256,9 +255,9 @@ bool BitState::TrySearch(int id0, const char* p0) {
256255
if (submatch_[0].data() == NULL ||
257256
(longest_ && p > submatch_[0].data() + submatch_[0].size())) {
258257
for (int i = 0; i < nsubmatch_; i++)
259-
submatch_[i] =
260-
StringPiece(cap_[2 * i],
261-
static_cast<size_t>(cap_[2 * i + 1] - cap_[2 * i]));
258+
submatch_[i] = absl::string_view(
259+
cap_[2 * i],
260+
static_cast<size_t>(cap_[2 * i + 1] - cap_[2 * i]));
262261
}
263262

264263
// If going for first match, we're done.
@@ -285,9 +284,9 @@ bool BitState::TrySearch(int id0, const char* p0) {
285284
}
286285

287286
// Search text (within context) for prog_.
288-
bool BitState::Search(const StringPiece& text, const StringPiece& context,
289-
bool anchored, bool longest,
290-
StringPiece* submatch, int nsubmatch) {
287+
bool BitState::Search(absl::string_view text, absl::string_view context,
288+
bool anchored, bool longest, absl::string_view* submatch,
289+
int nsubmatch) {
291290
// Search parameters.
292291
text_ = text;
293292
context_ = context;
@@ -303,7 +302,7 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context,
303302
submatch_ = submatch;
304303
nsubmatch_ = nsubmatch;
305304
for (int i = 0; i < nsubmatch_; i++)
306-
submatch_[i] = StringPiece();
305+
submatch_[i] = absl::string_view();
307306

308307
// Allocate scratch space.
309308
int nvisited = prog_->list_count() * static_cast<int>(text.size()+1);
@@ -353,16 +352,13 @@ bool BitState::Search(const StringPiece& text, const StringPiece& context,
353352
}
354353

355354
// Bit-state search.
356-
bool Prog::SearchBitState(const StringPiece& text,
357-
const StringPiece& context,
358-
Anchor anchor,
359-
MatchKind kind,
360-
StringPiece* match,
361-
int nmatch) {
355+
bool Prog::SearchBitState(absl::string_view text, absl::string_view context,
356+
Anchor anchor, MatchKind kind,
357+
absl::string_view* match, int nmatch) {
362358
// If full match, we ask for an anchored longest match
363359
// and then check that match[0] == text.
364360
// So make sure match[0] exists.
365-
StringPiece sp0;
361+
absl::string_view sp0;
366362
if (kind == kFullMatch) {
367363
anchor = kAnchored;
368364
if (nmatch < 1) {

re2/compile.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
#include <stdint.h>
1212
#include <string.h>
13-
#include <unordered_map>
1413
#include <utility>
1514

15+
#include "absl/base/macros.h"
16+
#include "absl/container/flat_hash_map.h"
1617
#include "util/logging.h"
1718
#include "util/utf.h"
1819
#include "re2/pod_array.h"
@@ -211,7 +212,7 @@ class Compiler : public Regexp::Walker<Frag> {
211212

212213
int64_t max_mem_; // Total memory budget.
213214

214-
std::unordered_map<uint64_t, int> rune_cache_;
215+
absl::flat_hash_map<uint64_t, int> rune_cache_;
215216
Frag rune_range_;
216217

217218
RE2::Anchor anchor_; // anchor mode for RE2::Set
@@ -478,7 +479,7 @@ static uint64_t MakeRuneCacheKey(uint8_t lo, uint8_t hi, bool foldcase,
478479
int Compiler::CachedRuneByteSuffix(uint8_t lo, uint8_t hi, bool foldcase,
479480
int next) {
480481
uint64_t key = MakeRuneCacheKey(lo, hi, foldcase, next);
481-
std::unordered_map<uint64_t, int>::const_iterator it = rune_cache_.find(key);
482+
absl::flat_hash_map<uint64_t, int>::const_iterator it = rune_cache_.find(key);
482483
if (it != rune_cache_.end())
483484
return it->second;
484485
int id = UncachedRuneByteSuffix(lo, hi, foldcase, next);
@@ -1243,7 +1244,7 @@ Prog* Compiler::CompileSet(Regexp* re, RE2::Anchor anchor, int64_t max_mem) {
12431244
// Make sure DFA has enough memory to operate,
12441245
// since we're not going to fall back to the NFA.
12451246
bool dfa_failed = false;
1246-
StringPiece sp = "hello, world";
1247+
absl::string_view sp = "hello, world";
12471248
prog->SearchDFA(sp, sp, Prog::kAnchored, Prog::kManyMatch,
12481249
NULL, &dfa_failed, NULL);
12491250
if (dfa_failed) {

0 commit comments

Comments
 (0)