rugged 1.9.4 → 1.9.5.1

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +1 -1
  4. data/vendor/libgit2/COPYING +83 -11
  5. data/vendor/libgit2/cmake/SelectRegex.cmake +8 -3
  6. data/vendor/libgit2/deps/pcre2/CMakeLists.txt +110 -0
  7. data/vendor/libgit2/deps/pcre2/LICENCE.md +104 -0
  8. data/vendor/libgit2/deps/pcre2/config.h.in +54 -0
  9. data/vendor/libgit2/deps/pcre2/pcre2.h +1079 -0
  10. data/vendor/libgit2/deps/pcre2/pcre2_auto_possess.c +1416 -0
  11. data/vendor/libgit2/deps/{pcre/pcre_chartables.c → pcre2/pcre2_chartables.c} +41 -47
  12. data/vendor/libgit2/deps/{pcre/pcre_ord2utf8.c → pcre2/pcre2_chkdint.c} +36 -36
  13. data/vendor/libgit2/deps/pcre2/pcre2_compile.c +11345 -0
  14. data/vendor/libgit2/deps/pcre2/pcre2_compile.h +356 -0
  15. data/vendor/libgit2/deps/pcre2/pcre2_compile_cgroup.c +632 -0
  16. data/vendor/libgit2/deps/pcre2/pcre2_compile_class.c +2777 -0
  17. data/vendor/libgit2/deps/pcre2/pcre2_config.c +250 -0
  18. data/vendor/libgit2/deps/pcre2/pcre2_context.c +557 -0
  19. data/vendor/libgit2/deps/pcre2/pcre2_convert.c +1263 -0
  20. data/vendor/libgit2/deps/{pcre/pcre_dfa_exec.c → pcre2/pcre2_dfa_match.c} +1402 -943
  21. data/vendor/libgit2/deps/pcre2/pcre2_error.c +384 -0
  22. data/vendor/libgit2/deps/pcre2/pcre2_extuni.c +159 -0
  23. data/vendor/libgit2/deps/pcre2/pcre2_find_bracket.c +217 -0
  24. data/vendor/libgit2/deps/pcre2/pcre2_fuzzsupport.c +844 -0
  25. data/vendor/libgit2/deps/pcre2/pcre2_internal.h +2353 -0
  26. data/vendor/libgit2/deps/pcre2/pcre2_intmodedep.h +1044 -0
  27. data/vendor/libgit2/deps/pcre2/pcre2_maketables.c +177 -0
  28. data/vendor/libgit2/deps/pcre2/pcre2_match.c +8244 -0
  29. data/vendor/libgit2/deps/pcre2/pcre2_match_data.c +184 -0
  30. data/vendor/libgit2/deps/pcre2/pcre2_match_next.c +171 -0
  31. data/vendor/libgit2/deps/{pcre/pcre_newline.c → pcre2/pcre2_newline.c} +92 -63
  32. data/vendor/libgit2/deps/{pcre/pcre_refcount.c → pcre2/pcre2_ord2utf.c} +64 -38
  33. data/vendor/libgit2/deps/pcre2/pcre2_pattern_info.c +430 -0
  34. data/vendor/libgit2/deps/pcre2/pcre2_printint_inc.h +1098 -0
  35. data/vendor/libgit2/deps/pcre2/pcre2_script_run.c +344 -0
  36. data/vendor/libgit2/deps/pcre2/pcre2_serialize.c +284 -0
  37. data/vendor/libgit2/deps/pcre2/pcre2_string_utils.c +199 -0
  38. data/vendor/libgit2/deps/pcre2/pcre2_study.c +2087 -0
  39. data/vendor/libgit2/deps/pcre2/pcre2_substitute.c +1761 -0
  40. data/vendor/libgit2/deps/pcre2/pcre2_substring.c +553 -0
  41. data/vendor/libgit2/deps/pcre2/pcre2_tables.c +310 -0
  42. data/vendor/libgit2/deps/pcre2/pcre2_ucd.c +5805 -0
  43. data/vendor/libgit2/deps/pcre2/pcre2_ucp.h +408 -0
  44. data/vendor/libgit2/deps/pcre2/pcre2_ucptables_inc.h +1596 -0
  45. data/vendor/libgit2/deps/pcre2/pcre2_util.h +179 -0
  46. data/vendor/libgit2/deps/pcre2/pcre2_valid_utf.c +397 -0
  47. data/vendor/libgit2/deps/pcre2/pcre2_xclass.c +547 -0
  48. data/vendor/libgit2/include/git2/common.h +13 -1
  49. data/vendor/libgit2/include/git2/version.h +2 -2
  50. data/vendor/libgit2/src/libgit2/blame.c +6 -0
  51. data/vendor/libgit2/src/libgit2/delta.c +8 -0
  52. data/vendor/libgit2/src/libgit2/indexer.c +3 -2
  53. data/vendor/libgit2/src/libgit2/settings.c +9 -0
  54. data/vendor/libgit2/src/libgit2/streams/openssl.c +4 -1
  55. data/vendor/libgit2/src/libgit2/submodule.c +77 -12
  56. data/vendor/libgit2/src/libgit2/transports/http.c +4 -4
  57. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +2 -1
  58. data/vendor/libgit2/src/util/fs_path.h +10 -10
  59. data/vendor/libgit2/src/util/regexp.c +27 -12
  60. data/vendor/libgit2/src/util/regexp.h +7 -2
  61. metadata +44 -37
  62. data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
  63. data/vendor/libgit2/deps/pcre/COPYING +0 -5
  64. data/vendor/libgit2/deps/pcre/LICENCE +0 -93
  65. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
  66. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
  67. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
  68. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
  69. data/vendor/libgit2/deps/pcre/config.h.in +0 -57
  70. data/vendor/libgit2/deps/pcre/pcre.h +0 -641
  71. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
  72. data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9815
  73. data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
  74. data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
  75. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
  76. data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
  77. data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
  78. data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
  79. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
  80. data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
  81. data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
  82. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
  83. data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
  84. data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
  85. data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
  86. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
  87. data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
  88. data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
  89. data/vendor/libgit2/deps/pcre/pcreposix.c +0 -420
  90. data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
  91. data/vendor/libgit2/deps/pcre/ucp.h +0 -224
@@ -0,0 +1,2353 @@
1
+ /*************************************************
2
+ * Perl-Compatible Regular Expressions *
3
+ *************************************************/
4
+
5
+ /* PCRE2 is a library of functions to support regular expressions whose syntax
6
+ and semantics are as close as possible to those of the Perl 5 language.
7
+
8
+ Written by Philip Hazel
9
+ Original API code Copyright (c) 1997-2012 University of Cambridge
10
+ New API code Copyright (c) 2016-2024 University of Cambridge
11
+
12
+ -----------------------------------------------------------------------------
13
+ Redistribution and use in source and binary forms, with or without
14
+ modification, are permitted provided that the following conditions are met:
15
+
16
+ * Redistributions of source code must retain the above copyright notice,
17
+ this list of conditions and the following disclaimer.
18
+
19
+ * Redistributions in binary form must reproduce the above copyright
20
+ notice, this list of conditions and the following disclaimer in the
21
+ documentation and/or other materials provided with the distribution.
22
+
23
+ * Neither the name of the University of Cambridge nor the names of its
24
+ contributors may be used to endorse or promote products derived from
25
+ this software without specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
+ POSSIBILITY OF SUCH DAMAGE.
38
+ -----------------------------------------------------------------------------
39
+ */
40
+
41
+ #ifndef PCRE2_INTERNAL_H_IDEMPOTENT_GUARD
42
+ #define PCRE2_INTERNAL_H_IDEMPOTENT_GUARD
43
+
44
+ /* We do not assume that the config.h file has an idempotent include guard,
45
+ since it may well be written by clients. The standard Autoheader config.h does
46
+ not have an include guard (although we could customise that). */
47
+
48
+ #if defined HAVE_CONFIG_H && !defined PCRE2_CONFIG_H_IDEMPOTENT_GUARD
49
+ #define PCRE2_CONFIG_H_IDEMPOTENT_GUARD
50
+ #include "config.h"
51
+ #endif
52
+
53
+ /* We do not support both EBCDIC and Unicode at the same time. The "configure"
54
+ script prevents both being selected, but not everybody uses "configure". EBCDIC
55
+ is only supported for the 8-bit library, but the check for this has to be later
56
+ in this file, because the first part is not width-dependent, and is included by
57
+ pcre2test.c with CODE_UNIT_WIDTH == 0. */
58
+
59
+ #if defined EBCDIC && defined SUPPORT_UNICODE
60
+ #error The use of both EBCDIC and SUPPORT_UNICODE is not supported.
61
+ #endif
62
+
63
+ /* When compiling one of the libraries, the value of PCRE2_CODE_UNIT_WIDTH must
64
+ be 8, 16, or 32. AutoTools and CMake ensure that this is always the case, but
65
+ other other building methods may not, so here is a check. It is cut out when
66
+ building pcre2test, bcause that sets the value to zero. No other source should
67
+ be including this file. There is no explicit way of forcing a compile to be
68
+ abandoned, but trying to include a non-existent file seems cleanest. Otherwise
69
+ there will be many irrelevant consequential errors. */
70
+
71
+ #if (!defined PCRE2_PCRE2TEST && !defined PCRE2_DFTABLES) && \
72
+ (!defined PCRE2_CODE_UNIT_WIDTH || \
73
+ (PCRE2_CODE_UNIT_WIDTH != 8 && \
74
+ PCRE2_CODE_UNIT_WIDTH != 16 && \
75
+ PCRE2_CODE_UNIT_WIDTH != 32))
76
+ #error PCRE2_CODE_UNIT_WIDTH must be defined as 8, 16, or 32.
77
+ #endif
78
+
79
+
80
+ /* Standard C headers */
81
+
82
+ #include <ctype.h>
83
+ #include <limits.h>
84
+ #include <stddef.h>
85
+ #include <stdio.h>
86
+ #include <stdlib.h>
87
+ #include <string.h>
88
+
89
+ /* Macros to make boolean values more obvious. The #ifndef is to pacify
90
+ compiler warnings in environments where these macros are defined elsewhere.
91
+ Unfortunately, there is no way to do the same for the typedef. */
92
+
93
+ typedef int BOOL;
94
+ #ifndef FALSE
95
+ #define FALSE 0
96
+ #define TRUE 1
97
+ #endif
98
+
99
+ /* Helper macro for static (compile-time) assertions. Can be used inside
100
+ functions, or at the top-level of a file. */
101
+ #define STATIC_ASSERT_JOIN(a,b) a ## b
102
+ #define STATIC_ASSERT(cond, msg) \
103
+ typedef int STATIC_ASSERT_JOIN(static_assertion_,msg)[(cond)?1:-1]
104
+
105
+ /* Valgrind (memcheck) support */
106
+
107
+ #ifdef SUPPORT_VALGRIND
108
+ #include <valgrind/memcheck.h>
109
+ #endif
110
+
111
+ /* -ftrivial-auto-var-init support supports initializing all local variables
112
+ to avoid some classes of bug, but this can cause an unacceptable slowdown
113
+ for large on-stack arrays in hot functions. This macro lets us annotate
114
+ such arrays. */
115
+
116
+ #ifdef HAVE_ATTRIBUTE_UNINITIALIZED
117
+ #define PCRE2_KEEP_UNINITIALIZED __attribute__((uninitialized))
118
+ #else
119
+ #define PCRE2_KEEP_UNINITIALIZED
120
+ #endif
121
+
122
+ /* Older versions of MSVC lack snprintf(). This define allows for
123
+ warning/error-free compilation and testing with MSVC compilers back to at least
124
+ MSVC 10/2010. Except for VC6 (which is missing some fundamentals and fails). */
125
+
126
+ #if defined(_MSC_VER) && (_MSC_VER < 1900)
127
+ #define snprintf _snprintf
128
+ #endif
129
+
130
+ /* When compiling a DLL for Windows, the exported symbols have to be declared
131
+ using some MS magic, as documented here:
132
+ https://learn.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-declspec-dllexport
133
+
134
+ In pcre2.h (which is included below), we define only PCRE2_EXP_DECL,
135
+ which is all that is needed for applications (they just import the symbols). To
136
+ compile the library, we use:
137
+
138
+ PCRE2_EXP_DECL for declarations
139
+ PCRE2_EXP_DEFN for definitions
140
+
141
+ The reason for wrapping this in #ifndef PCRE2_EXP_DECL is so that pcre2test,
142
+ which is an application, but needs to import this file in order to "peek" at
143
+ internals, can #include pcre2.h first to get an application's-eye view.
144
+
145
+ In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
146
+ special-purpose environments) might want to stick other stuff in front of
147
+ exported symbols. That's why, in the non-Windows case, we set PCRE2_EXP_DEFN
148
+ only if it is not already set. */
149
+
150
+ #if defined __cplusplus
151
+ #error This project uses C99. C++ is not supported.
152
+ #endif
153
+
154
+ #ifndef PCRE2_EXP_DECL
155
+ # if defined(_WIN32) && !defined(PCRE2_STATIC)
156
+ # define PCRE2_EXP_DECL extern __declspec(dllexport)
157
+ # else
158
+ # define PCRE2_EXP_DECL extern PCRE2_EXPORT
159
+ # endif
160
+ #endif
161
+
162
+ #ifndef PCRE2_EXP_DEFN
163
+ # if defined(_WIN32) && !defined(PCRE2_STATIC)
164
+ # define PCRE2_EXP_DEFN extern __declspec(dllexport)
165
+ # else
166
+ # define PCRE2_EXP_DEFN extern PCRE2_EXPORT
167
+ # endif
168
+ #endif
169
+
170
+ /* Include the public PCRE2 header and the definitions of UCP character
171
+ property values. This must follow the setting of PCRE2_EXP_DECL above. */
172
+
173
+ #include "pcre2.h"
174
+ #include "pcre2_ucp.h"
175
+
176
+ /* When checking for integer overflow, we need to handle large integers.
177
+ If a 64-bit integer type is available, we can use that.
178
+ Otherwise we have to cast to double, which of course requires floating point
179
+ arithmetic. Handle this by defining a macro for the appropriate type. */
180
+
181
+ #if defined INT64_MAX || defined int64_t
182
+ #define INT64_OR_DOUBLE int64_t
183
+ #else
184
+ #define INT64_OR_DOUBLE double
185
+ #endif
186
+
187
+ /* External (in the C sense) functions and tables that are private to the
188
+ libraries are always referenced using the PRIV macro. This makes it possible
189
+ for pcre2test.c to include some of the source files from the libraries using a
190
+ different PRIV definition to avoid name clashes. It also makes it clear in the
191
+ code that a non-static object is being referenced. */
192
+
193
+ #ifndef PRIV
194
+ #define PRIV(name) _pcre2_##name
195
+ #endif
196
+
197
+ /* This is an unsigned int value that no UTF character can ever have, as
198
+ Unicode doesn't go beyond 0x0010ffff. */
199
+
200
+ #define NOTACHAR 0xffffffff
201
+
202
+ /* This is the largest valid UTF/Unicode code point. */
203
+
204
+ #define MAX_UTF_CODE_POINT 0x10ffff
205
+
206
+ /* Compile-time positive error numbers (all except UTF errors, which are
207
+ negative) start at this value. It should probably never be changed, in case
208
+ some application is checking for specific numbers. There is a copy of this
209
+ #define in pcre2posix.c (which now no longer includes this file). Ideally, a
210
+ way of having a single definition should be found, but as the number is
211
+ unlikely to change, this is not a pressing issue. The original reason for
212
+ having a base other than 0 was to keep the absolute values of compile-time and
213
+ run-time error numbers numerically different, but in the event the code does
214
+ not rely on this. */
215
+
216
+ #define COMPILE_ERROR_BASE 100
217
+
218
+ /* The initial frames vector for remembering pcre2_match() backtracking points
219
+ is allocated on the heap, of this size (bytes) or ten times the frame size if
220
+ larger, unless the heap limit is smaller. Typical frame sizes are a few hundred
221
+ bytes (it depends on the number of capturing parentheses) so 20KiB handles
222
+ quite a few frames. A larger vector on the heap is obtained for matches that
223
+ need more frames, subject to the heap limit. */
224
+
225
+ #define START_FRAMES_SIZE 20480
226
+
227
+ /* For DFA matching, an initial internal workspace vector is allocated on the
228
+ stack. The heap is used only if this turns out to be too small. */
229
+
230
+ #define DFA_START_RWS_SIZE 30720
231
+
232
+ /* Define the default BSR convention. */
233
+
234
+ #ifdef BSR_ANYCRLF
235
+ #define BSR_DEFAULT PCRE2_BSR_ANYCRLF
236
+ #else
237
+ #define BSR_DEFAULT PCRE2_BSR_UNICODE
238
+ #endif
239
+
240
+
241
+ /* ---------------- Basic UTF-8 macros ---------------- */
242
+
243
+ /* These UTF-8 macros are always defined because they are used in pcre2test for
244
+ handling wide characters in 16-bit and 32-bit modes, even if an 8-bit library
245
+ is not supported. */
246
+
247
+ /* Tests whether a UTF-8 code point needs extra bytes to decode. */
248
+
249
+ #define HASUTF8EXTRALEN(c) ((c) >= 0xc0)
250
+
251
+ /* The following macros were originally written in the form of loops that used
252
+ data from the tables whose names start with PRIV(utf8_table). They were
253
+ rewritten by a user so as not to use loops, because in some environments this
254
+ gives a significant performance advantage, and it seems never to do any harm.
255
+ */
256
+
257
+ /* Base macro to pick up the remaining bytes of a UTF-8 character, not
258
+ advancing the pointer. */
259
+
260
+ #define GETUTF8(c, eptr) \
261
+ { \
262
+ if ((c & 0x20u) == 0) \
263
+ c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \
264
+ else if ((c & 0x10u) == 0) \
265
+ c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
266
+ else if ((c & 0x08u) == 0) \
267
+ c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \
268
+ ((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \
269
+ else if ((c & 0x04u) == 0) \
270
+ c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \
271
+ ((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \
272
+ (eptr[4] & 0x3fu); \
273
+ else \
274
+ c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \
275
+ ((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \
276
+ ((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \
277
+ }
278
+
279
+ /* Base macro to pick up the remaining bytes of a UTF-8 character, advancing
280
+ the pointer. */
281
+
282
+ #define GETUTF8INC(c, eptr) \
283
+ { \
284
+ if ((c & 0x20u) == 0) \
285
+ c = ((c & 0x1fu) << 6) | (*eptr++ & 0x3fu); \
286
+ else if ((c & 0x10u) == 0) \
287
+ { \
288
+ c = ((c & 0x0fu) << 12) | ((*eptr & 0x3fu) << 6) | (eptr[1] & 0x3fu); \
289
+ eptr += 2; \
290
+ } \
291
+ else if ((c & 0x08u) == 0) \
292
+ { \
293
+ c = ((c & 0x07u) << 18) | ((*eptr & 0x3fu) << 12) | \
294
+ ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
295
+ eptr += 3; \
296
+ } \
297
+ else if ((c & 0x04u) == 0) \
298
+ { \
299
+ c = ((c & 0x03u) << 24) | ((*eptr & 0x3fu) << 18) | \
300
+ ((eptr[1] & 0x3fu) << 12) | ((eptr[2] & 0x3fu) << 6) | \
301
+ (eptr[3] & 0x3fu); \
302
+ eptr += 4; \
303
+ } \
304
+ else \
305
+ { \
306
+ c = ((c & 0x01u) << 30) | ((*eptr & 0x3fu) << 24) | \
307
+ ((eptr[1] & 0x3fu) << 18) | ((eptr[2] & 0x3fu) << 12) | \
308
+ ((eptr[3] & 0x3fu) << 6) | (eptr[4] & 0x3fu); \
309
+ eptr += 5; \
310
+ } \
311
+ }
312
+
313
+ /* Base macro to pick up the remaining bytes of a UTF-8 character, not
314
+ advancing the pointer, incrementing the length. */
315
+
316
+ #define GETUTF8LEN(c, eptr, len) \
317
+ { \
318
+ if ((c & 0x20u) == 0) \
319
+ { \
320
+ c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \
321
+ len++; \
322
+ } \
323
+ else if ((c & 0x10u) == 0) \
324
+ { \
325
+ c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \
326
+ len += 2; \
327
+ } \
328
+ else if ((c & 0x08u) == 0) \
329
+ {\
330
+ c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \
331
+ ((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \
332
+ len += 3; \
333
+ } \
334
+ else if ((c & 0x04u) == 0) \
335
+ { \
336
+ c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \
337
+ ((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \
338
+ (eptr[4] & 0x3fu); \
339
+ len += 4; \
340
+ } \
341
+ else \
342
+ {\
343
+ c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \
344
+ ((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \
345
+ ((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \
346
+ len += 5; \
347
+ } \
348
+ }
349
+
350
+ /* --------------- Whitespace macros ---------------- */
351
+
352
+ /* Tests for Unicode horizontal and vertical whitespace characters must check a
353
+ number of different values. Using a switch statement for this generates the
354
+ fastest code (no loop, no memory access), and there are several places in the
355
+ interpreter code where this happens. In order to ensure that all the case lists
356
+ remain in step, we use macros so that there is only one place where the lists
357
+ are defined.
358
+
359
+ These values are also required as lists in pcre2_compile.c when processing \h,
360
+ \H, \v and \V in a character class. The lists are defined in pcre2_tables.c,
361
+ but macros that define the values are here so that all the definitions are
362
+ together. The lists must be in ascending character order, terminated by
363
+ NOTACHAR (which is 0xffffffff).
364
+
365
+ Any changes should ensure that the various macros are kept in step with each
366
+ other. NOTE: The values also appear in pcre2_jit_compile.c. */
367
+
368
+ /* -------------- ASCII/Unicode environments -------------- */
369
+
370
+ #ifndef EBCDIC
371
+
372
+ /* Character U+180E (Mongolian Vowel Separator) is not included in the list of
373
+ spaces in the Unicode file PropList.txt, and Perl does not recognize it as a
374
+ space. However, in many other sources it is listed as a space and has been in
375
+ PCRE (both APIs) for a long time. */
376
+
377
+ #define HSPACE_LIST \
378
+ CHAR_HT, CHAR_SPACE, CHAR_NBSP, \
379
+ 0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \
380
+ 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f, 0x205f, 0x3000, \
381
+ NOTACHAR
382
+
383
+ #define HSPACE_MULTIBYTE_CASES \
384
+ case 0x1680: /* OGHAM SPACE MARK */ \
385
+ case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ \
386
+ case 0x2000: /* EN QUAD */ \
387
+ case 0x2001: /* EM QUAD */ \
388
+ case 0x2002: /* EN SPACE */ \
389
+ case 0x2003: /* EM SPACE */ \
390
+ case 0x2004: /* THREE-PER-EM SPACE */ \
391
+ case 0x2005: /* FOUR-PER-EM SPACE */ \
392
+ case 0x2006: /* SIX-PER-EM SPACE */ \
393
+ case 0x2007: /* FIGURE SPACE */ \
394
+ case 0x2008: /* PUNCTUATION SPACE */ \
395
+ case 0x2009: /* THIN SPACE */ \
396
+ case 0x200a: /* HAIR SPACE */ \
397
+ case 0x202f: /* NARROW NO-BREAK SPACE */ \
398
+ case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ \
399
+ case 0x3000 /* IDEOGRAPHIC SPACE */
400
+
401
+ #define HSPACE_BYTE_CASES \
402
+ case CHAR_HT: \
403
+ case CHAR_SPACE: \
404
+ case CHAR_NBSP
405
+
406
+ #define HSPACE_CASES \
407
+ HSPACE_BYTE_CASES: \
408
+ HSPACE_MULTIBYTE_CASES
409
+
410
+ #define VSPACE_LIST \
411
+ CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, 0x2028, 0x2029, NOTACHAR
412
+
413
+ #define VSPACE_MULTIBYTE_CASES \
414
+ case 0x2028: /* LINE SEPARATOR */ \
415
+ case 0x2029 /* PARAGRAPH SEPARATOR */
416
+
417
+ #define VSPACE_BYTE_CASES \
418
+ case CHAR_LF: \
419
+ case CHAR_VT: \
420
+ case CHAR_FF: \
421
+ case CHAR_CR: \
422
+ case CHAR_NEL
423
+
424
+ #define VSPACE_CASES \
425
+ VSPACE_BYTE_CASES: \
426
+ VSPACE_MULTIBYTE_CASES
427
+
428
+ /* -------------- EBCDIC environments -------------- */
429
+
430
+ #else
431
+ #define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR
432
+
433
+ #define HSPACE_BYTE_CASES \
434
+ case CHAR_HT: \
435
+ case CHAR_SPACE: \
436
+ case CHAR_NBSP
437
+
438
+ #define HSPACE_CASES HSPACE_BYTE_CASES
439
+
440
+ #ifdef EBCDIC_NL25
441
+ #define VSPACE_LIST \
442
+ CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, CHAR_LF, NOTACHAR
443
+ #else
444
+ #define VSPACE_LIST \
445
+ CHAR_VT, CHAR_FF, CHAR_CR, CHAR_LF, CHAR_NEL, NOTACHAR
446
+ #endif
447
+
448
+ #define VSPACE_BYTE_CASES \
449
+ case CHAR_LF: \
450
+ case CHAR_VT: \
451
+ case CHAR_FF: \
452
+ case CHAR_CR: \
453
+ case CHAR_NEL
454
+
455
+ #define VSPACE_CASES VSPACE_BYTE_CASES
456
+ #endif /* EBCDIC */
457
+
458
+ /* -------------- End of whitespace macros -------------- */
459
+
460
+
461
+ /* PCRE2 is able to support several different kinds of newline (CR, LF, CRLF,
462
+ "any" and "anycrlf" at present). The following macros are used to package up
463
+ testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various
464
+ modules to indicate in which datablock the parameters exist, and what the
465
+ start/end of string field names are. */
466
+
467
+ #define NLTYPE_FIXED 0 /* Newline is a fixed length string */
468
+ #define NLTYPE_ANY 1 /* Newline is any Unicode line ending */
469
+ #define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */
470
+
471
+ /* This macro checks for a newline at the given position */
472
+
473
+ #define IS_NEWLINE(p) \
474
+ ((NLBLOCK->nltype != NLTYPE_FIXED)? \
475
+ ((p) < NLBLOCK->PSEND && \
476
+ PRIV(is_newline)((p), NLBLOCK->nltype, NLBLOCK->PSEND, \
477
+ &(NLBLOCK->nllen), utf)) \
478
+ : \
479
+ ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
480
+ UCHAR21TEST(p) == NLBLOCK->nl[0] && \
481
+ (NLBLOCK->nllen == 1 || UCHAR21TEST(p+1) == NLBLOCK->nl[1]) \
482
+ ) \
483
+ )
484
+
485
+ /* This macro checks for a newline immediately preceding the given position */
486
+
487
+ #define WAS_NEWLINE(p) \
488
+ ((NLBLOCK->nltype != NLTYPE_FIXED)? \
489
+ ((p) > NLBLOCK->PSSTART && \
490
+ PRIV(was_newline)((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
491
+ &(NLBLOCK->nllen), utf)) \
492
+ : \
493
+ ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
494
+ UCHAR21TEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \
495
+ (NLBLOCK->nllen == 1 || UCHAR21TEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \
496
+ ) \
497
+ )
498
+
499
+ /* Private flags containing information about the compiled pattern. The first
500
+ three must not be changed, because whichever is set is actually the number of
501
+ bytes in a code unit in that mode. */
502
+
503
+ #define PCRE2_MODE8 0x00000001u /* compiled in 8 bit mode */
504
+ #define PCRE2_MODE16 0x00000002u /* compiled in 16 bit mode */
505
+ #define PCRE2_MODE32 0x00000004u /* compiled in 32 bit mode */
506
+ #define PCRE2_FIRSTSET 0x00000010u /* first_code unit is set */
507
+ #define PCRE2_FIRSTCASELESS 0x00000020u /* caseless first code unit */
508
+ #define PCRE2_FIRSTMAPSET 0x00000040u /* bitmap of first code units is set */
509
+ #define PCRE2_LASTSET 0x00000080u /* last code unit is set */
510
+ #define PCRE2_LASTCASELESS 0x00000100u /* caseless last code unit */
511
+ #define PCRE2_STARTLINE 0x00000200u /* start after \n for multiline */
512
+ #define PCRE2_JCHANGED 0x00000400u /* j option used in pattern */
513
+ #define PCRE2_HASCRORLF 0x00000800u /* explicit \r or \n in pattern */
514
+ #define PCRE2_HASTHEN 0x00001000u /* pattern contains (*THEN) */
515
+ #define PCRE2_MATCH_EMPTY 0x00002000u /* pattern can match empty string */
516
+ #define PCRE2_BSR_SET 0x00004000u /* BSR was set in the pattern */
517
+ #define PCRE2_NL_SET 0x00008000u /* newline was set in the pattern */
518
+ #define PCRE2_NOTEMPTY_SET 0x00010000u /* (*NOTEMPTY) used ) keep */
519
+ #define PCRE2_NE_ATST_SET 0x00020000u /* (*NOTEMPTY_ATSTART) used) together */
520
+ #define PCRE2_DEREF_TABLES 0x00040000u /* release character tables */
521
+ #define PCRE2_NOJIT 0x00080000u /* (*NOJIT) used */
522
+ #define PCRE2_HASBKPORX 0x00100000u /* contains \P, \p, or \X */
523
+ #define PCRE2_DUPCAPUSED 0x00200000u /* contains (?| */
524
+ #define PCRE2_HASBKC 0x00400000u /* contains \C */
525
+ #define PCRE2_HASACCEPT 0x00800000u /* contains (*ACCEPT) */
526
+ #define PCRE2_HASBSK 0x01000000u /* contains \K */
527
+
528
+ #define PCRE2_MODE_MASK (PCRE2_MODE8 | PCRE2_MODE16 | PCRE2_MODE32)
529
+
530
+ /* Values for the matchedby field in a match data block. */
531
+
532
+ enum { PCRE2_MATCHEDBY_INTERPRETER, /* pcre2_match() */
533
+ PCRE2_MATCHEDBY_DFA_INTERPRETER, /* pcre2_dfa_match() */
534
+ PCRE2_MATCHEDBY_JIT }; /* pcre2_jit_match() */
535
+
536
+ /* Values for the flags field in a match data block. */
537
+
538
+ #define PCRE2_MD_COPIED_SUBJECT 0x01u
539
+
540
+ /* Magic number to provide a small check against being handed junk. */
541
+
542
+ #define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
543
+
544
+ /* The maximum remaining length of subject we are prepared to search for a
545
+ req_unit match from an anchored pattern. In 8-bit mode, memchr() is used and is
546
+ much faster than the search loop that has to be used in 16-bit and 32-bit
547
+ modes. */
548
+
549
+ #if PCRE2_CODE_UNIT_WIDTH == 8
550
+ #define REQ_CU_MAX 5000
551
+ #else
552
+ #define REQ_CU_MAX 2000
553
+ #endif
554
+
555
+ /* The maximum nesting depth for Unicode character class sets.
556
+ Currently fixed. Warning: the interpreter relies on this so it can encode
557
+ the operand stack in a uint32_t. A nesting limit of 15 implies (15*2+1)=31
558
+ stack operands required, due to the fact that we have two (and only two)
559
+ levels of operator precedence. In the UTS#18 syntax, you can write 'x&&y[z]'
560
+ and in Perl syntax you can write '(?[ x - y & (z) ])', both of which imply
561
+ pushing the match results for x & y to the stack. */
562
+
563
+ #define ECLASS_NEST_LIMIT 15
564
+
565
+ /* Offsets for the bitmap tables in the cbits set of tables. Each table
566
+ contains a set of bits for a class map. Some classes are built by combining
567
+ these tables. */
568
+
569
+ #define cbit_space 0 /* [:space:] or \s */
570
+ #define cbit_xdigit 32 /* [:xdigit:] */
571
+ #define cbit_digit 64 /* [:digit:] or \d */
572
+ #define cbit_upper 96 /* [:upper:] */
573
+ #define cbit_lower 128 /* [:lower:] */
574
+ #define cbit_word 160 /* [:word:] or \w */
575
+ #define cbit_graph 192 /* [:graph:] */
576
+ #define cbit_print 224 /* [:print:] */
577
+ #define cbit_punct 256 /* [:punct:] */
578
+ #define cbit_cntrl 288 /* [:cntrl:] */
579
+ #define cbit_length 320 /* Length of the cbits table */
580
+
581
+ /* Bit definitions for entries in the ctypes table. Do not change these values
582
+ without checking pcre2_jit_compile.c, which has an assertion to ensure that
583
+ ctype_word has the value 16. */
584
+
585
+ #define ctype_space 0x01
586
+ #define ctype_letter 0x02
587
+ #define ctype_lcletter 0x04
588
+ #define ctype_digit 0x08
589
+ #define ctype_word 0x10 /* alphanumeric or '_' */
590
+
591
+ /* Offsets of the various tables from the base tables pointer, and
592
+ total length of the tables. */
593
+
594
+ #define lcc_offset 0 /* Lower case */
595
+ #define fcc_offset 256 /* Flip case */
596
+ #define cbits_offset 512 /* Character classes */
597
+ #define ctypes_offset (cbits_offset + cbit_length) /* Character types */
598
+ #define TABLES_LENGTH (ctypes_offset + 256)
599
+
600
+ /* Private flags used in compile_context.optimization_flags */
601
+
602
+ #define PCRE2_OPTIM_AUTO_POSSESS 0x00000001u
603
+ #define PCRE2_OPTIM_DOTSTAR_ANCHOR 0x00000002u
604
+ #define PCRE2_OPTIM_START_OPTIMIZE 0x00000004u
605
+
606
+ #define PCRE2_OPTIMIZATION_ALL 0x00000007u
607
+
608
+ /* -------------------- Character and string names ------------------------ */
609
+
610
+ /* If PCRE2 is to support UTF-8 on EBCDIC platforms, we cannot use normal
611
+ character constants like '*' because the compiler would emit their EBCDIC code,
612
+ which is different from their ASCII/UTF-8 code. Instead we define macros for
613
+ the characters so that they always use the ASCII/UTF-8 code when UTF-8 support
614
+ is enabled. When UTF-8 support is not enabled, the definitions use character
615
+ literals. Both character and string versions of each character are needed, and
616
+ there are some longer strings as well.
617
+
618
+ This means that, on EBCDIC platforms, the PCRE2 library can handle either
619
+ EBCDIC, or UTF-8, but not both. To support both in the same compiled library
620
+ would need different lookups depending on whether PCRE2_UTF was set or not.
621
+ This would make it impossible to use characters in switch/case statements,
622
+ which would reduce performance. For a theoretical use (which nobody has asked
623
+ for) in a minority area (EBCDIC platforms), this is not sensible. Any
624
+ application that did need both could compile two versions of the library, using
625
+ macros to give the functions distinct names. */
626
+
627
+ #ifndef SUPPORT_UNICODE
628
+
629
+ /* UTF-8 support is not enabled; use the platform-dependent character literals
630
+ so that PCRE2 works in both ASCII and EBCDIC environments, but only in non-UTF
631
+ mode. Newline characters are problematic in EBCDIC. Though it has CR and LF
632
+ characters, a common practice has been to use its NL (0x15) character as the
633
+ line terminator in C-like processing environments. However, sometimes the LF
634
+ (0x25) character is used instead, according to this Unicode document:
635
+
636
+ http://unicode.org/standard/reports/tr13/tr13-5.html
637
+
638
+ PCRE2 defaults EBCDIC NL to 0x15, but has a build-time option to select 0x25
639
+ instead. Whichever is *not* chosen is defined as NEL.
640
+
641
+ In both ASCII and EBCDIC environments, CHAR_NL and CHAR_LF are synonyms for the
642
+ same code point. */
643
+
644
+ #ifdef EBCDIC
645
+
646
+ #ifndef EBCDIC_NL25
647
+ #define CHAR_NL '\x15'
648
+ #define CHAR_NEL '\x25'
649
+ #define STR_NL "\x15"
650
+ #define STR_NEL "\x25"
651
+ #else
652
+ #define CHAR_NL '\x25'
653
+ #define CHAR_NEL '\x15'
654
+ #define STR_NL "\x25"
655
+ #define STR_NEL "\x15"
656
+ #endif
657
+
658
+ #define CHAR_LF CHAR_NL
659
+ #define STR_LF STR_NL
660
+
661
+ #define CHAR_ESC '\047'
662
+ #define CHAR_DEL '\007'
663
+ #define CHAR_NBSP ((unsigned char)'\x41')
664
+ #define STR_ESC "\047"
665
+ #define STR_DEL "\007"
666
+
667
+ #else /* Not EBCDIC */
668
+
669
+ /* In ASCII/Unicode, linefeed is '\n' and we equate this to NL for
670
+ compatibility. NEL is the Unicode newline character; make sure it is
671
+ a positive value. */
672
+
673
+ #if '\n' != 0x0a
674
+ #error "ASCII character '\n' is not 0x0a"
675
+ #endif
676
+
677
+ #define CHAR_LF '\n'
678
+ #define CHAR_NL CHAR_LF
679
+ #define CHAR_NEL ((unsigned char)'\x85')
680
+ #define CHAR_ESC '\033'
681
+ #define CHAR_DEL '\177'
682
+ #define CHAR_NBSP ((unsigned char)'\xa0')
683
+
684
+ #define STR_LF "\n"
685
+ #define STR_NL STR_LF
686
+ #define STR_NEL "\x85"
687
+ #define STR_ESC "\033"
688
+ #define STR_DEL "\177"
689
+
690
+ #endif /* EBCDIC */
691
+
692
+ /* When we want to use EBCDIC with an ASCII compiler, for testing EBCDIC on
693
+ ASCII platforms, then we can hardcode an EBCDIC codepage (IBM-1047). */
694
+
695
+ #ifdef EBCDIC_IGNORING_COMPILER
696
+
697
+ #define CHAR_NUL '\000'
698
+ #define CHAR_HT '\005'
699
+ #define CHAR_VT '\013'
700
+ #define CHAR_FF '\014'
701
+ #define CHAR_CR '\015'
702
+ #define CHAR_BS '\026'
703
+ #define CHAR_BEL '\057'
704
+
705
+ #define CHAR_SPACE '\100'
706
+ #define CHAR_EXCLAMATION_MARK '\132'
707
+ #define CHAR_QUOTATION_MARK '\177'
708
+ #define CHAR_NUMBER_SIGN '\173'
709
+ #define CHAR_DOLLAR_SIGN '\133'
710
+ #define CHAR_PERCENT_SIGN '\154'
711
+ #define CHAR_AMPERSAND '\120'
712
+ #define CHAR_APOSTROPHE '\175'
713
+ #define CHAR_LEFT_PARENTHESIS '\115'
714
+ #define CHAR_RIGHT_PARENTHESIS '\135'
715
+ #define CHAR_ASTERISK '\134'
716
+ #define CHAR_PLUS '\116'
717
+ #define CHAR_COMMA '\153'
718
+ #define CHAR_MINUS '\140'
719
+ #define CHAR_DOT '\113'
720
+ #define CHAR_SLASH '\141'
721
+ #define CHAR_0 ((unsigned char)'\xf0')
722
+ #define CHAR_1 ((unsigned char)'\xf1')
723
+ #define CHAR_2 ((unsigned char)'\xf2')
724
+ #define CHAR_3 ((unsigned char)'\xf3')
725
+ #define CHAR_4 ((unsigned char)'\xf4')
726
+ #define CHAR_5 ((unsigned char)'\xf5')
727
+ #define CHAR_6 ((unsigned char)'\xf6')
728
+ #define CHAR_7 ((unsigned char)'\xf7')
729
+ #define CHAR_8 ((unsigned char)'\xf8')
730
+ #define CHAR_9 ((unsigned char)'\xf9')
731
+ #define CHAR_COLON '\172'
732
+ #define CHAR_SEMICOLON '\136'
733
+ #define CHAR_LESS_THAN_SIGN '\114'
734
+ #define CHAR_EQUALS_SIGN '\176'
735
+ #define CHAR_GREATER_THAN_SIGN '\156'
736
+ #define CHAR_QUESTION_MARK '\157'
737
+ #define CHAR_COMMERCIAL_AT '\174'
738
+ #define CHAR_A ((unsigned char)'\xc1')
739
+ #define CHAR_B ((unsigned char)'\xc2')
740
+ #define CHAR_C ((unsigned char)'\xc3')
741
+ #define CHAR_D ((unsigned char)'\xc4')
742
+ #define CHAR_E ((unsigned char)'\xc5')
743
+ #define CHAR_F ((unsigned char)'\xc6')
744
+ #define CHAR_G ((unsigned char)'\xc7')
745
+ #define CHAR_H ((unsigned char)'\xc8')
746
+ #define CHAR_I ((unsigned char)'\xc9')
747
+ #define CHAR_J ((unsigned char)'\xd1')
748
+ #define CHAR_K ((unsigned char)'\xd2')
749
+ #define CHAR_L ((unsigned char)'\xd3')
750
+ #define CHAR_M ((unsigned char)'\xd4')
751
+ #define CHAR_N ((unsigned char)'\xd5')
752
+ #define CHAR_O ((unsigned char)'\xd6')
753
+ #define CHAR_P ((unsigned char)'\xd7')
754
+ #define CHAR_Q ((unsigned char)'\xd8')
755
+ #define CHAR_R ((unsigned char)'\xd9')
756
+ #define CHAR_S ((unsigned char)'\xe2')
757
+ #define CHAR_T ((unsigned char)'\xe3')
758
+ #define CHAR_U ((unsigned char)'\xe4')
759
+ #define CHAR_V ((unsigned char)'\xe5')
760
+ #define CHAR_W ((unsigned char)'\xe6')
761
+ #define CHAR_X ((unsigned char)'\xe7')
762
+ #define CHAR_Y ((unsigned char)'\xe8')
763
+ #define CHAR_Z ((unsigned char)'\xe9')
764
+ #define CHAR_LEFT_SQUARE_BRACKET ((unsigned char)'\xad')
765
+ #define CHAR_BACKSLASH ((unsigned char)'\xe0')
766
+ #define CHAR_RIGHT_SQUARE_BRACKET ((unsigned char)'\xbd')
767
+ #define CHAR_CIRCUMFLEX_ACCENT '\137'
768
+ #define CHAR_UNDERSCORE '\155'
769
+ #define CHAR_GRAVE_ACCENT '\171'
770
+ #define CHAR_a ((unsigned char)'\x81')
771
+ #define CHAR_b ((unsigned char)'\x82')
772
+ #define CHAR_c ((unsigned char)'\x83')
773
+ #define CHAR_d ((unsigned char)'\x84')
774
+ #define CHAR_e ((unsigned char)'\x85')
775
+ #define CHAR_f ((unsigned char)'\x86')
776
+ #define CHAR_g ((unsigned char)'\x87')
777
+ #define CHAR_h ((unsigned char)'\x88')
778
+ #define CHAR_i ((unsigned char)'\x89')
779
+ #define CHAR_j ((unsigned char)'\x91')
780
+ #define CHAR_k ((unsigned char)'\x92')
781
+ #define CHAR_l ((unsigned char)'\x93')
782
+ #define CHAR_m ((unsigned char)'\x94')
783
+ #define CHAR_n ((unsigned char)'\x95')
784
+ #define CHAR_o ((unsigned char)'\x96')
785
+ #define CHAR_p ((unsigned char)'\x97')
786
+ #define CHAR_q ((unsigned char)'\x98')
787
+ #define CHAR_r ((unsigned char)'\x99')
788
+ #define CHAR_s ((unsigned char)'\xa2')
789
+ #define CHAR_t ((unsigned char)'\xa3')
790
+ #define CHAR_u ((unsigned char)'\xa4')
791
+ #define CHAR_v ((unsigned char)'\xa5')
792
+ #define CHAR_w ((unsigned char)'\xa6')
793
+ #define CHAR_x ((unsigned char)'\xa7')
794
+ #define CHAR_y ((unsigned char)'\xa8')
795
+ #define CHAR_z ((unsigned char)'\xa9')
796
+ #define CHAR_LEFT_CURLY_BRACKET ((unsigned char)'\xc0')
797
+ #define CHAR_VERTICAL_LINE '\117'
798
+ #define CHAR_RIGHT_CURLY_BRACKET ((unsigned char)'\xd0')
799
+ #define CHAR_TILDE ((unsigned char)'\xa1')
800
+
801
+ #define STR_HT "\005"
802
+ #define STR_VT "\013"
803
+ #define STR_FF "\014"
804
+ #define STR_CR "\015"
805
+ #define STR_BS "\026"
806
+ #define STR_BEL "\057"
807
+
808
+ #define STR_SPACE "\100"
809
+ #define STR_EXCLAMATION_MARK "\132"
810
+ #define STR_QUOTATION_MARK "\177"
811
+ #define STR_NUMBER_SIGN "\173"
812
+ #define STR_DOLLAR_SIGN "\133"
813
+ #define STR_PERCENT_SIGN "\154"
814
+ #define STR_AMPERSAND "\120"
815
+ #define STR_APOSTROPHE "\175"
816
+ #define STR_LEFT_PARENTHESIS "\115"
817
+ #define STR_RIGHT_PARENTHESIS "\135"
818
+ #define STR_ASTERISK "\134"
819
+ #define STR_PLUS "\116"
820
+ #define STR_COMMA "\153"
821
+ #define STR_MINUS "\140"
822
+ #define STR_DOT "\113"
823
+ #define STR_SLASH "\141"
824
+ #define STR_0 "\360"
825
+ #define STR_1 "\361"
826
+ #define STR_2 "\362"
827
+ #define STR_3 "\363"
828
+ #define STR_4 "\364"
829
+ #define STR_5 "\365"
830
+ #define STR_6 "\366"
831
+ #define STR_7 "\367"
832
+ #define STR_8 "\370"
833
+ #define STR_9 "\371"
834
+ #define STR_COLON "\172"
835
+ #define STR_SEMICOLON "\136"
836
+ #define STR_LESS_THAN_SIGN "\114"
837
+ #define STR_EQUALS_SIGN "\176"
838
+ #define STR_GREATER_THAN_SIGN "\156"
839
+ #define STR_QUESTION_MARK "\157"
840
+ #define STR_COMMERCIAL_AT "\174"
841
+ #define STR_A "\301"
842
+ #define STR_B "\302"
843
+ #define STR_C "\303"
844
+ #define STR_D "\304"
845
+ #define STR_E "\305"
846
+ #define STR_F "\306"
847
+ #define STR_G "\307"
848
+ #define STR_H "\310"
849
+ #define STR_I "\311"
850
+ #define STR_J "\321"
851
+ #define STR_K "\322"
852
+ #define STR_L "\323"
853
+ #define STR_M "\324"
854
+ #define STR_N "\325"
855
+ #define STR_O "\326"
856
+ #define STR_P "\327"
857
+ #define STR_Q "\330"
858
+ #define STR_R "\331"
859
+ #define STR_S "\342"
860
+ #define STR_T "\343"
861
+ #define STR_U "\344"
862
+ #define STR_V "\345"
863
+ #define STR_W "\346"
864
+ #define STR_X "\347"
865
+ #define STR_Y "\350"
866
+ #define STR_Z "\351"
867
+ #define STR_LEFT_SQUARE_BRACKET "\255"
868
+ #define STR_BACKSLASH "\340"
869
+ #define STR_RIGHT_SQUARE_BRACKET "\275"
870
+ #define STR_CIRCUMFLEX_ACCENT "\137"
871
+ #define STR_UNDERSCORE "\155"
872
+ #define STR_GRAVE_ACCENT "\171"
873
+ #define STR_a "\201"
874
+ #define STR_b "\202"
875
+ #define STR_c "\203"
876
+ #define STR_d "\204"
877
+ #define STR_e "\205"
878
+ #define STR_f "\206"
879
+ #define STR_g "\207"
880
+ #define STR_h "\210"
881
+ #define STR_i "\211"
882
+ #define STR_j "\221"
883
+ #define STR_k "\222"
884
+ #define STR_l "\223"
885
+ #define STR_m "\224"
886
+ #define STR_n "\225"
887
+ #define STR_o "\226"
888
+ #define STR_p "\227"
889
+ #define STR_q "\230"
890
+ #define STR_r "\231"
891
+ #define STR_s "\242"
892
+ #define STR_t "\243"
893
+ #define STR_u "\244"
894
+ #define STR_v "\245"
895
+ #define STR_w "\246"
896
+ #define STR_x "\247"
897
+ #define STR_y "\250"
898
+ #define STR_z "\251"
899
+ #define STR_LEFT_CURLY_BRACKET "\300"
900
+ #define STR_VERTICAL_LINE "\117"
901
+ #define STR_RIGHT_CURLY_BRACKET "\320"
902
+ #define STR_TILDE "\241"
903
+
904
+ #else /* EBCDIC_IGNORING_COMPILER */
905
+
906
+ /* Otherwise, on a real EBCDIC compiler or an ASCII compiler, we can use simple
907
+ string and character literals. */
908
+
909
+ #ifdef EBCDIC
910
+ #if 'a' != 0x81
911
+ #error "EBCDIC character 'a' is not 0x81"
912
+ #endif
913
+ #else
914
+ #if 'a' != 0x61
915
+ #error "ASCII character 'a' is not 0x61"
916
+ #endif
917
+ #endif
918
+
919
+ #define CHAR_NUL '\0'
920
+ #define CHAR_HT '\t'
921
+ #define CHAR_VT '\v'
922
+ #define CHAR_FF '\f'
923
+ #define CHAR_CR '\r'
924
+ #define CHAR_BS '\b'
925
+ #define CHAR_BEL '\a'
926
+
927
+ #define CHAR_SPACE ' '
928
+ #define CHAR_EXCLAMATION_MARK '!'
929
+ #define CHAR_QUOTATION_MARK '"'
930
+ #define CHAR_NUMBER_SIGN '#'
931
+ #define CHAR_DOLLAR_SIGN '$'
932
+ #define CHAR_PERCENT_SIGN '%'
933
+ #define CHAR_AMPERSAND '&'
934
+ #define CHAR_APOSTROPHE '\''
935
+ #define CHAR_LEFT_PARENTHESIS '('
936
+ #define CHAR_RIGHT_PARENTHESIS ')'
937
+ #define CHAR_ASTERISK '*'
938
+ #define CHAR_PLUS '+'
939
+ #define CHAR_COMMA ','
940
+ #define CHAR_MINUS '-'
941
+ #define CHAR_DOT '.'
942
+ #define CHAR_SLASH '/'
943
+ #define CHAR_0 '0'
944
+ #define CHAR_1 '1'
945
+ #define CHAR_2 '2'
946
+ #define CHAR_3 '3'
947
+ #define CHAR_4 '4'
948
+ #define CHAR_5 '5'
949
+ #define CHAR_6 '6'
950
+ #define CHAR_7 '7'
951
+ #define CHAR_8 '8'
952
+ #define CHAR_9 '9'
953
+ #define CHAR_COLON ':'
954
+ #define CHAR_SEMICOLON ';'
955
+ #define CHAR_LESS_THAN_SIGN '<'
956
+ #define CHAR_EQUALS_SIGN '='
957
+ #define CHAR_GREATER_THAN_SIGN '>'
958
+ #define CHAR_QUESTION_MARK '?'
959
+ #define CHAR_COMMERCIAL_AT '@'
960
+ #define CHAR_A 'A'
961
+ #define CHAR_B 'B'
962
+ #define CHAR_C 'C'
963
+ #define CHAR_D 'D'
964
+ #define CHAR_E 'E'
965
+ #define CHAR_F 'F'
966
+ #define CHAR_G 'G'
967
+ #define CHAR_H 'H'
968
+ #define CHAR_I 'I'
969
+ #define CHAR_J 'J'
970
+ #define CHAR_K 'K'
971
+ #define CHAR_L 'L'
972
+ #define CHAR_M 'M'
973
+ #define CHAR_N 'N'
974
+ #define CHAR_O 'O'
975
+ #define CHAR_P 'P'
976
+ #define CHAR_Q 'Q'
977
+ #define CHAR_R 'R'
978
+ #define CHAR_S 'S'
979
+ #define CHAR_T 'T'
980
+ #define CHAR_U 'U'
981
+ #define CHAR_V 'V'
982
+ #define CHAR_W 'W'
983
+ #define CHAR_X 'X'
984
+ #define CHAR_Y 'Y'
985
+ #define CHAR_Z 'Z'
986
+ #define CHAR_LEFT_SQUARE_BRACKET '['
987
+ #define CHAR_BACKSLASH '\\'
988
+ #define CHAR_RIGHT_SQUARE_BRACKET ']'
989
+ #define CHAR_CIRCUMFLEX_ACCENT '^'
990
+ #define CHAR_UNDERSCORE '_'
991
+ #define CHAR_GRAVE_ACCENT '`'
992
+ #define CHAR_a 'a'
993
+ #define CHAR_b 'b'
994
+ #define CHAR_c 'c'
995
+ #define CHAR_d 'd'
996
+ #define CHAR_e 'e'
997
+ #define CHAR_f 'f'
998
+ #define CHAR_g 'g'
999
+ #define CHAR_h 'h'
1000
+ #define CHAR_i 'i'
1001
+ #define CHAR_j 'j'
1002
+ #define CHAR_k 'k'
1003
+ #define CHAR_l 'l'
1004
+ #define CHAR_m 'm'
1005
+ #define CHAR_n 'n'
1006
+ #define CHAR_o 'o'
1007
+ #define CHAR_p 'p'
1008
+ #define CHAR_q 'q'
1009
+ #define CHAR_r 'r'
1010
+ #define CHAR_s 's'
1011
+ #define CHAR_t 't'
1012
+ #define CHAR_u 'u'
1013
+ #define CHAR_v 'v'
1014
+ #define CHAR_w 'w'
1015
+ #define CHAR_x 'x'
1016
+ #define CHAR_y 'y'
1017
+ #define CHAR_z 'z'
1018
+ #define CHAR_LEFT_CURLY_BRACKET '{'
1019
+ #define CHAR_VERTICAL_LINE '|'
1020
+ #define CHAR_RIGHT_CURLY_BRACKET '}'
1021
+ #define CHAR_TILDE '~'
1022
+
1023
+ #define STR_HT "\t"
1024
+ #define STR_VT "\v"
1025
+ #define STR_FF "\f"
1026
+ #define STR_CR "\r"
1027
+ #define STR_BS "\b"
1028
+ #define STR_BEL "\a"
1029
+
1030
+ #define STR_SPACE " "
1031
+ #define STR_EXCLAMATION_MARK "!"
1032
+ #define STR_QUOTATION_MARK "\""
1033
+ #define STR_NUMBER_SIGN "#"
1034
+ #define STR_DOLLAR_SIGN "$"
1035
+ #define STR_PERCENT_SIGN "%"
1036
+ #define STR_AMPERSAND "&"
1037
+ #define STR_APOSTROPHE "'"
1038
+ #define STR_LEFT_PARENTHESIS "("
1039
+ #define STR_RIGHT_PARENTHESIS ")"
1040
+ #define STR_ASTERISK "*"
1041
+ #define STR_PLUS "+"
1042
+ #define STR_COMMA ","
1043
+ #define STR_MINUS "-"
1044
+ #define STR_DOT "."
1045
+ #define STR_SLASH "/"
1046
+ #define STR_0 "0"
1047
+ #define STR_1 "1"
1048
+ #define STR_2 "2"
1049
+ #define STR_3 "3"
1050
+ #define STR_4 "4"
1051
+ #define STR_5 "5"
1052
+ #define STR_6 "6"
1053
+ #define STR_7 "7"
1054
+ #define STR_8 "8"
1055
+ #define STR_9 "9"
1056
+ #define STR_COLON ":"
1057
+ #define STR_SEMICOLON ";"
1058
+ #define STR_LESS_THAN_SIGN "<"
1059
+ #define STR_EQUALS_SIGN "="
1060
+ #define STR_GREATER_THAN_SIGN ">"
1061
+ #define STR_QUESTION_MARK "?"
1062
+ #define STR_COMMERCIAL_AT "@"
1063
+ #define STR_A "A"
1064
+ #define STR_B "B"
1065
+ #define STR_C "C"
1066
+ #define STR_D "D"
1067
+ #define STR_E "E"
1068
+ #define STR_F "F"
1069
+ #define STR_G "G"
1070
+ #define STR_H "H"
1071
+ #define STR_I "I"
1072
+ #define STR_J "J"
1073
+ #define STR_K "K"
1074
+ #define STR_L "L"
1075
+ #define STR_M "M"
1076
+ #define STR_N "N"
1077
+ #define STR_O "O"
1078
+ #define STR_P "P"
1079
+ #define STR_Q "Q"
1080
+ #define STR_R "R"
1081
+ #define STR_S "S"
1082
+ #define STR_T "T"
1083
+ #define STR_U "U"
1084
+ #define STR_V "V"
1085
+ #define STR_W "W"
1086
+ #define STR_X "X"
1087
+ #define STR_Y "Y"
1088
+ #define STR_Z "Z"
1089
+ #define STR_LEFT_SQUARE_BRACKET "["
1090
+ #define STR_BACKSLASH "\\"
1091
+ #define STR_RIGHT_SQUARE_BRACKET "]"
1092
+ #define STR_CIRCUMFLEX_ACCENT "^"
1093
+ #define STR_UNDERSCORE "_"
1094
+ #define STR_GRAVE_ACCENT "`"
1095
+ #define STR_a "a"
1096
+ #define STR_b "b"
1097
+ #define STR_c "c"
1098
+ #define STR_d "d"
1099
+ #define STR_e "e"
1100
+ #define STR_f "f"
1101
+ #define STR_g "g"
1102
+ #define STR_h "h"
1103
+ #define STR_i "i"
1104
+ #define STR_j "j"
1105
+ #define STR_k "k"
1106
+ #define STR_l "l"
1107
+ #define STR_m "m"
1108
+ #define STR_n "n"
1109
+ #define STR_o "o"
1110
+ #define STR_p "p"
1111
+ #define STR_q "q"
1112
+ #define STR_r "r"
1113
+ #define STR_s "s"
1114
+ #define STR_t "t"
1115
+ #define STR_u "u"
1116
+ #define STR_v "v"
1117
+ #define STR_w "w"
1118
+ #define STR_x "x"
1119
+ #define STR_y "y"
1120
+ #define STR_z "z"
1121
+ #define STR_LEFT_CURLY_BRACKET "{"
1122
+ #define STR_VERTICAL_LINE "|"
1123
+ #define STR_RIGHT_CURLY_BRACKET "}"
1124
+ #define STR_TILDE "~"
1125
+
1126
+ #endif /* EBCDIC_WITH_ASCII_COMPILER */
1127
+
1128
+ #else /* SUPPORT_UNICODE */
1129
+
1130
+ /* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This
1131
+ works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode
1132
+ only. */
1133
+
1134
+ #define CHAR_HT '\011'
1135
+ #define CHAR_VT '\013'
1136
+ #define CHAR_FF '\014'
1137
+ #define CHAR_CR '\015'
1138
+ #define CHAR_LF '\012'
1139
+ #define CHAR_NL CHAR_LF
1140
+ #define CHAR_NEL ((unsigned char)'\x85')
1141
+ #define CHAR_BS '\010'
1142
+ #define CHAR_BEL '\007'
1143
+ #define CHAR_ESC '\033'
1144
+ #define CHAR_DEL '\177'
1145
+
1146
+ #define CHAR_NUL '\0'
1147
+ #define CHAR_SPACE '\040'
1148
+ #define CHAR_EXCLAMATION_MARK '\041'
1149
+ #define CHAR_QUOTATION_MARK '\042'
1150
+ #define CHAR_NUMBER_SIGN '\043'
1151
+ #define CHAR_DOLLAR_SIGN '\044'
1152
+ #define CHAR_PERCENT_SIGN '\045'
1153
+ #define CHAR_AMPERSAND '\046'
1154
+ #define CHAR_APOSTROPHE '\047'
1155
+ #define CHAR_LEFT_PARENTHESIS '\050'
1156
+ #define CHAR_RIGHT_PARENTHESIS '\051'
1157
+ #define CHAR_ASTERISK '\052'
1158
+ #define CHAR_PLUS '\053'
1159
+ #define CHAR_COMMA '\054'
1160
+ #define CHAR_MINUS '\055'
1161
+ #define CHAR_DOT '\056'
1162
+ #define CHAR_SLASH '\057'
1163
+ #define CHAR_0 '\060'
1164
+ #define CHAR_1 '\061'
1165
+ #define CHAR_2 '\062'
1166
+ #define CHAR_3 '\063'
1167
+ #define CHAR_4 '\064'
1168
+ #define CHAR_5 '\065'
1169
+ #define CHAR_6 '\066'
1170
+ #define CHAR_7 '\067'
1171
+ #define CHAR_8 '\070'
1172
+ #define CHAR_9 '\071'
1173
+ #define CHAR_COLON '\072'
1174
+ #define CHAR_SEMICOLON '\073'
1175
+ #define CHAR_LESS_THAN_SIGN '\074'
1176
+ #define CHAR_EQUALS_SIGN '\075'
1177
+ #define CHAR_GREATER_THAN_SIGN '\076'
1178
+ #define CHAR_QUESTION_MARK '\077'
1179
+ #define CHAR_COMMERCIAL_AT '\100'
1180
+ #define CHAR_A '\101'
1181
+ #define CHAR_B '\102'
1182
+ #define CHAR_C '\103'
1183
+ #define CHAR_D '\104'
1184
+ #define CHAR_E '\105'
1185
+ #define CHAR_F '\106'
1186
+ #define CHAR_G '\107'
1187
+ #define CHAR_H '\110'
1188
+ #define CHAR_I '\111'
1189
+ #define CHAR_J '\112'
1190
+ #define CHAR_K '\113'
1191
+ #define CHAR_L '\114'
1192
+ #define CHAR_M '\115'
1193
+ #define CHAR_N '\116'
1194
+ #define CHAR_O '\117'
1195
+ #define CHAR_P '\120'
1196
+ #define CHAR_Q '\121'
1197
+ #define CHAR_R '\122'
1198
+ #define CHAR_S '\123'
1199
+ #define CHAR_T '\124'
1200
+ #define CHAR_U '\125'
1201
+ #define CHAR_V '\126'
1202
+ #define CHAR_W '\127'
1203
+ #define CHAR_X '\130'
1204
+ #define CHAR_Y '\131'
1205
+ #define CHAR_Z '\132'
1206
+ #define CHAR_LEFT_SQUARE_BRACKET '\133'
1207
+ #define CHAR_BACKSLASH '\134'
1208
+ #define CHAR_RIGHT_SQUARE_BRACKET '\135'
1209
+ #define CHAR_CIRCUMFLEX_ACCENT '\136'
1210
+ #define CHAR_UNDERSCORE '\137'
1211
+ #define CHAR_GRAVE_ACCENT '\140'
1212
+ #define CHAR_a '\141'
1213
+ #define CHAR_b '\142'
1214
+ #define CHAR_c '\143'
1215
+ #define CHAR_d '\144'
1216
+ #define CHAR_e '\145'
1217
+ #define CHAR_f '\146'
1218
+ #define CHAR_g '\147'
1219
+ #define CHAR_h '\150'
1220
+ #define CHAR_i '\151'
1221
+ #define CHAR_j '\152'
1222
+ #define CHAR_k '\153'
1223
+ #define CHAR_l '\154'
1224
+ #define CHAR_m '\155'
1225
+ #define CHAR_n '\156'
1226
+ #define CHAR_o '\157'
1227
+ #define CHAR_p '\160'
1228
+ #define CHAR_q '\161'
1229
+ #define CHAR_r '\162'
1230
+ #define CHAR_s '\163'
1231
+ #define CHAR_t '\164'
1232
+ #define CHAR_u '\165'
1233
+ #define CHAR_v '\166'
1234
+ #define CHAR_w '\167'
1235
+ #define CHAR_x '\170'
1236
+ #define CHAR_y '\171'
1237
+ #define CHAR_z '\172'
1238
+ #define CHAR_LEFT_CURLY_BRACKET '\173'
1239
+ #define CHAR_VERTICAL_LINE '\174'
1240
+ #define CHAR_RIGHT_CURLY_BRACKET '\175'
1241
+ #define CHAR_TILDE '\176'
1242
+ #define CHAR_NBSP ((unsigned char)'\xa0')
1243
+
1244
+ #define STR_HT "\011"
1245
+ #define STR_VT "\013"
1246
+ #define STR_FF "\014"
1247
+ #define STR_CR "\015"
1248
+ #define STR_NL "\012"
1249
+ #define STR_BS "\010"
1250
+ #define STR_BEL "\007"
1251
+ #define STR_ESC "\033"
1252
+ #define STR_DEL "\177"
1253
+
1254
+ #define STR_SPACE "\040"
1255
+ #define STR_EXCLAMATION_MARK "\041"
1256
+ #define STR_QUOTATION_MARK "\042"
1257
+ #define STR_NUMBER_SIGN "\043"
1258
+ #define STR_DOLLAR_SIGN "\044"
1259
+ #define STR_PERCENT_SIGN "\045"
1260
+ #define STR_AMPERSAND "\046"
1261
+ #define STR_APOSTROPHE "\047"
1262
+ #define STR_LEFT_PARENTHESIS "\050"
1263
+ #define STR_RIGHT_PARENTHESIS "\051"
1264
+ #define STR_ASTERISK "\052"
1265
+ #define STR_PLUS "\053"
1266
+ #define STR_COMMA "\054"
1267
+ #define STR_MINUS "\055"
1268
+ #define STR_DOT "\056"
1269
+ #define STR_SLASH "\057"
1270
+ #define STR_0 "\060"
1271
+ #define STR_1 "\061"
1272
+ #define STR_2 "\062"
1273
+ #define STR_3 "\063"
1274
+ #define STR_4 "\064"
1275
+ #define STR_5 "\065"
1276
+ #define STR_6 "\066"
1277
+ #define STR_7 "\067"
1278
+ #define STR_8 "\070"
1279
+ #define STR_9 "\071"
1280
+ #define STR_COLON "\072"
1281
+ #define STR_SEMICOLON "\073"
1282
+ #define STR_LESS_THAN_SIGN "\074"
1283
+ #define STR_EQUALS_SIGN "\075"
1284
+ #define STR_GREATER_THAN_SIGN "\076"
1285
+ #define STR_QUESTION_MARK "\077"
1286
+ #define STR_COMMERCIAL_AT "\100"
1287
+ #define STR_A "\101"
1288
+ #define STR_B "\102"
1289
+ #define STR_C "\103"
1290
+ #define STR_D "\104"
1291
+ #define STR_E "\105"
1292
+ #define STR_F "\106"
1293
+ #define STR_G "\107"
1294
+ #define STR_H "\110"
1295
+ #define STR_I "\111"
1296
+ #define STR_J "\112"
1297
+ #define STR_K "\113"
1298
+ #define STR_L "\114"
1299
+ #define STR_M "\115"
1300
+ #define STR_N "\116"
1301
+ #define STR_O "\117"
1302
+ #define STR_P "\120"
1303
+ #define STR_Q "\121"
1304
+ #define STR_R "\122"
1305
+ #define STR_S "\123"
1306
+ #define STR_T "\124"
1307
+ #define STR_U "\125"
1308
+ #define STR_V "\126"
1309
+ #define STR_W "\127"
1310
+ #define STR_X "\130"
1311
+ #define STR_Y "\131"
1312
+ #define STR_Z "\132"
1313
+ #define STR_LEFT_SQUARE_BRACKET "\133"
1314
+ #define STR_BACKSLASH "\134"
1315
+ #define STR_RIGHT_SQUARE_BRACKET "\135"
1316
+ #define STR_CIRCUMFLEX_ACCENT "\136"
1317
+ #define STR_UNDERSCORE "\137"
1318
+ #define STR_GRAVE_ACCENT "\140"
1319
+ #define STR_a "\141"
1320
+ #define STR_b "\142"
1321
+ #define STR_c "\143"
1322
+ #define STR_d "\144"
1323
+ #define STR_e "\145"
1324
+ #define STR_f "\146"
1325
+ #define STR_g "\147"
1326
+ #define STR_h "\150"
1327
+ #define STR_i "\151"
1328
+ #define STR_j "\152"
1329
+ #define STR_k "\153"
1330
+ #define STR_l "\154"
1331
+ #define STR_m "\155"
1332
+ #define STR_n "\156"
1333
+ #define STR_o "\157"
1334
+ #define STR_p "\160"
1335
+ #define STR_q "\161"
1336
+ #define STR_r "\162"
1337
+ #define STR_s "\163"
1338
+ #define STR_t "\164"
1339
+ #define STR_u "\165"
1340
+ #define STR_v "\166"
1341
+ #define STR_w "\167"
1342
+ #define STR_x "\170"
1343
+ #define STR_y "\171"
1344
+ #define STR_z "\172"
1345
+ #define STR_LEFT_CURLY_BRACKET "\173"
1346
+ #define STR_VERTICAL_LINE "\174"
1347
+ #define STR_RIGHT_CURLY_BRACKET "\175"
1348
+ #define STR_TILDE "\176"
1349
+
1350
+ #endif /* SUPPORT_UNICODE */
1351
+
1352
+
1353
+ #define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"
1354
+ #define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"
1355
+ #define STRING_F0 STR_F "\0"
1356
+ #define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"
1357
+ #define STRING_MARK0 STR_M STR_A STR_R STR_K "\0"
1358
+ #define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"
1359
+ #define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"
1360
+ #define STRING_THEN STR_T STR_H STR_E STR_N
1361
+
1362
+ #define STRING_atomic0 STR_a STR_t STR_o STR_m STR_i STR_c "\0"
1363
+ #define STRING_pla0 STR_p STR_l STR_a "\0"
1364
+ #define STRING_plb0 STR_p STR_l STR_b "\0"
1365
+ #define STRING_napla0 STR_n STR_a STR_p STR_l STR_a "\0"
1366
+ #define STRING_naplb0 STR_n STR_a STR_p STR_l STR_b "\0"
1367
+ #define STRING_nla0 STR_n STR_l STR_a "\0"
1368
+ #define STRING_nlb0 STR_n STR_l STR_b "\0"
1369
+ #define STRING_scs0 STR_s STR_c STR_s "\0"
1370
+ #define STRING_sr0 STR_s STR_r "\0"
1371
+ #define STRING_asr0 STR_a STR_s STR_r "\0"
1372
+ #define STRING_positive_lookahead0 STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_a STR_h STR_e STR_a STR_d "\0"
1373
+ #define STRING_positive_lookbehind0 STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_b STR_e STR_h STR_i STR_n STR_d "\0"
1374
+ #define STRING_non_atomic_positive_lookahead0 STR_n STR_o STR_n STR_UNDERSCORE STR_a STR_t STR_o STR_m STR_i STR_c STR_UNDERSCORE STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_a STR_h STR_e STR_a STR_d "\0"
1375
+ #define STRING_non_atomic_positive_lookbehind0 STR_n STR_o STR_n STR_UNDERSCORE STR_a STR_t STR_o STR_m STR_i STR_c STR_UNDERSCORE STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_b STR_e STR_h STR_i STR_n STR_d "\0"
1376
+ #define STRING_negative_lookahead0 STR_n STR_e STR_g STR_a STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_a STR_h STR_e STR_a STR_d "\0"
1377
+ #define STRING_negative_lookbehind0 STR_n STR_e STR_g STR_a STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_b STR_e STR_h STR_i STR_n STR_d "\0"
1378
+ #define STRING_script_run0 STR_s STR_c STR_r STR_i STR_p STR_t STR_UNDERSCORE STR_r STR_u STR_n "\0"
1379
+ #define STRING_atomic_script_run STR_a STR_t STR_o STR_m STR_i STR_c STR_UNDERSCORE STR_s STR_c STR_r STR_i STR_p STR_t STR_UNDERSCORE STR_r STR_u STR_n
1380
+ #define STRING_scan_substring0 STR_s STR_c STR_a STR_n STR_UNDERSCORE STR_s STR_u STR_b STR_s STR_t STR_r STR_i STR_n STR_g "\0"
1381
+
1382
+ #define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"
1383
+ #define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"
1384
+ #define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"
1385
+ #define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"
1386
+ #define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"
1387
+ #define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"
1388
+ #define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"
1389
+ #define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"
1390
+ #define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"
1391
+ #define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"
1392
+ #define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"
1393
+ #define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"
1394
+ #define STRING_word0 STR_w STR_o STR_r STR_d "\0"
1395
+ #define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t
1396
+
1397
+ #define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E
1398
+ #define STRING_VERSION STR_V STR_E STR_R STR_S STR_I STR_O STR_N
1399
+ #define STRING_WEIRD_STARTWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_LESS_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET
1400
+ #define STRING_WEIRD_ENDWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_GREATER_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET
1401
+
1402
+ #define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS
1403
+ #define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS
1404
+ #define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
1405
+ #define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS
1406
+ #define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
1407
+ #define STRING_NUL_RIGHTPAR STR_N STR_U STR_L STR_RIGHT_PARENTHESIS
1408
+ #define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
1409
+ #define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
1410
+ #define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
1411
+ #define STRING_UTF16_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS
1412
+ #define STRING_UTF32_RIGHTPAR STR_U STR_T STR_F STR_3 STR_2 STR_RIGHT_PARENTHESIS
1413
+ #define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_RIGHT_PARENTHESIS
1414
+ #define STRING_UCP_RIGHTPAR STR_U STR_C STR_P STR_RIGHT_PARENTHESIS
1415
+ #define STRING_NO_AUTO_POSSESS_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_A STR_U STR_T STR_O STR_UNDERSCORE STR_P STR_O STR_S STR_S STR_E STR_S STR_S STR_RIGHT_PARENTHESIS
1416
+ #define STRING_NO_DOTSTAR_ANCHOR_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_D STR_O STR_T STR_S STR_T STR_A STR_R STR_UNDERSCORE STR_A STR_N STR_C STR_H STR_O STR_R STR_RIGHT_PARENTHESIS
1417
+ #define STRING_NO_JIT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_J STR_I STR_T STR_RIGHT_PARENTHESIS
1418
+ #define STRING_NO_START_OPT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_S STR_T STR_A STR_R STR_T STR_UNDERSCORE STR_O STR_P STR_T STR_RIGHT_PARENTHESIS
1419
+ #define STRING_NOTEMPTY_RIGHTPAR STR_N STR_O STR_T STR_E STR_M STR_P STR_T STR_Y STR_RIGHT_PARENTHESIS
1420
+ #define STRING_NOTEMPTY_ATSTART_RIGHTPAR STR_N STR_O STR_T STR_E STR_M STR_P STR_T STR_Y STR_UNDERSCORE STR_A STR_T STR_S STR_T STR_A STR_R STR_T STR_RIGHT_PARENTHESIS
1421
+ #define STRING_CASELESS_RESTRICT_RIGHTPAR STR_C STR_A STR_S STR_E STR_L STR_E STR_S STR_S STR_UNDERSCORE STR_R STR_E STR_S STR_T STR_R STR_I STR_C STR_T STR_RIGHT_PARENTHESIS
1422
+ #define STRING_TURKISH_CASING_RIGHTPAR STR_T STR_U STR_R STR_K STR_I STR_S STR_H STR_UNDERSCORE STR_C STR_A STR_S STR_I STR_N STR_G STR_RIGHT_PARENTHESIS
1423
+ #define STRING_LIMIT_HEAP_EQ STR_L STR_I STR_M STR_I STR_T STR_UNDERSCORE STR_H STR_E STR_A STR_P STR_EQUALS_SIGN
1424
+ #define STRING_LIMIT_MATCH_EQ STR_L STR_I STR_M STR_I STR_T STR_UNDERSCORE STR_M STR_A STR_T STR_C STR_H STR_EQUALS_SIGN
1425
+ #define STRING_LIMIT_DEPTH_EQ STR_L STR_I STR_M STR_I STR_T STR_UNDERSCORE STR_D STR_E STR_P STR_T STR_H STR_EQUALS_SIGN
1426
+ #define STRING_LIMIT_RECURSION_EQ STR_L STR_I STR_M STR_I STR_T STR_UNDERSCORE STR_R STR_E STR_C STR_U STR_R STR_S STR_I STR_O STR_N STR_EQUALS_SIGN
1427
+ #define STRING_MARK STR_M STR_A STR_R STR_K
1428
+
1429
+ #define STRING_bc STR_b STR_c
1430
+ #define STRING_bidiclass STR_b STR_i STR_d STR_i STR_c STR_l STR_a STR_s STR_s
1431
+ #define STRING_sc STR_s STR_c
1432
+ #define STRING_script STR_s STR_c STR_r STR_i STR_p STR_t
1433
+ #define STRING_scriptextensions STR_s STR_c STR_r STR_i STR_p STR_t STR_e STR_x STR_t STR_e STR_n STR_s STR_i STR_o STR_n STR_s
1434
+ #define STRING_scx STR_s STR_c STR_x
1435
+
1436
+
1437
+ /* -------------------- End of character and string names -------------------*/
1438
+
1439
+ /* -------------------- Definitions for compiled patterns -------------------*/
1440
+
1441
+ /* Codes for different types of Unicode property. If these definitions are
1442
+ changed, the autopossessifying table in pcre2_auto_possess.c must be updated to
1443
+ match. */
1444
+
1445
+ #define PT_LAMP 0 /* L& - the union of Lu, Ll, Lt */
1446
+ #define PT_GC 1 /* Specified general characteristic (e.g. L) */
1447
+ #define PT_PC 2 /* Specified particular characteristic (e.g. Lu) */
1448
+ #define PT_SC 3 /* Script only (e.g. Han) */
1449
+ #define PT_SCX 4 /* Script extensions (includes SC) */
1450
+ #define PT_ALNUM 5 /* Alphanumeric - the union of L and N */
1451
+ #define PT_SPACE 6 /* Perl space - general category Z plus 9,10,12,13 */
1452
+ #define PT_PXSPACE 7 /* POSIX space - Z plus 9,10,11,12,13 */
1453
+ #define PT_WORD 8 /* Word - L, N, Mn, or Pc */
1454
+ #define PT_CLIST 9 /* Pseudo-property: match character list */
1455
+ #define PT_UCNC 10 /* Universal Character nameable character */
1456
+ #define PT_BIDICL 11 /* Specified bidi class */
1457
+ #define PT_BOOL 12 /* Boolean property */
1458
+ #define PT_ANY 13 /* Must be the last entry!
1459
+ Any property - matches all chars */
1460
+ #define PT_TABSIZE PT_ANY /* Size of square table for autopossessify tests */
1461
+
1462
+ /* The following special properties are used only in XCLASS items, when POSIX
1463
+ classes are specified and PCRE2_UCP is set - in other words, for Unicode
1464
+ handling of these classes. They are not available via the \p or \P escapes like
1465
+ those in the above list, and so they do not take part in the autopossessifying
1466
+ table. */
1467
+
1468
+ #define PT_PXGRAPH 14 /* [:graph:] - characters that mark the paper */
1469
+ #define PT_PXPRINT 15 /* [:print:] - [:graph:] plus non-control spaces */
1470
+ #define PT_PXPUNCT 16 /* [:punct:] - punctuation characters */
1471
+ #define PT_PXXDIGIT 17 /* [:xdigit:] - hex digits */
1472
+
1473
+ /* This value is used when parsing \p and \P escapes to indicate that neither
1474
+ \p{script:...} nor \p{scx:...} has been encountered. */
1475
+
1476
+ #define PT_NOTSCRIPT 255
1477
+
1478
+ /* Flag bits and data types for the extended class (OP_XCLASS) for classes that
1479
+ contain characters with values greater than 255. */
1480
+
1481
+ #define XCL_NOT 0x01 /* Flag: this is a negative class */
1482
+ #define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
1483
+ #define XCL_HASPROP 0x04 /* Flag: property checks are present. */
1484
+
1485
+ #define XCL_END 0 /* Marks end of individual items */
1486
+ #define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
1487
+ #define XCL_RANGE 2 /* A range (two multibyte chars) follows */
1488
+ #define XCL_PROP 3 /* Unicode property (2-byte property code follows) */
1489
+ #define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
1490
+ /* This value represents the beginning of character lists. The value
1491
+ is 16 bit long, and stored as a high and low byte pair in 8 bit mode.
1492
+ The lower 12 bit contains information about character lists (see later). */
1493
+ #define XCL_LIST (sizeof(PCRE2_UCHAR) == 1 ? 0x10 : 0x1000)
1494
+
1495
+ /* When a character class contains many characters/ranges,
1496
+ they are stored in character lists. There are four character
1497
+ lists which contain characters/ranges within a given range.
1498
+
1499
+ The name, character range and item size for each list:
1500
+ Low16 [0x100 - 0x7fff] 16 bit items
1501
+ High16 [0x8000 - 0xffff] 16 bit items
1502
+ Low32 [0x10000 - 0x7fffffff] 32 bit items
1503
+ High32 [0x80000000 - 0xffffffff] 32 bit items
1504
+
1505
+ The Low32 character list is used only when utf encoding or 32 bit
1506
+ character width is enabled, and the High32 character is used only
1507
+ when 32 bit character width is enabled.
1508
+
1509
+ Each character list contain items. The lowest bit represents that
1510
+ an item is the beginning of a range (bit is cleared), or not (bit
1511
+ is set). The other bits represent the character shifted left by
1512
+ one, so its highest bit is discarded. Due to the layout of character
1513
+ lists, the highest bit of a character is always known:
1514
+
1515
+ Low16 and Low32: the highest bit is always zero
1516
+ High16 and High32: the highest bit is always one
1517
+
1518
+ The items are ordered in increasing order, so binary search can be
1519
+ used to find the lower bound of an input character. The lower bound
1520
+ is the highest item, which value is less or equal than the input
1521
+ character. If the lower bit of the item is cleard, or the character
1522
+ stored in the item equals to the input character, the input
1523
+ character is in the character list. */
1524
+
1525
+ /* Character list constants. */
1526
+ #define XCL_CHAR_LIST_LOW_16_START 0x100
1527
+ #define XCL_CHAR_LIST_LOW_16_END 0x7fff
1528
+ #define XCL_CHAR_LIST_LOW_16_ADD 0x0
1529
+
1530
+ #define XCL_CHAR_LIST_HIGH_16_START 0x8000
1531
+ #define XCL_CHAR_LIST_HIGH_16_END 0xffff
1532
+ #define XCL_CHAR_LIST_HIGH_16_ADD 0x8000
1533
+
1534
+ #define XCL_CHAR_LIST_LOW_32_START 0x10000
1535
+ #define XCL_CHAR_LIST_LOW_32_END 0x7fffffff
1536
+ #define XCL_CHAR_LIST_LOW_32_ADD 0x0
1537
+
1538
+ #define XCL_CHAR_LIST_HIGH_32_START 0x80000000
1539
+ #define XCL_CHAR_LIST_HIGH_32_END 0xffffffff
1540
+ #define XCL_CHAR_LIST_HIGH_32_ADD 0x80000000
1541
+
1542
+ /* Mask for getting the descriptors of character list ranges.
1543
+ Each descriptor has XCL_TYPE_BIT_LEN bits, and can be processed
1544
+ by XCL_BEGIN_WITH_RANGE and XCL_ITEM_COUNT_MASK macros. */
1545
+ #define XCL_TYPE_MASK 0xfff
1546
+ #define XCL_TYPE_BIT_LEN 3
1547
+ /* If this bit is set, the first item of the character list is the
1548
+ end of a range, which started before the starting character of the
1549
+ character list. */
1550
+ #define XCL_BEGIN_WITH_RANGE 0x4
1551
+ /* Number of items in the character list: 0, 1, or 2. The value 3
1552
+ represents that the item count is stored at the begining of the
1553
+ character list. The item count has the same width as the items
1554
+ in the character list (e.g. 16 bit for Low16 and High16 lists). */
1555
+ #define XCL_ITEM_COUNT_MASK 0x3
1556
+ /* Shift and flag for constructing character list items. The XCL_CHAR_END
1557
+ is set, when the item is not the beginning of a range. The XCL_CHAR_SHIFT
1558
+ can be used to encode / decode the character value stored in an item. */
1559
+ #define XCL_CHAR_END 0x1
1560
+ #define XCL_CHAR_SHIFT 1
1561
+
1562
+ /* Flag bits for an extended class (OP_ECLASS), which is used for complex
1563
+ character matches such as [\p{Greek} && \p{Ll}]. */
1564
+
1565
+ #define ECL_MAP 0x01 /* Flag: a 32-byte map is present */
1566
+
1567
+ /* Type tags for the items stored in an extended class (OP_ECLASS). These items
1568
+ follow the OP_ECLASS's flag char and bitmap, and represent a Reverse Polish
1569
+ Notation list of operands and operators manipulating a stack of bits. */
1570
+
1571
+ #define ECL_AND 1 /* Pop two from the stack, AND, and push result. */
1572
+ #define ECL_OR 2 /* Pop two from the stack, OR, and push result. */
1573
+ #define ECL_XOR 3 /* Pop two from the stack, XOR, and push result. */
1574
+ #define ECL_NOT 4 /* Pop one from the stack, NOT, and push result. */
1575
+ #define ECL_XCLASS 5 /* XCLASS nested within ECLASS; match and push result. */
1576
+ #define ECL_ANY 6 /* Temporary, only used during compilation. */
1577
+ #define ECL_NONE 7 /* Temporary, only used during compilation. */
1578
+
1579
+ /* These are escaped items that aren't just an encoding of a particular data
1580
+ value such as \n. They must have non-zero values, as check_escape() returns 0
1581
+ for a data character. In the escapes[] table in pcre2_compile.c their values
1582
+ are negated in order to distinguish them from data values.
1583
+
1584
+ They must appear here in the same order as in the opcode definitions below, up
1585
+ to ESC_z. There's a dummy for OP_ALLANY because it corresponds to "." in DOTALL
1586
+ mode rather than an escape sequence. It is also used for [^] in JavaScript
1587
+ compatibility mode, and for \C in non-utf mode. In non-DOTALL mode, "." behaves
1588
+ like \N.
1589
+
1590
+ ESC_ub is a special return from check_escape() when, in BSUX mode, \u{ is not
1591
+ followed by hex digits and }, in which case it should mean a literal "u"
1592
+ followed by a literal "{". This hack is necessary for cases like \u{ 12}
1593
+ because without it, this is interpreted as u{12} now that spaces are allowed in
1594
+ quantifiers.
1595
+
1596
+ Negative numbers are used to encode a backreference (\1, \2, \3, etc.) in
1597
+ check_escape(). There are tests in the code for an escape greater than ESC_b
1598
+ and less than ESC_Z to detect the types that may be repeated. These are the
1599
+ types that consume characters. If any new escapes are put in between that don't
1600
+ consume a character, that code will have to change. */
1601
+
1602
+ enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
1603
+ ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
1604
+ ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,
1605
+ ESC_E, ESC_Q, ESC_g, ESC_k, ESC_ub };
1606
+
1607
+
1608
+ /********************** Opcode definitions ******************/
1609
+
1610
+ /****** NOTE NOTE NOTE ******
1611
+
1612
+ Starting from 1 (i.e. after OP_END), the values up to OP_EOD must correspond in
1613
+ order to the list of escapes immediately above. Furthermore, values up to
1614
+ OP_DOLLM must not be changed without adjusting the table called autoposstab in
1615
+ pcre2_auto_possess.c.
1616
+
1617
+ Whenever this list is updated, the two macro definitions that follow must be
1618
+ updated to match. The possessification table called "opcode_possessify" in
1619
+ pcre2_compile.c must also be updated, and also the tables called "coptable"
1620
+ and "poptable" in pcre2_dfa_match.c.
1621
+
1622
+ ****** NOTE NOTE NOTE ******/
1623
+
1624
+
1625
+ /* The values between FIRST_AUTOTAB_OP and LAST_AUTOTAB_RIGHT_OP, inclusive,
1626
+ are used in a table for deciding whether a repeated character type can be
1627
+ auto-possessified. */
1628
+
1629
+ #define FIRST_AUTOTAB_OP OP_NOT_DIGIT
1630
+ #define LAST_AUTOTAB_LEFT_OP OP_EXTUNI
1631
+ #define LAST_AUTOTAB_RIGHT_OP OP_DOLLM
1632
+
1633
+ enum {
1634
+ OP_END, /* 0 End of pattern */
1635
+
1636
+ /* Values corresponding to backslashed metacharacters */
1637
+
1638
+ OP_SOD, /* 1 Start of data: \A */
1639
+ OP_SOM, /* 2 Start of match (subject + offset): \G */
1640
+ OP_SET_SOM, /* 3 Set start of match (\K) */
1641
+ OP_NOT_WORD_BOUNDARY, /* 4 \B -- see also OP_NOT_UCP_WORD_BOUNDARY */
1642
+ OP_WORD_BOUNDARY, /* 5 \b -- see also OP_UCP_WORD_BOUNDARY */
1643
+ OP_NOT_DIGIT, /* 6 \D */
1644
+ OP_DIGIT, /* 7 \d */
1645
+ OP_NOT_WHITESPACE, /* 8 \S */
1646
+ OP_WHITESPACE, /* 9 \s */
1647
+ OP_NOT_WORDCHAR, /* 10 \W */
1648
+ OP_WORDCHAR, /* 11 \w */
1649
+
1650
+ OP_ANY, /* 12 Match any character except newline (\N) */
1651
+ OP_ALLANY, /* 13 Match any character */
1652
+ OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
1653
+ OP_NOTPROP, /* 15 \P (not Unicode property) */
1654
+ OP_PROP, /* 16 \p (Unicode property) */
1655
+ OP_ANYNL, /* 17 \R (any newline sequence) */
1656
+ OP_NOT_HSPACE, /* 18 \H (not horizontal whitespace) */
1657
+ OP_HSPACE, /* 19 \h (horizontal whitespace) */
1658
+ OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */
1659
+ OP_VSPACE, /* 21 \v (vertical whitespace) */
1660
+ OP_EXTUNI, /* 22 \X (extended Unicode sequence */
1661
+ OP_EODN, /* 23 End of data or \n at end of data (\Z) */
1662
+ OP_EOD, /* 24 End of data (\z) */
1663
+
1664
+ /* Line end assertions */
1665
+
1666
+ OP_DOLL, /* 25 End of line - not multiline */
1667
+ OP_DOLLM, /* 26 End of line - multiline */
1668
+ OP_CIRC, /* 27 Start of line - not multiline */
1669
+ OP_CIRCM, /* 28 Start of line - multiline */
1670
+
1671
+ /* Single characters; caseful must precede the caseless ones, and these
1672
+ must remain in this order, and adjacent. */
1673
+
1674
+ OP_CHAR, /* 29 Match one character, casefully */
1675
+ OP_CHARI, /* 30 Match one character, caselessly */
1676
+ OP_NOT, /* 31 Match one character, not the given one, casefully */
1677
+ OP_NOTI, /* 32 Match one character, not the given one, caselessly */
1678
+
1679
+ /* The following sets of 13 opcodes must always be kept in step because
1680
+ the offset from the first one is used to generate the others. */
1681
+
1682
+ /* Repeated characters; caseful must precede the caseless ones */
1683
+
1684
+ OP_STAR, /* 33 The maximizing and minimizing versions of */
1685
+ OP_MINSTAR, /* 34 these six opcodes must come in pairs, with */
1686
+ OP_PLUS, /* 35 the minimizing one second. */
1687
+ OP_MINPLUS, /* 36 */
1688
+ OP_QUERY, /* 37 */
1689
+ OP_MINQUERY, /* 38 */
1690
+
1691
+ OP_UPTO, /* 39 From 0 to n matches of one character, caseful*/
1692
+ OP_MINUPTO, /* 40 */
1693
+ OP_EXACT, /* 41 Exactly n matches */
1694
+
1695
+ OP_POSSTAR, /* 42 Possessified star, caseful */
1696
+ OP_POSPLUS, /* 43 Possessified plus, caseful */
1697
+ OP_POSQUERY, /* 44 Posesssified query, caseful */
1698
+ OP_POSUPTO, /* 45 Possessified upto, caseful */
1699
+
1700
+ /* Repeated characters; caseless must follow the caseful ones */
1701
+
1702
+ OP_STARI, /* 46 */
1703
+ OP_MINSTARI, /* 47 */
1704
+ OP_PLUSI, /* 48 */
1705
+ OP_MINPLUSI, /* 49 */
1706
+ OP_QUERYI, /* 50 */
1707
+ OP_MINQUERYI, /* 51 */
1708
+
1709
+ OP_UPTOI, /* 52 From 0 to n matches of one character, caseless */
1710
+ OP_MINUPTOI, /* 53 */
1711
+ OP_EXACTI, /* 54 */
1712
+
1713
+ OP_POSSTARI, /* 55 Possessified star, caseless */
1714
+ OP_POSPLUSI, /* 56 Possessified plus, caseless */
1715
+ OP_POSQUERYI, /* 57 Posesssified query, caseless */
1716
+ OP_POSUPTOI, /* 58 Possessified upto, caseless */
1717
+
1718
+ /* The negated ones must follow the non-negated ones, and match them */
1719
+ /* Negated repeated character, caseful; must precede the caseless ones */
1720
+
1721
+ OP_NOTSTAR, /* 59 The maximizing and minimizing versions of */
1722
+ OP_NOTMINSTAR, /* 60 these six opcodes must come in pairs, with */
1723
+ OP_NOTPLUS, /* 61 the minimizing one second. They must be in */
1724
+ OP_NOTMINPLUS, /* 62 exactly the same order as those above. */
1725
+ OP_NOTQUERY, /* 63 */
1726
+ OP_NOTMINQUERY, /* 64 */
1727
+
1728
+ OP_NOTUPTO, /* 65 From 0 to n matches, caseful */
1729
+ OP_NOTMINUPTO, /* 66 */
1730
+ OP_NOTEXACT, /* 67 Exactly n matches */
1731
+
1732
+ OP_NOTPOSSTAR, /* 68 Possessified versions, caseful */
1733
+ OP_NOTPOSPLUS, /* 69 */
1734
+ OP_NOTPOSQUERY, /* 70 */
1735
+ OP_NOTPOSUPTO, /* 71 */
1736
+
1737
+ /* Negated repeated character, caseless; must follow the caseful ones */
1738
+
1739
+ OP_NOTSTARI, /* 72 */
1740
+ OP_NOTMINSTARI, /* 73 */
1741
+ OP_NOTPLUSI, /* 74 */
1742
+ OP_NOTMINPLUSI, /* 75 */
1743
+ OP_NOTQUERYI, /* 76 */
1744
+ OP_NOTMINQUERYI, /* 77 */
1745
+
1746
+ OP_NOTUPTOI, /* 78 From 0 to n matches, caseless */
1747
+ OP_NOTMINUPTOI, /* 79 */
1748
+ OP_NOTEXACTI, /* 80 Exactly n matches */
1749
+
1750
+ OP_NOTPOSSTARI, /* 81 Possessified versions, caseless */
1751
+ OP_NOTPOSPLUSI, /* 82 */
1752
+ OP_NOTPOSQUERYI, /* 83 */
1753
+ OP_NOTPOSUPTOI, /* 84 */
1754
+
1755
+ /* Character types */
1756
+
1757
+ OP_TYPESTAR, /* 85 The maximizing and minimizing versions of */
1758
+ OP_TYPEMINSTAR, /* 86 these six opcodes must come in pairs, with */
1759
+ OP_TYPEPLUS, /* 87 the minimizing one second. These codes must */
1760
+ OP_TYPEMINPLUS, /* 88 be in exactly the same order as those above. */
1761
+ OP_TYPEQUERY, /* 89 */
1762
+ OP_TYPEMINQUERY, /* 90 */
1763
+
1764
+ OP_TYPEUPTO, /* 91 From 0 to n matches */
1765
+ OP_TYPEMINUPTO, /* 92 */
1766
+ OP_TYPEEXACT, /* 93 Exactly n matches */
1767
+
1768
+ OP_TYPEPOSSTAR, /* 94 Possessified versions */
1769
+ OP_TYPEPOSPLUS, /* 95 */
1770
+ OP_TYPEPOSQUERY, /* 96 */
1771
+ OP_TYPEPOSUPTO, /* 97 */
1772
+
1773
+ /* These are used for character classes and back references; only the
1774
+ first six are the same as the sets above. */
1775
+
1776
+ OP_CRSTAR, /* 98 The maximizing and minimizing versions of */
1777
+ OP_CRMINSTAR, /* 99 all these opcodes must come in pairs, with */
1778
+ OP_CRPLUS, /* 100 the minimizing one second. These codes must */
1779
+ OP_CRMINPLUS, /* 101 be in exactly the same order as those above. */
1780
+ OP_CRQUERY, /* 102 */
1781
+ OP_CRMINQUERY, /* 103 */
1782
+
1783
+ OP_CRRANGE, /* 104 These are different to the three sets above. */
1784
+ OP_CRMINRANGE, /* 105 */
1785
+
1786
+ OP_CRPOSSTAR, /* 106 Possessified versions */
1787
+ OP_CRPOSPLUS, /* 107 */
1788
+ OP_CRPOSQUERY, /* 108 */
1789
+ OP_CRPOSRANGE, /* 109 */
1790
+
1791
+ /* End of quantifier opcodes */
1792
+
1793
+ OP_CLASS, /* 110 Match a character class, chars < 256 only */
1794
+ OP_NCLASS, /* 111 Same, but the bitmap was created from a negative
1795
+ class - the difference is relevant only when a
1796
+ character > 255 is encountered. */
1797
+ OP_XCLASS, /* 112 Extended class for handling > 255 chars within the
1798
+ class. This does both positive and negative. */
1799
+ OP_ECLASS, /* 113 Really-extended class, for handling logical
1800
+ expressions computed over characters. */
1801
+ OP_REF, /* 114 Match a back reference, casefully */
1802
+ OP_REFI, /* 115 Match a back reference, caselessly */
1803
+ OP_DNREF, /* 116 Match a duplicate name backref, casefully */
1804
+ OP_DNREFI, /* 117 Match a duplicate name backref, caselessly */
1805
+ OP_RECURSE, /* 118 Match a numbered subpattern (possibly recursive) */
1806
+ OP_CALLOUT, /* 119 Call out to external function if provided */
1807
+ OP_CALLOUT_STR, /* 120 Call out with string argument */
1808
+
1809
+ OP_ALT, /* 121 Start of alternation */
1810
+ OP_KET, /* 122 End of group that doesn't have an unbounded repeat */
1811
+ OP_KETRMAX, /* 123 These two must remain together and in this */
1812
+ OP_KETRMIN, /* 124 order. They are for groups the repeat for ever. */
1813
+ OP_KETRPOS, /* 125 Possessive unlimited repeat. */
1814
+
1815
+ /* The assertions must come before BRA, CBRA, ONCE, and COND. */
1816
+
1817
+ OP_REVERSE, /* 126 Move pointer back - used in lookbehind assertions */
1818
+ OP_VREVERSE, /* 127 Move pointer back - variable */
1819
+ OP_ASSERT, /* 128 Positive lookahead */
1820
+ OP_ASSERT_NOT, /* 129 Negative lookahead */
1821
+ OP_ASSERTBACK, /* 130 Positive lookbehind */
1822
+ OP_ASSERTBACK_NOT, /* 131 Negative lookbehind */
1823
+ OP_ASSERT_NA, /* 132 Positive non-atomic lookahead */
1824
+ OP_ASSERTBACK_NA, /* 133 Positive non-atomic lookbehind */
1825
+ OP_ASSERT_SCS, /* 134 Scan substring */
1826
+
1827
+ /* ONCE, SCRIPT_RUN, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come
1828
+ immediately after the assertions, with ONCE first, as there's a test for >=
1829
+ ONCE for a subpattern that isn't an assertion. The POS versions must
1830
+ immediately follow the non-POS versions in each case. */
1831
+
1832
+ OP_ONCE, /* 135 Atomic group, contains captures */
1833
+ OP_SCRIPT_RUN, /* 136 Non-capture, but check characters' scripts */
1834
+ OP_BRA, /* 137 Start of non-capturing bracket */
1835
+ OP_BRAPOS, /* 138 Ditto, with unlimited, possessive repeat */
1836
+ OP_CBRA, /* 139 Start of capturing bracket */
1837
+ OP_CBRAPOS, /* 140 Ditto, with unlimited, possessive repeat */
1838
+ OP_COND, /* 141 Conditional group */
1839
+
1840
+ /* These five must follow the previous five, in the same order. There's a
1841
+ check for >= SBRA to distinguish the two sets. */
1842
+
1843
+ OP_SBRA, /* 142 Start of non-capturing bracket, check empty */
1844
+ OP_SBRAPOS, /* 143 Ditto, with unlimited, possessive repeat */
1845
+ OP_SCBRA, /* 144 Start of capturing bracket, check empty */
1846
+ OP_SCBRAPOS, /* 145 Ditto, with unlimited, possessive repeat */
1847
+ OP_SCOND, /* 146 Conditional group, check empty */
1848
+
1849
+ /* The next two pairs must (respectively) be kept together. */
1850
+
1851
+ OP_CREF, /* 147 Used to hold a capture number as condition */
1852
+ OP_DNCREF, /* 148 Used to point to duplicate names as a condition */
1853
+ OP_RREF, /* 149 Used to hold a recursion number as condition */
1854
+ OP_DNRREF, /* 150 Used to point to duplicate names as a condition */
1855
+ OP_FALSE, /* 151 Always false (used by DEFINE and VERSION) */
1856
+ OP_TRUE, /* 152 Always true (used by VERSION) */
1857
+
1858
+ OP_BRAZERO, /* 153 These two must remain together and in this */
1859
+ OP_BRAMINZERO, /* 154 order. */
1860
+ OP_BRAPOSZERO, /* 155 */
1861
+
1862
+ /* These are backtracking control verbs */
1863
+
1864
+ OP_MARK, /* 156 always has an argument */
1865
+ OP_PRUNE, /* 157 */
1866
+ OP_PRUNE_ARG, /* 158 same, but with argument */
1867
+ OP_SKIP, /* 159 */
1868
+ OP_SKIP_ARG, /* 160 same, but with argument */
1869
+ OP_THEN, /* 161 */
1870
+ OP_THEN_ARG, /* 162 same, but with argument */
1871
+ OP_COMMIT, /* 163 */
1872
+ OP_COMMIT_ARG, /* 164 same, but with argument */
1873
+
1874
+ /* These are forced failure and success verbs. FAIL and ACCEPT do accept an
1875
+ argument, but these cases can be compiled as, for example, (*MARK:X)(*FAIL)
1876
+ without the need for a special opcode. */
1877
+
1878
+ OP_FAIL, /* 165 */
1879
+ OP_ACCEPT, /* 166 */
1880
+ OP_ASSERT_ACCEPT, /* 167 Used inside assertions */
1881
+ OP_CLOSE, /* 168 Used before OP_ACCEPT to close open captures */
1882
+
1883
+ /* This is used to skip a subpattern with a {0} quantifier */
1884
+
1885
+ OP_SKIPZERO, /* 169 */
1886
+
1887
+ /* This is used to identify a DEFINE group during compilation so that it can
1888
+ be checked for having only one branch. It is changed to OP_FALSE before
1889
+ compilation finishes. */
1890
+
1891
+ OP_DEFINE, /* 170 */
1892
+
1893
+ /* These opcodes replace their normal counterparts in UCP mode when
1894
+ PCRE2_EXTRA_ASCII_BSW is not set. */
1895
+
1896
+ OP_NOT_UCP_WORD_BOUNDARY, /* 171 */
1897
+ OP_UCP_WORD_BOUNDARY, /* 172 */
1898
+
1899
+ /* This is not an opcode, but is used to check that tables indexed by opcode
1900
+ are the correct length, in order to catch updating errors - there have been
1901
+ some in the past. */
1902
+
1903
+ OP_TABLE_LENGTH
1904
+
1905
+ };
1906
+
1907
+ /* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro
1908
+ definitions that follow must also be updated to match. There are also tables
1909
+ called "opcode_possessify" in pcre2_compile.c and "coptable" and "poptable" in
1910
+ pcre2_dfa_match.c that must be updated. */
1911
+
1912
+
1913
+ /* This macro defines textual names for all the opcodes. These are used only
1914
+ for debugging, and some of them are only partial names. The macro is referenced
1915
+ only in pcre2_printint_inc.h, which fills out the full names in many cases (and in
1916
+ some cases doesn't actually use these names at all). */
1917
+
1918
+ #define OP_NAME_LIST \
1919
+ "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \
1920
+ "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte", \
1921
+ "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \
1922
+ "extuni", "\\Z", "\\z", \
1923
+ "$", "$", "^", "^", "char", "chari", "not", "noti", \
1924
+ "*", "*?", "+", "+?", "?", "??", \
1925
+ "{", "{", "{", \
1926
+ "*+","++", "?+", "{", \
1927
+ "*", "*?", "+", "+?", "?", "??", \
1928
+ "{", "{", "{", \
1929
+ "*+","++", "?+", "{", \
1930
+ "*", "*?", "+", "+?", "?", "??", \
1931
+ "{", "{", "{", \
1932
+ "*+","++", "?+", "{", \
1933
+ "*", "*?", "+", "+?", "?", "??", \
1934
+ "{", "{", "{", \
1935
+ "*+","++", "?+", "{", \
1936
+ "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
1937
+ "*+","++", "?+", "{", \
1938
+ "*", "*?", "+", "+?", "?", "??", "{", "{", \
1939
+ "*+","++", "?+", "{", \
1940
+ "class", "nclass", "xclass", "eclass", \
1941
+ "Ref", "Refi", "DnRef", "DnRefi", \
1942
+ "Recurse", "Callout", "CalloutStr", \
1943
+ "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos", \
1944
+ "Reverse", "VReverse", "Assert", "Assert not", \
1945
+ "Assert back", "Assert back not", \
1946
+ "Non-atomic assert", "Non-atomic assert back", \
1947
+ "Scan substring", \
1948
+ "Once", \
1949
+ "Script run", \
1950
+ "Bra", "BraPos", "CBra", "CBraPos", \
1951
+ "Cond", \
1952
+ "SBra", "SBraPos", "SCBra", "SCBraPos", \
1953
+ "SCond", \
1954
+ "Capture ref", "Capture dnref", "Cond rec", "Cond dnrec", \
1955
+ "Cond false", "Cond true", \
1956
+ "Brazero", "Braminzero", "Braposzero", \
1957
+ "*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP", \
1958
+ "*THEN", "*THEN", "*COMMIT", "*COMMIT", "*FAIL", \
1959
+ "*ACCEPT", "*ASSERT_ACCEPT", \
1960
+ "Close", "Skip zero", "Define", "\\B (ucp)", "\\b (ucp)"
1961
+
1962
+
1963
+ /* This macro defines the length of fixed length operations in the compiled
1964
+ regex. The lengths are used when searching for specific things, and also in the
1965
+ debugging printing of a compiled regex. We use a macro so that it can be
1966
+ defined close to the definitions of the opcodes themselves.
1967
+
1968
+ As things have been extended, some of these are no longer fixed lenths, but are
1969
+ minima instead. For example, the length of a single-character repeat may vary
1970
+ in UTF-8 mode. The code that uses this table must know about such things. */
1971
+
1972
+ #define OP_LENGTHS \
1973
+ 1, /* End */ \
1974
+ 1, 1, 1, 1, 1, /* \A, \G, \K, \B, \b */ \
1975
+ 1, 1, 1, 1, 1, 1, /* \D, \d, \S, \s, \W, \w */ \
1976
+ 1, 1, 1, /* Any, AllAny, Anybyte */ \
1977
+ 3, 3, /* \P, \p */ \
1978
+ 1, 1, 1, 1, 1, /* \R, \H, \h, \V, \v */ \
1979
+ 1, /* \X */ \
1980
+ 1, 1, 1, 1, 1, 1, /* \Z, \z, $, $M ^, ^M */ \
1981
+ 2, /* Char - the minimum length */ \
1982
+ 2, /* Chari - the minimum length */ \
1983
+ 2, /* not */ \
1984
+ 2, /* noti */ \
1985
+ /* Positive single-char repeats ** These are */ \
1986
+ 2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \
1987
+ 2+IMM2_SIZE, 2+IMM2_SIZE, /* upto, minupto ** mode */ \
1988
+ 2+IMM2_SIZE, /* exact */ \
1989
+ 2, 2, 2, 2+IMM2_SIZE, /* *+, ++, ?+, upto+ */ \
1990
+ 2, 2, 2, 2, 2, 2, /* *I, *?I, +I, +?I, ?I, ??I ** UTF-8 */ \
1991
+ 2+IMM2_SIZE, 2+IMM2_SIZE, /* upto I, minupto I */ \
1992
+ 2+IMM2_SIZE, /* exact I */ \
1993
+ 2, 2, 2, 2+IMM2_SIZE, /* *+I, ++I, ?+I, upto+I */ \
1994
+ /* Negative single-char repeats - only for chars < 256 */ \
1995
+ 2, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \
1996
+ 2+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto, minupto */ \
1997
+ 2+IMM2_SIZE, /* NOT exact */ \
1998
+ 2, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *, +, ?, upto */ \
1999
+ 2, 2, 2, 2, 2, 2, /* NOT *I, *?I, +I, +?I, ?I, ??I */ \
2000
+ 2+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto I, minupto I */ \
2001
+ 2+IMM2_SIZE, /* NOT exact I */ \
2002
+ 2, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *I, +I, ?I, upto I */ \
2003
+ /* Positive type repeats */ \
2004
+ 2, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \
2005
+ 2+IMM2_SIZE, 2+IMM2_SIZE, /* Type upto, minupto */ \
2006
+ 2+IMM2_SIZE, /* Type exact */ \
2007
+ 2, 2, 2, 2+IMM2_SIZE, /* Possessive *+, ++, ?+, upto+ */ \
2008
+ /* Character class & ref repeats */ \
2009
+ 1, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \
2010
+ 1+2*IMM2_SIZE, 1+2*IMM2_SIZE, /* CRRANGE, CRMINRANGE */ \
2011
+ 1, 1, 1, 1+2*IMM2_SIZE, /* Possessive *+, ++, ?+, CRPOSRANGE */ \
2012
+ 1+(32/sizeof(PCRE2_UCHAR)), /* CLASS */ \
2013
+ 1+(32/sizeof(PCRE2_UCHAR)), /* NCLASS */ \
2014
+ 0, /* XCLASS - variable length */ \
2015
+ 0, /* ECLASS - variable length */ \
2016
+ 1+IMM2_SIZE, /* REF */ \
2017
+ 1+IMM2_SIZE+1, /* REFI */ \
2018
+ 1+2*IMM2_SIZE, /* DNREF */ \
2019
+ 1+2*IMM2_SIZE+1, /* DNREFI */ \
2020
+ 1+LINK_SIZE, /* RECURSE */ \
2021
+ 1+2*LINK_SIZE+1, /* CALLOUT */ \
2022
+ 0, /* CALLOUT_STR - variable length */ \
2023
+ 1+LINK_SIZE, /* Alt */ \
2024
+ 1+LINK_SIZE, /* Ket */ \
2025
+ 1+LINK_SIZE, /* KetRmax */ \
2026
+ 1+LINK_SIZE, /* KetRmin */ \
2027
+ 1+LINK_SIZE, /* KetRpos */ \
2028
+ 1+IMM2_SIZE, /* Reverse */ \
2029
+ 1+2*IMM2_SIZE, /* VReverse */ \
2030
+ 1+LINK_SIZE, /* Assert */ \
2031
+ 1+LINK_SIZE, /* Assert not */ \
2032
+ 1+LINK_SIZE, /* Assert behind */ \
2033
+ 1+LINK_SIZE, /* Assert behind not */ \
2034
+ 1+LINK_SIZE, /* NA Assert */ \
2035
+ 1+LINK_SIZE, /* NA Assert behind */ \
2036
+ 1+LINK_SIZE, /* Scan substring */ \
2037
+ 1+LINK_SIZE, /* ONCE */ \
2038
+ 1+LINK_SIZE, /* SCRIPT_RUN */ \
2039
+ 1+LINK_SIZE, /* BRA */ \
2040
+ 1+LINK_SIZE, /* BRAPOS */ \
2041
+ 1+LINK_SIZE+IMM2_SIZE, /* CBRA */ \
2042
+ 1+LINK_SIZE+IMM2_SIZE, /* CBRAPOS */ \
2043
+ 1+LINK_SIZE, /* COND */ \
2044
+ 1+LINK_SIZE, /* SBRA */ \
2045
+ 1+LINK_SIZE, /* SBRAPOS */ \
2046
+ 1+LINK_SIZE+IMM2_SIZE, /* SCBRA */ \
2047
+ 1+LINK_SIZE+IMM2_SIZE, /* SCBRAPOS */ \
2048
+ 1+LINK_SIZE, /* SCOND */ \
2049
+ 1+IMM2_SIZE, 1+2*IMM2_SIZE, /* CREF, DNCREF */ \
2050
+ 1+IMM2_SIZE, 1+2*IMM2_SIZE, /* RREF, DNRREF */ \
2051
+ 1, 1, /* FALSE, TRUE */ \
2052
+ 1, 1, 1, /* BRAZERO, BRAMINZERO, BRAPOSZERO */ \
2053
+ 3, 1, 3, /* MARK, PRUNE, PRUNE_ARG */ \
2054
+ 1, 3, /* SKIP, SKIP_ARG */ \
2055
+ 1, 3, /* THEN, THEN_ARG */ \
2056
+ 1, 3, /* COMMIT, COMMIT_ARG */ \
2057
+ 1, 1, 1, /* FAIL, ACCEPT, ASSERT_ACCEPT */ \
2058
+ 1+IMM2_SIZE, 1, /* CLOSE, SKIPZERO */ \
2059
+ 1, /* DEFINE */ \
2060
+ 1, 1 /* \B and \b in UCP mode */
2061
+
2062
+ /* A magic value for OP_RREF to indicate the "any recursion" condition. */
2063
+
2064
+ #define RREF_ANY 0xffff
2065
+
2066
+ /* Constants used by OP_REFI and OP_DNREFI to control matching behaviour. */
2067
+
2068
+ #define REFI_FLAG_CASELESS_RESTRICT 0x1
2069
+ #define REFI_FLAG_TURKISH_CASING 0x2
2070
+
2071
+
2072
+ /* ---------- Private structures that are mode-independent. ---------- */
2073
+
2074
+ /* Structure to hold data for custom memory management. */
2075
+
2076
+ typedef struct pcre2_memctl {
2077
+ void * (*malloc)(size_t, void *);
2078
+ void (*free)(void *, void *);
2079
+ void *memory_data;
2080
+ } pcre2_memctl;
2081
+
2082
+ /* Structure for building a chain of open capturing subpatterns during
2083
+ compiling, so that instructions to close them can be compiled when (*ACCEPT) is
2084
+ encountered. */
2085
+
2086
+ typedef struct open_capitem {
2087
+ struct open_capitem *next; /* Chain link */
2088
+ uint16_t number; /* Capture number */
2089
+ uint16_t assert_depth; /* Assertion depth when opened */
2090
+ } open_capitem;
2091
+
2092
+ /* Layout of the UCP type table that translates property names into types and
2093
+ codes. Each entry used to point directly to a name, but to reduce the number of
2094
+ relocations in shared libraries, it now has an offset into a single string
2095
+ instead. */
2096
+
2097
+ typedef struct {
2098
+ uint16_t name_offset;
2099
+ uint16_t type;
2100
+ uint16_t value;
2101
+ } ucp_type_table;
2102
+
2103
+ /* Unicode character database (UCD) record format */
2104
+
2105
+ typedef struct {
2106
+ uint8_t script; /* ucp_Arabic, etc. */
2107
+ uint8_t chartype; /* ucp_Cc, etc. (general categories) */
2108
+ uint8_t gbprop; /* ucp_gbControl, etc. (grapheme break property) */
2109
+ uint8_t caseset; /* offset to multichar other cases or zero */
2110
+ int32_t other_case; /* offset to other case, or zero if none */
2111
+ uint16_t scriptx_bidiclass; /* script extension (11 bit) and bidi class (5 bit) values */
2112
+ uint16_t bprops; /* binary properties offset */
2113
+ } ucd_record;
2114
+
2115
+ /* UCD access macros */
2116
+
2117
+ #define UCD_BLOCK_SIZE 128
2118
+ #define REAL_GET_UCD(ch) (PRIV(ucd_records) + \
2119
+ PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
2120
+ UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
2121
+
2122
+ #if PCRE2_CODE_UNIT_WIDTH == 32
2123
+ #define GET_UCD(ch) ((ch > MAX_UTF_CODE_POINT)? \
2124
+ PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))
2125
+ #else
2126
+ #define GET_UCD(ch) REAL_GET_UCD(ch)
2127
+ #endif
2128
+
2129
+ #define UCD_SCRIPTX_MASK 0x3ff
2130
+ #define UCD_BIDICLASS_SHIFT 11
2131
+ #define UCD_BPROPS_MASK 0xfff
2132
+
2133
+ #define UCD_SCRIPTX_PROP(prop) ((prop)->scriptx_bidiclass & UCD_SCRIPTX_MASK)
2134
+ #define UCD_BIDICLASS_PROP(prop) ((prop)->scriptx_bidiclass >> UCD_BIDICLASS_SHIFT)
2135
+ #define UCD_BPROPS_PROP(prop) ((prop)->bprops & UCD_BPROPS_MASK)
2136
+
2137
+ #define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
2138
+ #define UCD_SCRIPT(ch) GET_UCD(ch)->script
2139
+ #define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
2140
+ #define UCD_GRAPHBREAK(ch) GET_UCD(ch)->gbprop
2141
+ #define UCD_CASESET(ch) GET_UCD(ch)->caseset
2142
+ #define UCD_OTHERCASE(ch) ((uint32_t)((int)ch + (int)(GET_UCD(ch)->other_case)))
2143
+ #define UCD_SCRIPTX(ch) UCD_SCRIPTX_PROP(GET_UCD(ch))
2144
+ #define UCD_BPROPS(ch) UCD_BPROPS_PROP(GET_UCD(ch))
2145
+ #define UCD_BIDICLASS(ch) UCD_BIDICLASS_PROP(GET_UCD(ch))
2146
+ #define UCD_ANY_I(ch) \
2147
+ /* match any of the four characters 'i', 'I', U+0130, U+0131 */ \
2148
+ (((uint32_t)(ch) | 0x20u) == 0x69u || ((uint32_t)(ch) | 1u) == 0x0131u)
2149
+ #define UCD_DOTTED_I(ch) \
2150
+ ((uint32_t)(ch) == 0x69u || (uint32_t)(ch) == 0x0130u)
2151
+ #define UCD_FOLD_I_TURKISH(ch) \
2152
+ ((uint32_t)(ch) == 0x0130u ? 0x69u : \
2153
+ (uint32_t)(ch) == 0x49u ? 0x0131u : (uint32_t)(ch))
2154
+
2155
+ /* The "scriptx" and bprops fields contain offsets into vectors of 32-bit words
2156
+ that form a bitmap representing a list of scripts or boolean properties. These
2157
+ macros test or set a bit in the map by number. */
2158
+
2159
+ #define MAPBIT(map,n) ((map)[(n)/32]&(1u<<((n)%32)))
2160
+ #define MAPSET(map,n) ((map)[(n)/32]|=(1u<<((n)%32)))
2161
+
2162
+ /* Header for serialized pcre2 codes. */
2163
+
2164
+ typedef struct pcre2_serialized_data {
2165
+ uint32_t magic;
2166
+ uint32_t version;
2167
+ uint32_t config;
2168
+ int32_t number_of_codes;
2169
+ } pcre2_serialized_data;
2170
+
2171
+
2172
+
2173
+ /* ----------------- Items that need PCRE2_CODE_UNIT_WIDTH ----------------- */
2174
+
2175
+ /* When this file is included by pcre2test, PCRE2_CODE_UNIT_WIDTH is defined as
2176
+ 0, so the following items are omitted. */
2177
+
2178
+ #if defined PCRE2_CODE_UNIT_WIDTH && PCRE2_CODE_UNIT_WIDTH != 0
2179
+
2180
+ /* EBCDIC is supported only for the 8-bit library. */
2181
+
2182
+ #if defined EBCDIC && PCRE2_CODE_UNIT_WIDTH != 8
2183
+ #error EBCDIC is not supported for the 16-bit or 32-bit libraries
2184
+ #endif
2185
+
2186
+ /* This is the largest non-UTF code point. */
2187
+
2188
+ #define MAX_NON_UTF_CHAR (0xffffffffU >> (32 - PCRE2_CODE_UNIT_WIDTH))
2189
+
2190
+ /* Internal shared data tables and variables. These are used by more than one
2191
+ of the exported public functions. They have to be "external" in the C sense,
2192
+ but are not part of the PCRE2 public API. Although the data for some of them is
2193
+ identical in all libraries, they must have different names so that multiple
2194
+ libraries can be simultaneously linked to a single application. However, UTF-8
2195
+ tables are needed only when compiling the 8-bit library. */
2196
+
2197
+ #if PCRE2_CODE_UNIT_WIDTH == 8
2198
+ extern const int PRIV(utf8_table1)[];
2199
+ extern const unsigned PRIV(utf8_table1_size);
2200
+ extern const int PRIV(utf8_table2)[];
2201
+ extern const int PRIV(utf8_table3)[];
2202
+ extern const uint8_t PRIV(utf8_table4)[];
2203
+ #endif
2204
+
2205
+ #define _pcre2_OP_lengths PCRE2_SUFFIX(_pcre2_OP_lengths_)
2206
+ #define _pcre2_callout_end_delims PCRE2_SUFFIX(_pcre2_callout_end_delims_)
2207
+ #define _pcre2_callout_start_delims PCRE2_SUFFIX(_pcre2_callout_start_delims_)
2208
+ #define _pcre2_default_compile_context PCRE2_SUFFIX(_pcre2_default_compile_context_)
2209
+ #define _pcre2_default_convert_context PCRE2_SUFFIX(_pcre2_default_convert_context_)
2210
+ #define _pcre2_default_match_context PCRE2_SUFFIX(_pcre2_default_match_context_)
2211
+ #define _pcre2_default_tables PCRE2_SUFFIX(_pcre2_default_tables_)
2212
+ #if PCRE2_CODE_UNIT_WIDTH == 32
2213
+ #define _pcre2_dummy_ucd_record PCRE2_SUFFIX(_pcre2_dummy_ucd_record_)
2214
+ #endif
2215
+ #define _pcre2_hspace_list PCRE2_SUFFIX(_pcre2_hspace_list_)
2216
+ #define _pcre2_vspace_list PCRE2_SUFFIX(_pcre2_vspace_list_)
2217
+ #define _pcre2_ucd_boolprop_sets PCRE2_SUFFIX(_pcre2_ucd_boolprop_sets_)
2218
+ #define _pcre2_ucd_caseless_sets PCRE2_SUFFIX(_pcre2_ucd_caseless_sets_)
2219
+ #define _pcre2_ucd_turkish_dotted_i_caseset PCRE2_SUFFIX(_pcre2_ucd_turkish_dotted_i_caseset_)
2220
+ #define _pcre2_ucd_nocase_ranges PCRE2_SUFFIX(_pcre2_ucd_nocase_ranges_)
2221
+ #define _pcre2_ucd_nocase_ranges_size PCRE2_SUFFIX(_pcre2_ucd_nocase_ranges_size_)
2222
+ #define _pcre2_ucd_digit_sets PCRE2_SUFFIX(_pcre2_ucd_digit_sets_)
2223
+ #define _pcre2_ucd_script_sets PCRE2_SUFFIX(_pcre2_ucd_script_sets_)
2224
+ #define _pcre2_ucd_records PCRE2_SUFFIX(_pcre2_ucd_records_)
2225
+ #define _pcre2_ucd_stage1 PCRE2_SUFFIX(_pcre2_ucd_stage1_)
2226
+ #define _pcre2_ucd_stage2 PCRE2_SUFFIX(_pcre2_ucd_stage2_)
2227
+ #define _pcre2_ucp_gbtable PCRE2_SUFFIX(_pcre2_ucp_gbtable_)
2228
+ #define _pcre2_ucp_gentype PCRE2_SUFFIX(_pcre2_ucp_gentype_)
2229
+ #define _pcre2_ucp_typerange PCRE2_SUFFIX(_pcre2_ucp_typerange_)
2230
+ #define _pcre2_unicode_version PCRE2_SUFFIX(_pcre2_unicode_version_)
2231
+ #define _pcre2_utt PCRE2_SUFFIX(_pcre2_utt_)
2232
+ #define _pcre2_utt_names PCRE2_SUFFIX(_pcre2_utt_names_)
2233
+ #define _pcre2_utt_size PCRE2_SUFFIX(_pcre2_utt_size_)
2234
+ #define _pcre2_ebcdic_1047_to_ascii PCRE2_SUFFIX(_pcre2_ebcdic_1047_to_ascii_)
2235
+ #define _pcre2_ascii_to_ebcdic_1047 PCRE2_SUFFIX(_pcre2_ascii_to_ebcdic_1047_)
2236
+
2237
+ extern const uint8_t PRIV(OP_lengths)[];
2238
+ extern const uint32_t PRIV(callout_end_delims)[];
2239
+ extern const uint32_t PRIV(callout_start_delims)[];
2240
+ extern pcre2_compile_context PRIV(default_compile_context);
2241
+ extern pcre2_convert_context PRIV(default_convert_context);
2242
+ extern pcre2_match_context PRIV(default_match_context);
2243
+ extern const uint8_t PRIV(default_tables)[];
2244
+ extern const uint32_t PRIV(hspace_list)[];
2245
+ extern const uint32_t PRIV(vspace_list)[];
2246
+ extern const uint32_t PRIV(ucd_boolprop_sets)[];
2247
+ extern const uint32_t PRIV(ucd_caseless_sets)[];
2248
+ extern const uint32_t PRIV(ucd_turkish_dotted_i_caseset);
2249
+ extern const uint32_t PRIV(ucd_nocase_ranges)[];
2250
+ extern const uint32_t PRIV(ucd_nocase_ranges_size);
2251
+ extern const uint32_t PRIV(ucd_digit_sets)[];
2252
+ extern const uint32_t PRIV(ucd_script_sets)[];
2253
+ extern const ucd_record PRIV(ucd_records)[];
2254
+ #if PCRE2_CODE_UNIT_WIDTH == 32
2255
+ extern const ucd_record PRIV(dummy_ucd_record)[];
2256
+ #endif
2257
+ extern const uint16_t PRIV(ucd_stage1)[];
2258
+ extern const uint16_t PRIV(ucd_stage2)[];
2259
+ extern const uint32_t PRIV(ucp_gbtable)[];
2260
+ extern const uint32_t PRIV(ucp_gentype)[];
2261
+ #ifdef SUPPORT_JIT
2262
+ extern const int PRIV(ucp_typerange)[];
2263
+ #endif
2264
+ extern const char *PRIV(unicode_version);
2265
+ extern const ucp_type_table PRIV(utt)[];
2266
+ extern const char PRIV(utt_names)[];
2267
+ extern const size_t PRIV(utt_size);
2268
+ extern const uint8_t PRIV(ebcdic_1047_to_ascii)[];
2269
+ extern const uint8_t PRIV(ascii_to_ebcdic_1047)[];
2270
+
2271
+ /* Mode-dependent macros and hidden and private structures are defined in a
2272
+ separate file so that pcre2test can include them at all supported widths. When
2273
+ compiling the library, PCRE2_CODE_UNIT_WIDTH will be defined, and we can
2274
+ include them at the appropriate width, after setting up suffix macros for the
2275
+ private structures. */
2276
+
2277
+ #define branch_chain PCRE2_SUFFIX(branch_chain_)
2278
+ #define compile_block PCRE2_SUFFIX(compile_block_)
2279
+ #define dfa_match_block PCRE2_SUFFIX(dfa_match_block_)
2280
+ #define match_block PCRE2_SUFFIX(match_block_)
2281
+ #define named_group PCRE2_SUFFIX(named_group_)
2282
+
2283
+ #include "pcre2_intmodedep.h"
2284
+
2285
+ /* Private "external" functions. These are internal functions that are called
2286
+ from modules other than the one in which they are defined. They have to be
2287
+ "external" in the C sense, but are not part of the PCRE2 public API. They are
2288
+ not referenced from pcre2test, and must not be defined when no code unit width
2289
+ is available. */
2290
+
2291
+ #define _pcre2_auto_possessify PCRE2_SUFFIX(_pcre2_auto_possessify_)
2292
+ #define _pcre2_check_escape PCRE2_SUFFIX(_pcre2_check_escape_)
2293
+ #define _pcre2_ckd_smul PCRE2_SUFFIX(_pcre2_ckd_smul_)
2294
+ #define _pcre2_extuni PCRE2_SUFFIX(_pcre2_extuni_)
2295
+ #define _pcre2_find_bracket PCRE2_SUFFIX(_pcre2_find_bracket_)
2296
+ #define _pcre2_is_newline PCRE2_SUFFIX(_pcre2_is_newline_)
2297
+ #define _pcre2_jit_free_rodata PCRE2_SUFFIX(_pcre2_jit_free_rodata_)
2298
+ #define _pcre2_jit_free PCRE2_SUFFIX(_pcre2_jit_free_)
2299
+ #define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_)
2300
+ #define _pcre2_jit_get_target PCRE2_SUFFIX(_pcre2_jit_get_target_)
2301
+ #define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_)
2302
+ #define _pcre2_ord2utf PCRE2_SUFFIX(_pcre2_ord2utf_)
2303
+ #define _pcre2_script_run PCRE2_SUFFIX(_pcre2_script_run_)
2304
+ #define _pcre2_strcmp PCRE2_SUFFIX(_pcre2_strcmp_)
2305
+ #define _pcre2_strcmp_c8 PCRE2_SUFFIX(_pcre2_strcmp_c8_)
2306
+ #define _pcre2_strcpy_c8 PCRE2_SUFFIX(_pcre2_strcpy_c8_)
2307
+ #define _pcre2_strlen PCRE2_SUFFIX(_pcre2_strlen_)
2308
+ #define _pcre2_strncmp PCRE2_SUFFIX(_pcre2_strncmp_)
2309
+ #define _pcre2_strncmp_c8 PCRE2_SUFFIX(_pcre2_strncmp_c8_)
2310
+ #define _pcre2_study PCRE2_SUFFIX(_pcre2_study_)
2311
+ #define _pcre2_valid_utf PCRE2_SUFFIX(_pcre2_valid_utf_)
2312
+ #define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_)
2313
+ #define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_)
2314
+ #define _pcre2_eclass PCRE2_SUFFIX(_pcre2_eclass_)
2315
+
2316
+ extern int _pcre2_auto_possessify(PCRE2_UCHAR *,
2317
+ const compile_block *);
2318
+ extern int _pcre2_check_escape(PCRE2_SPTR *, PCRE2_SPTR, uint32_t *,
2319
+ int *, uint32_t, uint32_t, uint32_t, BOOL, compile_block *);
2320
+ extern BOOL _pcre2_ckd_smul(PCRE2_SIZE *, int, int);
2321
+ extern PCRE2_SPTR _pcre2_extuni(uint32_t, PCRE2_SPTR, PCRE2_SPTR, PCRE2_SPTR,
2322
+ BOOL, int *);
2323
+ extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);
2324
+ extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,
2325
+ uint32_t *, BOOL);
2326
+ extern void _pcre2_jit_free_rodata(void *, void *);
2327
+ extern void _pcre2_jit_free(void *, pcre2_memctl *);
2328
+ extern size_t _pcre2_jit_get_size(void *);
2329
+ const char * _pcre2_jit_get_target(void);
2330
+ extern void * _pcre2_memctl_malloc(size_t, pcre2_memctl *);
2331
+ extern unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *);
2332
+ extern BOOL _pcre2_script_run(PCRE2_SPTR, PCRE2_SPTR, BOOL);
2333
+ extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);
2334
+ extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *);
2335
+ extern PCRE2_SIZE _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *);
2336
+ extern PCRE2_SIZE _pcre2_strlen(PCRE2_SPTR);
2337
+ extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);
2338
+ extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);
2339
+ extern int _pcre2_study(pcre2_real_code *);
2340
+ extern int _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *);
2341
+ extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,
2342
+ uint32_t *, BOOL);
2343
+ extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, const uint8_t *, BOOL);
2344
+ extern BOOL _pcre2_eclass(uint32_t, PCRE2_SPTR, PCRE2_SPTR,
2345
+ const uint8_t *, BOOL);
2346
+
2347
+ #endif /* PCRE2_CODE_UNIT_WIDTH */
2348
+
2349
+ #include "pcre2_util.h"
2350
+
2351
+ #endif /* PCRE2_INTERNAL_H_IDEMPOTENT_GUARD */
2352
+
2353
+ /* End of pcre2_internal.h */