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.
- package/.github/actions/linux-alpine-node-16/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-18/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-20/Dockerfile +1 -1
- package/.gitmodules +5 -2
- package/README.md +1 -0
- package/binding.gyp +82 -25
- package/lib/replace.cc +4 -4
- package/package.json +1 -1
- package/tsconfig.json +2 -1
- package/vendor/re2/.bazelrc +16 -0
- package/vendor/re2/.github/bazel.sh +24 -0
- package/vendor/re2/.github/cmake.sh +12 -0
- package/vendor/re2/.github/workflows/ci-bazel.yml +17 -0
- package/vendor/re2/.github/workflows/ci-cmake.yml +108 -0
- package/vendor/re2/.github/workflows/ci.yml +89 -0
- package/vendor/re2/.github/workflows/pr.yml +26 -0
- package/vendor/re2/.github/workflows/python.yml +185 -0
- package/vendor/re2/AUTHORS +13 -0
- package/vendor/re2/BUILD.bazel +280 -0
- package/vendor/re2/CMakeLists.txt +268 -0
- package/vendor/re2/CONTRIBUTING.md +2 -0
- package/vendor/re2/CONTRIBUTORS +41 -0
- package/vendor/re2/Makefile +400 -0
- package/vendor/{README → re2/README} +5 -0
- package/vendor/re2/SECURITY.md +4 -0
- package/vendor/re2/WORKSPACE.bazel +62 -0
- package/vendor/re2/app/BUILD.bazel +19 -0
- package/vendor/re2/app/_re2.cc +94 -0
- package/vendor/re2/app/_re2.d.ts +23 -0
- package/vendor/re2/app/app.ts +111 -0
- package/vendor/re2/app/build.sh +50 -0
- package/vendor/re2/app/index.html +5 -0
- package/vendor/re2/app/package.json +14 -0
- package/vendor/re2/app/rollup.config.js +28 -0
- package/vendor/re2/app/tsconfig.json +17 -0
- package/vendor/re2/benchlog/benchplot.py +98 -0
- package/vendor/re2/benchlog/mktable +155 -0
- package/vendor/re2/doc/mksyntaxgo +42 -0
- package/vendor/re2/doc/mksyntaxhtml +42 -0
- package/vendor/re2/doc/mksyntaxwiki +36 -0
- package/vendor/re2/doc/syntax.html +477 -0
- package/vendor/re2/doc/syntax.txt +463 -0
- package/vendor/re2/lib/git/commit-msg.hook +104 -0
- package/vendor/re2/libre2.symbols +19 -0
- package/vendor/re2/libre2.symbols.darwin +15 -0
- package/vendor/re2/python/BUILD.bazel +36 -0
- package/vendor/re2/python/README +1 -0
- package/vendor/re2/python/_re2.cc +338 -0
- package/vendor/re2/python/re2.py +582 -0
- package/vendor/re2/python/re2_test.py +482 -0
- package/vendor/re2/python/setup.py +105 -0
- package/vendor/re2/{bitmap256.cc → re2/bitmap256.cc} +4 -4
- package/vendor/re2/{bitstate.cc → re2/bitstate.cc} +21 -25
- package/vendor/re2/{compile.cc → re2/compile.cc} +5 -4
- package/vendor/re2/{dfa.cc → re2/dfa.cc} +120 -101
- package/vendor/re2/{filtered_re2.cc → re2/filtered_re2.cc} +8 -11
- package/vendor/re2/{filtered_re2.h → re2/filtered_re2.h} +5 -4
- package/vendor/re2/{fuzzing → re2/fuzzing}/re2_fuzzer.cc +4 -6
- package/vendor/re2/{mimics_pcre.cc → re2/mimics_pcre.cc} +0 -1
- package/vendor/re2/{nfa.cc → re2/nfa.cc} +34 -37
- package/vendor/re2/{onepass.cc → re2/onepass.cc} +25 -27
- package/vendor/re2/{parse.cc → re2/parse.cc} +118 -121
- package/vendor/re2/{prefilter.cc → re2/prefilter.cc} +2 -3
- package/vendor/re2/{prefilter.h → re2/prefilter.h} +0 -1
- package/vendor/re2/{prefilter_tree.cc → re2/prefilter_tree.cc} +4 -5
- package/vendor/re2/{prefilter_tree.h → re2/prefilter_tree.h} +1 -2
- package/vendor/re2/{prog.cc → re2/prog.cc} +20 -21
- package/vendor/re2/{prog.h → re2/prog.h} +21 -22
- package/vendor/re2/{re2.cc → re2/re2.cc} +51 -62
- package/vendor/re2/{re2.h → re2/re2.h} +78 -40
- package/vendor/re2/{regexp.cc → re2/regexp.cc} +11 -12
- package/vendor/re2/{regexp.h → re2/regexp.h} +9 -10
- package/vendor/re2/{set.cc → re2/set.cc} +3 -5
- package/vendor/re2/{set.h → re2/set.h} +4 -3
- package/vendor/re2/{simplify.cc → re2/simplify.cc} +1 -2
- package/vendor/re2/re2/stringpiece.h +24 -0
- package/vendor/re2/{testing → re2/testing}/backtrack.cc +22 -25
- package/vendor/re2/{testing → re2/testing}/charclass_test.cc +23 -21
- package/vendor/re2/{testing → re2/testing}/compile_test.cc +5 -4
- package/vendor/re2/{testing → re2/testing}/dfa_test.cc +36 -30
- package/vendor/re2/{testing → re2/testing}/dump.cc +8 -8
- package/vendor/re2/{testing → re2/testing}/exhaustive1_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive2_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive3_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/exhaustive_tester.cc +36 -32
- package/vendor/re2/{testing → re2/testing}/exhaustive_tester.h +0 -1
- package/vendor/re2/{testing → re2/testing}/filtered_re2_test.cc +9 -8
- package/vendor/re2/{testing → re2/testing}/mimics_pcre_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/null_walker.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/parse_test.cc +13 -12
- package/vendor/re2/{testing → re2/testing}/possible_match_test.cc +15 -14
- package/vendor/re2/{testing → re2/testing}/random_test.cc +13 -12
- package/vendor/re2/{testing → re2/testing}/re2_arg_test.cc +25 -2
- package/vendor/re2/{testing → re2/testing}/re2_test.cc +49 -47
- package/vendor/re2/{testing → re2/testing}/regexp_benchmark.cc +144 -145
- package/vendor/re2/{testing → re2/testing}/regexp_generator.cc +18 -14
- package/vendor/re2/{testing → re2/testing}/regexp_generator.h +3 -4
- package/vendor/re2/{testing → re2/testing}/regexp_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/required_prefix_test.cc +5 -4
- package/vendor/re2/{testing → re2/testing}/search_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/set_test.cc +1 -1
- package/vendor/re2/{testing → re2/testing}/simplify_test.cc +3 -2
- package/vendor/re2/{testing → re2/testing}/string_generator.cc +3 -3
- package/vendor/re2/{testing → re2/testing}/string_generator.h +5 -6
- package/vendor/re2/{testing → re2/testing}/string_generator_test.cc +2 -2
- package/vendor/re2/{testing → re2/testing}/tester.cc +77 -78
- package/vendor/re2/{testing → re2/testing}/tester.h +13 -15
- package/vendor/re2/{tostring.cc → re2/tostring.cc} +7 -8
- package/vendor/re2/{unicode_casefold.h → re2/unicode_casefold.h} +0 -1
- package/vendor/re2/{unicode_groups.h → re2/unicode_groups.h} +0 -1
- package/vendor/re2/{walker-inl.h → re2/walker-inl.h} +2 -1
- package/vendor/re2/re2.pc.in +9 -0
- package/vendor/re2/re2Config.cmake.in +28 -0
- package/vendor/re2/runtests +33 -0
- package/vendor/re2/testinstall.cc +27 -0
- package/vendor/re2/ucs2.diff +567 -0
- package/vendor/{util → re2/util}/logging.h +2 -2
- package/vendor/{util → re2/util}/pcre.cc +47 -116
- package/vendor/{util → re2/util}/pcre.h +53 -63
- package/vendor/re2/util/strutil.cc +26 -0
- package/vendor/{util → re2/util}/strutil.h +0 -5
- package/vendor/re2/stringpiece.cc +0 -65
- package/vendor/re2/stringpiece.h +0 -213
- package/vendor/util/benchmark.cc +0 -131
- package/vendor/util/benchmark.h +0 -156
- package/vendor/util/flags.h +0 -26
- package/vendor/util/mix.h +0 -41
- package/vendor/util/mutex.h +0 -164
- package/vendor/util/strutil.cc +0 -149
- package/vendor/util/test.cc +0 -34
- package/vendor/util/test.h +0 -50
- package/vendor/util/util.h +0 -42
- /package/vendor/{LICENSE → re2/LICENSE} +0 -0
- /package/vendor/re2/{bitmap256.h → re2/bitmap256.h} +0 -0
- /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/LICENSE +0 -0
- /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/include/fuzzer/FuzzedDataProvider.h +0 -0
- /package/vendor/re2/{make_perl_groups.pl → re2/make_perl_groups.pl} +0 -0
- /package/vendor/re2/{make_unicode_casefold.py → re2/make_unicode_casefold.py} +0 -0
- /package/vendor/re2/{make_unicode_groups.py → re2/make_unicode_groups.py} +0 -0
- /package/vendor/re2/{perl_groups.cc → re2/perl_groups.cc} +0 -0
- /package/vendor/re2/{pod_array.h → re2/pod_array.h} +0 -0
- /package/vendor/re2/{sparse_array.h → re2/sparse_array.h} +0 -0
- /package/vendor/re2/{sparse_set.h → re2/sparse_set.h} +0 -0
- /package/vendor/re2/{unicode.py → re2/unicode.py} +0 -0
- /package/vendor/re2/{unicode_casefold.cc → re2/unicode_casefold.cc} +0 -0
- /package/vendor/re2/{unicode_groups.cc → re2/unicode_groups.cc} +0 -0
- /package/vendor/{util → re2/util}/fuzz.cc +0 -0
- /package/vendor/{util → re2/util}/malloc_counter.h +0 -0
- /package/vendor/{util → re2/util}/rune.cc +0 -0
- /package/vendor/{util → re2/util}/utf.h +0 -0
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
#include <string>
|
|
16
16
|
#include <utility>
|
|
17
17
|
|
|
18
|
-
#include "
|
|
19
|
-
#include "
|
|
18
|
+
#include "absl/flags/flag.h"
|
|
19
|
+
#include "absl/strings/str_format.h"
|
|
20
20
|
#include "util/logging.h"
|
|
21
21
|
#include "util/pcre.h"
|
|
22
|
-
#include "util/strutil.h"
|
|
23
22
|
|
|
24
23
|
// Silence warnings about the wacky formatting in the operator() functions.
|
|
25
24
|
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 6
|
|
@@ -33,10 +32,10 @@
|
|
|
33
32
|
// not exceed main thread stacks. Note that other threads
|
|
34
33
|
// often have smaller stacks, and therefore tightening
|
|
35
34
|
// regexp_stack_limit may frequently be necessary.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
ABSL_FLAG(int, regexp_stack_limit, 256 << 10,
|
|
36
|
+
"default PCRE stack limit (bytes)");
|
|
37
|
+
ABSL_FLAG(int, regexp_match_limit, 1000000,
|
|
38
|
+
"default PCRE match limit (function calls)");
|
|
40
39
|
|
|
41
40
|
#ifndef USEPCRE
|
|
42
41
|
|
|
@@ -191,24 +190,11 @@ pcre* PCRE::Compile(Anchor anchor) {
|
|
|
191
190
|
|
|
192
191
|
/***** Convenience interfaces *****/
|
|
193
192
|
|
|
194
|
-
bool PCRE::FullMatchFunctor::operator
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const Arg& a3,
|
|
200
|
-
const Arg& a4,
|
|
201
|
-
const Arg& a5,
|
|
202
|
-
const Arg& a6,
|
|
203
|
-
const Arg& a7,
|
|
204
|
-
const Arg& a8,
|
|
205
|
-
const Arg& a9,
|
|
206
|
-
const Arg& a10,
|
|
207
|
-
const Arg& a11,
|
|
208
|
-
const Arg& a12,
|
|
209
|
-
const Arg& a13,
|
|
210
|
-
const Arg& a14,
|
|
211
|
-
const Arg& a15) const {
|
|
193
|
+
bool PCRE::FullMatchFunctor::operator()(
|
|
194
|
+
absl::string_view text, const PCRE& re, const Arg& a0, const Arg& a1,
|
|
195
|
+
const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, const Arg& a6,
|
|
196
|
+
const Arg& a7, const Arg& a8, const Arg& a9, const Arg& a10, const Arg& a11,
|
|
197
|
+
const Arg& a12, const Arg& a13, const Arg& a14, const Arg& a15) const {
|
|
212
198
|
const Arg* args[kMaxArgs];
|
|
213
199
|
int n = 0;
|
|
214
200
|
if (&a0 == &no_more_args) goto done; args[n++] = &a0;
|
|
@@ -234,24 +220,11 @@ done:
|
|
|
234
220
|
return re.DoMatchImpl(text, ANCHOR_BOTH, &consumed, args, n, vec, kVecSize);
|
|
235
221
|
}
|
|
236
222
|
|
|
237
|
-
bool PCRE::PartialMatchFunctor::operator
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const Arg& a3,
|
|
243
|
-
const Arg& a4,
|
|
244
|
-
const Arg& a5,
|
|
245
|
-
const Arg& a6,
|
|
246
|
-
const Arg& a7,
|
|
247
|
-
const Arg& a8,
|
|
248
|
-
const Arg& a9,
|
|
249
|
-
const Arg& a10,
|
|
250
|
-
const Arg& a11,
|
|
251
|
-
const Arg& a12,
|
|
252
|
-
const Arg& a13,
|
|
253
|
-
const Arg& a14,
|
|
254
|
-
const Arg& a15) const {
|
|
223
|
+
bool PCRE::PartialMatchFunctor::operator()(
|
|
224
|
+
absl::string_view text, const PCRE& re, const Arg& a0, const Arg& a1,
|
|
225
|
+
const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, const Arg& a6,
|
|
226
|
+
const Arg& a7, const Arg& a8, const Arg& a9, const Arg& a10, const Arg& a11,
|
|
227
|
+
const Arg& a12, const Arg& a13, const Arg& a14, const Arg& a15) const {
|
|
255
228
|
const Arg* args[kMaxArgs];
|
|
256
229
|
int n = 0;
|
|
257
230
|
if (&a0 == &no_more_args) goto done; args[n++] = &a0;
|
|
@@ -277,24 +250,11 @@ done:
|
|
|
277
250
|
return re.DoMatchImpl(text, UNANCHORED, &consumed, args, n, vec, kVecSize);
|
|
278
251
|
}
|
|
279
252
|
|
|
280
|
-
bool PCRE::ConsumeFunctor::operator
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const Arg& a3,
|
|
286
|
-
const Arg& a4,
|
|
287
|
-
const Arg& a5,
|
|
288
|
-
const Arg& a6,
|
|
289
|
-
const Arg& a7,
|
|
290
|
-
const Arg& a8,
|
|
291
|
-
const Arg& a9,
|
|
292
|
-
const Arg& a10,
|
|
293
|
-
const Arg& a11,
|
|
294
|
-
const Arg& a12,
|
|
295
|
-
const Arg& a13,
|
|
296
|
-
const Arg& a14,
|
|
297
|
-
const Arg& a15) const {
|
|
253
|
+
bool PCRE::ConsumeFunctor::operator()(
|
|
254
|
+
absl::string_view* input, const PCRE& pattern, const Arg& a0, const Arg& a1,
|
|
255
|
+
const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, const Arg& a6,
|
|
256
|
+
const Arg& a7, const Arg& a8, const Arg& a9, const Arg& a10, const Arg& a11,
|
|
257
|
+
const Arg& a12, const Arg& a13, const Arg& a14, const Arg& a15) const {
|
|
298
258
|
const Arg* args[kMaxArgs];
|
|
299
259
|
int n = 0;
|
|
300
260
|
if (&a0 == &no_more_args) goto done; args[n++] = &a0;
|
|
@@ -326,24 +286,11 @@ done:
|
|
|
326
286
|
}
|
|
327
287
|
}
|
|
328
288
|
|
|
329
|
-
bool PCRE::FindAndConsumeFunctor::operator
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const Arg& a3,
|
|
335
|
-
const Arg& a4,
|
|
336
|
-
const Arg& a5,
|
|
337
|
-
const Arg& a6,
|
|
338
|
-
const Arg& a7,
|
|
339
|
-
const Arg& a8,
|
|
340
|
-
const Arg& a9,
|
|
341
|
-
const Arg& a10,
|
|
342
|
-
const Arg& a11,
|
|
343
|
-
const Arg& a12,
|
|
344
|
-
const Arg& a13,
|
|
345
|
-
const Arg& a14,
|
|
346
|
-
const Arg& a15) const {
|
|
289
|
+
bool PCRE::FindAndConsumeFunctor::operator()(
|
|
290
|
+
absl::string_view* input, const PCRE& pattern, const Arg& a0, const Arg& a1,
|
|
291
|
+
const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, const Arg& a6,
|
|
292
|
+
const Arg& a7, const Arg& a8, const Arg& a9, const Arg& a10, const Arg& a11,
|
|
293
|
+
const Arg& a12, const Arg& a13, const Arg& a14, const Arg& a15) const {
|
|
347
294
|
const Arg* args[kMaxArgs];
|
|
348
295
|
int n = 0;
|
|
349
296
|
if (&a0 == &no_more_args) goto done; args[n++] = &a0;
|
|
@@ -375,9 +322,8 @@ done:
|
|
|
375
322
|
}
|
|
376
323
|
}
|
|
377
324
|
|
|
378
|
-
bool PCRE::Replace(std::string
|
|
379
|
-
|
|
380
|
-
const StringPiece& rewrite) {
|
|
325
|
+
bool PCRE::Replace(std::string* str, const PCRE& pattern,
|
|
326
|
+
absl::string_view rewrite) {
|
|
381
327
|
int vec[kVecSize] = {};
|
|
382
328
|
int matches = pattern.TryMatch(*str, 0, UNANCHORED, true, vec, kVecSize);
|
|
383
329
|
if (matches == 0)
|
|
@@ -393,9 +339,8 @@ bool PCRE::Replace(std::string *str,
|
|
|
393
339
|
return true;
|
|
394
340
|
}
|
|
395
341
|
|
|
396
|
-
int PCRE::GlobalReplace(std::string
|
|
397
|
-
|
|
398
|
-
const StringPiece& rewrite) {
|
|
342
|
+
int PCRE::GlobalReplace(std::string* str, const PCRE& pattern,
|
|
343
|
+
absl::string_view rewrite) {
|
|
399
344
|
int count = 0;
|
|
400
345
|
int vec[kVecSize] = {};
|
|
401
346
|
std::string out;
|
|
@@ -451,10 +396,8 @@ int PCRE::GlobalReplace(std::string *str,
|
|
|
451
396
|
return count;
|
|
452
397
|
}
|
|
453
398
|
|
|
454
|
-
bool PCRE::Extract(const
|
|
455
|
-
|
|
456
|
-
const StringPiece &rewrite,
|
|
457
|
-
std::string *out) {
|
|
399
|
+
bool PCRE::Extract(absl::string_view text, const PCRE& pattern,
|
|
400
|
+
absl::string_view rewrite, std::string* out) {
|
|
458
401
|
int vec[kVecSize] = {};
|
|
459
402
|
int matches = pattern.TryMatch(text, 0, UNANCHORED, true, vec, kVecSize);
|
|
460
403
|
if (matches == 0)
|
|
@@ -463,7 +406,7 @@ bool PCRE::Extract(const StringPiece &text,
|
|
|
463
406
|
return pattern.Rewrite(out, rewrite, text, vec, matches);
|
|
464
407
|
}
|
|
465
408
|
|
|
466
|
-
std::string PCRE::QuoteMeta(
|
|
409
|
+
std::string PCRE::QuoteMeta(absl::string_view unquoted) {
|
|
467
410
|
std::string result;
|
|
468
411
|
result.reserve(unquoted.size() << 1);
|
|
469
412
|
|
|
@@ -508,12 +451,8 @@ void PCRE::ClearHitLimit() {
|
|
|
508
451
|
hit_limit_ = 0;
|
|
509
452
|
}
|
|
510
453
|
|
|
511
|
-
int PCRE::TryMatch(
|
|
512
|
-
|
|
513
|
-
Anchor anchor,
|
|
514
|
-
bool empty_ok,
|
|
515
|
-
int *vec,
|
|
516
|
-
int vecsize) const {
|
|
454
|
+
int PCRE::TryMatch(absl::string_view text, size_t startpos, Anchor anchor,
|
|
455
|
+
bool empty_ok, int* vec, int vecsize) const {
|
|
517
456
|
pcre* re = (anchor == ANCHOR_BOTH) ? re_full_ : re_partial_;
|
|
518
457
|
if (re == NULL) {
|
|
519
458
|
PCREPORT(ERROR) << "Matching against invalid re: " << *error_;
|
|
@@ -522,12 +461,12 @@ int PCRE::TryMatch(const StringPiece& text,
|
|
|
522
461
|
|
|
523
462
|
int match_limit = match_limit_;
|
|
524
463
|
if (match_limit <= 0) {
|
|
525
|
-
match_limit = GetFlag(FLAGS_regexp_match_limit);
|
|
464
|
+
match_limit = absl::GetFlag(FLAGS_regexp_match_limit);
|
|
526
465
|
}
|
|
527
466
|
|
|
528
467
|
int stack_limit = stack_limit_;
|
|
529
468
|
if (stack_limit <= 0) {
|
|
530
|
-
stack_limit = GetFlag(FLAGS_regexp_stack_limit);
|
|
469
|
+
stack_limit = absl::GetFlag(FLAGS_regexp_stack_limit);
|
|
531
470
|
}
|
|
532
471
|
|
|
533
472
|
pcre_extra extra = { 0 };
|
|
@@ -604,12 +543,8 @@ int PCRE::TryMatch(const StringPiece& text,
|
|
|
604
543
|
return rc;
|
|
605
544
|
}
|
|
606
545
|
|
|
607
|
-
bool PCRE::DoMatchImpl(
|
|
608
|
-
|
|
609
|
-
size_t* consumed,
|
|
610
|
-
const Arg* const* args,
|
|
611
|
-
int n,
|
|
612
|
-
int* vec,
|
|
546
|
+
bool PCRE::DoMatchImpl(absl::string_view text, Anchor anchor, size_t* consumed,
|
|
547
|
+
const Arg* const* args, int n, int* vec,
|
|
613
548
|
int vecsize) const {
|
|
614
549
|
assert((1 + n) * 3 <= vecsize); // results + PCRE workspace
|
|
615
550
|
if (NumberOfCapturingGroups() < n) {
|
|
@@ -654,11 +589,8 @@ bool PCRE::DoMatchImpl(const StringPiece& text,
|
|
|
654
589
|
return true;
|
|
655
590
|
}
|
|
656
591
|
|
|
657
|
-
bool PCRE::DoMatch(
|
|
658
|
-
|
|
659
|
-
size_t* consumed,
|
|
660
|
-
const Arg* const args[],
|
|
661
|
-
int n) const {
|
|
592
|
+
bool PCRE::DoMatch(absl::string_view text, Anchor anchor, size_t* consumed,
|
|
593
|
+
const Arg* const args[], int n) const {
|
|
662
594
|
assert(n >= 0);
|
|
663
595
|
const int vecsize = (1 + n) * 3; // results + PCRE workspace
|
|
664
596
|
// (as for kVecSize)
|
|
@@ -668,8 +600,8 @@ bool PCRE::DoMatch(const StringPiece& text,
|
|
|
668
600
|
return b;
|
|
669
601
|
}
|
|
670
602
|
|
|
671
|
-
bool PCRE::Rewrite(std::string
|
|
672
|
-
|
|
603
|
+
bool PCRE::Rewrite(std::string* out, absl::string_view rewrite,
|
|
604
|
+
absl::string_view text, int* vec, int veclen) const {
|
|
673
605
|
int number_of_capturing_groups = NumberOfCapturingGroups();
|
|
674
606
|
for (const char *s = rewrite.data(), *end = s + rewrite.size();
|
|
675
607
|
s < end; s++) {
|
|
@@ -704,7 +636,7 @@ bool PCRE::Rewrite(std::string *out, const StringPiece &rewrite,
|
|
|
704
636
|
return true;
|
|
705
637
|
}
|
|
706
638
|
|
|
707
|
-
bool PCRE::CheckRewriteString(
|
|
639
|
+
bool PCRE::CheckRewriteString(absl::string_view rewrite,
|
|
708
640
|
std::string* error) const {
|
|
709
641
|
int max_token = -1;
|
|
710
642
|
for (const char *s = rewrite.data(), *end = s + rewrite.size();
|
|
@@ -733,7 +665,7 @@ bool PCRE::CheckRewriteString(const StringPiece& rewrite,
|
|
|
733
665
|
}
|
|
734
666
|
|
|
735
667
|
if (max_token > NumberOfCapturingGroups()) {
|
|
736
|
-
*error =
|
|
668
|
+
*error = absl::StrFormat(
|
|
737
669
|
"Rewrite schema requests %d matches, but the regexp only has %d "
|
|
738
670
|
"parenthesized subexpressions.",
|
|
739
671
|
max_token, NumberOfCapturingGroups());
|
|
@@ -742,7 +674,6 @@ bool PCRE::CheckRewriteString(const StringPiece& rewrite,
|
|
|
742
674
|
return true;
|
|
743
675
|
}
|
|
744
676
|
|
|
745
|
-
|
|
746
677
|
// Return the number of capturing subpatterns, or -1 if the
|
|
747
678
|
// regexp wasn't valid on construction.
|
|
748
679
|
int PCRE::NumberOfCapturingGroups() const {
|
|
@@ -774,9 +705,9 @@ bool PCRE::Arg::parse_string(const char* str, size_t n, void* dest) {
|
|
|
774
705
|
return true;
|
|
775
706
|
}
|
|
776
707
|
|
|
777
|
-
bool PCRE::Arg::
|
|
708
|
+
bool PCRE::Arg::parse_string_view(const char* str, size_t n, void* dest) {
|
|
778
709
|
if (dest == NULL) return true;
|
|
779
|
-
*(reinterpret_cast<
|
|
710
|
+
*(reinterpret_cast<absl::string_view*>(dest)) = absl::string_view(str, n);
|
|
780
711
|
return true;
|
|
781
712
|
}
|
|
782
713
|
|
|
@@ -120,12 +120,12 @@
|
|
|
120
120
|
//
|
|
121
121
|
// The "Consume" operation may be useful if you want to repeatedly
|
|
122
122
|
// match regular expressions at the front of a string and skip over
|
|
123
|
-
// them as they match. This requires use of the
|
|
123
|
+
// them as they match. This requires use of the string_view type,
|
|
124
124
|
// which represents a sub-range of a real string.
|
|
125
125
|
//
|
|
126
126
|
// Example: read lines of the form "var = value" from a string.
|
|
127
|
-
// std::string contents = ...;
|
|
128
|
-
//
|
|
127
|
+
// std::string contents = ...; // Fill string somehow
|
|
128
|
+
// absl::string_view input(contents); // Wrap a string_view around it
|
|
129
129
|
//
|
|
130
130
|
// std::string var;
|
|
131
131
|
// int value;
|
|
@@ -161,8 +161,7 @@
|
|
|
161
161
|
// Octal(&a), Hex(&b), CRadix(&c), CRadix(&d));
|
|
162
162
|
// will leave 64 in a, b, c, and d.
|
|
163
163
|
|
|
164
|
-
#include "
|
|
165
|
-
#include "re2/stringpiece.h"
|
|
164
|
+
#include "absl/strings/string_view.h"
|
|
166
165
|
|
|
167
166
|
#ifdef USEPCRE
|
|
168
167
|
#include <pcre.h>
|
|
@@ -176,6 +175,16 @@ const bool UsingPCRE = false;
|
|
|
176
175
|
} // namespace re2
|
|
177
176
|
#endif
|
|
178
177
|
|
|
178
|
+
// To produce a DLL, CMake can automatically export code symbols,
|
|
179
|
+
// but not data symbols, so we have to annotate those manually...
|
|
180
|
+
#if defined(RE2_BUILD_TESTING_DLL)
|
|
181
|
+
#define RE2_TESTING_DLL __declspec(dllexport)
|
|
182
|
+
#elif defined(RE2_CONSUME_TESTING_DLL)
|
|
183
|
+
#define RE2_TESTING_DLL __declspec(dllimport)
|
|
184
|
+
#else
|
|
185
|
+
#define RE2_TESTING_DLL
|
|
186
|
+
#endif
|
|
187
|
+
|
|
179
188
|
namespace re2 {
|
|
180
189
|
|
|
181
190
|
class PCRE_Options;
|
|
@@ -191,7 +200,7 @@ class PCRE {
|
|
|
191
200
|
// Marks end of arg list.
|
|
192
201
|
// ONLY USE IN OPTIONAL ARG DEFAULTS.
|
|
193
202
|
// DO NOT PASS EXPLICITLY.
|
|
194
|
-
static Arg no_more_args;
|
|
203
|
+
RE2_TESTING_DLL static Arg no_more_args;
|
|
195
204
|
|
|
196
205
|
// Options are same value as those in pcre. We provide them here
|
|
197
206
|
// to avoid users needing to include pcre.h and also to isolate
|
|
@@ -246,10 +255,10 @@ class PCRE {
|
|
|
246
255
|
//
|
|
247
256
|
// The provided pointer arguments can be pointers to any scalar numeric
|
|
248
257
|
// type, or one of:
|
|
249
|
-
// std::string
|
|
250
|
-
//
|
|
251
|
-
// T
|
|
252
|
-
// (void*)NULL
|
|
258
|
+
// std::string (matched piece is copied to string)
|
|
259
|
+
// absl::string_view (string_view is mutated to point to matched piece)
|
|
260
|
+
// T ("bool T::ParseFrom(const char*, size_t)" must exist)
|
|
261
|
+
// (void*)NULL (the corresponding matched sub-pattern is not copied)
|
|
253
262
|
//
|
|
254
263
|
// Returns true iff all of the following conditions are satisfied:
|
|
255
264
|
// a. "text" matches "pattern" exactly
|
|
@@ -267,7 +276,7 @@ class PCRE {
|
|
|
267
276
|
// int number;
|
|
268
277
|
// PCRE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
|
|
269
278
|
struct FullMatchFunctor {
|
|
270
|
-
bool operator ()(
|
|
279
|
+
bool operator ()(absl::string_view text, const PCRE& re, // 3..16 args
|
|
271
280
|
const Arg& ptr1 = no_more_args,
|
|
272
281
|
const Arg& ptr2 = no_more_args,
|
|
273
282
|
const Arg& ptr3 = no_more_args,
|
|
@@ -286,12 +295,12 @@ class PCRE {
|
|
|
286
295
|
const Arg& ptr16 = no_more_args) const;
|
|
287
296
|
};
|
|
288
297
|
|
|
289
|
-
static const FullMatchFunctor FullMatch;
|
|
298
|
+
RE2_TESTING_DLL static const FullMatchFunctor FullMatch;
|
|
290
299
|
|
|
291
300
|
// Exactly like FullMatch(), except that "pattern" is allowed to match
|
|
292
301
|
// a substring of "text".
|
|
293
302
|
struct PartialMatchFunctor {
|
|
294
|
-
bool operator ()(
|
|
303
|
+
bool operator ()(absl::string_view text, const PCRE& re, // 3..16 args
|
|
295
304
|
const Arg& ptr1 = no_more_args,
|
|
296
305
|
const Arg& ptr2 = no_more_args,
|
|
297
306
|
const Arg& ptr3 = no_more_args,
|
|
@@ -310,13 +319,13 @@ class PCRE {
|
|
|
310
319
|
const Arg& ptr16 = no_more_args) const;
|
|
311
320
|
};
|
|
312
321
|
|
|
313
|
-
static const PartialMatchFunctor PartialMatch;
|
|
322
|
+
RE2_TESTING_DLL static const PartialMatchFunctor PartialMatch;
|
|
314
323
|
|
|
315
324
|
// Like FullMatch() and PartialMatch(), except that pattern has to
|
|
316
325
|
// match a prefix of "text", and "input" is advanced past the matched
|
|
317
326
|
// text. Note: "input" is modified iff this routine returns true.
|
|
318
327
|
struct ConsumeFunctor {
|
|
319
|
-
bool operator ()(
|
|
328
|
+
bool operator ()(absl::string_view* input, const PCRE& pattern, // 3..16 args
|
|
320
329
|
const Arg& ptr1 = no_more_args,
|
|
321
330
|
const Arg& ptr2 = no_more_args,
|
|
322
331
|
const Arg& ptr3 = no_more_args,
|
|
@@ -335,14 +344,14 @@ class PCRE {
|
|
|
335
344
|
const Arg& ptr16 = no_more_args) const;
|
|
336
345
|
};
|
|
337
346
|
|
|
338
|
-
static const ConsumeFunctor Consume;
|
|
347
|
+
RE2_TESTING_DLL static const ConsumeFunctor Consume;
|
|
339
348
|
|
|
340
349
|
// Like Consume(..), but does not anchor the match at the beginning of the
|
|
341
350
|
// string. That is, "pattern" need not start its match at the beginning of
|
|
342
351
|
// "input". For example, "FindAndConsume(s, "(\\w+)", &word)" finds the next
|
|
343
352
|
// word in "s" and stores it in "word".
|
|
344
353
|
struct FindAndConsumeFunctor {
|
|
345
|
-
bool operator ()(
|
|
354
|
+
bool operator ()(absl::string_view* input, const PCRE& pattern, // 3..16 args
|
|
346
355
|
const Arg& ptr1 = no_more_args,
|
|
347
356
|
const Arg& ptr2 = no_more_args,
|
|
348
357
|
const Arg& ptr3 = no_more_args,
|
|
@@ -361,7 +370,7 @@ class PCRE {
|
|
|
361
370
|
const Arg& ptr16 = no_more_args) const;
|
|
362
371
|
};
|
|
363
372
|
|
|
364
|
-
static const FindAndConsumeFunctor FindAndConsume;
|
|
373
|
+
RE2_TESTING_DLL static const FindAndConsumeFunctor FindAndConsume;
|
|
365
374
|
|
|
366
375
|
// Replace the first match of "pattern" in "str" with "rewrite".
|
|
367
376
|
// Within "rewrite", backslash-escaped digits (\1 to \9) can be
|
|
@@ -376,9 +385,8 @@ class PCRE {
|
|
|
376
385
|
//
|
|
377
386
|
// Returns true if the pattern matches and a replacement occurs,
|
|
378
387
|
// false otherwise.
|
|
379
|
-
static bool Replace(std::string
|
|
380
|
-
|
|
381
|
-
const StringPiece& rewrite);
|
|
388
|
+
static bool Replace(std::string* str, const PCRE& pattern,
|
|
389
|
+
absl::string_view rewrite);
|
|
382
390
|
|
|
383
391
|
// Like Replace(), except replaces all occurrences of the pattern in
|
|
384
392
|
// the string with the rewrite. Replacements are not subject to
|
|
@@ -390,9 +398,8 @@ class PCRE {
|
|
|
390
398
|
// will leave "s" containing "yada dada doo"
|
|
391
399
|
//
|
|
392
400
|
// Returns the number of replacements made.
|
|
393
|
-
static int GlobalReplace(std::string
|
|
394
|
-
|
|
395
|
-
const StringPiece& rewrite);
|
|
401
|
+
static int GlobalReplace(std::string* str, const PCRE& pattern,
|
|
402
|
+
absl::string_view rewrite);
|
|
396
403
|
|
|
397
404
|
// Like Replace, except that if the pattern matches, "rewrite"
|
|
398
405
|
// is copied into "out" with substitutions. The non-matching
|
|
@@ -400,10 +407,8 @@ class PCRE {
|
|
|
400
407
|
//
|
|
401
408
|
// Returns true iff a match occurred and the extraction happened
|
|
402
409
|
// successfully; if no match occurs, the string is left unaffected.
|
|
403
|
-
static bool Extract(const
|
|
404
|
-
|
|
405
|
-
const StringPiece &rewrite,
|
|
406
|
-
std::string *out);
|
|
410
|
+
static bool Extract(absl::string_view text, const PCRE& pattern,
|
|
411
|
+
absl::string_view rewrite, std::string* out);
|
|
407
412
|
|
|
408
413
|
// Check that the given @p rewrite string is suitable for use with
|
|
409
414
|
// this PCRE. It checks that:
|
|
@@ -418,8 +423,7 @@ class PCRE {
|
|
|
418
423
|
// @param error An error message is recorded here, iff we return false.
|
|
419
424
|
// Otherwise, it is unchanged.
|
|
420
425
|
// @return true, iff @p rewrite is suitable for use with the PCRE.
|
|
421
|
-
bool CheckRewriteString(
|
|
422
|
-
std::string* error) const;
|
|
426
|
+
bool CheckRewriteString(absl::string_view rewrite, std::string* error) const;
|
|
423
427
|
|
|
424
428
|
// Returns a copy of 'unquoted' with all potentially meaningful
|
|
425
429
|
// regexp characters backslash-escaped. The returned string, used
|
|
@@ -428,7 +432,7 @@ class PCRE {
|
|
|
428
432
|
// 1.5-2.0?
|
|
429
433
|
// becomes:
|
|
430
434
|
// 1\.5\-2\.0\?
|
|
431
|
-
static std::string QuoteMeta(
|
|
435
|
+
static std::string QuoteMeta(absl::string_view unquoted);
|
|
432
436
|
|
|
433
437
|
/***** Generic matching interface (not so nice to use) *****/
|
|
434
438
|
|
|
@@ -441,9 +445,7 @@ class PCRE {
|
|
|
441
445
|
|
|
442
446
|
// General matching routine. Stores the length of the match in
|
|
443
447
|
// "*consumed" if successful.
|
|
444
|
-
bool DoMatch(
|
|
445
|
-
Anchor anchor,
|
|
446
|
-
size_t* consumed,
|
|
448
|
+
bool DoMatch(absl::string_view text, Anchor anchor, size_t* consumed,
|
|
447
449
|
const Arg* const* args, int n) const;
|
|
448
450
|
|
|
449
451
|
// Return the number of capturing subpatterns, or -1 if the
|
|
@@ -465,29 +467,17 @@ class PCRE {
|
|
|
465
467
|
// against "foo", "bar", and "baz" respectively.
|
|
466
468
|
// When matching PCRE("(foo)|hello") against "hello", it will return 1.
|
|
467
469
|
// But the values for all subpattern are filled in into "vec".
|
|
468
|
-
int TryMatch(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
int *vec,
|
|
473
|
-
int vecsize) const;
|
|
474
|
-
|
|
475
|
-
// Append the "rewrite" string, with backslash subsitutions from "text"
|
|
470
|
+
int TryMatch(absl::string_view text, size_t startpos, Anchor anchor,
|
|
471
|
+
bool empty_ok, int* vec, int vecsize) const;
|
|
472
|
+
|
|
473
|
+
// Append the "rewrite" string, with backslash substitutions from "text"
|
|
476
474
|
// and "vec", to string "out".
|
|
477
|
-
bool Rewrite(std::string
|
|
478
|
-
|
|
479
|
-
const StringPiece &text,
|
|
480
|
-
int *vec,
|
|
481
|
-
int veclen) const;
|
|
475
|
+
bool Rewrite(std::string* out, absl::string_view rewrite,
|
|
476
|
+
absl::string_view text, int* vec, int veclen) const;
|
|
482
477
|
|
|
483
478
|
// internal implementation for DoMatch
|
|
484
|
-
bool DoMatchImpl(
|
|
485
|
-
|
|
486
|
-
size_t* consumed,
|
|
487
|
-
const Arg* const args[],
|
|
488
|
-
int n,
|
|
489
|
-
int* vec,
|
|
490
|
-
int vecsize) const;
|
|
479
|
+
bool DoMatchImpl(absl::string_view text, Anchor anchor, size_t* consumed,
|
|
480
|
+
const Arg* const args[], int n, int* vec, int vecsize) const;
|
|
491
481
|
|
|
492
482
|
// Compile the regexp for the specified anchoring mode
|
|
493
483
|
pcre* Compile(Anchor anchor);
|
|
@@ -586,7 +576,7 @@ class PCRE::Arg {
|
|
|
586
576
|
MAKE_PARSER(float, parse_float);
|
|
587
577
|
MAKE_PARSER(double, parse_double);
|
|
588
578
|
MAKE_PARSER(std::string, parse_string);
|
|
589
|
-
MAKE_PARSER(
|
|
579
|
+
MAKE_PARSER(absl::string_view, parse_string_view);
|
|
590
580
|
|
|
591
581
|
MAKE_PARSER(short, parse_short);
|
|
592
582
|
MAKE_PARSER(unsigned short, parse_ushort);
|
|
@@ -613,14 +603,14 @@ class PCRE::Arg {
|
|
|
613
603
|
void* arg_;
|
|
614
604
|
Parser parser_;
|
|
615
605
|
|
|
616
|
-
static bool parse_null
|
|
617
|
-
static bool parse_char
|
|
618
|
-
static bool parse_schar
|
|
619
|
-
static bool parse_uchar
|
|
620
|
-
static bool parse_float
|
|
621
|
-
static bool parse_double
|
|
622
|
-
static bool parse_string
|
|
623
|
-
static bool
|
|
606
|
+
static bool parse_null (const char* str, size_t n, void* dest);
|
|
607
|
+
static bool parse_char (const char* str, size_t n, void* dest);
|
|
608
|
+
static bool parse_schar (const char* str, size_t n, void* dest);
|
|
609
|
+
static bool parse_uchar (const char* str, size_t n, void* dest);
|
|
610
|
+
static bool parse_float (const char* str, size_t n, void* dest);
|
|
611
|
+
static bool parse_double (const char* str, size_t n, void* dest);
|
|
612
|
+
static bool parse_string (const char* str, size_t n, void* dest);
|
|
613
|
+
static bool parse_string_view (const char* str, size_t n, void* dest);
|
|
624
614
|
|
|
625
615
|
#define DECLARE_INTEGER_PARSER(name) \
|
|
626
616
|
private: \
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 1999-2005 The RE2 Authors. All Rights Reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#include "util/strutil.h"
|
|
6
|
+
|
|
7
|
+
namespace re2 {
|
|
8
|
+
|
|
9
|
+
void PrefixSuccessor(std::string* prefix) {
|
|
10
|
+
// We can increment the last character in the string and be done
|
|
11
|
+
// unless that character is 255, in which case we have to erase the
|
|
12
|
+
// last character and increment the previous character, unless that
|
|
13
|
+
// is 255, etc. If the string is empty or consists entirely of
|
|
14
|
+
// 255's, we just return the empty string.
|
|
15
|
+
while (!prefix->empty()) {
|
|
16
|
+
char& c = prefix->back();
|
|
17
|
+
if (c == '\xff') { // char literal avoids signed/unsigned.
|
|
18
|
+
prefix->pop_back();
|
|
19
|
+
} else {
|
|
20
|
+
++c;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace re2
|
|
@@ -7,14 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
#include <string>
|
|
9
9
|
|
|
10
|
-
#include "re2/stringpiece.h"
|
|
11
|
-
#include "util/util.h"
|
|
12
|
-
|
|
13
10
|
namespace re2 {
|
|
14
11
|
|
|
15
|
-
std::string CEscape(const StringPiece& src);
|
|
16
12
|
void PrefixSuccessor(std::string* prefix);
|
|
17
|
-
std::string StringPrintf(const char* format, ...);
|
|
18
13
|
|
|
19
14
|
} // namespace re2
|
|
20
15
|
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright 2004 The RE2 Authors. All Rights Reserved.
|
|
2
|
-
// Use of this source code is governed by a BSD-style
|
|
3
|
-
// license that can be found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
#include "re2/stringpiece.h"
|
|
6
|
-
|
|
7
|
-
#include <ostream>
|
|
8
|
-
|
|
9
|
-
#include "util/util.h"
|
|
10
|
-
|
|
11
|
-
namespace re2 {
|
|
12
|
-
|
|
13
|
-
const StringPiece::size_type StringPiece::npos; // initialized in stringpiece.h
|
|
14
|
-
|
|
15
|
-
StringPiece::size_type StringPiece::copy(char* buf, size_type n,
|
|
16
|
-
size_type pos) const {
|
|
17
|
-
size_type ret = std::min(size_ - pos, n);
|
|
18
|
-
memcpy(buf, data_ + pos, ret);
|
|
19
|
-
return ret;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
StringPiece StringPiece::substr(size_type pos, size_type n) const {
|
|
23
|
-
if (pos > size_) pos = size_;
|
|
24
|
-
if (n > size_ - pos) n = size_ - pos;
|
|
25
|
-
return StringPiece(data_ + pos, n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
StringPiece::size_type StringPiece::find(const StringPiece& s,
|
|
29
|
-
size_type pos) const {
|
|
30
|
-
if (pos > size_) return npos;
|
|
31
|
-
const_pointer result = std::search(data_ + pos, data_ + size_,
|
|
32
|
-
s.data_, s.data_ + s.size_);
|
|
33
|
-
size_type xpos = result - data_;
|
|
34
|
-
return xpos + s.size_ <= size_ ? xpos : npos;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
StringPiece::size_type StringPiece::find(char c, size_type pos) const {
|
|
38
|
-
if (size_ <= 0 || pos >= size_) return npos;
|
|
39
|
-
const_pointer result = std::find(data_ + pos, data_ + size_, c);
|
|
40
|
-
return result != data_ + size_ ? result - data_ : npos;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
StringPiece::size_type StringPiece::rfind(const StringPiece& s,
|
|
44
|
-
size_type pos) const {
|
|
45
|
-
if (size_ < s.size_) return npos;
|
|
46
|
-
if (s.size_ == 0) return std::min(size_, pos);
|
|
47
|
-
const_pointer last = data_ + std::min(size_ - s.size_, pos) + s.size_;
|
|
48
|
-
const_pointer result = std::find_end(data_, last, s.data_, s.data_ + s.size_);
|
|
49
|
-
return result != last ? result - data_ : npos;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
StringPiece::size_type StringPiece::rfind(char c, size_type pos) const {
|
|
53
|
-
if (size_ <= 0) return npos;
|
|
54
|
-
for (size_t i = std::min(pos + 1, size_); i != 0;) {
|
|
55
|
-
if (data_[--i] == c) return i;
|
|
56
|
-
}
|
|
57
|
-
return npos;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
std::ostream& operator<<(std::ostream& o, const StringPiece& p) {
|
|
61
|
-
o.write(p.data(), p.size());
|
|
62
|
-
return o;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
} // namespace re2
|