re2 1.19.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/.github/actions/linux-alpine-node-16/Dockerfile +1 -1
  2. package/.github/actions/linux-alpine-node-18/Dockerfile +1 -1
  3. package/.github/actions/linux-alpine-node-20/Dockerfile +1 -1
  4. package/.gitmodules +5 -2
  5. package/README.md +1 -0
  6. package/binding.gyp +82 -25
  7. package/lib/replace.cc +4 -4
  8. package/package.json +1 -1
  9. package/tsconfig.json +2 -1
  10. package/vendor/re2/.bazelrc +16 -0
  11. package/vendor/re2/.github/bazel.sh +24 -0
  12. package/vendor/re2/.github/cmake.sh +12 -0
  13. package/vendor/re2/.github/workflows/ci-bazel.yml +17 -0
  14. package/vendor/re2/.github/workflows/ci-cmake.yml +108 -0
  15. package/vendor/re2/.github/workflows/ci.yml +89 -0
  16. package/vendor/re2/.github/workflows/pr.yml +26 -0
  17. package/vendor/re2/.github/workflows/python.yml +185 -0
  18. package/vendor/re2/AUTHORS +13 -0
  19. package/vendor/re2/BUILD.bazel +280 -0
  20. package/vendor/re2/CMakeLists.txt +268 -0
  21. package/vendor/re2/CONTRIBUTING.md +2 -0
  22. package/vendor/re2/CONTRIBUTORS +41 -0
  23. package/vendor/re2/Makefile +400 -0
  24. package/vendor/{README → re2/README} +5 -0
  25. package/vendor/re2/SECURITY.md +4 -0
  26. package/vendor/re2/WORKSPACE.bazel +62 -0
  27. package/vendor/re2/app/BUILD.bazel +19 -0
  28. package/vendor/re2/app/_re2.cc +94 -0
  29. package/vendor/re2/app/_re2.d.ts +23 -0
  30. package/vendor/re2/app/app.ts +111 -0
  31. package/vendor/re2/app/build.sh +50 -0
  32. package/vendor/re2/app/index.html +5 -0
  33. package/vendor/re2/app/package.json +14 -0
  34. package/vendor/re2/app/rollup.config.js +28 -0
  35. package/vendor/re2/app/tsconfig.json +17 -0
  36. package/vendor/re2/benchlog/benchplot.py +98 -0
  37. package/vendor/re2/benchlog/mktable +155 -0
  38. package/vendor/re2/doc/mksyntaxgo +42 -0
  39. package/vendor/re2/doc/mksyntaxhtml +42 -0
  40. package/vendor/re2/doc/mksyntaxwiki +36 -0
  41. package/vendor/re2/doc/syntax.html +477 -0
  42. package/vendor/re2/doc/syntax.txt +463 -0
  43. package/vendor/re2/lib/git/commit-msg.hook +104 -0
  44. package/vendor/re2/libre2.symbols +19 -0
  45. package/vendor/re2/libre2.symbols.darwin +15 -0
  46. package/vendor/re2/python/BUILD.bazel +36 -0
  47. package/vendor/re2/python/README +1 -0
  48. package/vendor/re2/python/_re2.cc +338 -0
  49. package/vendor/re2/python/re2.py +582 -0
  50. package/vendor/re2/python/re2_test.py +482 -0
  51. package/vendor/re2/python/setup.py +105 -0
  52. package/vendor/re2/{bitmap256.cc → re2/bitmap256.cc} +4 -4
  53. package/vendor/re2/{bitstate.cc → re2/bitstate.cc} +21 -25
  54. package/vendor/re2/{compile.cc → re2/compile.cc} +5 -4
  55. package/vendor/re2/{dfa.cc → re2/dfa.cc} +120 -101
  56. package/vendor/re2/{filtered_re2.cc → re2/filtered_re2.cc} +8 -11
  57. package/vendor/re2/{filtered_re2.h → re2/filtered_re2.h} +5 -4
  58. package/vendor/re2/{fuzzing → re2/fuzzing}/re2_fuzzer.cc +4 -6
  59. package/vendor/re2/{mimics_pcre.cc → re2/mimics_pcre.cc} +0 -1
  60. package/vendor/re2/{nfa.cc → re2/nfa.cc} +34 -37
  61. package/vendor/re2/{onepass.cc → re2/onepass.cc} +25 -27
  62. package/vendor/re2/{parse.cc → re2/parse.cc} +118 -121
  63. package/vendor/re2/{prefilter.cc → re2/prefilter.cc} +2 -3
  64. package/vendor/re2/{prefilter.h → re2/prefilter.h} +0 -1
  65. package/vendor/re2/{prefilter_tree.cc → re2/prefilter_tree.cc} +4 -5
  66. package/vendor/re2/{prefilter_tree.h → re2/prefilter_tree.h} +1 -2
  67. package/vendor/re2/{prog.cc → re2/prog.cc} +20 -21
  68. package/vendor/re2/{prog.h → re2/prog.h} +21 -22
  69. package/vendor/re2/{re2.cc → re2/re2.cc} +51 -62
  70. package/vendor/re2/{re2.h → re2/re2.h} +78 -40
  71. package/vendor/re2/{regexp.cc → re2/regexp.cc} +11 -12
  72. package/vendor/re2/{regexp.h → re2/regexp.h} +9 -10
  73. package/vendor/re2/{set.cc → re2/set.cc} +3 -5
  74. package/vendor/re2/{set.h → re2/set.h} +4 -3
  75. package/vendor/re2/{simplify.cc → re2/simplify.cc} +1 -2
  76. package/vendor/re2/re2/stringpiece.h +24 -0
  77. package/vendor/re2/{testing → re2/testing}/backtrack.cc +22 -25
  78. package/vendor/re2/{testing → re2/testing}/charclass_test.cc +23 -21
  79. package/vendor/re2/{testing → re2/testing}/compile_test.cc +5 -4
  80. package/vendor/re2/{testing → re2/testing}/dfa_test.cc +36 -30
  81. package/vendor/re2/{testing → re2/testing}/dump.cc +8 -8
  82. package/vendor/re2/{testing → re2/testing}/exhaustive1_test.cc +1 -1
  83. package/vendor/re2/{testing → re2/testing}/exhaustive2_test.cc +1 -1
  84. package/vendor/re2/{testing → re2/testing}/exhaustive3_test.cc +1 -1
  85. package/vendor/re2/{testing → re2/testing}/exhaustive_test.cc +1 -1
  86. package/vendor/re2/{testing → re2/testing}/exhaustive_tester.cc +36 -32
  87. package/vendor/re2/{testing → re2/testing}/exhaustive_tester.h +0 -1
  88. package/vendor/re2/{testing → re2/testing}/filtered_re2_test.cc +9 -8
  89. package/vendor/re2/{testing → re2/testing}/mimics_pcre_test.cc +3 -2
  90. package/vendor/re2/{testing → re2/testing}/null_walker.cc +1 -1
  91. package/vendor/re2/{testing → re2/testing}/parse_test.cc +13 -12
  92. package/vendor/re2/{testing → re2/testing}/possible_match_test.cc +15 -14
  93. package/vendor/re2/{testing → re2/testing}/random_test.cc +13 -12
  94. package/vendor/re2/{testing → re2/testing}/re2_arg_test.cc +25 -2
  95. package/vendor/re2/{testing → re2/testing}/re2_test.cc +49 -47
  96. package/vendor/re2/{testing → re2/testing}/regexp_benchmark.cc +144 -145
  97. package/vendor/re2/{testing → re2/testing}/regexp_generator.cc +18 -14
  98. package/vendor/re2/{testing → re2/testing}/regexp_generator.h +3 -4
  99. package/vendor/re2/{testing → re2/testing}/regexp_test.cc +1 -1
  100. package/vendor/re2/{testing → re2/testing}/required_prefix_test.cc +5 -4
  101. package/vendor/re2/{testing → re2/testing}/search_test.cc +3 -2
  102. package/vendor/re2/{testing → re2/testing}/set_test.cc +1 -1
  103. package/vendor/re2/{testing → re2/testing}/simplify_test.cc +3 -2
  104. package/vendor/re2/{testing → re2/testing}/string_generator.cc +3 -3
  105. package/vendor/re2/{testing → re2/testing}/string_generator.h +5 -6
  106. package/vendor/re2/{testing → re2/testing}/string_generator_test.cc +2 -2
  107. package/vendor/re2/{testing → re2/testing}/tester.cc +77 -78
  108. package/vendor/re2/{testing → re2/testing}/tester.h +13 -15
  109. package/vendor/re2/{tostring.cc → re2/tostring.cc} +7 -8
  110. package/vendor/re2/{unicode_casefold.h → re2/unicode_casefold.h} +0 -1
  111. package/vendor/re2/{unicode_groups.h → re2/unicode_groups.h} +0 -1
  112. package/vendor/re2/{walker-inl.h → re2/walker-inl.h} +2 -1
  113. package/vendor/re2/re2.pc.in +9 -0
  114. package/vendor/re2/re2Config.cmake.in +28 -0
  115. package/vendor/re2/runtests +33 -0
  116. package/vendor/re2/testinstall.cc +27 -0
  117. package/vendor/re2/ucs2.diff +567 -0
  118. package/vendor/{util → re2/util}/logging.h +2 -2
  119. package/vendor/{util → re2/util}/pcre.cc +47 -116
  120. package/vendor/{util → re2/util}/pcre.h +53 -63
  121. package/vendor/re2/util/strutil.cc +26 -0
  122. package/vendor/{util → re2/util}/strutil.h +0 -5
  123. package/vendor/re2/stringpiece.cc +0 -65
  124. package/vendor/re2/stringpiece.h +0 -213
  125. package/vendor/util/benchmark.cc +0 -131
  126. package/vendor/util/benchmark.h +0 -156
  127. package/vendor/util/flags.h +0 -26
  128. package/vendor/util/mix.h +0 -41
  129. package/vendor/util/mutex.h +0 -164
  130. package/vendor/util/strutil.cc +0 -149
  131. package/vendor/util/test.cc +0 -34
  132. package/vendor/util/test.h +0 -50
  133. package/vendor/util/util.h +0 -42
  134. /package/vendor/{LICENSE → re2/LICENSE} +0 -0
  135. /package/vendor/re2/{bitmap256.h → re2/bitmap256.h} +0 -0
  136. /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/LICENSE +0 -0
  137. /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/include/fuzzer/FuzzedDataProvider.h +0 -0
  138. /package/vendor/re2/{make_perl_groups.pl → re2/make_perl_groups.pl} +0 -0
  139. /package/vendor/re2/{make_unicode_casefold.py → re2/make_unicode_casefold.py} +0 -0
  140. /package/vendor/re2/{make_unicode_groups.py → re2/make_unicode_groups.py} +0 -0
  141. /package/vendor/re2/{perl_groups.cc → re2/perl_groups.cc} +0 -0
  142. /package/vendor/re2/{pod_array.h → re2/pod_array.h} +0 -0
  143. /package/vendor/re2/{sparse_array.h → re2/sparse_array.h} +0 -0
  144. /package/vendor/re2/{sparse_set.h → re2/sparse_set.h} +0 -0
  145. /package/vendor/re2/{unicode.py → re2/unicode.py} +0 -0
  146. /package/vendor/re2/{unicode_casefold.cc → re2/unicode_casefold.cc} +0 -0
  147. /package/vendor/re2/{unicode_groups.cc → re2/unicode_groups.cc} +0 -0
  148. /package/vendor/{util → re2/util}/fuzz.cc +0 -0
  149. /package/vendor/{util → re2/util}/malloc_counter.h +0 -0
  150. /package/vendor/{util → re2/util}/rune.cc +0 -0
  151. /package/vendor/{util → re2/util}/utf.h +0 -0
@@ -15,8 +15,6 @@
15
15
  #include "re2/set.h"
16
16
  #include "re2/walker-inl.h"
17
17
 
18
- using re2::StringPiece;
19
-
20
18
  // NOT static, NOT signed.
21
19
  uint8_t dummy = 0;
22
20
 
@@ -97,8 +95,8 @@ class SubstringWalker : public re2::Regexp::Walker<int> {
97
95
  SubstringWalker& operator=(const SubstringWalker&) = delete;
98
96
  };
99
97
 
100
- void TestOneInput(StringPiece pattern, const RE2::Options& options,
101
- RE2::Anchor anchor, StringPiece text) {
98
+ void TestOneInput(absl::string_view pattern, const RE2::Options& options,
99
+ RE2::Anchor anchor, absl::string_view text) {
102
100
  // Crudely limit the use of ., \p, \P, \d, \D, \s, \S, \w and \W.
103
101
  // Otherwise, we will waste time on inputs that have long runs of various
104
102
  // character classes. The fuzzer has shown itself to be easily capable of
@@ -178,7 +176,7 @@ void TestOneInput(StringPiece pattern, const RE2::Options& options,
178
176
 
179
177
  if (re.NumberOfCapturingGroups() == 0) {
180
178
  // Avoid early return due to too many arguments.
181
- StringPiece sp = text;
179
+ absl::string_view sp = text;
182
180
  RE2::FullMatch(sp, re);
183
181
  RE2::PartialMatch(sp, re);
184
182
  RE2::Consume(&sp, re);
@@ -187,7 +185,7 @@ void TestOneInput(StringPiece pattern, const RE2::Options& options,
187
185
  } else {
188
186
  // Okay, we have at least one capturing group...
189
187
  // Try conversion for variously typed arguments.
190
- StringPiece sp = text;
188
+ absl::string_view sp = text;
191
189
  short s;
192
190
  RE2::FullMatch(sp, re, &s);
193
191
  long l;
@@ -22,7 +22,6 @@
22
22
  //
23
23
  // Regexp::MimicsPCRE checks for any of these conditions.
24
24
 
25
- #include "util/util.h"
26
25
  #include "util/logging.h"
27
26
  #include "re2/regexp.h"
28
27
  #include "re2/walker-inl.h"
@@ -32,8 +32,8 @@
32
32
  #include <utility>
33
33
  #include <vector>
34
34
 
35
+ #include "absl/strings/str_format.h"
35
36
  #include "util/logging.h"
36
- #include "util/strutil.h"
37
37
  #include "re2/pod_array.h"
38
38
  #include "re2/prog.h"
39
39
  #include "re2/regexp.h"
@@ -60,9 +60,8 @@ class NFA {
60
60
  // Submatch[0] is the entire match. When there is a choice in
61
61
  // which text matches each subexpression, the submatch boundaries
62
62
  // are chosen to match what a backtracking implementation would choose.
63
- bool Search(const StringPiece& text, const StringPiece& context,
64
- bool anchored, bool longest,
65
- StringPiece* submatch, int nsubmatch);
63
+ bool Search(absl::string_view text, absl::string_view context, bool anchored,
64
+ bool longest, absl::string_view* submatch, int nsubmatch);
66
65
 
67
66
  private:
68
67
  struct Thread {
@@ -92,7 +91,7 @@ class NFA {
92
91
  // Enqueues only the ByteRange instructions that match byte c.
93
92
  // context is used (with p) for evaluating empty-width specials.
94
93
  // p is the current input position, and t0 is the current thread.
95
- void AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context,
94
+ void AddToThreadq(Threadq* q, int id0, int c, absl::string_view context,
96
95
  const char* p, Thread* t0);
97
96
 
98
97
  // Run runq on byte c, appending new states to nextq.
@@ -102,7 +101,7 @@ class NFA {
102
101
  // p-1 will be used when processing Match instructions.
103
102
  // Frees all the threads on runq.
104
103
  // If there is a shortcut to the end, returns that shortcut.
105
- int Step(Threadq* runq, Threadq* nextq, int c, const StringPiece& context,
104
+ int Step(Threadq* runq, Threadq* nextq, int c, absl::string_view context,
106
105
  const char* p);
107
106
 
108
107
  // Returns text version of capture information, for debugging.
@@ -192,7 +191,7 @@ void NFA::Decref(Thread* t) {
192
191
  // Enqueues only the ByteRange instructions that match byte c.
193
192
  // context is used (with p) for evaluating empty-width specials.
194
193
  // p is the current input position, and t0 is the current thread.
195
- void NFA::AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context,
194
+ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context,
196
195
  const char* p, Thread* t0) {
197
196
  if (id0 == 0)
198
197
  return;
@@ -225,7 +224,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context,
225
224
  continue;
226
225
  if (q->has_index(id)) {
227
226
  if (ExtraDebug)
228
- fprintf(stderr, " [%d%s]\n", id, FormatCapture(t0->capture).c_str());
227
+ absl::FPrintF(stderr, " [%d%s]\n", id, FormatCapture(t0->capture));
229
228
  continue;
230
229
  }
231
230
 
@@ -288,7 +287,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context,
288
287
  t = Incref(t0);
289
288
  *tp = t;
290
289
  if (ExtraDebug)
291
- fprintf(stderr, " + %d%s\n", id, FormatCapture(t0->capture).c_str());
290
+ absl::FPrintF(stderr, " + %d%s\n", id, FormatCapture(t0->capture));
292
291
 
293
292
  if (ip->hint() == 0)
294
293
  break;
@@ -300,7 +299,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context,
300
299
  t = Incref(t0);
301
300
  *tp = t;
302
301
  if (ExtraDebug)
303
- fprintf(stderr, " ! %d%s\n", id, FormatCapture(t0->capture).c_str());
302
+ absl::FPrintF(stderr, " ! %d%s\n", id, FormatCapture(t0->capture));
304
303
 
305
304
  Next:
306
305
  if (ip->last())
@@ -328,7 +327,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, const StringPiece& context,
328
327
  // p-1 will be used when processing Match instructions.
329
328
  // Frees all the threads on runq.
330
329
  // If there is a shortcut to the end, returns that shortcut.
331
- int NFA::Step(Threadq* runq, Threadq* nextq, int c, const StringPiece& context,
330
+ int NFA::Step(Threadq* runq, Threadq* nextq, int c, absl::string_view context,
332
331
  const char* p) {
333
332
  nextq->clear();
334
333
 
@@ -435,23 +434,22 @@ std::string NFA::FormatCapture(const char** capture) {
435
434
  if (capture[i] == NULL)
436
435
  s += "(?,?)";
437
436
  else if (capture[i+1] == NULL)
438
- s += StringPrintf("(%td,?)",
439
- capture[i] - btext_);
437
+ s += absl::StrFormat("(%d,?)",
438
+ capture[i] - btext_);
440
439
  else
441
- s += StringPrintf("(%td,%td)",
442
- capture[i] - btext_,
443
- capture[i+1] - btext_);
440
+ s += absl::StrFormat("(%d,%d)",
441
+ capture[i] - btext_,
442
+ capture[i+1] - btext_);
444
443
  }
445
444
  return s;
446
445
  }
447
446
 
448
- bool NFA::Search(const StringPiece& text, const StringPiece& const_context,
449
- bool anchored, bool longest,
450
- StringPiece* submatch, int nsubmatch) {
447
+ bool NFA::Search(absl::string_view text, absl::string_view context,
448
+ bool anchored, bool longest, absl::string_view* submatch,
449
+ int nsubmatch) {
451
450
  if (start_ == 0)
452
451
  return false;
453
452
 
454
- StringPiece context = const_context;
455
453
  if (context.data() == NULL)
456
454
  context = text;
457
455
 
@@ -497,8 +495,8 @@ bool NFA::Search(const StringPiece& text, const StringPiece& const_context,
497
495
  etext_ = text.data() + text.size();
498
496
 
499
497
  if (ExtraDebug)
500
- fprintf(stderr, "NFA::Search %s (context: %s) anchored=%d longest=%d\n",
501
- std::string(text).c_str(), std::string(context).c_str(), anchored, longest);
498
+ absl::FPrintF(stderr, "NFA::Search %s (context: %s) anchored=%d longest=%d\n",
499
+ text, context, anchored, longest);
502
500
 
503
501
  // Set up search.
504
502
  Threadq* runq = &q0_;
@@ -517,14 +515,14 @@ bool NFA::Search(const StringPiece& text, const StringPiece& const_context,
517
515
  else if (p < etext_)
518
516
  c = p[0] & 0xFF;
519
517
 
520
- fprintf(stderr, "%c:", c);
518
+ absl::FPrintF(stderr, "%c:", c);
521
519
  for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i) {
522
520
  Thread* t = i->value();
523
521
  if (t == NULL)
524
522
  continue;
525
- fprintf(stderr, " %d%s", i->index(), FormatCapture(t->capture).c_str());
523
+ absl::FPrintF(stderr, " %d%s", i->index(), FormatCapture(t->capture));
526
524
  }
527
- fprintf(stderr, "\n");
525
+ absl::FPrintF(stderr, "\n");
528
526
  }
529
527
 
530
528
  // This is a no-op the first time around the loop because runq is empty.
@@ -592,7 +590,7 @@ bool NFA::Search(const StringPiece& text, const StringPiece& const_context,
592
590
  // If all the threads have died, stop early.
593
591
  if (runq->size() == 0) {
594
592
  if (ExtraDebug)
595
- fprintf(stderr, "dead\n");
593
+ absl::FPrintF(stderr, "dead\n");
596
594
  break;
597
595
  }
598
596
 
@@ -616,27 +614,26 @@ bool NFA::Search(const StringPiece& text, const StringPiece& const_context,
616
614
 
617
615
  if (matched_) {
618
616
  for (int i = 0; i < nsubmatch; i++)
619
- submatch[i] =
620
- StringPiece(match_[2 * i],
621
- static_cast<size_t>(match_[2 * i + 1] - match_[2 * i]));
617
+ submatch[i] = absl::string_view(
618
+ match_[2 * i],
619
+ static_cast<size_t>(match_[2 * i + 1] - match_[2 * i]));
622
620
  if (ExtraDebug)
623
- fprintf(stderr, "match (%td,%td)\n",
624
- match_[0] - btext_,
625
- match_[1] - btext_);
621
+ absl::FPrintF(stderr, "match (%d,%d)\n",
622
+ match_[0] - btext_,
623
+ match_[1] - btext_);
626
624
  return true;
627
625
  }
628
626
  return false;
629
627
  }
630
628
 
631
- bool
632
- Prog::SearchNFA(const StringPiece& text, const StringPiece& context,
633
- Anchor anchor, MatchKind kind,
634
- StringPiece* match, int nmatch) {
629
+ bool Prog::SearchNFA(absl::string_view text, absl::string_view context,
630
+ Anchor anchor, MatchKind kind, absl::string_view* match,
631
+ int nmatch) {
635
632
  if (ExtraDebug)
636
633
  Dump();
637
634
 
638
635
  NFA nfa(this);
639
- StringPiece sp;
636
+ absl::string_view sp;
640
637
  if (kind == kFullMatch) {
641
638
  anchor = kAnchored;
642
639
  if (nmatch == 0) {
@@ -57,14 +57,14 @@
57
57
  #include <string>
58
58
  #include <vector>
59
59
 
60
- #include "util/util.h"
60
+ #include "absl/container/fixed_array.h"
61
+ #include "absl/container/inlined_vector.h"
62
+ #include "absl/strings/str_format.h"
61
63
  #include "util/logging.h"
62
- #include "util/strutil.h"
63
64
  #include "util/utf.h"
64
65
  #include "re2/pod_array.h"
65
66
  #include "re2/prog.h"
66
67
  #include "re2/sparse_set.h"
67
- #include "re2/stringpiece.h"
68
68
 
69
69
  // Silence "zero-sized array in struct/union" warning for OneState::action.
70
70
  #ifdef _MSC_VER
@@ -189,7 +189,7 @@ void OnePass_Checks() {
189
189
  "kMaxCap disagrees with kMaxOnePassCapture");
190
190
  }
191
191
 
192
- static bool Satisfy(uint32_t cond, const StringPiece& context, const char* p) {
192
+ static bool Satisfy(uint32_t cond, absl::string_view context, const char* p) {
193
193
  uint32_t satisfied = Prog::EmptyFlags(context, p);
194
194
  if (cond & kEmptyAllFlags & ~satisfied)
195
195
  return false;
@@ -211,10 +211,9 @@ static inline OneState* IndexToNode(uint8_t* nodes, int statesize,
211
211
  return reinterpret_cast<OneState*>(nodes + statesize*nodeindex);
212
212
  }
213
213
 
214
- bool Prog::SearchOnePass(const StringPiece& text,
215
- const StringPiece& const_context,
214
+ bool Prog::SearchOnePass(absl::string_view text, absl::string_view context,
216
215
  Anchor anchor, MatchKind kind,
217
- StringPiece* match, int nmatch) {
216
+ absl::string_view* match, int nmatch) {
218
217
  if (anchor != kAnchored && kind != kFullMatch) {
219
218
  LOG(DFATAL) << "Cannot use SearchOnePass for unanchored matches.";
220
219
  return false;
@@ -234,7 +233,6 @@ bool Prog::SearchOnePass(const StringPiece& text,
234
233
  for (int i = 0; i < ncap; i++)
235
234
  matchcap[i] = NULL;
236
235
 
237
- StringPiece context = const_context;
238
236
  if (context.data() == NULL)
239
237
  context = text;
240
238
  if (anchor_start() && BeginPtr(context) != BeginPtr(text))
@@ -339,13 +337,12 @@ done:
339
337
  if (!matched)
340
338
  return false;
341
339
  for (int i = 0; i < nmatch; i++)
342
- match[i] =
343
- StringPiece(matchcap[2 * i],
344
- static_cast<size_t>(matchcap[2 * i + 1] - matchcap[2 * i]));
340
+ match[i] = absl::string_view(
341
+ matchcap[2 * i],
342
+ static_cast<size_t>(matchcap[2 * i + 1] - matchcap[2 * i]));
345
343
  return true;
346
344
  }
347
345
 
348
-
349
346
  // Analysis to determine whether a given regexp program is one-pass.
350
347
 
351
348
  // If ip is not on workq, adds ip to work queue and returns true.
@@ -404,16 +401,17 @@ bool Prog::IsOnePass() {
404
401
  int stacksize = inst_count(kInstCapture) +
405
402
  inst_count(kInstEmptyWidth) +
406
403
  inst_count(kInstNop) + 1; // + 1 for start inst
407
- PODArray<InstCond> stack(stacksize);
404
+ absl::FixedArray<InstCond, 64> stack_storage(stacksize);
405
+ InstCond* stack = stack_storage.data();
408
406
 
409
407
  int size = this->size();
410
- PODArray<int> nodebyid(size); // indexed by ip
411
- memset(nodebyid.data(), 0xFF, size*sizeof nodebyid[0]);
408
+ absl::FixedArray<int, 128> nodebyid_storage(size, -1); // indexed by ip
409
+ int* nodebyid = nodebyid_storage.data();
412
410
 
413
411
  // Originally, nodes was a uint8_t[maxnodes*statesize], but that was
414
412
  // unnecessarily optimistic: why allocate a large amount of memory
415
413
  // upfront for a large program when it is unlikely to be one-pass?
416
- std::vector<uint8_t> nodes;
414
+ absl::InlinedVector<uint8_t, 2048> nodes;
417
415
 
418
416
  Instq tovisit(size), workq(size);
419
417
  AddQ(&tovisit, start());
@@ -462,7 +460,7 @@ bool Prog::IsOnePass() {
462
460
  if (nextindex == -1) {
463
461
  if (nalloc >= maxnodes) {
464
462
  if (ExtraDebug)
465
- LOG(ERROR) << StringPrintf(
463
+ LOG(ERROR) << absl::StrFormat(
466
464
  "Not OnePass: hit node limit %d >= %d", nalloc, maxnodes);
467
465
  goto fail;
468
466
  }
@@ -487,7 +485,7 @@ bool Prog::IsOnePass() {
487
485
  node->action[b] = newact;
488
486
  } else if (act != newact) {
489
487
  if (ExtraDebug)
490
- LOG(ERROR) << StringPrintf(
488
+ LOG(ERROR) << absl::StrFormat(
491
489
  "Not OnePass: conflict on byte %#x at state %d", c, *it);
492
490
  goto fail;
493
491
  }
@@ -508,7 +506,7 @@ bool Prog::IsOnePass() {
508
506
  node->action[b] = newact;
509
507
  } else if (act != newact) {
510
508
  if (ExtraDebug)
511
- LOG(ERROR) << StringPrintf(
509
+ LOG(ERROR) << absl::StrFormat(
512
510
  "Not OnePass: conflict on byte %#x at state %d", c, *it);
513
511
  goto fail;
514
512
  }
@@ -549,7 +547,7 @@ bool Prog::IsOnePass() {
549
547
  // If already on work queue, (1) is violated: bail out.
550
548
  if (!AddQ(&workq, ip->out())) {
551
549
  if (ExtraDebug)
552
- LOG(ERROR) << StringPrintf(
550
+ LOG(ERROR) << absl::StrFormat(
553
551
  "Not OnePass: multiple paths %d -> %d", *it, ip->out());
554
552
  goto fail;
555
553
  }
@@ -560,7 +558,7 @@ bool Prog::IsOnePass() {
560
558
  if (matched) {
561
559
  // (3) is violated
562
560
  if (ExtraDebug)
563
- LOG(ERROR) << StringPrintf(
561
+ LOG(ERROR) << absl::StrFormat(
564
562
  "Not OnePass: multiple matches from %d", *it);
565
563
  goto fail;
566
564
  }
@@ -597,15 +595,15 @@ bool Prog::IsOnePass() {
597
595
  if (nodeindex == -1)
598
596
  continue;
599
597
  OneState* node = IndexToNode(nodes.data(), statesize, nodeindex);
600
- dump += StringPrintf("node %d id=%d: matchcond=%#x\n",
601
- nodeindex, id, node->matchcond);
598
+ dump += absl::StrFormat("node %d id=%d: matchcond=%#x\n",
599
+ nodeindex, id, node->matchcond);
602
600
  for (int i = 0; i < bytemap_range_; i++) {
603
601
  if ((node->action[i] & kImpossible) == kImpossible)
604
602
  continue;
605
- dump += StringPrintf(" %d cond %#x -> %d id=%d\n",
606
- i, node->action[i] & 0xFFFF,
607
- node->action[i] >> kIndexShift,
608
- idmap[node->action[i] >> kIndexShift]);
603
+ dump += absl::StrFormat(" %d cond %#x -> %d id=%d\n",
604
+ i, node->action[i] & 0xFFFF,
605
+ node->action[i] >> kIndexShift,
606
+ idmap[node->action[i] >> kIndexShift]);
609
607
  }
610
608
  }
611
609
  LOG(ERROR) << "nodes:\n" << dump;