re2 1.15.6 → 1.16.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-12/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-12/entrypoint.sh +1 -1
- package/.github/actions/linux-alpine-node-14/Dockerfile +1 -1
- package/.github/actions/linux-alpine-node-14/entrypoint.sh +1 -1
- package/.github/actions/{linux-alpine-node-10 → linux-alpine-node-15}/Dockerfile +2 -2
- package/.github/actions/linux-alpine-node-15/action.yml +7 -0
- package/.github/actions/{linux-alpine-node-10 → linux-alpine-node-15}/entrypoint.sh +2 -1
- package/.github/actions/linux-alpine-node-16/Dockerfile +6 -0
- package/.github/actions/linux-alpine-node-16/action.yml +7 -0
- package/.github/actions/linux-alpine-node-16/entrypoint.sh +9 -0
- package/.github/actions/linux-node-12/Dockerfile +5 -4
- package/.github/actions/linux-node-12/entrypoint.sh +1 -1
- package/.github/workflows/build.yml +31 -26
- package/.github/workflows/tests.yml +2 -2
- package/README.md +7 -35
- package/binding.gyp +2 -2
- package/package.json +4 -4
- package/re2.d.ts +39 -2
- package/vendor/re2/re2.cc +84 -117
- package/vendor/re2/re2.h +114 -134
- package/vendor/re2/testing/charclass_test.cc +2 -2
- package/vendor/re2/testing/re2_arg_test.cc +25 -0
- package/vendor/util/pcre.h +3 -3
- package/.github/actions/linux-alpine-node-10/action.yml +0 -7
- package/.github/actions/linux-node-10/Dockerfile +0 -14
- package/.github/actions/linux-node-10/action.yml +0 -12
- package/.github/actions/linux-node-10/entrypoint.sh +0 -15
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
FROM centos:centos7
|
|
2
2
|
|
|
3
3
|
RUN yum install -y centos-release-scl && \
|
|
4
|
-
INSTALL_PKGS="devtoolset-7-gcc devtoolset-7-gcc-c++
|
|
4
|
+
INSTALL_PKGS="devtoolset-7-gcc devtoolset-7-gcc-c++ python3 make" && \
|
|
5
5
|
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
|
|
6
6
|
rpm -V $INSTALL_PKGS && \
|
|
7
|
-
yum -y clean all --enablerepo='*'
|
|
8
|
-
|
|
9
|
-
source scl_source enable
|
|
7
|
+
yum -y clean all --enablerepo='*'
|
|
8
|
+
# && \
|
|
9
|
+
# source scl_source enable devtoolset-7 && \
|
|
10
|
+
# source scl_source enable python3
|
|
10
11
|
|
|
11
12
|
ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
|
|
12
13
|
|
|
@@ -31,7 +31,7 @@ jobs:
|
|
|
31
31
|
strategy:
|
|
32
32
|
matrix:
|
|
33
33
|
os: [windows-latest, macOS-latest]
|
|
34
|
-
node-version: [
|
|
34
|
+
node-version: [12, 14, 15, 16]
|
|
35
35
|
|
|
36
36
|
steps:
|
|
37
37
|
- uses: actions/checkout@v2
|
|
@@ -57,7 +57,7 @@ jobs:
|
|
|
57
57
|
env:
|
|
58
58
|
DEVELOPMENT_SKIP_GETTING_ASSET: true
|
|
59
59
|
run: |
|
|
60
|
-
npm
|
|
60
|
+
npm i
|
|
61
61
|
npm run build --if-present
|
|
62
62
|
npm test
|
|
63
63
|
- name: Save to GitHub
|
|
@@ -65,10 +65,15 @@ jobs:
|
|
|
65
65
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
66
66
|
run: npm run save-to-github
|
|
67
67
|
|
|
68
|
-
build-linux-node
|
|
69
|
-
name: Node.js
|
|
68
|
+
build-linux-node:
|
|
69
|
+
name: Node.js ${{matrix.node-version}} on CentOS 7
|
|
70
70
|
needs: create-release
|
|
71
71
|
runs-on: ubuntu-latest
|
|
72
|
+
continue-on-error: true
|
|
73
|
+
|
|
74
|
+
strategy:
|
|
75
|
+
matrix:
|
|
76
|
+
node-version: [12, 14, 15, 16]
|
|
72
77
|
|
|
73
78
|
steps:
|
|
74
79
|
- uses: actions/checkout@v2
|
|
@@ -87,18 +92,17 @@ jobs:
|
|
|
87
92
|
Linux-node-
|
|
88
93
|
Linux-
|
|
89
94
|
- name: Install, test, and create artifact
|
|
90
|
-
uses: ./.github/actions/linux-node-
|
|
95
|
+
uses: ./.github/actions/linux-node-12/
|
|
91
96
|
env:
|
|
92
97
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
98
|
+
with:
|
|
99
|
+
node-version: ${{matrix.node-version}}
|
|
93
100
|
|
|
94
|
-
build-linux-node:
|
|
95
|
-
name: Node.js
|
|
101
|
+
build-linux-alpine-node-12:
|
|
102
|
+
name: Node.js 12 on Alpine Linux
|
|
96
103
|
needs: create-release
|
|
97
104
|
runs-on: ubuntu-latest
|
|
98
|
-
|
|
99
|
-
strategy:
|
|
100
|
-
matrix:
|
|
101
|
-
node-version: [12, 14]
|
|
105
|
+
continue-on-error: true
|
|
102
106
|
|
|
103
107
|
steps:
|
|
104
108
|
- uses: actions/checkout@v2
|
|
@@ -112,21 +116,20 @@ jobs:
|
|
|
112
116
|
uses: actions/cache@v2
|
|
113
117
|
with:
|
|
114
118
|
path: ${{steps.npm-cache.outputs.dir}}
|
|
115
|
-
key: Linux-node-${{hashFiles('**/package-lock.json')}}
|
|
119
|
+
key: Linux-Alpine-node-${{hashFiles('**/package-lock.json')}}
|
|
116
120
|
restore-keys: |
|
|
117
|
-
Linux-node-
|
|
118
|
-
Linux-
|
|
121
|
+
Linux-Alpine-node-
|
|
122
|
+
Linux-Alpine-
|
|
119
123
|
- name: Install, test, and create artifact
|
|
120
|
-
uses: ./.github/actions/linux-node-12/
|
|
124
|
+
uses: ./.github/actions/linux-alpine-node-12/
|
|
121
125
|
env:
|
|
122
126
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
123
|
-
with:
|
|
124
|
-
node-version: ${{matrix.node-version}}
|
|
125
127
|
|
|
126
|
-
build-linux-alpine-node-
|
|
127
|
-
name: Node.js
|
|
128
|
+
build-linux-alpine-node-14:
|
|
129
|
+
name: Node.js 14 on Alpine Linux
|
|
128
130
|
needs: create-release
|
|
129
131
|
runs-on: ubuntu-latest
|
|
132
|
+
continue-on-error: true
|
|
130
133
|
|
|
131
134
|
steps:
|
|
132
135
|
- uses: actions/checkout@v2
|
|
@@ -145,14 +148,15 @@ jobs:
|
|
|
145
148
|
Linux-Alpine-node-
|
|
146
149
|
Linux-Alpine-
|
|
147
150
|
- name: Install, test, and create artifact
|
|
148
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
151
|
+
uses: ./.github/actions/linux-alpine-node-14/
|
|
149
152
|
env:
|
|
150
153
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
151
154
|
|
|
152
|
-
build-linux-alpine-node-
|
|
153
|
-
name: Node.js
|
|
155
|
+
build-linux-alpine-node-15:
|
|
156
|
+
name: Node.js 15 on Alpine Linux
|
|
154
157
|
needs: create-release
|
|
155
158
|
runs-on: ubuntu-latest
|
|
159
|
+
continue-on-error: true
|
|
156
160
|
|
|
157
161
|
steps:
|
|
158
162
|
- uses: actions/checkout@v2
|
|
@@ -171,14 +175,15 @@ jobs:
|
|
|
171
175
|
Linux-Alpine-node-
|
|
172
176
|
Linux-Alpine-
|
|
173
177
|
- name: Install, test, and create artifact
|
|
174
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
178
|
+
uses: ./.github/actions/linux-alpine-node-15/
|
|
175
179
|
env:
|
|
176
180
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
177
181
|
|
|
178
|
-
build-linux-alpine-node-
|
|
179
|
-
name: Node.js
|
|
182
|
+
build-linux-alpine-node-16:
|
|
183
|
+
name: Node.js 16 on Alpine Linux
|
|
180
184
|
needs: create-release
|
|
181
185
|
runs-on: ubuntu-latest
|
|
186
|
+
continue-on-error: true
|
|
182
187
|
|
|
183
188
|
steps:
|
|
184
189
|
- uses: actions/checkout@v2
|
|
@@ -197,6 +202,6 @@ jobs:
|
|
|
197
202
|
Linux-Alpine-node-
|
|
198
203
|
Linux-Alpine-
|
|
199
204
|
- name: Install, test, and create artifact
|
|
200
|
-
uses: ./.github/actions/linux-alpine-node-
|
|
205
|
+
uses: ./.github/actions/linux-alpine-node-16/
|
|
201
206
|
env:
|
|
202
207
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
16
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
|
17
|
-
node-version: [
|
|
17
|
+
node-version: [12, 14, 15, 16]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v2
|
|
@@ -39,6 +39,6 @@ jobs:
|
|
|
39
39
|
env:
|
|
40
40
|
DEVELOPMENT_SKIP_GETTING_ASSET: true
|
|
41
41
|
run: |
|
|
42
|
-
npm
|
|
42
|
+
npm i
|
|
43
43
|
npm run build --if-present
|
|
44
44
|
npm test
|
package/README.md
CHANGED
|
@@ -211,7 +211,7 @@ For example, [yarn](https://yarnpkg.com/) is known to fail in some scenarios
|
|
|
211
211
|
|
|
212
212
|
### Precompiled artifacts
|
|
213
213
|
|
|
214
|
-
When installing re2 the [install script](
|
|
214
|
+
When installing re2 the [install script](https://github.com/uhop/install-artifact-from-github/blob/master/bin/install-from-cache.js) attempts to download a prebuilt artifact for your system from the Github releases. The download location can be overridden by setting the `RE2_DOWNLOAD_MIRROR` environment variable as seen in the install script.
|
|
215
215
|
|
|
216
216
|
If all attempts to download the prebuilt artifact for your system fails the script attempts to built re2 locally on your machine using [node-gyp](https://github.com/nodejs/node-gyp).
|
|
217
217
|
|
|
@@ -343,6 +343,10 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
343
343
|
|
|
344
344
|
## Release history
|
|
345
345
|
|
|
346
|
+
- 1.16.0 *Updated the compiler (thx, [Sergei Dyshel](https://github.com/sergei-dyshel)), updated GYP, removed support for Node 10, added support for Node 16, updated TS bindings (thx, [BannerBomb](https://github.com/BannerBomb)).*
|
|
347
|
+
- 1.15.9 *Updated deps.*
|
|
348
|
+
- 1.15.8 *Updated deps.*
|
|
349
|
+
- 1.15.7 *Updated deps.*
|
|
346
350
|
- 1.15.6 *Technical release: less dependencies for the build.*
|
|
347
351
|
- 1.15.5 *Updated deps. Fixed a `node2nix`-related problem (thx [malte-v](https://github.com/malte-v)).*
|
|
348
352
|
- 1.15.4 *Updated deps. Fixed a yarn-related bug (thx [Michael Kriese](https://github.com/viceice)).*
|
|
@@ -350,40 +354,8 @@ console.log('re2_res : ' + re2_res); // prints: re2_res : abc,a,b,c
|
|
|
350
354
|
- 1.15.2 *Added `linux-musl` target for precompiled images (thx [Uzlopak](https://github.com/Uzlopak)).*
|
|
351
355
|
- 1.15.1 *Refreshed dependencies, updated the verification check on installation, general maintenance.*
|
|
352
356
|
- 1.15.0 *Fix for multiline expressions (thx [Frederic Rudman](https://github.com/frudman)), `toString()` uses `source` now, updated deps.*
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
- 1.13.0 *Got rid of a single static variable to support multithreading.*
|
|
356
|
-
- 1.12.1 *Updated re2 to the latest version.*
|
|
357
|
-
- 1.12.0 *Updated the way `RE2` objects are constructed.*
|
|
358
|
-
- 1.11.0 *Updated the way to initialize the extension (thx [BannerBomb](https://github.com/BannerBomb)).*
|
|
359
|
-
- 1.10.5 *Bugfix for optional groups (thx [Josh Yudaken](https://github.com/qix)), the latest version of re2.*
|
|
360
|
-
- 1.10.4 *Technical release: even better TypeScript types (thx [Louis Brann](https://github.com/louis-brann)).*
|
|
361
|
-
- 1.10.3 *Technical release: missing reference to TS types (thx [Jamie Magee](https://github.com/JamieMagee)).*
|
|
362
|
-
- 1.10.2 *Technical release: added TypeScript types (thx [Jamie Magee](https://github.com/JamieMagee)).*
|
|
363
|
-
- 1.10.1 *Updated re2 to the latest version (thx [Jamie Magee](https://github.com/JamieMagee)), dropped Node 6.*
|
|
364
|
-
- 1.10.0 *Added back support for Node 6 and Node 8. Now Node 6-12 is supported.*
|
|
365
|
-
- 1.9.0 *Refreshed dependencies to support Node 12. Only versions 10-12 are supported now (`v8` restrictions). For older versions use `node-re2@1.8`.*
|
|
366
|
-
- 1.8.4 *Refreshed dependencies, removed `unistd.h` to compile on Windows.*
|
|
367
|
-
- 1.8.3 *Refreshed dependencies, removed suppression of some warnings.*
|
|
368
|
-
- 1.8.2 *Bugfix to support the null prototype for groups. Thx [Exter-N](https://github.com/Exter-N).*
|
|
369
|
-
- 1.8.1 *Bugfix for better source escaping.*
|
|
370
|
-
- 1.8.0 *Clarified Unicode support, added `unicode` flag, added named groups — thx [Exter-N](https://github.com/Exter-N)! Bugfixes — thx [Barak Amar](https://github.com/nopcoder).*
|
|
371
|
-
- 1.7.0 *Implemented `sticky` and `flags` + bug fixes + more tests. Thx [Exter-N](https://github.com/Exter-N).*
|
|
372
|
-
- 1.6.2 *Bugfix for a prototype access. Thx [Exter-N](https://github.com/Exter-N).*
|
|
373
|
-
- 1.6.1 *Returned support for node 4 LTS. Thx [Kannan Goundan](https://github.com/cakoose).*
|
|
374
|
-
- 1.6.0 *Added well-known symbol-based methods of ES6. Refreshed NAN.*
|
|
375
|
-
- 1.5.0 *Bugfixes, error checks, better docs. Thx [Jamie Davis](https://github.com/davisjam), and [omg](https://github.com/omg).*
|
|
376
|
-
- 1.4.1 *Minor corrections in README.*
|
|
377
|
-
- 1.4.0 *Use re2 as a git submodule. Thx [Ben James](https://github.com/benhjames).*
|
|
378
|
-
- 1.3.3 *Refreshed dependencies.*
|
|
379
|
-
- 1.3.2 *Updated references in README (re2 was moved to github).*
|
|
380
|
-
- 1.3.1 *Refreshed dependencies, new Travis-CI config.*
|
|
381
|
-
- 1.3.0 *Upgraded NAN to 1.6.3, now we support node.js 0.10.36, 0.12.0, and io.js 1.3.0. Thx [Reid Burke](https://github.com/reid)!*
|
|
382
|
-
- 1.2.0 *Documented getUtfXLength() functions. Added support for `\c` and `\u` commands.*
|
|
383
|
-
- 1.1.1 *Minor corrections in README.*
|
|
384
|
-
- 1.1.0 *Buffer-based API is public. Unicode is fully supported.*
|
|
385
|
-
- 1.0.0 *Implemented all `RegExp` methods, and all relevant `String` methods.*
|
|
386
|
-
- 0.9.0 *The initial public release.*
|
|
357
|
+
|
|
358
|
+
The rest can be consulted in the project's wiki [Release history](https://github.com/uhop/node-re2/wiki/Release-history).
|
|
387
359
|
|
|
388
360
|
## License
|
|
389
361
|
|
package/binding.gyp
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vendor/util/strutil.cc"
|
|
40
40
|
],
|
|
41
41
|
"cflags": [
|
|
42
|
-
"-std=c++
|
|
42
|
+
"-std=c++14",
|
|
43
43
|
"-Wall",
|
|
44
44
|
"-Wextra",
|
|
45
45
|
"-Wno-sign-compare",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"CLANG_CXX_LANGUAGE_STANDARD": "c++11",
|
|
63
63
|
"CLANG_CXX_LIBRARY": "libc++",
|
|
64
64
|
"OTHER_CFLAGS": [
|
|
65
|
-
"-std=c++
|
|
65
|
+
"-std=c++14",
|
|
66
66
|
"-Wall",
|
|
67
67
|
"-Wextra",
|
|
68
68
|
"-Wno-sign-compare",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "re2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Bindings for RE2: fast, safe alternative to backtracking regular expression engines.",
|
|
5
5
|
"homepage": "https://github.com/uhop/node-re2",
|
|
6
6
|
"bugs": "https://github.com/uhop/node-re2/issues",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"test": "tests"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"install-artifact-from-github": "^1.
|
|
14
|
-
"nan": "^2.14.
|
|
15
|
-
"node-gyp": "^
|
|
13
|
+
"install-artifact-from-github": "^1.2.0",
|
|
14
|
+
"nan": "^2.14.2",
|
|
15
|
+
"node-gyp": "^8.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"heya-unit": "^0.3.0"
|
package/re2.d.ts
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
declare module 're2' {
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
interface RE2MatchArray<K> extends Array<K> {
|
|
4
|
+
index?: number;
|
|
5
|
+
input?: K;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface RE2ExecArray<K> extends Array<K> {
|
|
9
|
+
index: number;
|
|
10
|
+
input: K;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface RE2 extends RegExp {
|
|
14
|
+
exec<K extends String | Buffer>(str: K): RE2ExecArray<K> | null;
|
|
15
|
+
|
|
16
|
+
test(str: string | Buffer): boolean;
|
|
17
|
+
|
|
18
|
+
match<K extends String | Buffer>(str: K): RE2MatchArray<K> | null;
|
|
19
|
+
|
|
20
|
+
replace<K extends String | Buffer>(str: K, replaceValue: string | Buffer): K;
|
|
21
|
+
replace<K extends String | Buffer>(str: K, replacer: (substring: string, ...args: any[]) => string | Buffer): K;
|
|
22
|
+
|
|
23
|
+
search(str: string | Buffer): number;
|
|
24
|
+
|
|
25
|
+
split<K extends String | Buffer>(str: K, limit?: number): K[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface RE2Constructor extends RegExpConstructor {
|
|
29
|
+
new(pattern: Buffer | RegExp | string): RE2;
|
|
30
|
+
new(pattern: Buffer | string, flags?: string): RE2;
|
|
31
|
+
(pattern: Buffer | RegExp | string): RE2;
|
|
32
|
+
(pattern: Buffer | string, flags?: string): RE2;
|
|
33
|
+
readonly prototype: RE2;
|
|
34
|
+
|
|
35
|
+
unicodeWarningLevel: 'nothing' | 'warnOnce' | 'warn' | 'throw';
|
|
36
|
+
getUtf8Length(value: string): number;
|
|
37
|
+
getUtf16Length(value: Buffer): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var RE2: RE2Constructor;
|
|
3
41
|
export = RE2;
|
|
4
42
|
}
|
|
5
|
-
|
package/vendor/re2/re2.cc
CHANGED
|
@@ -1040,41 +1040,49 @@ bool RE2::Rewrite(std::string* out,
|
|
|
1040
1040
|
|
|
1041
1041
|
/***** Parsers for various types *****/
|
|
1042
1042
|
|
|
1043
|
-
|
|
1043
|
+
namespace re2_internal {
|
|
1044
|
+
|
|
1045
|
+
template <>
|
|
1046
|
+
bool Parse(const char* str, size_t n, void* dest) {
|
|
1044
1047
|
// We fail if somebody asked us to store into a non-NULL void* pointer
|
|
1045
1048
|
return (dest == NULL);
|
|
1046
1049
|
}
|
|
1047
1050
|
|
|
1048
|
-
|
|
1051
|
+
template <>
|
|
1052
|
+
bool Parse(const char* str, size_t n, std::string* dest) {
|
|
1049
1053
|
if (dest == NULL) return true;
|
|
1050
|
-
|
|
1054
|
+
dest->assign(str, n);
|
|
1051
1055
|
return true;
|
|
1052
1056
|
}
|
|
1053
1057
|
|
|
1054
|
-
|
|
1058
|
+
template <>
|
|
1059
|
+
bool Parse(const char* str, size_t n, StringPiece* dest) {
|
|
1055
1060
|
if (dest == NULL) return true;
|
|
1056
|
-
*
|
|
1061
|
+
*dest = StringPiece(str, n);
|
|
1057
1062
|
return true;
|
|
1058
1063
|
}
|
|
1059
1064
|
|
|
1060
|
-
|
|
1065
|
+
template <>
|
|
1066
|
+
bool Parse(const char* str, size_t n, char* dest) {
|
|
1061
1067
|
if (n != 1) return false;
|
|
1062
1068
|
if (dest == NULL) return true;
|
|
1063
|
-
*
|
|
1069
|
+
*dest = str[0];
|
|
1064
1070
|
return true;
|
|
1065
1071
|
}
|
|
1066
1072
|
|
|
1067
|
-
|
|
1073
|
+
template <>
|
|
1074
|
+
bool Parse(const char* str, size_t n, signed char* dest) {
|
|
1068
1075
|
if (n != 1) return false;
|
|
1069
1076
|
if (dest == NULL) return true;
|
|
1070
|
-
*
|
|
1077
|
+
*dest = str[0];
|
|
1071
1078
|
return true;
|
|
1072
1079
|
}
|
|
1073
1080
|
|
|
1074
|
-
|
|
1081
|
+
template <>
|
|
1082
|
+
bool Parse(const char* str, size_t n, unsigned char* dest) {
|
|
1075
1083
|
if (n != 1) return false;
|
|
1076
1084
|
if (dest == NULL) return true;
|
|
1077
|
-
*
|
|
1085
|
+
*dest = str[0];
|
|
1078
1086
|
return true;
|
|
1079
1087
|
}
|
|
1080
1088
|
|
|
@@ -1138,10 +1146,40 @@ static const char* TerminateNumber(char* buf, size_t nbuf, const char* str,
|
|
|
1138
1146
|
return buf;
|
|
1139
1147
|
}
|
|
1140
1148
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1149
|
+
template <>
|
|
1150
|
+
bool Parse(const char* str, size_t n, float* dest) {
|
|
1151
|
+
if (n == 0) return false;
|
|
1152
|
+
static const int kMaxLength = 200;
|
|
1153
|
+
char buf[kMaxLength+1];
|
|
1154
|
+
str = TerminateNumber(buf, sizeof buf, str, &n, true);
|
|
1155
|
+
char* end;
|
|
1156
|
+
errno = 0;
|
|
1157
|
+
float r = strtof(str, &end);
|
|
1158
|
+
if (end != str + n) return false; // Leftover junk
|
|
1159
|
+
if (errno) return false;
|
|
1160
|
+
if (dest == NULL) return true;
|
|
1161
|
+
*dest = r;
|
|
1162
|
+
return true;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
template <>
|
|
1166
|
+
bool Parse(const char* str, size_t n, double* dest) {
|
|
1167
|
+
if (n == 0) return false;
|
|
1168
|
+
static const int kMaxLength = 200;
|
|
1169
|
+
char buf[kMaxLength+1];
|
|
1170
|
+
str = TerminateNumber(buf, sizeof buf, str, &n, true);
|
|
1171
|
+
char* end;
|
|
1172
|
+
errno = 0;
|
|
1173
|
+
double r = strtod(str, &end);
|
|
1174
|
+
if (end != str + n) return false; // Leftover junk
|
|
1175
|
+
if (errno) return false;
|
|
1176
|
+
if (dest == NULL) return true;
|
|
1177
|
+
*dest = r;
|
|
1178
|
+
return true;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
template <>
|
|
1182
|
+
bool Parse(const char* str, size_t n, long* dest, int radix) {
|
|
1145
1183
|
if (n == 0) return false;
|
|
1146
1184
|
char buf[kMaxNumberLength+1];
|
|
1147
1185
|
str = TerminateNumber(buf, sizeof buf, str, &n, false);
|
|
@@ -1151,14 +1189,12 @@ bool RE2::Arg::parse_long_radix(const char* str,
|
|
|
1151
1189
|
if (end != str + n) return false; // Leftover junk
|
|
1152
1190
|
if (errno) return false;
|
|
1153
1191
|
if (dest == NULL) return true;
|
|
1154
|
-
*
|
|
1192
|
+
*dest = r;
|
|
1155
1193
|
return true;
|
|
1156
1194
|
}
|
|
1157
1195
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
void* dest,
|
|
1161
|
-
int radix) {
|
|
1196
|
+
template <>
|
|
1197
|
+
bool Parse(const char* str, size_t n, unsigned long* dest, int radix) {
|
|
1162
1198
|
if (n == 0) return false;
|
|
1163
1199
|
char buf[kMaxNumberLength+1];
|
|
1164
1200
|
str = TerminateNumber(buf, sizeof buf, str, &n, false);
|
|
@@ -1174,62 +1210,52 @@ bool RE2::Arg::parse_ulong_radix(const char* str,
|
|
|
1174
1210
|
if (end != str + n) return false; // Leftover junk
|
|
1175
1211
|
if (errno) return false;
|
|
1176
1212
|
if (dest == NULL) return true;
|
|
1177
|
-
*
|
|
1213
|
+
*dest = r;
|
|
1178
1214
|
return true;
|
|
1179
1215
|
}
|
|
1180
1216
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
void* dest,
|
|
1184
|
-
int radix) {
|
|
1217
|
+
template <>
|
|
1218
|
+
bool Parse(const char* str, size_t n, short* dest, int radix) {
|
|
1185
1219
|
long r;
|
|
1186
|
-
if (!
|
|
1187
|
-
if ((short)r != r) return false;
|
|
1220
|
+
if (!Parse(str, n, &r, radix)) return false; // Could not parse
|
|
1221
|
+
if ((short)r != r) return false; // Out of range
|
|
1188
1222
|
if (dest == NULL) return true;
|
|
1189
|
-
*
|
|
1223
|
+
*dest = (short)r;
|
|
1190
1224
|
return true;
|
|
1191
1225
|
}
|
|
1192
1226
|
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
void* dest,
|
|
1196
|
-
int radix) {
|
|
1227
|
+
template <>
|
|
1228
|
+
bool Parse(const char* str, size_t n, unsigned short* dest, int radix) {
|
|
1197
1229
|
unsigned long r;
|
|
1198
|
-
if (!
|
|
1199
|
-
if ((unsigned short)r != r) return false;
|
|
1230
|
+
if (!Parse(str, n, &r, radix)) return false; // Could not parse
|
|
1231
|
+
if ((unsigned short)r != r) return false; // Out of range
|
|
1200
1232
|
if (dest == NULL) return true;
|
|
1201
|
-
*
|
|
1233
|
+
*dest = (unsigned short)r;
|
|
1202
1234
|
return true;
|
|
1203
1235
|
}
|
|
1204
1236
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
void* dest,
|
|
1208
|
-
int radix) {
|
|
1237
|
+
template <>
|
|
1238
|
+
bool Parse(const char* str, size_t n, int* dest, int radix) {
|
|
1209
1239
|
long r;
|
|
1210
|
-
if (!
|
|
1211
|
-
if ((int)r != r) return false;
|
|
1240
|
+
if (!Parse(str, n, &r, radix)) return false; // Could not parse
|
|
1241
|
+
if ((int)r != r) return false; // Out of range
|
|
1212
1242
|
if (dest == NULL) return true;
|
|
1213
|
-
*
|
|
1243
|
+
*dest = (int)r;
|
|
1214
1244
|
return true;
|
|
1215
1245
|
}
|
|
1216
1246
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
void* dest,
|
|
1220
|
-
int radix) {
|
|
1247
|
+
template <>
|
|
1248
|
+
bool Parse(const char* str, size_t n, unsigned int* dest, int radix) {
|
|
1221
1249
|
unsigned long r;
|
|
1222
|
-
if (!
|
|
1223
|
-
if ((unsigned int)r != r) return false;
|
|
1250
|
+
if (!Parse(str, n, &r, radix)) return false; // Could not parse
|
|
1251
|
+
if ((unsigned int)r != r) return false; // Out of range
|
|
1224
1252
|
if (dest == NULL) return true;
|
|
1225
|
-
*
|
|
1253
|
+
*dest = (unsigned int)r;
|
|
1226
1254
|
return true;
|
|
1227
1255
|
}
|
|
1228
1256
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
void* dest,
|
|
1232
|
-
int radix) {
|
|
1257
|
+
template <>
|
|
1258
|
+
bool Parse(const char* str, size_t n, long long* dest, int radix) {
|
|
1233
1259
|
if (n == 0) return false;
|
|
1234
1260
|
char buf[kMaxNumberLength+1];
|
|
1235
1261
|
str = TerminateNumber(buf, sizeof buf, str, &n, false);
|
|
@@ -1239,14 +1265,12 @@ bool RE2::Arg::parse_longlong_radix(const char* str,
|
|
|
1239
1265
|
if (end != str + n) return false; // Leftover junk
|
|
1240
1266
|
if (errno) return false;
|
|
1241
1267
|
if (dest == NULL) return true;
|
|
1242
|
-
*
|
|
1268
|
+
*dest = r;
|
|
1243
1269
|
return true;
|
|
1244
1270
|
}
|
|
1245
1271
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
void* dest,
|
|
1249
|
-
int radix) {
|
|
1272
|
+
template <>
|
|
1273
|
+
bool Parse(const char* str, size_t n, unsigned long long* dest, int radix) {
|
|
1250
1274
|
if (n == 0) return false;
|
|
1251
1275
|
char buf[kMaxNumberLength+1];
|
|
1252
1276
|
str = TerminateNumber(buf, sizeof buf, str, &n, false);
|
|
@@ -1261,68 +1285,11 @@ bool RE2::Arg::parse_ulonglong_radix(const char* str,
|
|
|
1261
1285
|
if (end != str + n) return false; // Leftover junk
|
|
1262
1286
|
if (errno) return false;
|
|
1263
1287
|
if (dest == NULL) return true;
|
|
1264
|
-
*
|
|
1265
|
-
return true;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
static bool parse_double_float(const char* str, size_t n, bool isfloat,
|
|
1269
|
-
void* dest) {
|
|
1270
|
-
if (n == 0) return false;
|
|
1271
|
-
static const int kMaxLength = 200;
|
|
1272
|
-
char buf[kMaxLength+1];
|
|
1273
|
-
str = TerminateNumber(buf, sizeof buf, str, &n, true);
|
|
1274
|
-
char* end;
|
|
1275
|
-
errno = 0;
|
|
1276
|
-
double r;
|
|
1277
|
-
if (isfloat) {
|
|
1278
|
-
r = strtof(str, &end);
|
|
1279
|
-
} else {
|
|
1280
|
-
r = strtod(str, &end);
|
|
1281
|
-
}
|
|
1282
|
-
if (end != str + n) return false; // Leftover junk
|
|
1283
|
-
if (errno) return false;
|
|
1284
|
-
if (dest == NULL) return true;
|
|
1285
|
-
if (isfloat) {
|
|
1286
|
-
*(reinterpret_cast<float*>(dest)) = (float)r;
|
|
1287
|
-
} else {
|
|
1288
|
-
*(reinterpret_cast<double*>(dest)) = r;
|
|
1289
|
-
}
|
|
1288
|
+
*dest = r;
|
|
1290
1289
|
return true;
|
|
1291
1290
|
}
|
|
1292
1291
|
|
|
1293
|
-
|
|
1294
|
-
return parse_double_float(str, n, false, dest);
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
bool RE2::Arg::parse_float(const char* str, size_t n, void* dest) {
|
|
1298
|
-
return parse_double_float(str, n, true, dest);
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
#define DEFINE_INTEGER_PARSER(name) \
|
|
1302
|
-
bool RE2::Arg::parse_##name(const char* str, size_t n, void* dest) { \
|
|
1303
|
-
return parse_##name##_radix(str, n, dest, 10); \
|
|
1304
|
-
} \
|
|
1305
|
-
bool RE2::Arg::parse_##name##_hex(const char* str, size_t n, void* dest) { \
|
|
1306
|
-
return parse_##name##_radix(str, n, dest, 16); \
|
|
1307
|
-
} \
|
|
1308
|
-
bool RE2::Arg::parse_##name##_octal(const char* str, size_t n, void* dest) { \
|
|
1309
|
-
return parse_##name##_radix(str, n, dest, 8); \
|
|
1310
|
-
} \
|
|
1311
|
-
bool RE2::Arg::parse_##name##_cradix(const char* str, size_t n, \
|
|
1312
|
-
void* dest) { \
|
|
1313
|
-
return parse_##name##_radix(str, n, dest, 0); \
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
DEFINE_INTEGER_PARSER(short)
|
|
1317
|
-
DEFINE_INTEGER_PARSER(ushort)
|
|
1318
|
-
DEFINE_INTEGER_PARSER(int)
|
|
1319
|
-
DEFINE_INTEGER_PARSER(uint)
|
|
1320
|
-
DEFINE_INTEGER_PARSER(long)
|
|
1321
|
-
DEFINE_INTEGER_PARSER(ulong)
|
|
1322
|
-
DEFINE_INTEGER_PARSER(longlong)
|
|
1323
|
-
DEFINE_INTEGER_PARSER(ulonglong)
|
|
1324
|
-
|
|
1325
|
-
#undef DEFINE_INTEGER_PARSER
|
|
1292
|
+
} // namespace re2_internal
|
|
1326
1293
|
|
|
1327
1294
|
namespace hooks {
|
|
1328
1295
|
|
package/vendor/re2/re2.h
CHANGED
|
@@ -208,6 +208,7 @@
|
|
|
208
208
|
#include <map>
|
|
209
209
|
#include <mutex>
|
|
210
210
|
#include <string>
|
|
211
|
+
#include <type_traits>
|
|
211
212
|
#include <vector>
|
|
212
213
|
|
|
213
214
|
#if defined(__APPLE__)
|
|
@@ -734,32 +735,12 @@ class RE2 {
|
|
|
734
735
|
const Options& options() const { return options_; }
|
|
735
736
|
|
|
736
737
|
// Argument converters; see below.
|
|
737
|
-
|
|
738
|
-
static
|
|
739
|
-
|
|
740
|
-
static
|
|
741
|
-
|
|
742
|
-
static
|
|
743
|
-
static inline Arg CRadix(long long* x);
|
|
744
|
-
static inline Arg CRadix(unsigned long long* x);
|
|
745
|
-
|
|
746
|
-
static inline Arg Hex(short* x);
|
|
747
|
-
static inline Arg Hex(unsigned short* x);
|
|
748
|
-
static inline Arg Hex(int* x);
|
|
749
|
-
static inline Arg Hex(unsigned int* x);
|
|
750
|
-
static inline Arg Hex(long* x);
|
|
751
|
-
static inline Arg Hex(unsigned long* x);
|
|
752
|
-
static inline Arg Hex(long long* x);
|
|
753
|
-
static inline Arg Hex(unsigned long long* x);
|
|
754
|
-
|
|
755
|
-
static inline Arg Octal(short* x);
|
|
756
|
-
static inline Arg Octal(unsigned short* x);
|
|
757
|
-
static inline Arg Octal(int* x);
|
|
758
|
-
static inline Arg Octal(unsigned int* x);
|
|
759
|
-
static inline Arg Octal(long* x);
|
|
760
|
-
static inline Arg Octal(unsigned long* x);
|
|
761
|
-
static inline Arg Octal(long long* x);
|
|
762
|
-
static inline Arg Octal(unsigned long long* x);
|
|
738
|
+
template <typename T>
|
|
739
|
+
static Arg CRadix(T* ptr);
|
|
740
|
+
template <typename T>
|
|
741
|
+
static Arg Hex(T* ptr);
|
|
742
|
+
template <typename T>
|
|
743
|
+
static Arg Octal(T* ptr);
|
|
763
744
|
|
|
764
745
|
private:
|
|
765
746
|
void Init(const StringPiece& pattern, const Options& options);
|
|
@@ -802,130 +783,129 @@ class RE2 {
|
|
|
802
783
|
|
|
803
784
|
/***** Implementation details *****/
|
|
804
785
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
//
|
|
808
|
-
template <
|
|
809
|
-
|
|
810
|
-
public
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
};
|
|
786
|
+
namespace re2_internal {
|
|
787
|
+
|
|
788
|
+
// Types for which the 3-ary Parse() function template has specializations.
|
|
789
|
+
template <typename T> struct Parse3ary : public std::false_type {};
|
|
790
|
+
template <> struct Parse3ary<void> : public std::true_type {};
|
|
791
|
+
template <> struct Parse3ary<std::string> : public std::true_type {};
|
|
792
|
+
template <> struct Parse3ary<StringPiece> : public std::true_type {};
|
|
793
|
+
template <> struct Parse3ary<char> : public std::true_type {};
|
|
794
|
+
template <> struct Parse3ary<signed char> : public std::true_type {};
|
|
795
|
+
template <> struct Parse3ary<unsigned char> : public std::true_type {};
|
|
796
|
+
template <> struct Parse3ary<float> : public std::true_type {};
|
|
797
|
+
template <> struct Parse3ary<double> : public std::true_type {};
|
|
798
|
+
|
|
799
|
+
template <typename T>
|
|
800
|
+
bool Parse(const char* str, size_t n, T* dest);
|
|
801
|
+
|
|
802
|
+
// Types for which the 4-ary Parse() function template has specializations.
|
|
803
|
+
template <typename T> struct Parse4ary : public std::false_type {};
|
|
804
|
+
template <> struct Parse4ary<long> : public std::true_type {};
|
|
805
|
+
template <> struct Parse4ary<unsigned long> : public std::true_type {};
|
|
806
|
+
template <> struct Parse4ary<short> : public std::true_type {};
|
|
807
|
+
template <> struct Parse4ary<unsigned short> : public std::true_type {};
|
|
808
|
+
template <> struct Parse4ary<int> : public std::true_type {};
|
|
809
|
+
template <> struct Parse4ary<unsigned int> : public std::true_type {};
|
|
810
|
+
template <> struct Parse4ary<long long> : public std::true_type {};
|
|
811
|
+
template <> struct Parse4ary<unsigned long long> : public std::true_type {};
|
|
812
|
+
|
|
813
|
+
template <typename T>
|
|
814
|
+
bool Parse(const char* str, size_t n, T* dest, int radix);
|
|
815
|
+
|
|
816
|
+
} // namespace re2_internal
|
|
817
817
|
|
|
818
818
|
class RE2::Arg {
|
|
819
|
+
private:
|
|
820
|
+
template <typename T>
|
|
821
|
+
using CanParse3ary = typename std::enable_if<
|
|
822
|
+
re2_internal::Parse3ary<T>::value,
|
|
823
|
+
int>::type;
|
|
824
|
+
|
|
825
|
+
template <typename T>
|
|
826
|
+
using CanParse4ary = typename std::enable_if<
|
|
827
|
+
re2_internal::Parse4ary<T>::value,
|
|
828
|
+
int>::type;
|
|
829
|
+
|
|
830
|
+
#if !defined(_MSC_VER)
|
|
831
|
+
template <typename T>
|
|
832
|
+
using CanParseFrom = typename std::enable_if<
|
|
833
|
+
std::is_member_function_pointer<decltype(
|
|
834
|
+
(bool (T::*)(const char*, size_t))&T::ParseFrom)>::value,
|
|
835
|
+
int>::type;
|
|
836
|
+
#endif
|
|
837
|
+
|
|
819
838
|
public:
|
|
820
|
-
|
|
821
|
-
Arg()
|
|
839
|
+
Arg() : Arg(nullptr) {}
|
|
840
|
+
Arg(std::nullptr_t ptr) : arg_(ptr), parser_(DoNothing) {}
|
|
822
841
|
|
|
823
|
-
|
|
824
|
-
Arg(
|
|
825
|
-
|
|
842
|
+
template <typename T, CanParse3ary<T> = 0>
|
|
843
|
+
Arg(T* ptr) : arg_(ptr), parser_(DoParse3ary<T>) {}
|
|
844
|
+
|
|
845
|
+
template <typename T, CanParse4ary<T> = 0>
|
|
846
|
+
Arg(T* ptr) : arg_(ptr), parser_(DoParse4ary<T>) {}
|
|
847
|
+
|
|
848
|
+
#if !defined(_MSC_VER)
|
|
849
|
+
template <typename T, CanParseFrom<T> = 0>
|
|
850
|
+
Arg(T* ptr) : arg_(ptr), parser_(DoParseFrom<T>) {}
|
|
851
|
+
#endif
|
|
826
852
|
|
|
827
853
|
typedef bool (*Parser)(const char* str, size_t n, void* dest);
|
|
828
854
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
MAKE_PARSER(signed char, parse_schar)
|
|
836
|
-
MAKE_PARSER(unsigned char, parse_uchar)
|
|
837
|
-
MAKE_PARSER(float, parse_float)
|
|
838
|
-
MAKE_PARSER(double, parse_double)
|
|
839
|
-
MAKE_PARSER(std::string, parse_string)
|
|
840
|
-
MAKE_PARSER(StringPiece, parse_stringpiece)
|
|
841
|
-
|
|
842
|
-
MAKE_PARSER(short, parse_short)
|
|
843
|
-
MAKE_PARSER(unsigned short, parse_ushort)
|
|
844
|
-
MAKE_PARSER(int, parse_int)
|
|
845
|
-
MAKE_PARSER(unsigned int, parse_uint)
|
|
846
|
-
MAKE_PARSER(long, parse_long)
|
|
847
|
-
MAKE_PARSER(unsigned long, parse_ulong)
|
|
848
|
-
MAKE_PARSER(long long, parse_longlong)
|
|
849
|
-
MAKE_PARSER(unsigned long long, parse_ulonglong)
|
|
850
|
-
|
|
851
|
-
#undef MAKE_PARSER
|
|
852
|
-
|
|
853
|
-
// Generic constructor templates
|
|
854
|
-
template <class T> Arg(T* p)
|
|
855
|
-
: arg_(p), parser_(_RE2_MatchObject<T>::Parse) { }
|
|
856
|
-
template <class T> Arg(T* p, Parser parser)
|
|
857
|
-
: arg_(p), parser_(parser) { }
|
|
858
|
-
|
|
859
|
-
// Parse the data
|
|
860
|
-
bool Parse(const char* str, size_t n) const;
|
|
855
|
+
template <typename T>
|
|
856
|
+
Arg(T* ptr, Parser parser) : arg_(ptr), parser_(parser) {}
|
|
857
|
+
|
|
858
|
+
bool Parse(const char* str, size_t n) const {
|
|
859
|
+
return (*parser_)(str, n, arg_);
|
|
860
|
+
}
|
|
861
861
|
|
|
862
862
|
private:
|
|
863
|
-
void*
|
|
864
|
-
|
|
863
|
+
static bool DoNothing(const char* /*str*/, size_t /*n*/, void* /*dest*/) {
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
865
866
|
|
|
866
|
-
|
|
867
|
-
static bool
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
static bool parse_float (const char* str, size_t n, void* dest);
|
|
871
|
-
static bool parse_double (const char* str, size_t n, void* dest);
|
|
872
|
-
static bool parse_string (const char* str, size_t n, void* dest);
|
|
873
|
-
static bool parse_stringpiece (const char* str, size_t n, void* dest);
|
|
874
|
-
|
|
875
|
-
#define DECLARE_INTEGER_PARSER(name) \
|
|
876
|
-
private: \
|
|
877
|
-
static bool parse_##name(const char* str, size_t n, void* dest); \
|
|
878
|
-
static bool parse_##name##_radix(const char* str, size_t n, void* dest, \
|
|
879
|
-
int radix); \
|
|
880
|
-
\
|
|
881
|
-
public: \
|
|
882
|
-
static bool parse_##name##_hex(const char* str, size_t n, void* dest); \
|
|
883
|
-
static bool parse_##name##_octal(const char* str, size_t n, void* dest); \
|
|
884
|
-
static bool parse_##name##_cradix(const char* str, size_t n, void* dest);
|
|
885
|
-
|
|
886
|
-
DECLARE_INTEGER_PARSER(short)
|
|
887
|
-
DECLARE_INTEGER_PARSER(ushort)
|
|
888
|
-
DECLARE_INTEGER_PARSER(int)
|
|
889
|
-
DECLARE_INTEGER_PARSER(uint)
|
|
890
|
-
DECLARE_INTEGER_PARSER(long)
|
|
891
|
-
DECLARE_INTEGER_PARSER(ulong)
|
|
892
|
-
DECLARE_INTEGER_PARSER(longlong)
|
|
893
|
-
DECLARE_INTEGER_PARSER(ulonglong)
|
|
894
|
-
|
|
895
|
-
#undef DECLARE_INTEGER_PARSER
|
|
867
|
+
template <typename T>
|
|
868
|
+
static bool DoParse3ary(const char* str, size_t n, void* dest) {
|
|
869
|
+
return re2_internal::Parse(str, n, reinterpret_cast<T*>(dest));
|
|
870
|
+
}
|
|
896
871
|
|
|
897
|
-
|
|
872
|
+
template <typename T>
|
|
873
|
+
static bool DoParse4ary(const char* str, size_t n, void* dest) {
|
|
874
|
+
return re2_internal::Parse(str, n, reinterpret_cast<T*>(dest), 10);
|
|
875
|
+
}
|
|
898
876
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
877
|
+
#if !defined(_MSC_VER)
|
|
878
|
+
template <typename T>
|
|
879
|
+
static bool DoParseFrom(const char* str, size_t n, void* dest) {
|
|
880
|
+
if (dest == NULL) return true;
|
|
881
|
+
return reinterpret_cast<T*>(dest)->ParseFrom(str, n);
|
|
882
|
+
}
|
|
883
|
+
#endif
|
|
902
884
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
885
|
+
void* arg_;
|
|
886
|
+
Parser parser_;
|
|
887
|
+
};
|
|
906
888
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
return
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
return RE2::Arg(ptr, RE2::Arg::parse_##name##_octal); \
|
|
914
|
-
} \
|
|
915
|
-
inline RE2::Arg RE2::CRadix(type* ptr) { \
|
|
916
|
-
return RE2::Arg(ptr, RE2::Arg::parse_##name##_cradix); \
|
|
917
|
-
}
|
|
889
|
+
template <typename T>
|
|
890
|
+
inline RE2::Arg RE2::CRadix(T* ptr) {
|
|
891
|
+
return RE2::Arg(ptr, [](const char* str, size_t n, void* dest) -> bool {
|
|
892
|
+
return re2_internal::Parse(str, n, reinterpret_cast<T*>(dest), 0);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
918
895
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
MAKE_INTEGER_PARSER(long long, longlong)
|
|
926
|
-
MAKE_INTEGER_PARSER(unsigned long long, ulonglong)
|
|
896
|
+
template <typename T>
|
|
897
|
+
inline RE2::Arg RE2::Hex(T* ptr) {
|
|
898
|
+
return RE2::Arg(ptr, [](const char* str, size_t n, void* dest) -> bool {
|
|
899
|
+
return re2_internal::Parse(str, n, reinterpret_cast<T*>(dest), 16);
|
|
900
|
+
});
|
|
901
|
+
}
|
|
927
902
|
|
|
928
|
-
|
|
903
|
+
template <typename T>
|
|
904
|
+
inline RE2::Arg RE2::Octal(T* ptr) {
|
|
905
|
+
return RE2::Arg(ptr, [](const char* str, size_t n, void* dest) -> bool {
|
|
906
|
+
return re2_internal::Parse(str, n, reinterpret_cast<T*>(dest), 8);
|
|
907
|
+
});
|
|
908
|
+
}
|
|
929
909
|
|
|
930
910
|
#ifndef SWIG
|
|
931
911
|
// Silence warnings about missing initializers for members of LazyRE2.
|
|
@@ -85,7 +85,7 @@ static CCTest tests[] = {
|
|
|
85
85
|
{ {-1} } },
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
template<
|
|
88
|
+
template <typename CharClass>
|
|
89
89
|
static void Broke(const char *desc, const CCTest* t, CharClass* cc) {
|
|
90
90
|
if (t == NULL) {
|
|
91
91
|
printf("\t%s:", desc);
|
|
@@ -136,7 +136,7 @@ void Delete(CharClassBuilder* cc) {
|
|
|
136
136
|
delete cc;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
template<
|
|
139
|
+
template <typename CharClass>
|
|
140
140
|
bool CorrectCC(CharClass *cc, CCTest *t, const char *desc) {
|
|
141
141
|
typename CharClass::iterator it = cc->begin();
|
|
142
142
|
int size = 0;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include <string.h>
|
|
12
12
|
|
|
13
13
|
#include "util/test.h"
|
|
14
|
+
#include "util/logging.h"
|
|
14
15
|
#include "re2/re2.h"
|
|
15
16
|
|
|
16
17
|
namespace re2 {
|
|
@@ -132,4 +133,28 @@ TEST(RE2ArgTest, Uint64Test) {
|
|
|
132
133
|
PARSE_FOR_TYPE(uint64_t, 5);
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
TEST(RE2ArgTest, ParseFromTest) {
|
|
137
|
+
#if !defined(_MSC_VER)
|
|
138
|
+
struct {
|
|
139
|
+
bool ParseFrom(const char* str, size_t n) {
|
|
140
|
+
LOG(INFO) << "str = " << str << ", n = " << n;
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
} obj1;
|
|
144
|
+
RE2::Arg arg1(&obj1);
|
|
145
|
+
EXPECT_TRUE(arg1.Parse("one", 3));
|
|
146
|
+
|
|
147
|
+
struct {
|
|
148
|
+
bool ParseFrom(const char* str, size_t n) {
|
|
149
|
+
LOG(INFO) << "str = " << str << ", n = " << n;
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
// Ensure that RE2::Arg works even with overloaded ParseFrom().
|
|
153
|
+
void ParseFrom(const char* str) {}
|
|
154
|
+
} obj2;
|
|
155
|
+
RE2::Arg arg2(&obj2);
|
|
156
|
+
EXPECT_FALSE(arg2.Parse("two", 3));
|
|
157
|
+
#endif
|
|
158
|
+
}
|
|
159
|
+
|
|
135
160
|
} // namespace re2
|
package/vendor/util/pcre.h
CHANGED
|
@@ -555,7 +555,7 @@ class PCRE_Options {
|
|
|
555
555
|
// Hex/Octal/Binary?
|
|
556
556
|
|
|
557
557
|
// Special class for parsing into objects that define a ParseFrom() method
|
|
558
|
-
template <
|
|
558
|
+
template <typename T>
|
|
559
559
|
class _PCRE_MatchObject {
|
|
560
560
|
public:
|
|
561
561
|
static inline bool Parse(const char* str, size_t n, void* dest) {
|
|
@@ -600,9 +600,9 @@ class PCRE::Arg {
|
|
|
600
600
|
#undef MAKE_PARSER
|
|
601
601
|
|
|
602
602
|
// Generic constructor
|
|
603
|
-
template <
|
|
603
|
+
template <typename T> Arg(T*, Parser parser);
|
|
604
604
|
// Generic constructor template
|
|
605
|
-
template <
|
|
605
|
+
template <typename T> Arg(T* p)
|
|
606
606
|
: arg_(p), parser_(_PCRE_MatchObject<T>::Parse) {
|
|
607
607
|
}
|
|
608
608
|
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
FROM centos:centos6
|
|
2
|
-
|
|
3
|
-
RUN yum install -y centos-release-scl && \
|
|
4
|
-
INSTALL_PKGS="devtoolset-7-gcc devtoolset-7-gcc-c++ python27 python-argparse" && \
|
|
5
|
-
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
|
|
6
|
-
rpm -V $INSTALL_PKGS && \
|
|
7
|
-
yum -y clean all --enablerepo='*' && \
|
|
8
|
-
source scl_source enable devtoolset-7 && \
|
|
9
|
-
source scl_source enable python27
|
|
10
|
-
|
|
11
|
-
ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
|
|
12
|
-
|
|
13
|
-
COPY entrypoint.sh /entrypoint.sh
|
|
14
|
-
ENTRYPOINT ["/entrypoint.sh"]
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
name: 'Create a binary artifact for Node 10 on Linux'
|
|
2
|
-
description: 'Create a binary artifact for Node 10 on Linux using CentOS6 and glibc 2.12'
|
|
3
|
-
inputs:
|
|
4
|
-
node-version:
|
|
5
|
-
description: 'Node.js version'
|
|
6
|
-
required: false
|
|
7
|
-
default: '10'
|
|
8
|
-
runs:
|
|
9
|
-
using: 'docker'
|
|
10
|
-
image: 'Dockerfile'
|
|
11
|
-
args:
|
|
12
|
-
- ${{inputs.node-version}}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/bin/bash -l
|
|
2
|
-
|
|
3
|
-
NVM_DIR=$HOME/.nvm
|
|
4
|
-
|
|
5
|
-
curl -sS -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
|
|
6
|
-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
7
|
-
|
|
8
|
-
nvm install --no-progress $1
|
|
9
|
-
|
|
10
|
-
npm config set unsafe-perm true
|
|
11
|
-
export DEVELOPMENT_SKIP_GETTING_ASSET=true
|
|
12
|
-
npm ci
|
|
13
|
-
npm run build --if-present
|
|
14
|
-
npm test
|
|
15
|
-
npm run save-to-github
|