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
@@ -0,0 +1,400 @@
1
+ # Copyright 2009 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
+ # Build against Abseil.
6
+ ABSL_DEPS=\
7
+ absl_base\
8
+ absl_core_headers\
9
+ absl_fixed_array\
10
+ absl_flags\
11
+ absl_flat_hash_map\
12
+ absl_flat_hash_set\
13
+ absl_inlined_vector\
14
+ absl_optional\
15
+ absl_span\
16
+ absl_str_format\
17
+ absl_strings\
18
+ absl_synchronization\
19
+
20
+ CCABSL=$(shell pkg-config $(ABSL_DEPS) --cflags)
21
+ # GCC barfs on `-Wl` whereas Clang doesn't mind, but it's unclear what
22
+ # causes it to manifest on Ubuntu 22.04 LTS, so filter it out for now.
23
+ LDABSL=$(shell pkg-config $(ABSL_DEPS) --libs | sed -e 's/-Wl / /g')
24
+
25
+ # To build against ICU for full Unicode properties support,
26
+ # uncomment the next two lines:
27
+ # CCICU=$(shell pkg-config icu-uc --cflags) -DRE2_USE_ICU
28
+ # LDICU=$(shell pkg-config icu-uc --libs)
29
+
30
+ # To build against PCRE for testing and benchmarking,
31
+ # uncomment the next two lines:
32
+ # CCPCRE=-I/usr/local/include -DUSEPCRE
33
+ # LDPCRE=-L/usr/local/lib -lpcre
34
+
35
+ CXX?=g++
36
+ # can override
37
+ CXXFLAGS?=-O3 -g
38
+ LDFLAGS?=
39
+ # required
40
+ RE2_CXXFLAGS?=-pthread -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -I. $(CCABSL) $(CCICU) $(CCPCRE)
41
+ RE2_LDFLAGS?=-pthread $(LDABSL) $(LDICU) $(LDPCRE)
42
+ AR?=ar
43
+ ARFLAGS?=rsc
44
+ NM?=nm
45
+ NMFLAGS?=-p
46
+
47
+ # Variables mandated by GNU, the arbiter of all good taste on the internet.
48
+ # http://www.gnu.org/prep/standards/standards.html
49
+ prefix=/usr/local
50
+ exec_prefix=$(prefix)
51
+ includedir=$(prefix)/include
52
+ libdir=$(exec_prefix)/lib
53
+ INSTALL=install
54
+ INSTALL_DATA=$(INSTALL) -m 644
55
+
56
+ # Work around the weirdness of sed(1) on Darwin. :/
57
+ ifeq ($(shell uname),Darwin)
58
+ SED_INPLACE=sed -i ''
59
+ else ifeq ($(shell uname),SunOS)
60
+ SED_INPLACE=sed -i
61
+ else
62
+ SED_INPLACE=sed -i
63
+ endif
64
+
65
+ # The pkg-config Requires: field.
66
+ REQUIRES=$(ABSL_DEPS)
67
+ ifdef LDICU
68
+ REQUIRES+=icu-uc
69
+ endif
70
+
71
+ # ABI version
72
+ # http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
73
+ SONAME=11
74
+
75
+ # To rebuild the Tables generated by Perl and Python scripts (requires Internet
76
+ # access for Unicode data), uncomment the following line:
77
+ # REBUILD_TABLES=1
78
+
79
+ # The SunOS linker does not support wildcards. :(
80
+ ifeq ($(shell uname),Darwin)
81
+ SOEXT=dylib
82
+ SOEXTVER=$(SONAME).$(SOEXT)
83
+ SOEXTVER00=$(SONAME).0.0.$(SOEXT)
84
+ MAKE_SHARED_LIBRARY=$(CXX) -dynamiclib -Wl,-compatibility_version,$(SONAME),-current_version,$(SONAME).0.0,-install_name,$(libdir)/libre2.$(SOEXTVER),-exported_symbols_list,libre2.symbols.darwin $(RE2_LDFLAGS) $(LDFLAGS)
85
+ else ifeq ($(shell uname),SunOS)
86
+ SOEXT=so
87
+ SOEXTVER=$(SOEXT).$(SONAME)
88
+ SOEXTVER00=$(SOEXT).$(SONAME).0.0
89
+ MAKE_SHARED_LIBRARY=$(CXX) -shared -Wl,-soname,libre2.$(SOEXTVER) $(RE2_LDFLAGS) $(LDFLAGS)
90
+ else
91
+ SOEXT=so
92
+ SOEXTVER=$(SOEXT).$(SONAME)
93
+ SOEXTVER00=$(SOEXT).$(SONAME).0.0
94
+ MAKE_SHARED_LIBRARY=$(CXX) -shared -Wl,-soname,libre2.$(SOEXTVER),--version-script,libre2.symbols $(RE2_LDFLAGS) $(LDFLAGS)
95
+ endif
96
+
97
+ .PHONY: all
98
+ all: obj/libre2.a obj/so/libre2.$(SOEXT)
99
+
100
+ INSTALL_HFILES=\
101
+ re2/filtered_re2.h\
102
+ re2/re2.h\
103
+ re2/set.h\
104
+ re2/stringpiece.h\
105
+
106
+ HFILES=\
107
+ util/logging.h\
108
+ util/malloc_counter.h\
109
+ util/pcre.h\
110
+ util/strutil.h\
111
+ util/utf.h\
112
+ re2/bitmap256.h\
113
+ re2/filtered_re2.h\
114
+ re2/pod_array.h\
115
+ re2/prefilter.h\
116
+ re2/prefilter_tree.h\
117
+ re2/prog.h\
118
+ re2/re2.h\
119
+ re2/regexp.h\
120
+ re2/set.h\
121
+ re2/sparse_array.h\
122
+ re2/sparse_set.h\
123
+ re2/stringpiece.h\
124
+ re2/testing/exhaustive_tester.h\
125
+ re2/testing/regexp_generator.h\
126
+ re2/testing/string_generator.h\
127
+ re2/testing/tester.h\
128
+ re2/unicode_casefold.h\
129
+ re2/unicode_groups.h\
130
+ re2/walker-inl.h\
131
+
132
+ OFILES=\
133
+ obj/util/rune.o\
134
+ obj/util/strutil.o\
135
+ obj/re2/bitmap256.o\
136
+ obj/re2/bitstate.o\
137
+ obj/re2/compile.o\
138
+ obj/re2/dfa.o\
139
+ obj/re2/filtered_re2.o\
140
+ obj/re2/mimics_pcre.o\
141
+ obj/re2/nfa.o\
142
+ obj/re2/onepass.o\
143
+ obj/re2/parse.o\
144
+ obj/re2/perl_groups.o\
145
+ obj/re2/prefilter.o\
146
+ obj/re2/prefilter_tree.o\
147
+ obj/re2/prog.o\
148
+ obj/re2/re2.o\
149
+ obj/re2/regexp.o\
150
+ obj/re2/set.o\
151
+ obj/re2/simplify.o\
152
+ obj/re2/tostring.o\
153
+ obj/re2/unicode_casefold.o\
154
+ obj/re2/unicode_groups.o\
155
+
156
+ TESTOFILES=\
157
+ obj/util/pcre.o\
158
+ obj/re2/testing/backtrack.o\
159
+ obj/re2/testing/dump.o\
160
+ obj/re2/testing/exhaustive_tester.o\
161
+ obj/re2/testing/null_walker.o\
162
+ obj/re2/testing/regexp_generator.o\
163
+ obj/re2/testing/string_generator.o\
164
+ obj/re2/testing/tester.o\
165
+
166
+ TESTS=\
167
+ obj/test/charclass_test\
168
+ obj/test/compile_test\
169
+ obj/test/filtered_re2_test\
170
+ obj/test/mimics_pcre_test\
171
+ obj/test/parse_test\
172
+ obj/test/possible_match_test\
173
+ obj/test/re2_test\
174
+ obj/test/re2_arg_test\
175
+ obj/test/regexp_test\
176
+ obj/test/required_prefix_test\
177
+ obj/test/search_test\
178
+ obj/test/set_test\
179
+ obj/test/simplify_test\
180
+ obj/test/string_generator_test\
181
+
182
+ BIGTESTS=\
183
+ obj/test/dfa_test\
184
+ obj/test/exhaustive1_test\
185
+ obj/test/exhaustive2_test\
186
+ obj/test/exhaustive3_test\
187
+ obj/test/exhaustive_test\
188
+ obj/test/random_test\
189
+
190
+ SOFILES=$(patsubst obj/%,obj/so/%,$(OFILES))
191
+ # We use TESTOFILES for testing the shared lib, only it is built differently.
192
+ STESTS=$(patsubst obj/%,obj/so/%,$(TESTS))
193
+ SBIGTESTS=$(patsubst obj/%,obj/so/%,$(BIGTESTS))
194
+
195
+ DOFILES=$(patsubst obj/%,obj/dbg/%,$(OFILES))
196
+ DTESTOFILES=$(patsubst obj/%,obj/dbg/%,$(TESTOFILES))
197
+ DTESTS=$(patsubst obj/%,obj/dbg/%,$(TESTS))
198
+ DBIGTESTS=$(patsubst obj/%,obj/dbg/%,$(BIGTESTS))
199
+
200
+ .PRECIOUS: obj/%.o
201
+ obj/%.o: %.cc $(HFILES)
202
+ @mkdir -p $$(dirname $@)
203
+ $(CXX) -c -o $@ $(CPPFLAGS) $(RE2_CXXFLAGS) $(CXXFLAGS) -DNDEBUG $*.cc
204
+
205
+ .PRECIOUS: obj/dbg/%.o
206
+ obj/dbg/%.o: %.cc $(HFILES)
207
+ @mkdir -p $$(dirname $@)
208
+ $(CXX) -c -o $@ $(CPPFLAGS) $(RE2_CXXFLAGS) $(CXXFLAGS) $*.cc
209
+
210
+ .PRECIOUS: obj/so/%.o
211
+ obj/so/%.o: %.cc $(HFILES)
212
+ @mkdir -p $$(dirname $@)
213
+ $(CXX) -c -o $@ -fPIC $(CPPFLAGS) $(RE2_CXXFLAGS) $(CXXFLAGS) -DNDEBUG $*.cc
214
+
215
+ .PRECIOUS: obj/libre2.a
216
+ obj/libre2.a: $(OFILES)
217
+ @mkdir -p obj
218
+ $(AR) $(ARFLAGS) obj/libre2.a $(OFILES)
219
+
220
+ .PRECIOUS: obj/dbg/libre2.a
221
+ obj/dbg/libre2.a: $(DOFILES)
222
+ @mkdir -p obj/dbg
223
+ $(AR) $(ARFLAGS) obj/dbg/libre2.a $(DOFILES)
224
+
225
+ .PRECIOUS: obj/so/libre2.$(SOEXT)
226
+ obj/so/libre2.$(SOEXT): $(SOFILES) libre2.symbols libre2.symbols.darwin
227
+ @mkdir -p obj/so
228
+ $(MAKE_SHARED_LIBRARY) -o obj/so/libre2.$(SOEXTVER) $(SOFILES)
229
+ ln -sf libre2.$(SOEXTVER) $@
230
+
231
+ .PRECIOUS: obj/dbg/test/%
232
+ obj/dbg/test/%: obj/dbg/libre2.a obj/dbg/re2/testing/%.o $(DTESTOFILES)
233
+ @mkdir -p obj/dbg/test
234
+ $(CXX) -o $@ obj/dbg/re2/testing/$*.o $(DTESTOFILES) -lgtest -lgtest_main obj/dbg/libre2.a $(RE2_LDFLAGS) $(LDFLAGS)
235
+
236
+ .PRECIOUS: obj/test/%
237
+ obj/test/%: obj/libre2.a obj/re2/testing/%.o $(TESTOFILES)
238
+ @mkdir -p obj/test
239
+ $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) -lgtest -lgtest_main obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS)
240
+
241
+ # Test the shared lib, falling back to the static lib for private symbols
242
+ .PRECIOUS: obj/so/test/%
243
+ obj/so/test/%: obj/so/libre2.$(SOEXT) obj/libre2.a obj/re2/testing/%.o $(TESTOFILES)
244
+ @mkdir -p obj/so/test
245
+ $(CXX) -o $@ obj/re2/testing/$*.o $(TESTOFILES) -lgtest -lgtest_main -Lobj/so -lre2 obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS)
246
+
247
+ obj/test/regexp_benchmark: obj/libre2.a obj/re2/testing/regexp_benchmark.o $(TESTOFILES)
248
+ @mkdir -p obj/test
249
+ $(CXX) -o $@ obj/re2/testing/regexp_benchmark.o $(TESTOFILES) -lgtest -lbenchmark -lbenchmark_main obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS)
250
+
251
+ # re2_fuzzer is a target for fuzzers like libFuzzer and AFL. This fake fuzzing
252
+ # is simply a way to check that the target builds and then to run it against a
253
+ # fixed set of inputs. To perform real fuzzing, refer to the documentation for
254
+ # libFuzzer (llvm.org/docs/LibFuzzer.html) and AFL (lcamtuf.coredump.cx/afl/).
255
+ obj/test/re2_fuzzer: CXXFLAGS:=-I./re2/fuzzing/compiler-rt/include $(CXXFLAGS)
256
+ obj/test/re2_fuzzer: obj/libre2.a obj/re2/fuzzing/re2_fuzzer.o obj/util/fuzz.o
257
+ @mkdir -p obj/test
258
+ $(CXX) -o $@ obj/re2/fuzzing/re2_fuzzer.o obj/util/fuzz.o obj/libre2.a $(RE2_LDFLAGS) $(LDFLAGS)
259
+
260
+ ifdef REBUILD_TABLES
261
+ .PRECIOUS: re2/perl_groups.cc
262
+ re2/perl_groups.cc: re2/make_perl_groups.pl
263
+ perl $< > $@
264
+
265
+ .PRECIOUS: re2/unicode_%.cc
266
+ re2/unicode_%.cc: re2/make_unicode_%.py re2/unicode.py
267
+ python3 $< > $@
268
+ endif
269
+
270
+ .PHONY: distclean
271
+ distclean: clean
272
+ rm -f re2/perl_groups.cc re2/unicode_casefold.cc re2/unicode_groups.cc
273
+
274
+ .PHONY: clean
275
+ clean:
276
+ rm -rf obj
277
+ rm -f re2/*.pyc
278
+
279
+ .PHONY: testofiles
280
+ testofiles: $(TESTOFILES)
281
+
282
+ .PHONY: test
283
+ test: $(DTESTS) $(TESTS) $(STESTS) debug-test static-test shared-test
284
+
285
+ .PHONY: debug-test
286
+ debug-test: $(DTESTS)
287
+ @./runtests $(DTESTS)
288
+
289
+ .PHONY: static-test
290
+ static-test: $(TESTS)
291
+ @./runtests $(TESTS)
292
+
293
+ .PHONY: shared-test
294
+ shared-test: $(STESTS)
295
+ @./runtests -shared-library-path obj/so $(STESTS)
296
+
297
+ .PHONY: debug-bigtest
298
+ debug-bigtest: $(DTESTS) $(DBIGTESTS)
299
+ @./runtests $(DTESTS) $(DBIGTESTS)
300
+
301
+ .PHONY: static-bigtest
302
+ static-bigtest: $(TESTS) $(BIGTESTS)
303
+ @./runtests $(TESTS) $(BIGTESTS)
304
+
305
+ .PHONY: shared-bigtest
306
+ shared-bigtest: $(STESTS) $(SBIGTESTS)
307
+ @./runtests -shared-library-path obj/so $(STESTS) $(SBIGTESTS)
308
+
309
+ .PHONY: benchmark
310
+ benchmark: obj/test/regexp_benchmark
311
+
312
+ .PHONY: fuzz
313
+ fuzz: obj/test/re2_fuzzer
314
+
315
+ .PHONY: install
316
+ install: static-install shared-install
317
+
318
+ .PHONY: static
319
+ static: obj/libre2.a
320
+
321
+ .PHONY: static-install
322
+ static-install: obj/libre2.a common-install
323
+ $(INSTALL) obj/libre2.a $(DESTDIR)$(libdir)/libre2.a
324
+
325
+ .PHONY: shared
326
+ shared: obj/so/libre2.$(SOEXT)
327
+
328
+ .PHONY: shared-install
329
+ shared-install: obj/so/libre2.$(SOEXT) common-install
330
+ $(INSTALL) obj/so/libre2.$(SOEXT) $(DESTDIR)$(libdir)/libre2.$(SOEXTVER00)
331
+ ln -sf libre2.$(SOEXTVER00) $(DESTDIR)$(libdir)/libre2.$(SOEXTVER)
332
+ ln -sf libre2.$(SOEXTVER00) $(DESTDIR)$(libdir)/libre2.$(SOEXT)
333
+
334
+ .PHONY: common-install
335
+ common-install:
336
+ mkdir -p $(DESTDIR)$(includedir)/re2 $(DESTDIR)$(libdir)/pkgconfig
337
+ $(INSTALL_DATA) $(INSTALL_HFILES) $(DESTDIR)$(includedir)/re2
338
+ $(INSTALL_DATA) re2.pc.in $(DESTDIR)$(libdir)/pkgconfig/re2.pc
339
+ $(SED_INPLACE) -e "s#@CMAKE_INSTALL_FULL_INCLUDEDIR@#$(includedir)#" $(DESTDIR)$(libdir)/pkgconfig/re2.pc
340
+ $(SED_INPLACE) -e "s#@CMAKE_INSTALL_FULL_LIBDIR@#$(libdir)#" $(DESTDIR)$(libdir)/pkgconfig/re2.pc
341
+ $(SED_INPLACE) -e "s#@REQUIRES@#$(REQUIRES)#" $(DESTDIR)$(libdir)/pkgconfig/re2.pc
342
+ $(SED_INPLACE) -e "s#@SONAME@#$(SONAME)#" $(DESTDIR)$(libdir)/pkgconfig/re2.pc
343
+
344
+ .PHONY: testinstall
345
+ testinstall: static-testinstall shared-testinstall
346
+ @echo
347
+ @echo Install tests passed.
348
+ @echo
349
+
350
+ .PHONY: static-testinstall
351
+ static-testinstall:
352
+ ifeq ($(shell uname),Darwin)
353
+ @echo Skipping test for libre2.a on Darwin.
354
+ else ifeq ($(shell uname),SunOS)
355
+ @echo Skipping test for libre2.a on SunOS.
356
+ else
357
+ @mkdir -p obj
358
+ @cp testinstall.cc obj/static-testinstall.cc
359
+ (cd obj && export PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig; \
360
+ $(CXX) static-testinstall.cc -o static-testinstall $(CXXFLAGS) $(LDFLAGS) \
361
+ $$(pkg-config re2 --cflags --libs | sed -e 's/-lre2/-l:libre2.a/'))
362
+ obj/static-testinstall
363
+ endif
364
+
365
+ .PHONY: shared-testinstall
366
+ shared-testinstall:
367
+ @mkdir -p obj
368
+ @cp testinstall.cc obj/shared-testinstall.cc
369
+ (cd obj && export PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig; \
370
+ $(CXX) shared-testinstall.cc -o shared-testinstall $(CXXFLAGS) $(LDFLAGS) \
371
+ $$(pkg-config re2 --cflags --libs))
372
+ ifeq ($(shell uname),Darwin)
373
+ DYLD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(DYLD_LIBRARY_PATH)" obj/shared-testinstall
374
+ else
375
+ LD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(LD_LIBRARY_PATH)" obj/shared-testinstall
376
+ endif
377
+
378
+ .PHONY: benchlog
379
+ benchlog: obj/test/regexp_benchmark
380
+ (echo '==BENCHMARK==' `hostname` `date`; \
381
+ (uname -a; $(CXX) --version; git rev-parse --short HEAD; file obj/test/regexp_benchmark) | sed 's/^/# /'; \
382
+ echo; \
383
+ ./obj/test/regexp_benchmark 'PCRE|RE2') | tee -a benchlog.$$(hostname | sed 's/\..*//')
384
+
385
+ .PHONY: log
386
+ log:
387
+ $(MAKE) clean
388
+ $(MAKE) CXXFLAGS="$(CXXFLAGS) -DLOGGING=1" \
389
+ $(filter obj/test/exhaustive%_test,$(BIGTESTS))
390
+ echo '#' RE2 exhaustive tests built by make log >re2-exhaustive.txt
391
+ echo '#' $$(date) >>re2-exhaustive.txt
392
+ obj/test/exhaustive_test |grep -v '^PASS$$' >>re2-exhaustive.txt
393
+ obj/test/exhaustive1_test |grep -v '^PASS$$' >>re2-exhaustive.txt
394
+ obj/test/exhaustive2_test |grep -v '^PASS$$' >>re2-exhaustive.txt
395
+ obj/test/exhaustive3_test |grep -v '^PASS$$' >>re2-exhaustive.txt
396
+
397
+ $(MAKE) CXXFLAGS="$(CXXFLAGS) -DLOGGING=1" obj/test/search_test
398
+ echo '#' RE2 basic search tests built by make $@ >re2-search.txt
399
+ echo '#' $$(date) >>re2-search.txt
400
+ obj/test/search_test |grep -v '^PASS$$' >>re2-search.txt
@@ -10,6 +10,11 @@ make test
10
10
  make install
11
11
  make testinstall
12
12
 
13
+ Building RE2 requires Abseil (https://github.com/abseil/abseil-cpp)
14
+ to be installed on your system. Building the testing for RE2 requires
15
+ GoogleTest (https://github.com/google/googletest) and Benchmark
16
+ (https://github.com/google/benchmark) to be installed as well.
17
+
13
18
  There is a fair amount of documentation (including code snippets) in
14
19
  the re2.h header file.
15
20
 
@@ -0,0 +1,4 @@
1
+ To report a security issue, please use https://g.co/vulnz. We use
2
+ https://g.co/vulnz for our intake, and do coordination and disclosure here on
3
+ GitHub (including using GitHub Security Advisory). The Google Security Team will
4
+ respond within 5 working days of your report on https://g.co/vulnz.
@@ -0,0 +1,62 @@
1
+ # Copyright 2009 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
+ # Bazel (http://bazel.io/) WORKSPACE file for RE2.
6
+
7
+ workspace(name = "com_googlesource_code_re2")
8
+
9
+ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
10
+
11
+ http_archive(
12
+ name = "com_google_absl",
13
+ strip_prefix = "abseil-cpp-master",
14
+ urls = ["https://github.com/abseil/abseil-cpp/archive/master.zip"],
15
+ )
16
+
17
+ http_archive(
18
+ name = "bazel_skylib",
19
+ strip_prefix = "bazel-skylib-main",
20
+ urls = ["https://github.com/bazelbuild/bazel-skylib/archive/main.zip"],
21
+ )
22
+
23
+ http_archive(
24
+ name = "com_github_google_benchmark",
25
+ strip_prefix = "benchmark-main",
26
+ urls = ["https://github.com/google/benchmark/archive/main.zip"],
27
+ )
28
+
29
+ http_archive(
30
+ name = "com_google_googletest",
31
+ strip_prefix = "googletest-main",
32
+ urls = ["https://github.com/google/googletest/archive/main.zip"],
33
+ )
34
+
35
+ http_archive(
36
+ name = "rules_python",
37
+ strip_prefix = "rules_python-main",
38
+ urls = ["https://github.com/bazelbuild/rules_python/archive/main.zip"],
39
+ )
40
+
41
+ http_archive(
42
+ name = "io_abseil_py",
43
+ strip_prefix = "abseil-py-main",
44
+ urls = ["https://github.com/abseil/abseil-py/archive/main.zip"],
45
+ )
46
+
47
+ http_archive(
48
+ name = "pybind11_bazel",
49
+ strip_prefix = "pybind11_bazel-master",
50
+ urls = ["https://github.com/pybind/pybind11_bazel/archive/master.zip"],
51
+ )
52
+
53
+ http_archive(
54
+ name = "pybind11",
55
+ build_file = "@pybind11_bazel//:pybind11.BUILD",
56
+ strip_prefix = "pybind11-master",
57
+ urls = ["https://github.com/pybind/pybind11/archive/master.zip"],
58
+ )
59
+
60
+ load("@pybind11_bazel//:python_configure.bzl", "python_configure")
61
+
62
+ python_configure(name = "local_config_python")
@@ -0,0 +1,19 @@
1
+ # Copyright 2009 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
+ # Bazel (http://bazel.io/) BUILD file for RE2 app.
6
+
7
+ cc_binary(
8
+ name = "_re2.js",
9
+ srcs = ["_re2.cc"],
10
+ linkopts = [
11
+ "--bind",
12
+ "-sENVIRONMENT=web",
13
+ "-sMODULARIZE=1",
14
+ "-sEXPORT_ES6=1",
15
+ "-sEXPORT_NAME=loadModule",
16
+ "-sUSE_PTHREADS=0",
17
+ ],
18
+ deps = ["//:re2"],
19
+ )
@@ -0,0 +1,94 @@
1
+ // Copyright 2022 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 <memory>
6
+ #include <string>
7
+
8
+ #include <emscripten/bind.h>
9
+ #include "re2/prog.h"
10
+ #include "re2/re2.h"
11
+ #include "re2/regexp.h"
12
+
13
+ namespace re2_app {
14
+
15
+ struct Info {
16
+ std::string pattern;
17
+ std::string error;
18
+ std::string prefix;
19
+ bool prefix_foldcase = false;
20
+ std::string accel_prefix;
21
+ bool accel_prefix_foldcase = false;
22
+ int num_captures;
23
+ bool is_one_pass;
24
+ bool can_bit_state;
25
+ std::string bytecode;
26
+ std::string bytemap;
27
+ };
28
+
29
+ Info GetInfo(const std::string& pattern) {
30
+ Info info;
31
+ info.pattern = pattern;
32
+
33
+ RE2::Options options;
34
+ re2::RegexpStatus status;
35
+ re2::Regexp* regexp = re2::Regexp::Parse(
36
+ pattern, static_cast<re2::Regexp::ParseFlags>(options.ParseFlags()),
37
+ &status);
38
+ if (regexp == nullptr) {
39
+ info.error = "failed to parse pattern: " + status.Text();
40
+ return info;
41
+ }
42
+
43
+ std::string prefix;
44
+ bool prefix_foldcase;
45
+ re2::Regexp* suffix;
46
+ if (regexp->RequiredPrefix(&prefix, &prefix_foldcase, &suffix)) {
47
+ info.prefix = prefix;
48
+ info.prefix_foldcase = prefix_foldcase;
49
+ } else {
50
+ suffix = regexp->Incref();
51
+ }
52
+
53
+ std::unique_ptr<re2::Prog> prog(suffix->CompileToProg(options.max_mem()));
54
+ if (prog == nullptr) {
55
+ info.error = "failed to compile forward Prog";
56
+ suffix->Decref();
57
+ regexp->Decref();
58
+ return info;
59
+ }
60
+
61
+ if (regexp->RequiredPrefixForAccel(&prefix, &prefix_foldcase)) {
62
+ info.accel_prefix = prefix;
63
+ info.accel_prefix_foldcase = prefix_foldcase;
64
+ }
65
+
66
+ info.num_captures = suffix->NumCaptures();
67
+ info.is_one_pass = prog->IsOnePass();
68
+ info.can_bit_state = prog->CanBitState();
69
+ info.bytecode = prog->Dump();
70
+ info.bytemap = prog->DumpByteMap();
71
+
72
+ suffix->Decref();
73
+ regexp->Decref();
74
+ return info;
75
+ }
76
+
77
+ EMSCRIPTEN_BINDINGS(_re2) {
78
+ emscripten::value_object<Info>("Info")
79
+ .field("pattern", &Info::pattern)
80
+ .field("error", &Info::error)
81
+ .field("prefix", &Info::prefix)
82
+ .field("prefix_foldcase", &Info::prefix_foldcase)
83
+ .field("accel_prefix", &Info::accel_prefix)
84
+ .field("accel_prefix_foldcase", &Info::accel_prefix_foldcase)
85
+ .field("num_captures", &Info::num_captures)
86
+ .field("is_one_pass", &Info::is_one_pass)
87
+ .field("can_bit_state", &Info::can_bit_state)
88
+ .field("bytecode", &Info::bytecode)
89
+ .field("bytemap", &Info::bytemap);
90
+
91
+ emscripten::function("getInfo", &GetInfo);
92
+ }
93
+
94
+ } // namespace re2_app
@@ -0,0 +1,23 @@
1
+ // Copyright 2022 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
+ export type Info = {
6
+ pattern: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string,
7
+ error: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string,
8
+ prefix: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string,
9
+ prefix_foldcase: boolean,
10
+ accel_prefix: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string,
11
+ accel_prefix_foldcase: boolean,
12
+ num_captures: number,
13
+ is_one_pass: boolean,
14
+ can_bit_state: boolean,
15
+ bytecode: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string,
16
+ bytemap: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string,
17
+ };
18
+
19
+ export interface MainModule {
20
+ getInfo(pattern: ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string): Info;
21
+ }
22
+
23
+ export default function loadModule(): Promise<MainModule>;