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 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 /* We do not support both EBCDIC and Unicode at the same time. The "configure" 42 script prevents both being selected, but not everybody uses "configure". EBCDIC 43 is only supported for the 8-bit library, but the check for this has to be later 44 in this file, because the first part is not width-dependent, and is included by 45 pcre2test.c with CODE_UNIT_WIDTH == 0. */ 46 47 #if defined EBCDIC && defined SUPPORT_UNICODE 48 #error The use of both EBCDIC and SUPPORT_UNICODE is not supported. 49 #endif 50 51 /* Standard C headers */ 52 53 #include <ctype.h> 54 #include <limits.h> 55 #include <stddef.h> 56 #include <stdio.h> 57 #include <stdlib.h> 58 #include <string.h> 59 60 /* Macros to make boolean values more obvious. The #ifndef is to pacify 61 compiler warnings in environments where these macros are defined elsewhere. 62 Unfortunately, there is no way to do the same for the typedef. */ 63 64 typedef int BOOL; 65 #ifndef FALSE 66 #define FALSE 0 67 #define TRUE 1 68 #endif 69 70 /* Valgrind (memcheck) support */ 71 72 #ifdef SUPPORT_VALGRIND 73 #include <valgrind/memcheck.h> 74 #endif 75 76 /* Older versions of MSVC lack snprintf(). This define allows for 77 warning/error-free compilation and testing with MSVC compilers back to at least 78 MSVC 10/2010. Except for VC6 (which is missing some fundamentals and fails). */ 79 80 #if defined(_MSC_VER) && (_MSC_VER < 1900) 81 #define snprintf _snprintf 82 #endif 83 84 /* When compiling a DLL for Windows, the exported symbols have to be declared 85 using some MS magic. I found some useful information on this web page: 86 http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the 87 information there, using __declspec(dllexport) without "extern" we have a 88 definition; with "extern" we have a declaration. The settings here override the 89 setting in pcre2.h (which is included below); it defines only PCRE2_EXP_DECL, 90 which is all that is needed for applications (they just import the symbols). We 91 use: 92 93 PCRE2_EXP_DECL for declarations 94 PCRE2_EXP_DEFN for definitions 95 96 The reason for wrapping this in #ifndef PCRE2_EXP_DECL is so that pcre2test, 97 which is an application, but needs to import this file in order to "peek" at 98 internals, can #include pcre2.h first to get an application's-eye view. 99 100 In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon, 101 special-purpose environments) might want to stick other stuff in front of 102 exported symbols. That's why, in the non-Windows case, we set PCRE2_EXP_DEFN 103 only if it is not already set. */ 104 105 #ifndef PCRE2_EXP_DECL 106 # ifdef _WIN32 107 # ifndef PCRE2_STATIC 108 # define PCRE2_EXP_DECL extern __declspec(dllexport) 109 # define PCRE2_EXP_DEFN __declspec(dllexport) 110 # else 111 # define PCRE2_EXP_DECL extern 112 # define PCRE2_EXP_DEFN 113 # endif 114 # else 115 # ifdef __cplusplus 116 # define PCRE2_EXP_DECL extern "C" 117 # else 118 # define PCRE2_EXP_DECL extern 119 # endif 120 # ifndef PCRE2_EXP_DEFN 121 # define PCRE2_EXP_DEFN PCRE2_EXP_DECL 122 # endif 123 # endif 124 #endif 125 126 /* Include the public PCRE2 header and the definitions of UCP character 127 property values. This must follow the setting of PCRE2_EXP_DECL above. */ 128 129 #include "pcre2.h" 130 #include "pcre2_ucp.h" 131 132 /* When PCRE2 is compiled as a C++ library, the subject pointer can be replaced 133 with a custom type. This makes it possible, for example, to allow pcre2_match() 134 to process subject strings that are discontinuous by using a smart pointer 135 class. It must always be possible to inspect all of the subject string in 136 pcre2_match() because of the way it backtracks. */ 137 138 /* WARNING: This is as yet untested for PCRE2. */ 139 140 #ifdef CUSTOM_SUBJECT_PTR 141 #undef PCRE2_SPTR 142 #define PCRE2_SPTR CUSTOM_SUBJECT_PTR 143 #endif 144 145 /* When compiling with the MSVC compiler, it is sometimes necessary to include 146 a "calling convention" before exported function names. (This is secondhand 147 information; I know nothing about MSVC myself). For example, something like 148 149 void __cdecl function(....) 150 151 might be needed. In order so make this easy, all the exported functions have 152 PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not 153 set, we ensure here that it has no effect. */ 154 155 #ifndef PCRE2_CALL_CONVENTION 156 #define PCRE2_CALL_CONVENTION 157 #endif 158 159 /* When checking for integer overflow in pcre2_compile(), we need to handle 160 large integers. If a 64-bit integer type is available, we can use that. 161 Otherwise we have to cast to double, which of course requires floating point 162 arithmetic. Handle this by defining a macro for the appropriate type. If 163 stdint.h is available, include it; it may define INT64_MAX. Systems that do not 164 have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set 165 by "configure". */ 166 167 #if defined HAVE_STDINT_H 168 #include <stdint.h> 169 #elif defined HAVE_INTTYPES_H 170 #include <inttypes.h> 171 #endif 172 173 #if defined INT64_MAX || defined int64_t 174 #define INT64_OR_DOUBLE int64_t 175 #else 176 #define INT64_OR_DOUBLE double 177 #endif 178 179 /* When compiling for use with the Virtual Pascal compiler, these functions 180 need to have their names changed. PCRE2 must be compiled with the -DVPCOMPAT 181 option on the command line. */ 182 183 #ifdef VPCOMPAT 184 #define strlen(s) _strlen(s) 185 #define strncmp(s1,s2,m) _strncmp(s1,s2,m) 186 #define memcmp(s,c,n) _memcmp(s,c,n) 187 #define memcpy(d,s,n) _memcpy(d,s,n) 188 #define memmove(d,s,n) _memmove(d,s,n) 189 #define memset(s,c,n) _memset(s,c,n) 190 #else /* VPCOMPAT */ 191 192 /* To cope with SunOS4 and other systems that lack memmove() but have bcopy(), 193 define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY 194 is set. Otherwise, include an emulating function for those systems that have 195 neither (there some non-Unix environments where this is the case). */ 196 197 #ifndef HAVE_MEMMOVE 198 #undef memmove /* some systems may have a macro */ 199 #ifdef HAVE_BCOPY 200 #define memmove(a, b, c) bcopy(b, a, c) 201 #else /* HAVE_BCOPY */ 202 static void * 203 pcre2_memmove(void *d, const void *s, size_t n) 204 { 205 size_t i; 206 unsigned char *dest = (unsigned char *)d; 207 const unsigned char *src = (const unsigned char *)s; 208 if (dest > src) 209 { 210 dest += n; 211 src += n; 212 for (i = 0; i < n; ++i) *(--dest) = *(--src); 213 return (void *)dest; 214 } 215 else 216 { 217 for (i = 0; i < n; ++i) *dest++ = *src++; 218 return (void *)(dest - n); 219 } 220 } 221 #define memmove(a, b, c) pcre2_memmove(a, b, c) 222 #endif /* not HAVE_BCOPY */ 223 #endif /* not HAVE_MEMMOVE */ 224 #endif /* not VPCOMPAT */ 225 226 /* External (in the C sense) functions and tables that are private to the 227 libraries are always referenced using the PRIV macro. This makes it possible 228 for pcre2test.c to include some of the source files from the libraries using a 229 different PRIV definition to avoid name clashes. It also makes it clear in the 230 code that a non-static object is being referenced. */ 231 232 #ifndef PRIV 233 #define PRIV(name) _pcre2_##name 234 #endif 235 236 /* This is an unsigned int value that no UTF character can ever have, as 237 Unicode doesn't go beyond 0x0010ffff. */ 238 239 #define NOTACHAR 0xffffffff 240 241 /* This is the largest valid UTF/Unicode code point. */ 242 243 #define MAX_UTF_CODE_POINT 0x10ffff 244 245 /* Compile-time positive error numbers (all except UTF errors, which are 246 negative) start at this value. It should probably never be changed, in case 247 some application is checking for specific numbers. There is a copy of this 248 #define in pcre2posix.c (which now no longer includes this file). Ideally, a 249 way of having a single definition should be found, but as the number is 250 unlikely to change, this is not a pressing issue. The original reason for 251 having a base other than 0 was to keep the absolute values of compile-time and 252 run-time error numbers numerically different, but in the event the code does 253 not rely on this. */ 254 255 #define COMPILE_ERROR_BASE 100 256 257 /* Define the default BSR convention. */ 258 259 #ifdef BSR_ANYCRLF 260 #define BSR_DEFAULT PCRE2_BSR_ANYCRLF 261 #else 262 #define BSR_DEFAULT PCRE2_BSR_UNICODE 263 #endif 264 265 266 /* ---------------- Basic UTF-8 macros ---------------- */ 267 268 /* These UTF-8 macros are always defined because they are used in pcre2test for 269 handling wide characters in 16-bit and 32-bit modes, even if an 8-bit library 270 is not supported. */ 271 272 /* Tests whether a UTF-8 code point needs extra bytes to decode. */ 273 274 #define HASUTF8EXTRALEN(c) ((c) >= 0xc0) 275 276 /* The following macros were originally written in the form of loops that used 277 data from the tables whose names start with PRIV(utf8_table). They were 278 rewritten by a user so as not to use loops, because in some environments this 279 gives a significant performance advantage, and it seems never to do any harm. 280 */ 281 282 /* Base macro to pick up the remaining bytes of a UTF-8 character, not 283 advancing the pointer. */ 284 285 #define GETUTF8(c, eptr) \ 286 { \ 287 if ((c & 0x20u) == 0) \ 288 c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \ 289 else if ((c & 0x10u) == 0) \ 290 c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \ 291 else if ((c & 0x08u) == 0) \ 292 c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \ 293 ((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \ 294 else if ((c & 0x04u) == 0) \ 295 c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \ 296 ((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \ 297 (eptr[4] & 0x3fu); \ 298 else \ 299 c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \ 300 ((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \ 301 ((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \ 302 } 303 304 /* Base macro to pick up the remaining bytes of a UTF-8 character, advancing 305 the pointer. */ 306 307 #define GETUTF8INC(c, eptr) \ 308 { \ 309 if ((c & 0x20u) == 0) \ 310 c = ((c & 0x1fu) << 6) | (*eptr++ & 0x3fu); \ 311 else if ((c & 0x10u) == 0) \ 312 { \ 313 c = ((c & 0x0fu) << 12) | ((*eptr & 0x3fu) << 6) | (eptr[1] & 0x3fu); \ 314 eptr += 2; \ 315 } \ 316 else if ((c & 0x08u) == 0) \ 317 { \ 318 c = ((c & 0x07u) << 18) | ((*eptr & 0x3fu) << 12) | \ 319 ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \ 320 eptr += 3; \ 321 } \ 322 else if ((c & 0x04u) == 0) \ 323 { \ 324 c = ((c & 0x03u) << 24) | ((*eptr & 0x3fu) << 18) | \ 325 ((eptr[1] & 0x3fu) << 12) | ((eptr[2] & 0x3fu) << 6) | \ 326 (eptr[3] & 0x3fu); \ 327 eptr += 4; \ 328 } \ 329 else \ 330 { \ 331 c = ((c & 0x01u) << 30) | ((*eptr & 0x3fu) << 24) | \ 332 ((eptr[1] & 0x3fu) << 18) | ((eptr[2] & 0x3fu) << 12) | \ 333 ((eptr[3] & 0x3fu) << 6) | (eptr[4] & 0x3fu); \ 334 eptr += 5; \ 335 } \ 336 } 337 338 /* Base macro to pick up the remaining bytes of a UTF-8 character, not 339 advancing the pointer, incrementing the length. */ 340 341 #define GETUTF8LEN(c, eptr, len) \ 342 { \ 343 if ((c & 0x20u) == 0) \ 344 { \ 345 c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \ 346 len++; \ 347 } \ 348 else if ((c & 0x10u) == 0) \ 349 { \ 350 c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \ 351 len += 2; \ 352 } \ 353 else if ((c & 0x08u) == 0) \ 354 {\ 355 c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \ 356 ((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \ 357 len += 3; \ 358 } \ 359 else if ((c & 0x04u) == 0) \ 360 { \ 361 c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \ 362 ((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \ 363 (eptr[4] & 0x3fu); \ 364 len += 4; \ 365 } \ 366 else \ 367 {\ 368 c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \ 369 ((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \ 370 ((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \ 371 len += 5; \ 372 } \ 373 } 374 375 /* --------------- Whitespace macros ---------------- */ 376 377 /* Tests for Unicode horizontal and vertical whitespace characters must check a 378 number of different values. Using a switch statement for this generates the 379 fastest code (no loop, no memory access), and there are several places in the 380 interpreter code where this happens. In order to ensure that all the case lists 381 remain in step, we use macros so that there is only one place where the lists 382 are defined. 383 384 These values are also required as lists in pcre2_compile.c when processing \h, 385 \H, \v and \V in a character class. The lists are defined in pcre2_tables.c, 386 but macros that define the values are here so that all the definitions are 387 together. The lists must be in ascending character order, terminated by 388 NOTACHAR (which is 0xffffffff). 389 390 Any changes should ensure that the various macros are kept in step with each 391 other. NOTE: The values also appear in pcre2_jit_compile.c. */ 392 393 /* -------------- ASCII/Unicode environments -------------- */ 394 395 #ifndef EBCDIC 396 397 /* Character U+180E (Mongolian Vowel Separator) is not included in the list of 398 spaces in the Unicode file PropList.txt, and Perl does not recognize it as a 399 space. However, in many other sources it is listed as a space and has been in 400 PCRE (both APIs) for a long time. */ 401 402 #define HSPACE_LIST \ 403 CHAR_HT, CHAR_SPACE, CHAR_NBSP, \ 404 0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \ 405 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202f, 0x205f, 0x3000, \ 406 NOTACHAR 407 408 #define HSPACE_MULTIBYTE_CASES \ 409 case 0x1680: /* OGHAM SPACE MARK */ \ 410 case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ \ 411 case 0x2000: /* EN QUAD */ \ 412 case 0x2001: /* EM QUAD */ \ 413 case 0x2002: /* EN SPACE */ \ 414 case 0x2003: /* EM SPACE */ \ 415 case 0x2004: /* THREE-PER-EM SPACE */ \ 416 case 0x2005: /* FOUR-PER-EM SPACE */ \ 417 case 0x2006: /* SIX-PER-EM SPACE */ \ 418 case 0x2007: /* FIGURE SPACE */ \ 419 case 0x2008: /* PUNCTUATION SPACE */ \ 420 case 0x2009: /* THIN SPACE */ \ 421 case 0x200A: /* HAIR SPACE */ \ 422 case 0x202f: /* NARROW NO-BREAK SPACE */ \ 423 case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ \ 424 case 0x3000 /* IDEOGRAPHIC SPACE */ 425 426 #define HSPACE_BYTE_CASES \ 427 case CHAR_HT: \ 428 case CHAR_SPACE: \ 429 case CHAR_NBSP 430 431 #define HSPACE_CASES \ 432 HSPACE_BYTE_CASES: \ 433 HSPACE_MULTIBYTE_CASES 434 435 #define VSPACE_LIST \ 436 CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, 0x2028, 0x2029, NOTACHAR 437 438 #define VSPACE_MULTIBYTE_CASES \ 439 case 0x2028: /* LINE SEPARATOR */ \ 440 case 0x2029 /* PARAGRAPH SEPARATOR */ 441 442 #define VSPACE_BYTE_CASES \ 443 case CHAR_LF: \ 444 case CHAR_VT: \ 445 case CHAR_FF: \ 446 case CHAR_CR: \ 447 case CHAR_NEL 448 449 #define VSPACE_CASES \ 450 VSPACE_BYTE_CASES: \ 451 VSPACE_MULTIBYTE_CASES 452 453 /* -------------- EBCDIC environments -------------- */ 454 455 #else 456 #define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR 457 458 #define HSPACE_BYTE_CASES \ 459 case CHAR_HT: \ 460 case CHAR_SPACE: \ 461 case CHAR_NBSP 462 463 #define HSPACE_CASES HSPACE_BYTE_CASES 464 465 #ifdef EBCDIC_NL25 466 #define VSPACE_LIST \ 467 CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, CHAR_LF, NOTACHAR 468 #else 469 #define VSPACE_LIST \ 470 CHAR_VT, CHAR_FF, CHAR_CR, CHAR_LF, CHAR_NEL, NOTACHAR 471 #endif 472 473 #define VSPACE_BYTE_CASES \ 474 case CHAR_LF: \ 475 case CHAR_VT: \ 476 case CHAR_FF: \ 477 case CHAR_CR: \ 478 case CHAR_NEL 479 480 #define VSPACE_CASES VSPACE_BYTE_CASES 481 #endif /* EBCDIC */ 482 483 /* -------------- End of whitespace macros -------------- */ 484 485 486 /* PCRE2 is able to support several different kinds of newline (CR, LF, CRLF, 487 "any" and "anycrlf" at present). The following macros are used to package up 488 testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various 489 modules to indicate in which datablock the parameters exist, and what the 490 start/end of string field names are. */ 491 492 #define NLTYPE_FIXED 0 /* Newline is a fixed length string */ 493 #define NLTYPE_ANY 1 /* Newline is any Unicode line ending */ 494 #define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */ 495 496 /* This macro checks for a newline at the given position */ 497 498 #define IS_NEWLINE(p) \ 499 ((NLBLOCK->nltype != NLTYPE_FIXED)? \ 500 ((p) < NLBLOCK->PSEND && \ 501 PRIV(is_newline)((p), NLBLOCK->nltype, NLBLOCK->PSEND, \ 502 &(NLBLOCK->nllen), utf)) \ 503 : \ 504 ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \ 505 UCHAR21TEST(p) == NLBLOCK->nl[0] && \ 506 (NLBLOCK->nllen == 1 || UCHAR21TEST(p+1) == NLBLOCK->nl[1]) \ 507 ) \ 508 ) 509 510 /* This macro checks for a newline immediately preceding the given position */ 511 512 #define WAS_NEWLINE(p) \ 513 ((NLBLOCK->nltype != NLTYPE_FIXED)? \ 514 ((p) > NLBLOCK->PSSTART && \ 515 PRIV(was_newline)((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \ 516 &(NLBLOCK->nllen), utf)) \ 517 : \ 518 ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \ 519 UCHAR21TEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \ 520 (NLBLOCK->nllen == 1 || UCHAR21TEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \ 521 ) \ 522 ) 523 524 /* Private flags containing information about the compiled pattern. The first 525 three must not be changed, because whichever is set is actually the number of 526 bytes in a code unit in that mode. */ 527 528 #define PCRE2_MODE8 0x00000001 /* compiled in 8 bit mode */ 529 #define PCRE2_MODE16 0x00000002 /* compiled in 16 bit mode */ 530 #define PCRE2_MODE32 0x00000004 /* compiled in 32 bit mode */ 531 #define PCRE2_FIRSTSET 0x00000010 /* first_code unit is set */ 532 #define PCRE2_FIRSTCASELESS 0x00000020 /* caseless first code unit */ 533 #define PCRE2_FIRSTMAPSET 0x00000040 /* bitmap of first code units is set */ 534 #define PCRE2_LASTSET 0x00000080 /* last code unit is set */ 535 #define PCRE2_LASTCASELESS 0x00000100 /* caseless last code unit */ 536 #define PCRE2_STARTLINE 0x00000200 /* start after \n for multiline */ 537 #define PCRE2_JCHANGED 0x00000400 /* j option used in pattern */ 538 #define PCRE2_HASCRORLF 0x00000800 /* explicit \r or \n in pattern */ 539 #define PCRE2_HASTHEN 0x00001000 /* pattern contains (*THEN) */ 540 #define PCRE2_MATCH_EMPTY 0x00002000 /* pattern can match empty string */ 541 #define PCRE2_BSR_SET 0x00004000 /* BSR was set in the pattern */ 542 #define PCRE2_NL_SET 0x00008000 /* newline was set in the pattern */ 543 #define PCRE2_NOTEMPTY_SET 0x00010000 /* (*NOTEMPTY) used ) keep */ 544 #define PCRE2_NE_ATST_SET 0x00020000 /* (*NOTEMPTY_ATSTART) used) together */ 545 #define PCRE2_DEREF_TABLES 0x00040000 /* release character tables */ 546 #define PCRE2_NOJIT 0x00080000 /* (*NOJIT) used */ 547 #define PCRE2_HASBKPORX 0x00100000 /* contains \P, \p, or \X */ 548 #define PCRE2_DUPCAPUSED 0x00200000 /* contains (?| */ 549 #define PCRE2_HASBKC 0x00400000 /* contains \C */ 550 551 #define PCRE2_MODE_MASK (PCRE2_MODE8 | PCRE2_MODE16 | PCRE2_MODE32) 552 553 /* Values for the matchedby field in a match data block. */ 554 555 enum { PCRE2_MATCHEDBY_INTERPRETER, /* pcre2_match() */ 556 PCRE2_MATCHEDBY_DFA_INTERPRETER, /* pcre2_dfa_match() */ 557 PCRE2_MATCHEDBY_JIT }; /* pcre2_jit_match() */ 558 559 /* Magic number to provide a small check against being handed junk. */ 560 561 #define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */ 562 563 /* The maximum remaining length of subject we are prepared to search for a 564 req_unit match. */ 565 566 #define REQ_CU_MAX 1000 567 568 /* Offsets for the bitmap tables in the cbits set of tables. Each table 569 contains a set of bits for a class map. Some classes are built by combining 570 these tables. */ 571 572 #define cbit_space 0 /* [:space:] or \s */ 573 #define cbit_xdigit 32 /* [:xdigit:] */ 574 #define cbit_digit 64 /* [:digit:] or \d */ 575 #define cbit_upper 96 /* [:upper:] */ 576 #define cbit_lower 128 /* [:lower:] */ 577 #define cbit_word 160 /* [:word:] or \w */ 578 #define cbit_graph 192 /* [:graph:] */ 579 #define cbit_print 224 /* [:print:] */ 580 #define cbit_punct 256 /* [:punct:] */ 581 #define cbit_cntrl 288 /* [:cntrl:] */ 582 #define cbit_length 320 /* Length of the cbits table */ 583 584 /* Bit definitions for entries in the ctypes table. */ 585 586 #define ctype_space 0x01 587 #define ctype_letter 0x02 588 #define ctype_digit 0x04 589 #define ctype_xdigit 0x08 590 #define ctype_word 0x10 /* alphanumeric or '_' */ 591 #define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */ 592 593 /* Offsets of the various tables from the base tables pointer, and 594 total length of the tables. */ 595 596 #define lcc_offset 0 /* Lower case */ 597 #define fcc_offset 256 /* Flip case */ 598 #define cbits_offset 512 /* Character classes */ 599 #define ctypes_offset (cbits_offset + cbit_length) /* Character types */ 600 #define tables_length (ctypes_offset + 256) 601 602 603 /* -------------------- Character and string names ------------------------ */ 604 605 /* If PCRE2 is to support UTF-8 on EBCDIC platforms, we cannot use normal 606 character constants like '*' because the compiler would emit their EBCDIC code, 607 which is different from their ASCII/UTF-8 code. Instead we define macros for 608 the characters so that they always use the ASCII/UTF-8 code when UTF-8 support 609 is enabled. When UTF-8 support is not enabled, the definitions use character 610 literals. Both character and string versions of each character are needed, and 611 there are some longer strings as well. 612 613 This means that, on EBCDIC platforms, the PCRE2 library can handle either 614 EBCDIC, or UTF-8, but not both. To support both in the same compiled library 615 would need different lookups depending on whether PCRE2_UTF was set or not. 616 This would make it impossible to use characters in switch/case statements, 617 which would reduce performance. For a theoretical use (which nobody has asked 618 for) in a minority area (EBCDIC platforms), this is not sensible. Any 619 application that did need both could compile two versions of the library, using 620 macros to give the functions distinct names. */ 621 622 #ifndef SUPPORT_UNICODE 623 624 /* UTF-8 support is not enabled; use the platform-dependent character literals 625 so that PCRE2 works in both ASCII and EBCDIC environments, but only in non-UTF 626 mode. Newline characters are problematic in EBCDIC. Though it has CR and LF 627 characters, a common practice has been to use its NL (0x15) character as the 628 line terminator in C-like processing environments. However, sometimes the LF 629 (0x25) character is used instead, according to this Unicode document: 630 631 http://unicode.org/standard/reports/tr13/tr13-5.html 632 633 PCRE2 defaults EBCDIC NL to 0x15, but has a build-time option to select 0x25 634 instead. Whichever is *not* chosen is defined as NEL. 635 636 In both ASCII and EBCDIC environments, CHAR_NL and CHAR_LF are synonyms for the 637 same code point. */ 638 639 #ifdef EBCDIC 640 641 #ifndef EBCDIC_NL25 642 #define CHAR_NL '\x15' 643 #define CHAR_NEL '\x25' 644 #define STR_NL "\x15" 645 #define STR_NEL "\x25" 646 #else 647 #define CHAR_NL '\x25' 648 #define CHAR_NEL '\x15' 649 #define STR_NL "\x25" 650 #define STR_NEL "\x15" 651 #endif 652 653 #define CHAR_LF CHAR_NL 654 #define STR_LF STR_NL 655 656 #define CHAR_ESC '\047' 657 #define CHAR_DEL '\007' 658 #define CHAR_NBSP ((unsigned char)'\x41') 659 #define STR_ESC "\047" 660 #define STR_DEL "\007" 661 662 #else /* Not EBCDIC */ 663 664 /* In ASCII/Unicode, linefeed is '\n' and we equate this to NL for 665 compatibility. NEL is the Unicode newline character; make sure it is 666 a positive value. */ 667 668 #define CHAR_LF '\n' 669 #define CHAR_NL CHAR_LF 670 #define CHAR_NEL ((unsigned char)'\x85') 671 #define CHAR_ESC '\033' 672 #define CHAR_DEL '\177' 673 #define CHAR_NBSP ((unsigned char)'\xa0') 674 675 #define STR_LF "\n" 676 #define STR_NL STR_LF 677 #define STR_NEL "\x85" 678 #define STR_ESC "\033" 679 #define STR_DEL "\177" 680 681 #endif /* EBCDIC */ 682 683 /* The remaining definitions work in both environments. */ 684 685 #define CHAR_NULL '\0' 686 #define CHAR_HT '\t' 687 #define CHAR_VT '\v' 688 #define CHAR_FF '\f' 689 #define CHAR_CR '\r' 690 #define CHAR_BS '\b' 691 #define CHAR_BEL '\a' 692 693 #define CHAR_SPACE ' ' 694 #define CHAR_EXCLAMATION_MARK '!' 695 #define CHAR_QUOTATION_MARK '"' 696 #define CHAR_NUMBER_SIGN '#' 697 #define CHAR_DOLLAR_SIGN '$' 698 #define CHAR_PERCENT_SIGN '%' 699 #define CHAR_AMPERSAND '&' 700 #define CHAR_APOSTROPHE '\'' 701 #define CHAR_LEFT_PARENTHESIS '(' 702 #define CHAR_RIGHT_PARENTHESIS ')' 703 #define CHAR_ASTERISK '*' 704 #define CHAR_PLUS '+' 705 #define CHAR_COMMA ',' 706 #define CHAR_MINUS '-' 707 #define CHAR_DOT '.' 708 #define CHAR_SLASH '/' 709 #define CHAR_0 '0' 710 #define CHAR_1 '1' 711 #define CHAR_2 '2' 712 #define CHAR_3 '3' 713 #define CHAR_4 '4' 714 #define CHAR_5 '5' 715 #define CHAR_6 '6' 716 #define CHAR_7 '7' 717 #define CHAR_8 '8' 718 #define CHAR_9 '9' 719 #define CHAR_COLON ':' 720 #define CHAR_SEMICOLON ';' 721 #define CHAR_LESS_THAN_SIGN '<' 722 #define CHAR_EQUALS_SIGN '=' 723 #define CHAR_GREATER_THAN_SIGN '>' 724 #define CHAR_QUESTION_MARK '?' 725 #define CHAR_COMMERCIAL_AT '@' 726 #define CHAR_A 'A' 727 #define CHAR_B 'B' 728 #define CHAR_C 'C' 729 #define CHAR_D 'D' 730 #define CHAR_E 'E' 731 #define CHAR_F 'F' 732 #define CHAR_G 'G' 733 #define CHAR_H 'H' 734 #define CHAR_I 'I' 735 #define CHAR_J 'J' 736 #define CHAR_K 'K' 737 #define CHAR_L 'L' 738 #define CHAR_M 'M' 739 #define CHAR_N 'N' 740 #define CHAR_O 'O' 741 #define CHAR_P 'P' 742 #define CHAR_Q 'Q' 743 #define CHAR_R 'R' 744 #define CHAR_S 'S' 745 #define CHAR_T 'T' 746 #define CHAR_U 'U' 747 #define CHAR_V 'V' 748 #define CHAR_W 'W' 749 #define CHAR_X 'X' 750 #define CHAR_Y 'Y' 751 #define CHAR_Z 'Z' 752 #define CHAR_LEFT_SQUARE_BRACKET '[' 753 #define CHAR_BACKSLASH '\\' 754 #define CHAR_RIGHT_SQUARE_BRACKET ']' 755 #define CHAR_CIRCUMFLEX_ACCENT '^' 756 #define CHAR_UNDERSCORE '_' 757 #define CHAR_GRAVE_ACCENT '`' 758 #define CHAR_a 'a' 759 #define CHAR_b 'b' 760 #define CHAR_c 'c' 761 #define CHAR_d 'd' 762 #define CHAR_e 'e' 763 #define CHAR_f 'f' 764 #define CHAR_g 'g' 765 #define CHAR_h 'h' 766 #define CHAR_i 'i' 767 #define CHAR_j 'j' 768 #define CHAR_k 'k' 769 #define CHAR_l 'l' 770 #define CHAR_m 'm' 771 #define CHAR_n 'n' 772 #define CHAR_o 'o' 773 #define CHAR_p 'p' 774 #define CHAR_q 'q' 775 #define CHAR_r 'r' 776 #define CHAR_s 's' 777 #define CHAR_t 't' 778 #define CHAR_u 'u' 779 #define CHAR_v 'v' 780 #define CHAR_w 'w' 781 #define CHAR_x 'x' 782 #define CHAR_y 'y' 783 #define CHAR_z 'z' 784 #define CHAR_LEFT_CURLY_BRACKET '{' 785 #define CHAR_VERTICAL_LINE '|' 786 #define CHAR_RIGHT_CURLY_BRACKET '}' 787 #define CHAR_TILDE '~' 788 789 #define STR_HT "\t" 790 #define STR_VT "\v" 791 #define STR_FF "\f" 792 #define STR_CR "\r" 793 #define STR_BS "\b" 794 #define STR_BEL "\a" 795 796 #define STR_SPACE " " 797 #define STR_EXCLAMATION_MARK "!" 798 #define STR_QUOTATION_MARK "\"" 799 #define STR_NUMBER_SIGN "#" 800 #define STR_DOLLAR_SIGN "$" 801 #define STR_PERCENT_SIGN "%" 802 #define STR_AMPERSAND "&" 803 #define STR_APOSTROPHE "'" 804 #define STR_LEFT_PARENTHESIS "(" 805 #define STR_RIGHT_PARENTHESIS ")" 806 #define STR_ASTERISK "*" 807 #define STR_PLUS "+" 808 #define STR_COMMA "," 809 #define STR_MINUS "-" 810 #define STR_DOT "." 811 #define STR_SLASH "/" 812 #define STR_0 "0" 813 #define STR_1 "1" 814 #define STR_2 "2" 815 #define STR_3 "3" 816 #define STR_4 "4" 817 #define STR_5 "5" 818 #define STR_6 "6" 819 #define STR_7 "7" 820 #define STR_8 "8" 821 #define STR_9 "9" 822 #define STR_COLON ":" 823 #define STR_SEMICOLON ";" 824 #define STR_LESS_THAN_SIGN "<" 825 #define STR_EQUALS_SIGN "=" 826 #define STR_GREATER_THAN_SIGN ">" 827 #define STR_QUESTION_MARK "?" 828 #define STR_COMMERCIAL_AT "@" 829 #define STR_A "A" 830 #define STR_B "B" 831 #define STR_C "C" 832 #define STR_D "D" 833 #define STR_E "E" 834 #define STR_F "F" 835 #define STR_G "G" 836 #define STR_H "H" 837 #define STR_I "I" 838 #define STR_J "J" 839 #define STR_K "K" 840 #define STR_L "L" 841 #define STR_M "M" 842 #define STR_N "N" 843 #define STR_O "O" 844 #define STR_P "P" 845 #define STR_Q "Q" 846 #define STR_R "R" 847 #define STR_S "S" 848 #define STR_T "T" 849 #define STR_U "U" 850 #define STR_V "V" 851 #define STR_W "W" 852 #define STR_X "X" 853 #define STR_Y "Y" 854 #define STR_Z "Z" 855 #define STR_LEFT_SQUARE_BRACKET "[" 856 #define STR_BACKSLASH "\\" 857 #define STR_RIGHT_SQUARE_BRACKET "]" 858 #define STR_CIRCUMFLEX_ACCENT "^" 859 #define STR_UNDERSCORE "_" 860 #define STR_GRAVE_ACCENT "`" 861 #define STR_a "a" 862 #define STR_b "b" 863 #define STR_c "c" 864 #define STR_d "d" 865 #define STR_e "e" 866 #define STR_f "f" 867 #define STR_g "g" 868 #define STR_h "h" 869 #define STR_i "i" 870 #define STR_j "j" 871 #define STR_k "k" 872 #define STR_l "l" 873 #define STR_m "m" 874 #define STR_n "n" 875 #define STR_o "o" 876 #define STR_p "p" 877 #define STR_q "q" 878 #define STR_r "r" 879 #define STR_s "s" 880 #define STR_t "t" 881 #define STR_u "u" 882 #define STR_v "v" 883 #define STR_w "w" 884 #define STR_x "x" 885 #define STR_y "y" 886 #define STR_z "z" 887 #define STR_LEFT_CURLY_BRACKET "{" 888 #define STR_VERTICAL_LINE "|" 889 #define STR_RIGHT_CURLY_BRACKET "}" 890 #define STR_TILDE "~" 891 892 #define STRING_ACCEPT0 "ACCEPT\0" 893 #define STRING_COMMIT0 "COMMIT\0" 894 #define STRING_F0 "F\0" 895 #define STRING_FAIL0 "FAIL\0" 896 #define STRING_MARK0 "MARK\0" 897 #define STRING_PRUNE0 "PRUNE\0" 898 #define STRING_SKIP0 "SKIP\0" 899 #define STRING_THEN "THEN" 900 901 #define STRING_alpha0 "alpha\0" 902 #define STRING_lower0 "lower\0" 903 #define STRING_upper0 "upper\0" 904 #define STRING_alnum0 "alnum\0" 905 #define STRING_ascii0 "ascii\0" 906 #define STRING_blank0 "blank\0" 907 #define STRING_cntrl0 "cntrl\0" 908 #define STRING_digit0 "digit\0" 909 #define STRING_graph0 "graph\0" 910 #define STRING_print0 "print\0" 911 #define STRING_punct0 "punct\0" 912 #define STRING_space0 "space\0" 913 #define STRING_word0 "word\0" 914 #define STRING_xdigit "xdigit" 915 916 #define STRING_DEFINE "DEFINE" 917 #define STRING_VERSION "VERSION" 918 #define STRING_WEIRD_STARTWORD "[:<:]]" 919 #define STRING_WEIRD_ENDWORD "[:>:]]" 920 921 #define STRING_CR_RIGHTPAR "CR)" 922 #define STRING_LF_RIGHTPAR "LF)" 923 #define STRING_CRLF_RIGHTPAR "CRLF)" 924 #define STRING_ANY_RIGHTPAR "ANY)" 925 #define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)" 926 #define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)" 927 #define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)" 928 #define STRING_UTF8_RIGHTPAR "UTF8)" 929 #define STRING_UTF16_RIGHTPAR "UTF16)" 930 #define STRING_UTF32_RIGHTPAR "UTF32)" 931 #define STRING_UTF_RIGHTPAR "UTF)" 932 #define STRING_UCP_RIGHTPAR "UCP)" 933 #define STRING_NO_AUTO_POSSESS_RIGHTPAR "NO_AUTO_POSSESS)" 934 #define STRING_NO_DOTSTAR_ANCHOR_RIGHTPAR "NO_DOTSTAR_ANCHOR)" 935 #define STRING_NO_JIT_RIGHTPAR "NO_JIT)" 936 #define STRING_NO_START_OPT_RIGHTPAR "NO_START_OPT)" 937 #define STRING_NOTEMPTY_RIGHTPAR "NOTEMPTY)" 938 #define STRING_NOTEMPTY_ATSTART_RIGHTPAR "NOTEMPTY_ATSTART)" 939 #define STRING_LIMIT_MATCH_EQ "LIMIT_MATCH=" 940 #define STRING_LIMIT_RECURSION_EQ "LIMIT_RECURSION=" 941 #define STRING_MARK "MARK" 942 943 #else /* SUPPORT_UNICODE */ 944 945 /* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This 946 works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode 947 only. */ 948 949 #define CHAR_HT '\011' 950 #define CHAR_VT '\013' 951 #define CHAR_FF '\014' 952 #define CHAR_CR '\015' 953 #define CHAR_LF '\012' 954 #define CHAR_NL CHAR_LF 955 #define CHAR_NEL ((unsigned char)'\x85') 956 #define CHAR_BS '\010' 957 #define CHAR_BEL '\007' 958 #define CHAR_ESC '\033' 959 #define CHAR_DEL '\177' 960 961 #define CHAR_NULL '\0' 962 #define CHAR_SPACE '\040' 963 #define CHAR_EXCLAMATION_MARK '\041' 964 #define CHAR_QUOTATION_MARK '\042' 965 #define CHAR_NUMBER_SIGN '\043' 966 #define CHAR_DOLLAR_SIGN '\044' 967 #define CHAR_PERCENT_SIGN '\045' 968 #define CHAR_AMPERSAND '\046' 969 #define CHAR_APOSTROPHE '\047' 970 #define CHAR_LEFT_PARENTHESIS '\050' 971 #define CHAR_RIGHT_PARENTHESIS '\051' 972 #define CHAR_ASTERISK '\052' 973 #define CHAR_PLUS '\053' 974 #define CHAR_COMMA '\054' 975 #define CHAR_MINUS '\055' 976 #define CHAR_DOT '\056' 977 #define CHAR_SLASH '\057' 978 #define CHAR_0 '\060' 979 #define CHAR_1 '\061' 980 #define CHAR_2 '\062' 981 #define CHAR_3 '\063' 982 #define CHAR_4 '\064' 983 #define CHAR_5 '\065' 984 #define CHAR_6 '\066' 985 #define CHAR_7 '\067' 986 #define CHAR_8 '\070' 987 #define CHAR_9 '\071' 988 #define CHAR_COLON '\072' 989 #define CHAR_SEMICOLON '\073' 990 #define CHAR_LESS_THAN_SIGN '\074' 991 #define CHAR_EQUALS_SIGN '\075' 992 #define CHAR_GREATER_THAN_SIGN '\076' 993 #define CHAR_QUESTION_MARK '\077' 994 #define CHAR_COMMERCIAL_AT '\100' 995 #define CHAR_A '\101' 996 #define CHAR_B '\102' 997 #define CHAR_C '\103' 998 #define CHAR_D '\104' 999 #define CHAR_E '\105' 1000 #define CHAR_F '\106' 1001 #define CHAR_G '\107' 1002 #define CHAR_H '\110' 1003 #define CHAR_I '\111' 1004 #define CHAR_J '\112' 1005 #define CHAR_K '\113' 1006 #define CHAR_L '\114' 1007 #define CHAR_M '\115' 1008 #define CHAR_N '\116' 1009 #define CHAR_O '\117' 1010 #define CHAR_P '\120' 1011 #define CHAR_Q '\121' 1012 #define CHAR_R '\122' 1013 #define CHAR_S '\123' 1014 #define CHAR_T '\124' 1015 #define CHAR_U '\125' 1016 #define CHAR_V '\126' 1017 #define CHAR_W '\127' 1018 #define CHAR_X '\130' 1019 #define CHAR_Y '\131' 1020 #define CHAR_Z '\132' 1021 #define CHAR_LEFT_SQUARE_BRACKET '\133' 1022 #define CHAR_BACKSLASH '\134' 1023 #define CHAR_RIGHT_SQUARE_BRACKET '\135' 1024 #define CHAR_CIRCUMFLEX_ACCENT '\136' 1025 #define CHAR_UNDERSCORE '\137' 1026 #define CHAR_GRAVE_ACCENT '\140' 1027 #define CHAR_a '\141' 1028 #define CHAR_b '\142' 1029 #define CHAR_c '\143' 1030 #define CHAR_d '\144' 1031 #define CHAR_e '\145' 1032 #define CHAR_f '\146' 1033 #define CHAR_g '\147' 1034 #define CHAR_h '\150' 1035 #define CHAR_i '\151' 1036 #define CHAR_j '\152' 1037 #define CHAR_k '\153' 1038 #define CHAR_l '\154' 1039 #define CHAR_m '\155' 1040 #define CHAR_n '\156' 1041 #define CHAR_o '\157' 1042 #define CHAR_p '\160' 1043 #define CHAR_q '\161' 1044 #define CHAR_r '\162' 1045 #define CHAR_s '\163' 1046 #define CHAR_t '\164' 1047 #define CHAR_u '\165' 1048 #define CHAR_v '\166' 1049 #define CHAR_w '\167' 1050 #define CHAR_x '\170' 1051 #define CHAR_y '\171' 1052 #define CHAR_z '\172' 1053 #define CHAR_LEFT_CURLY_BRACKET '\173' 1054 #define CHAR_VERTICAL_LINE '\174' 1055 #define CHAR_RIGHT_CURLY_BRACKET '\175' 1056 #define CHAR_TILDE '\176' 1057 #define CHAR_NBSP ((unsigned char)'\xa0') 1058 1059 #define STR_HT "\011" 1060 #define STR_VT "\013" 1061 #define STR_FF "\014" 1062 #define STR_CR "\015" 1063 #define STR_NL "\012" 1064 #define STR_BS "\010" 1065 #define STR_BEL "\007" 1066 #define STR_ESC "\033" 1067 #define STR_DEL "\177" 1068 1069 #define STR_SPACE "\040" 1070 #define STR_EXCLAMATION_MARK "\041" 1071 #define STR_QUOTATION_MARK "\042" 1072 #define STR_NUMBER_SIGN "\043" 1073 #define STR_DOLLAR_SIGN "\044" 1074 #define STR_PERCENT_SIGN "\045" 1075 #define STR_AMPERSAND "\046" 1076 #define STR_APOSTROPHE "\047" 1077 #define STR_LEFT_PARENTHESIS "\050" 1078 #define STR_RIGHT_PARENTHESIS "\051" 1079 #define STR_ASTERISK "\052" 1080 #define STR_PLUS "\053" 1081 #define STR_COMMA "\054" 1082 #define STR_MINUS "\055" 1083 #define STR_DOT "\056" 1084 #define STR_SLASH "\057" 1085 #define STR_0 "\060" 1086 #define STR_1 "\061" 1087 #define STR_2 "\062" 1088 #define STR_3 "\063" 1089 #define STR_4 "\064" 1090 #define STR_5 "\065" 1091 #define STR_6 "\066" 1092 #define STR_7 "\067" 1093 #define STR_8 "\070" 1094 #define STR_9 "\071" 1095 #define STR_COLON "\072" 1096 #define STR_SEMICOLON "\073" 1097 #define STR_LESS_THAN_SIGN "\074" 1098 #define STR_EQUALS_SIGN "\075" 1099 #define STR_GREATER_THAN_SIGN "\076" 1100 #define STR_QUESTION_MARK "\077" 1101 #define STR_COMMERCIAL_AT "\100" 1102 #define STR_A "\101" 1103 #define STR_B "\102" 1104 #define STR_C "\103" 1105 #define STR_D "\104" 1106 #define STR_E "\105" 1107 #define STR_F "\106" 1108 #define STR_G "\107" 1109 #define STR_H "\110" 1110 #define STR_I "\111" 1111 #define STR_J "\112" 1112 #define STR_K "\113" 1113 #define STR_L "\114" 1114 #define STR_M "\115" 1115 #define STR_N "\116" 1116 #define STR_O "\117" 1117 #define STR_P "\120" 1118 #define STR_Q "\121" 1119 #define STR_R "\122" 1120 #define STR_S "\123" 1121 #define STR_T "\124" 1122 #define STR_U "\125" 1123 #define STR_V "\126" 1124 #define STR_W "\127" 1125 #define STR_X "\130" 1126 #define STR_Y "\131" 1127 #define STR_Z "\132" 1128 #define STR_LEFT_SQUARE_BRACKET "\133" 1129 #define STR_BACKSLASH "\134" 1130 #define STR_RIGHT_SQUARE_BRACKET "\135" 1131 #define STR_CIRCUMFLEX_ACCENT "\136" 1132 #define STR_UNDERSCORE "\137" 1133 #define STR_GRAVE_ACCENT "\140" 1134 #define STR_a "\141" 1135 #define STR_b "\142" 1136 #define STR_c "\143" 1137 #define STR_d "\144" 1138 #define STR_e "\145" 1139 #define STR_f "\146" 1140 #define STR_g "\147" 1141 #define STR_h "\150" 1142 #define STR_i "\151" 1143 #define STR_j "\152" 1144 #define STR_k "\153" 1145 #define STR_l "\154" 1146 #define STR_m "\155" 1147 #define STR_n "\156" 1148 #define STR_o "\157" 1149 #define STR_p "\160" 1150 #define STR_q "\161" 1151 #define STR_r "\162" 1152 #define STR_s "\163" 1153 #define STR_t "\164" 1154 #define STR_u "\165" 1155 #define STR_v "\166" 1156 #define STR_w "\167" 1157 #define STR_x "\170" 1158 #define STR_y "\171" 1159 #define STR_z "\172" 1160 #define STR_LEFT_CURLY_BRACKET "\173" 1161 #define STR_VERTICAL_LINE "\174" 1162 #define STR_RIGHT_CURLY_BRACKET "\175" 1163 #define STR_TILDE "\176" 1164 1165 #define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0" 1166 #define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0" 1167 #define STRING_F0 STR_F "\0" 1168 #define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0" 1169 #define STRING_MARK0 STR_M STR_A STR_R STR_K "\0" 1170 #define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0" 1171 #define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0" 1172 #define STRING_THEN STR_T STR_H STR_E STR_N 1173 1174 #define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0" 1175 #define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0" 1176 #define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0" 1177 #define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0" 1178 #define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0" 1179 #define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0" 1180 #define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0" 1181 #define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0" 1182 #define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0" 1183 #define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0" 1184 #define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0" 1185 #define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0" 1186 #define STRING_word0 STR_w STR_o STR_r STR_d "\0" 1187 #define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t 1188 1189 #define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E 1190 #define STRING_VERSION STR_V STR_E STR_R STR_S STR_I STR_O STR_N 1191 #define STRING_WEIRD_STARTWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_LESS_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET 1192 #define STRING_WEIRD_ENDWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_GREATER_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET 1193 1194 #define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS 1195 #define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS 1196 #define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS 1197 #define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS 1198 #define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS 1199 #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 1200 #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 1201 #define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS 1202 #define STRING_UTF16_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS 1203 #define STRING_UTF32_RIGHTPAR STR_U STR_T STR_F STR_3 STR_2 STR_RIGHT_PARENTHESIS 1204 #define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_RIGHT_PARENTHESIS 1205 #define STRING_UCP_RIGHTPAR STR_U STR_C STR_P STR_RIGHT_PARENTHESIS 1206 #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 1207 #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 1208 #define STRING_NO_JIT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_J STR_I STR_T STR_RIGHT_PARENTHESIS 1209 #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 1210 #define STRING_NOTEMPTY_RIGHTPAR STR_N STR_O STR_T STR_E STR_M STR_P STR_T STR_Y STR_RIGHT_PARENTHESIS 1211 #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 1212 #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 1213 #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 1214 #define STRING_MARK STR_M STR_A STR_R STR_K 1215 1216 #endif /* SUPPORT_UNICODE */ 1217 1218 /* -------------------- End of character and string names -------------------*/ 1219 1220 /* -------------------- Definitions for compiled patterns -------------------*/ 1221 1222 /* Codes for different types of Unicode property */ 1223 1224 #define PT_ANY 0 /* Any property - matches all chars */ 1225 #define PT_LAMP 1 /* L& - the union of Lu, Ll, Lt */ 1226 #define PT_GC 2 /* Specified general characteristic (e.g. L) */ 1227 #define PT_PC 3 /* Specified particular characteristic (e.g. Lu) */ 1228 #define PT_SC 4 /* Script (e.g. Han) */ 1229 #define PT_ALNUM 5 /* Alphanumeric - the union of L and N */ 1230 #define PT_SPACE 6 /* Perl space - Z plus 9,10,12,13 */ 1231 #define PT_PXSPACE 7 /* POSIX space - Z plus 9,10,11,12,13 */ 1232 #define PT_WORD 8 /* Word - L plus N plus underscore */ 1233 #define PT_CLIST 9 /* Pseudo-property: match character list */ 1234 #define PT_UCNC 10 /* Universal Character nameable character */ 1235 #define PT_TABSIZE 11 /* Size of square table for autopossessify tests */ 1236 1237 /* The following special properties are used only in XCLASS items, when POSIX 1238 classes are specified and PCRE2_UCP is set - in other words, for Unicode 1239 handling of these classes. They are not available via the \p or \P escapes like 1240 those in the above list, and so they do not take part in the autopossessifying 1241 table. */ 1242 1243 #define PT_PXGRAPH 11 /* [:graph:] - characters that mark the paper */ 1244 #define PT_PXPRINT 12 /* [:print:] - [:graph:] plus non-control spaces */ 1245 #define PT_PXPUNCT 13 /* [:punct:] - punctuation characters */ 1246 1247 /* Flag bits and data types for the extended class (OP_XCLASS) for classes that 1248 contain characters with values greater than 255. */ 1249 1250 #define XCL_NOT 0x01 /* Flag: this is a negative class */ 1251 #define XCL_MAP 0x02 /* Flag: a 32-byte map is present */ 1252 #define XCL_HASPROP 0x04 /* Flag: property checks are present. */ 1253 1254 #define XCL_END 0 /* Marks end of individual items */ 1255 #define XCL_SINGLE 1 /* Single item (one multibyte char) follows */ 1256 #define XCL_RANGE 2 /* A range (two multibyte chars) follows */ 1257 #define XCL_PROP 3 /* Unicode property (2-byte property code follows) */ 1258 #define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */ 1259 1260 /* Escape items that are just an encoding of a particular data value. These 1261 appear in the escapes[] table in pcre2_compile.c as positive numbers. */ 1262 1263 #ifndef ESC_a 1264 #define ESC_a CHAR_BEL 1265 #endif 1266 1267 #ifndef ESC_e 1268 #define ESC_e CHAR_ESC 1269 #endif 1270 1271 #ifndef ESC_f 1272 #define ESC_f CHAR_FF 1273 #endif 1274 1275 #ifndef ESC_n 1276 #define ESC_n CHAR_LF 1277 #endif 1278 1279 #ifndef ESC_r 1280 #define ESC_r CHAR_CR 1281 #endif 1282 1283 /* We can't officially use ESC_t because it is a POSIX reserved identifier 1284 (presumably because of all the others like size_t). */ 1285 1286 #ifndef ESC_tee 1287 #define ESC_tee CHAR_HT 1288 #endif 1289 1290 /* These are escaped items that aren't just an encoding of a particular data 1291 value such as \n. They must have non-zero values, as check_escape() returns 0 1292 for a data character. In the escapes[] table in pcre2_compile.c their values 1293 are negated in order to distinguish them from data values. 1294 1295 They must appear here in the same order as in the opcode definitions below, up 1296 to ESC_z. There's a dummy for OP_ALLANY because it corresponds to "." in DOTALL 1297 mode rather than an escape sequence. It is also used for [^] in JavaScript 1298 compatibility mode, and for \C in non-utf mode. In non-DOTALL mode, "." behaves 1299 like \N. 1300 1301 The special values ESC_DU, ESC_du, etc. are used instead of ESC_D, ESC_d, etc. 1302 when PCRE2_UCP is set and replacement of \d etc by \p sequences is required. 1303 They must be contiguous, and remain in order so that the replacements can be 1304 looked up from a table. 1305 1306 Negative numbers are used to encode a backreference (\1, \2, \3, etc.) in 1307 check_escape(). There are two tests in the code for an escape 1308 greater than ESC_b and less than ESC_Z to detect the types that may be 1309 repeated. These are the types that consume characters. If any new escapes are 1310 put in between that don't consume a character, that code will have to change. 1311 */ 1312 1313 enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, 1314 ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H, 1315 ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, 1316 ESC_E, ESC_Q, ESC_g, ESC_k, 1317 ESC_DU, ESC_du, ESC_SU, ESC_su, ESC_WU, ESC_wu }; 1318 1319 1320 /********************** Opcode definitions ******************/ 1321 1322 /****** NOTE NOTE NOTE ****** 1323 1324 Starting from 1 (i.e. after OP_END), the values up to OP_EOD must correspond in 1325 order to the list of escapes immediately above. Furthermore, values up to 1326 OP_DOLLM must not be changed without adjusting the table called autoposstab in 1327 pcre2_auto_possess.c 1328 1329 Whenever this list is updated, the two macro definitions that follow must be 1330 updated to match. The possessification table called "opcode_possessify" in 1331 pcre2_compile.c must also be updated, and also the tables called "coptable" 1332 and "poptable" in pcre2_dfa_match.c. 1333 1334 ****** NOTE NOTE NOTE ******/ 1335 1336 1337 /* The values between FIRST_AUTOTAB_OP and LAST_AUTOTAB_RIGHT_OP, inclusive, 1338 are used in a table for deciding whether a repeated character type can be 1339 auto-possessified. */ 1340 1341 #define FIRST_AUTOTAB_OP OP_NOT_DIGIT 1342 #define LAST_AUTOTAB_LEFT_OP OP_EXTUNI 1343 #define LAST_AUTOTAB_RIGHT_OP OP_DOLLM 1344 1345 enum { 1346 OP_END, /* 0 End of pattern */ 1347 1348 /* Values corresponding to backslashed metacharacters */ 1349 1350 OP_SOD, /* 1 Start of data: \A */ 1351 OP_SOM, /* 2 Start of match (subject + offset): \G */ 1352 OP_SET_SOM, /* 3 Set start of match (\K) */ 1353 OP_NOT_WORD_BOUNDARY, /* 4 \B */ 1354 OP_WORD_BOUNDARY, /* 5 \b */ 1355 OP_NOT_DIGIT, /* 6 \D */ 1356 OP_DIGIT, /* 7 \d */ 1357 OP_NOT_WHITESPACE, /* 8 \S */ 1358 OP_WHITESPACE, /* 9 \s */ 1359 OP_NOT_WORDCHAR, /* 10 \W */ 1360 OP_WORDCHAR, /* 11 \w */ 1361 1362 OP_ANY, /* 12 Match any character except newline (\N) */ 1363 OP_ALLANY, /* 13 Match any character */ 1364 OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */ 1365 OP_NOTPROP, /* 15 \P (not Unicode property) */ 1366 OP_PROP, /* 16 \p (Unicode property) */ 1367 OP_ANYNL, /* 17 \R (any newline sequence) */ 1368 OP_NOT_HSPACE, /* 18 \H (not horizontal whitespace) */ 1369 OP_HSPACE, /* 19 \h (horizontal whitespace) */ 1370 OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */ 1371 OP_VSPACE, /* 21 \v (vertical whitespace) */ 1372 OP_EXTUNI, /* 22 \X (extended Unicode sequence */ 1373 OP_EODN, /* 23 End of data or \n at end of data (\Z) */ 1374 OP_EOD, /* 24 End of data (\z) */ 1375 1376 /* Line end assertions */ 1377 1378 OP_DOLL, /* 25 End of line - not multiline */ 1379 OP_DOLLM, /* 26 End of line - multiline */ 1380 OP_CIRC, /* 27 Start of line - not multiline */ 1381 OP_CIRCM, /* 28 Start of line - multiline */ 1382 1383 /* Single characters; caseful must precede the caseless ones */ 1384 1385 OP_CHAR, /* 29 Match one character, casefully */ 1386 OP_CHARI, /* 30 Match one character, caselessly */ 1387 OP_NOT, /* 31 Match one character, not the given one, casefully */ 1388 OP_NOTI, /* 32 Match one character, not the given one, caselessly */ 1389 1390 /* The following sets of 13 opcodes must always be kept in step because 1391 the offset from the first one is used to generate the others. */ 1392 1393 /* Repeated characters; caseful must precede the caseless ones */ 1394 1395 OP_STAR, /* 33 The maximizing and minimizing versions of */ 1396 OP_MINSTAR, /* 34 these six opcodes must come in pairs, with */ 1397 OP_PLUS, /* 35 the minimizing one second. */ 1398 OP_MINPLUS, /* 36 */ 1399 OP_QUERY, /* 37 */ 1400 OP_MINQUERY, /* 38 */ 1401 1402 OP_UPTO, /* 39 From 0 to n matches of one character, caseful*/ 1403 OP_MINUPTO, /* 40 */ 1404 OP_EXACT, /* 41 Exactly n matches */ 1405 1406 OP_POSSTAR, /* 42 Possessified star, caseful */ 1407 OP_POSPLUS, /* 43 Possessified plus, caseful */ 1408 OP_POSQUERY, /* 44 Posesssified query, caseful */ 1409 OP_POSUPTO, /* 45 Possessified upto, caseful */ 1410 1411 /* Repeated characters; caseless must follow the caseful ones */ 1412 1413 OP_STARI, /* 46 */ 1414 OP_MINSTARI, /* 47 */ 1415 OP_PLUSI, /* 48 */ 1416 OP_MINPLUSI, /* 49 */ 1417 OP_QUERYI, /* 50 */ 1418 OP_MINQUERYI, /* 51 */ 1419 1420 OP_UPTOI, /* 52 From 0 to n matches of one character, caseless */ 1421 OP_MINUPTOI, /* 53 */ 1422 OP_EXACTI, /* 54 */ 1423 1424 OP_POSSTARI, /* 55 Possessified star, caseless */ 1425 OP_POSPLUSI, /* 56 Possessified plus, caseless */ 1426 OP_POSQUERYI, /* 57 Posesssified query, caseless */ 1427 OP_POSUPTOI, /* 58 Possessified upto, caseless */ 1428 1429 /* The negated ones must follow the non-negated ones, and match them */ 1430 /* Negated repeated character, caseful; must precede the caseless ones */ 1431 1432 OP_NOTSTAR, /* 59 The maximizing and minimizing versions of */ 1433 OP_NOTMINSTAR, /* 60 these six opcodes must come in pairs, with */ 1434 OP_NOTPLUS, /* 61 the minimizing one second. They must be in */ 1435 OP_NOTMINPLUS, /* 62 exactly the same order as those above. */ 1436 OP_NOTQUERY, /* 63 */ 1437 OP_NOTMINQUERY, /* 64 */ 1438 1439 OP_NOTUPTO, /* 65 From 0 to n matches, caseful */ 1440 OP_NOTMINUPTO, /* 66 */ 1441 OP_NOTEXACT, /* 67 Exactly n matches */ 1442 1443 OP_NOTPOSSTAR, /* 68 Possessified versions, caseful */ 1444 OP_NOTPOSPLUS, /* 69 */ 1445 OP_NOTPOSQUERY, /* 70 */ 1446 OP_NOTPOSUPTO, /* 71 */ 1447 1448 /* Negated repeated character, caseless; must follow the caseful ones */ 1449 1450 OP_NOTSTARI, /* 72 */ 1451 OP_NOTMINSTARI, /* 73 */ 1452 OP_NOTPLUSI, /* 74 */ 1453 OP_NOTMINPLUSI, /* 75 */ 1454 OP_NOTQUERYI, /* 76 */ 1455 OP_NOTMINQUERYI, /* 77 */ 1456 1457 OP_NOTUPTOI, /* 78 From 0 to n matches, caseless */ 1458 OP_NOTMINUPTOI, /* 79 */ 1459 OP_NOTEXACTI, /* 80 Exactly n matches */ 1460 1461 OP_NOTPOSSTARI, /* 81 Possessified versions, caseless */ 1462 OP_NOTPOSPLUSI, /* 82 */ 1463 OP_NOTPOSQUERYI, /* 83 */ 1464 OP_NOTPOSUPTOI, /* 84 */ 1465 1466 /* Character types */ 1467 1468 OP_TYPESTAR, /* 85 The maximizing and minimizing versions of */ 1469 OP_TYPEMINSTAR, /* 86 these six opcodes must come in pairs, with */ 1470 OP_TYPEPLUS, /* 87 the minimizing one second. These codes must */ 1471 OP_TYPEMINPLUS, /* 88 be in exactly the same order as those above. */ 1472 OP_TYPEQUERY, /* 89 */ 1473 OP_TYPEMINQUERY, /* 90 */ 1474 1475 OP_TYPEUPTO, /* 91 From 0 to n matches */ 1476 OP_TYPEMINUPTO, /* 92 */ 1477 OP_TYPEEXACT, /* 93 Exactly n matches */ 1478 1479 OP_TYPEPOSSTAR, /* 94 Possessified versions */ 1480 OP_TYPEPOSPLUS, /* 95 */ 1481 OP_TYPEPOSQUERY, /* 96 */ 1482 OP_TYPEPOSUPTO, /* 97 */ 1483 1484 /* These are used for character classes and back references; only the 1485 first six are the same as the sets above. */ 1486 1487 OP_CRSTAR, /* 98 The maximizing and minimizing versions of */ 1488 OP_CRMINSTAR, /* 99 all these opcodes must come in pairs, with */ 1489 OP_CRPLUS, /* 100 the minimizing one second. These codes must */ 1490 OP_CRMINPLUS, /* 101 be in exactly the same order as those above. */ 1491 OP_CRQUERY, /* 102 */ 1492 OP_CRMINQUERY, /* 103 */ 1493 1494 OP_CRRANGE, /* 104 These are different to the three sets above. */ 1495 OP_CRMINRANGE, /* 105 */ 1496 1497 OP_CRPOSSTAR, /* 106 Possessified versions */ 1498 OP_CRPOSPLUS, /* 107 */ 1499 OP_CRPOSQUERY, /* 108 */ 1500 OP_CRPOSRANGE, /* 109 */ 1501 1502 /* End of quantifier opcodes */ 1503 1504 OP_CLASS, /* 110 Match a character class, chars < 256 only */ 1505 OP_NCLASS, /* 111 Same, but the bitmap was created from a negative 1506 class - the difference is relevant only when a 1507 character > 255 is encountered. */ 1508 OP_XCLASS, /* 112 Extended class for handling > 255 chars within the 1509 class. This does both positive and negative. */ 1510 OP_REF, /* 113 Match a back reference, casefully */ 1511 OP_REFI, /* 114 Match a back reference, caselessly */ 1512 OP_DNREF, /* 115 Match a duplicate name backref, casefully */ 1513 OP_DNREFI, /* 116 Match a duplicate name backref, caselessly */ 1514 OP_RECURSE, /* 117 Match a numbered subpattern (possibly recursive) */ 1515 OP_CALLOUT, /* 118 Call out to external function if provided */ 1516 OP_CALLOUT_STR, /* 119 Call out with string argument */ 1517 1518 OP_ALT, /* 120 Start of alternation */ 1519 OP_KET, /* 121 End of group that doesn't have an unbounded repeat */ 1520 OP_KETRMAX, /* 122 These two must remain together and in this */ 1521 OP_KETRMIN, /* 123 order. They are for groups the repeat for ever. */ 1522 OP_KETRPOS, /* 124 Possessive unlimited repeat. */ 1523 1524 /* The assertions must come before BRA, CBRA, ONCE, and COND, and the four 1525 asserts must remain in order. */ 1526 1527 OP_REVERSE, /* 125 Move pointer back - used in lookbehind assertions */ 1528 OP_ASSERT, /* 126 Positive lookahead */ 1529 OP_ASSERT_NOT, /* 127 Negative lookahead */ 1530 OP_ASSERTBACK, /* 128 Positive lookbehind */ 1531 OP_ASSERTBACK_NOT, /* 129 Negative lookbehind */ 1532 1533 /* ONCE, ONCE_NC, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come immediately 1534 after the assertions, with ONCE first, as there's a test for >= ONCE for a 1535 subpattern that isn't an assertion. The POS versions must immediately follow 1536 the non-POS versions in each case. */ 1537 1538 OP_ONCE, /* 130 Atomic group, contains captures */ 1539 OP_ONCE_NC, /* 131 Atomic group containing no captures */ 1540 OP_BRA, /* 132 Start of non-capturing bracket */ 1541 OP_BRAPOS, /* 133 Ditto, with unlimited, possessive repeat */ 1542 OP_CBRA, /* 134 Start of capturing bracket */ 1543 OP_CBRAPOS, /* 135 Ditto, with unlimited, possessive repeat */ 1544 OP_COND, /* 136 Conditional group */ 1545 1546 /* These five must follow the previous five, in the same order. There's a 1547 check for >= SBRA to distinguish the two sets. */ 1548 1549 OP_SBRA, /* 137 Start of non-capturing bracket, check empty */ 1550 OP_SBRAPOS, /* 138 Ditto, with unlimited, possessive repeat */ 1551 OP_SCBRA, /* 139 Start of capturing bracket, check empty */ 1552 OP_SCBRAPOS, /* 140 Ditto, with unlimited, possessive repeat */ 1553 OP_SCOND, /* 141 Conditional group, check empty */ 1554 1555 /* The next two pairs must (respectively) be kept together. */ 1556 1557 OP_CREF, /* 142 Used to hold a capture number as condition */ 1558 OP_DNCREF, /* 143 Used to point to duplicate names as a condition */ 1559 OP_RREF, /* 144 Used to hold a recursion number as condition */ 1560 OP_DNRREF, /* 145 Used to point to duplicate names as a condition */ 1561 OP_FALSE, /* 146 Always false (used by DEFINE and VERSION) */ 1562 OP_TRUE, /* 147 Always true (used by VERSION) */ 1563 1564 OP_BRAZERO, /* 148 These two must remain together and in this */ 1565 OP_BRAMINZERO, /* 149 order. */ 1566 OP_BRAPOSZERO, /* 150 */ 1567 1568 /* These are backtracking control verbs */ 1569 1570 OP_MARK, /* 151 always has an argument */ 1571 OP_PRUNE, /* 152 */ 1572 OP_PRUNE_ARG, /* 153 same, but with argument */ 1573 OP_SKIP, /* 154 */ 1574 OP_SKIP_ARG, /* 155 same, but with argument */ 1575 OP_THEN, /* 156 */ 1576 OP_THEN_ARG, /* 157 same, but with argument */ 1577 OP_COMMIT, /* 158 */ 1578 1579 /* These are forced failure and success verbs */ 1580 1581 OP_FAIL, /* 159 */ 1582 OP_ACCEPT, /* 160 */ 1583 OP_ASSERT_ACCEPT, /* 161 Used inside assertions */ 1584 OP_CLOSE, /* 162 Used before OP_ACCEPT to close open captures */ 1585 1586 /* This is used to skip a subpattern with a {0} quantifier */ 1587 1588 OP_SKIPZERO, /* 163 */ 1589 1590 /* This is used to identify a DEFINE group during compilation so that it can 1591 be checked for having only one branch. It is changed to OP_FALSE before 1592 compilation finishes. */ 1593 1594 OP_DEFINE, /* 164 */ 1595 1596 /* This is not an opcode, but is used to check that tables indexed by opcode 1597 are the correct length, in order to catch updating errors - there have been 1598 some in the past. */ 1599 1600 OP_TABLE_LENGTH 1601 1602 }; 1603 1604 /* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro 1605 definitions that follow must also be updated to match. There are also tables 1606 called "opcode_possessify" in pcre2_compile.c and "coptable" and "poptable" in 1607 pcre2_dfa_exec.c that must be updated. */ 1608 1609 1610 /* This macro defines textual names for all the opcodes. These are used only 1611 for debugging, and some of them are only partial names. The macro is referenced 1612 only in pcre2_printint.c, which fills out the full names in many cases (and in 1613 some cases doesn't actually use these names at all). */ 1614 1615 #define OP_NAME_LIST \ 1616 "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \ 1617 "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte", \ 1618 "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \ 1619 "extuni", "\\Z", "\\z", \ 1620 "$", "$", "^", "^", "char", "chari", "not", "noti", \ 1621 "*", "*?", "+", "+?", "?", "??", \ 1622 "{", "{", "{", \ 1623 "*+","++", "?+", "{", \ 1624 "*", "*?", "+", "+?", "?", "??", \ 1625 "{", "{", "{", \ 1626 "*+","++", "?+", "{", \ 1627 "*", "*?", "+", "+?", "?", "??", \ 1628 "{", "{", "{", \ 1629 "*+","++", "?+", "{", \ 1630 "*", "*?", "+", "+?", "?", "??", \ 1631 "{", "{", "{", \ 1632 "*+","++", "?+", "{", \ 1633 "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \ 1634 "*+","++", "?+", "{", \ 1635 "*", "*?", "+", "+?", "?", "??", "{", "{", \ 1636 "*+","++", "?+", "{", \ 1637 "class", "nclass", "xclass", "Ref", "Refi", "DnRef", "DnRefi", \ 1638 "Recurse", "Callout", "CalloutStr", \ 1639 "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos", \ 1640 "Reverse", "Assert", "Assert not", "AssertB", "AssertB not", \ 1641 "Once", "Once_NC", \ 1642 "Bra", "BraPos", "CBra", "CBraPos", \ 1643 "Cond", \ 1644 "SBra", "SBraPos", "SCBra", "SCBraPos", \ 1645 "SCond", \ 1646 "Cond ref", "Cond dnref", "Cond rec", "Cond dnrec", \ 1647 "Cond false", "Cond true", \ 1648 "Brazero", "Braminzero", "Braposzero", \ 1649 "*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP", \ 1650 "*THEN", "*THEN", "*COMMIT", "*FAIL", \ 1651 "*ACCEPT", "*ASSERT_ACCEPT", \ 1652 "Close", "Skip zero", "Define" 1653 1654 1655 /* This macro defines the length of fixed length operations in the compiled 1656 regex. The lengths are used when searching for specific things, and also in the 1657 debugging printing of a compiled regex. We use a macro so that it can be 1658 defined close to the definitions of the opcodes themselves. 1659 1660 As things have been extended, some of these are no longer fixed lenths, but are 1661 minima instead. For example, the length of a single-character repeat may vary 1662 in UTF-8 mode. The code that uses this table must know about such things. */ 1663 1664 #define OP_LENGTHS \ 1665 1, /* End */ \ 1666 1, 1, 1, 1, 1, /* \A, \G, \K, \B, \b */ \ 1667 1, 1, 1, 1, 1, 1, /* \D, \d, \S, \s, \W, \w */ \ 1668 1, 1, 1, /* Any, AllAny, Anybyte */ \ 1669 3, 3, /* \P, \p */ \ 1670 1, 1, 1, 1, 1, /* \R, \H, \h, \V, \v */ \ 1671 1, /* \X */ \ 1672 1, 1, 1, 1, 1, 1, /* \Z, \z, $, $M ^, ^M */ \ 1673 2, /* Char - the minimum length */ \ 1674 2, /* Chari - the minimum length */ \ 1675 2, /* not */ \ 1676 2, /* noti */ \ 1677 /* Positive single-char repeats ** These are */ \ 1678 2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \ 1679 2+IMM2_SIZE, 2+IMM2_SIZE, /* upto, minupto ** mode */ \ 1680 2+IMM2_SIZE, /* exact */ \ 1681 2, 2, 2, 2+IMM2_SIZE, /* *+, ++, ?+, upto+ */ \ 1682 2, 2, 2, 2, 2, 2, /* *I, *?I, +I, +?I, ?I, ??I ** UTF-8 */ \ 1683 2+IMM2_SIZE, 2+IMM2_SIZE, /* upto I, minupto I */ \ 1684 2+IMM2_SIZE, /* exact I */ \ 1685 2, 2, 2, 2+IMM2_SIZE, /* *+I, ++I, ?+I, upto+I */ \ 1686 /* Negative single-char repeats - only for chars < 256 */ \ 1687 2, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \ 1688 2+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto, minupto */ \ 1689 2+IMM2_SIZE, /* NOT exact */ \ 1690 2, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *, +, ?, upto */ \ 1691 2, 2, 2, 2, 2, 2, /* NOT *I, *?I, +I, +?I, ?I, ??I */ \ 1692 2+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto I, minupto I */ \ 1693 2+IMM2_SIZE, /* NOT exact I */ \ 1694 2, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *I, +I, ?I, upto I */ \ 1695 /* Positive type repeats */ \ 1696 2, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \ 1697 2+IMM2_SIZE, 2+IMM2_SIZE, /* Type upto, minupto */ \ 1698 2+IMM2_SIZE, /* Type exact */ \ 1699 2, 2, 2, 2+IMM2_SIZE, /* Possessive *+, ++, ?+, upto+ */ \ 1700 /* Character class & ref repeats */ \ 1701 1, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \ 1702 1+2*IMM2_SIZE, 1+2*IMM2_SIZE, /* CRRANGE, CRMINRANGE */ \ 1703 1, 1, 1, 1+2*IMM2_SIZE, /* Possessive *+, ++, ?+, CRPOSRANGE */ \ 1704 1+(32/sizeof(PCRE2_UCHAR)), /* CLASS */ \ 1705 1+(32/sizeof(PCRE2_UCHAR)), /* NCLASS */ \ 1706 0, /* XCLASS - variable length */ \ 1707 1+IMM2_SIZE, /* REF */ \ 1708 1+IMM2_SIZE, /* REFI */ \ 1709 1+2*IMM2_SIZE, /* DNREF */ \ 1710 1+2*IMM2_SIZE, /* DNREFI */ \ 1711 1+LINK_SIZE, /* RECURSE */ \ 1712 1+2*LINK_SIZE+1, /* CALLOUT */ \ 1713 0, /* CALLOUT_STR - variable length */ \ 1714 1+LINK_SIZE, /* Alt */ \ 1715 1+LINK_SIZE, /* Ket */ \ 1716 1+LINK_SIZE, /* KetRmax */ \ 1717 1+LINK_SIZE, /* KetRmin */ \ 1718 1+LINK_SIZE, /* KetRpos */ \ 1719 1+LINK_SIZE, /* Reverse */ \ 1720 1+LINK_SIZE, /* Assert */ \ 1721 1+LINK_SIZE, /* Assert not */ \ 1722 1+LINK_SIZE, /* Assert behind */ \ 1723 1+LINK_SIZE, /* Assert behind not */ \ 1724 1+LINK_SIZE, /* ONCE */ \ 1725 1+LINK_SIZE, /* ONCE_NC */ \ 1726 1+LINK_SIZE, /* BRA */ \ 1727 1+LINK_SIZE, /* BRAPOS */ \ 1728 1+LINK_SIZE+IMM2_SIZE, /* CBRA */ \ 1729 1+LINK_SIZE+IMM2_SIZE, /* CBRAPOS */ \ 1730 1+LINK_SIZE, /* COND */ \ 1731 1+LINK_SIZE, /* SBRA */ \ 1732 1+LINK_SIZE, /* SBRAPOS */ \ 1733 1+LINK_SIZE+IMM2_SIZE, /* SCBRA */ \ 1734 1+LINK_SIZE+IMM2_SIZE, /* SCBRAPOS */ \ 1735 1+LINK_SIZE, /* SCOND */ \ 1736 1+IMM2_SIZE, 1+2*IMM2_SIZE, /* CREF, DNCREF */ \ 1737 1+IMM2_SIZE, 1+2*IMM2_SIZE, /* RREF, DNRREF */ \ 1738 1, 1, /* FALSE, TRUE */ \ 1739 1, 1, 1, /* BRAZERO, BRAMINZERO, BRAPOSZERO */ \ 1740 3, 1, 3, /* MARK, PRUNE, PRUNE_ARG */ \ 1741 1, 3, /* SKIP, SKIP_ARG */ \ 1742 1, 3, /* THEN, THEN_ARG */ \ 1743 1, 1, 1, 1, /* COMMIT, FAIL, ACCEPT, ASSERT_ACCEPT */ \ 1744 1+IMM2_SIZE, 1, /* CLOSE, SKIPZERO */ \ 1745 1 /* DEFINE */ 1746 1747 /* A magic value for OP_RREF to indicate the "any recursion" condition. */ 1748 1749 #define RREF_ANY 0xffff 1750 1751 1752 /* ---------- Private structures that are mode-independent. ---------- */ 1753 1754 /* Structure to hold data for custom memory management. */ 1755 1756 typedef struct pcre2_memctl { 1757 void * (*malloc)(size_t, void *); 1758 void (*free)(void *, void *); 1759 void *memory_data; 1760 } pcre2_memctl; 1761 1762 /* Structure for building a chain of open capturing subpatterns during 1763 compiling, so that instructions to close them can be compiled when (*ACCEPT) is 1764 encountered. This is also used to identify subpatterns that contain recursive 1765 back references to themselves, so that they can be made atomic. */ 1766 1767 typedef struct open_capitem { 1768 struct open_capitem *next; /* Chain link */ 1769 uint16_t number; /* Capture number */ 1770 uint16_t flag; /* Set TRUE if recursive back ref */ 1771 } open_capitem; 1772 1773 /* Layout of the UCP type table that translates property names into types and 1774 codes. Each entry used to point directly to a name, but to reduce the number of 1775 relocations in shared libraries, it now has an offset into a single string 1776 instead. */ 1777 1778 typedef struct { 1779 uint16_t name_offset; 1780 uint16_t type; 1781 uint16_t value; 1782 } ucp_type_table; 1783 1784 /* Unicode character database (UCD) record format */ 1785 1786 typedef struct { 1787 uint8_t script; /* ucp_Arabic, etc. */ 1788 uint8_t chartype; /* ucp_Cc, etc. (general categories) */ 1789 uint8_t gbprop; /* ucp_gbControl, etc. (grapheme break property) */ 1790 uint8_t caseset; /* offset to multichar other cases or zero */ 1791 int32_t other_case; /* offset to other case, or zero if none */ 1792 } ucd_record; 1793 1794 /* UCD access macros */ 1795 1796 #define UCD_BLOCK_SIZE 128 1797 #define GET_UCD(ch) (PRIV(ucd_records) + \ 1798 PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \ 1799 UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE]) 1800 1801 #define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype 1802 #define UCD_SCRIPT(ch) GET_UCD(ch)->script 1803 #define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)] 1804 #define UCD_GRAPHBREAK(ch) GET_UCD(ch)->gbprop 1805 #define UCD_CASESET(ch) GET_UCD(ch)->caseset 1806 #define UCD_OTHERCASE(ch) ((uint32_t)((int)ch + (int)(GET_UCD(ch)->other_case))) 1807 1808 /* Header for serialized pcre2 codes. */ 1809 1810 typedef struct pcre2_serialized_data { 1811 uint32_t magic; 1812 uint32_t version; 1813 uint32_t config; 1814 int32_t number_of_codes; 1815 } pcre2_serialized_data; 1816 1817 1818 1819 /* ----------------- Items that need PCRE2_CODE_UNIT_WIDTH ----------------- */ 1820 1821 /* When this file is included by pcre2test, PCRE2_CODE_UNIT_WIDTH is defined as 1822 0, so the following items are omitted. */ 1823 1824 #if defined PCRE2_CODE_UNIT_WIDTH && PCRE2_CODE_UNIT_WIDTH != 0 1825 1826 /* EBCDIC is supported only for the 8-bit library. */ 1827 1828 #if defined EBCDIC && PCRE2_CODE_UNIT_WIDTH != 8 1829 #error EBCDIC is not supported for the 16-bit or 32-bit libraries 1830 #endif 1831 1832 /* This is the largest non-UTF code point. */ 1833 1834 #define MAX_NON_UTF_CHAR (0xffffffffU >> (32 - PCRE2_CODE_UNIT_WIDTH)) 1835 1836 /* Internal shared data tables and variables. These are used by more than one 1837 of the exported public functions. They have to be "external" in the C sense, 1838 but are not part of the PCRE2 public API. Although the data for some of them is 1839 identical in all libraries, they must have different names so that multiple 1840 libraries can be simultaneously linked to a single application. However, UTF-8 1841 tables are needed only when compiling the 8-bit library. */ 1842 1843 #if PCRE2_CODE_UNIT_WIDTH == 8 1844 extern const int PRIV(utf8_table1)[]; 1845 extern const int PRIV(utf8_table1_size); 1846 extern const int PRIV(utf8_table2)[]; 1847 extern const int PRIV(utf8_table3)[]; 1848 extern const uint8_t PRIV(utf8_table4)[]; 1849 #endif 1850 1851 #define _pcre2_OP_lengths PCRE2_SUFFIX(_pcre2_OP_lengths_) 1852 #define _pcre2_callout_end_delims PCRE2_SUFFIX(_pcre2_callout_end_delims_) 1853 #define _pcre2_callout_start_delims PCRE2_SUFFIX(_pcre2_callout_start_delims_) 1854 #define _pcre2_default_compile_context PCRE2_SUFFIX(_pcre2_default_compile_context_) 1855 #define _pcre2_default_match_context PCRE2_SUFFIX(_pcre2_default_match_context_) 1856 #define _pcre2_default_tables PCRE2_SUFFIX(_pcre2_default_tables_) 1857 #define _pcre2_hspace_list PCRE2_SUFFIX(_pcre2_hspace_list_) 1858 #define _pcre2_vspace_list PCRE2_SUFFIX(_pcre2_vspace_list_) 1859 #define _pcre2_ucd_caseless_sets PCRE2_SUFFIX(_pcre2_ucd_caseless_sets_) 1860 #define _pcre2_ucd_records PCRE2_SUFFIX(_pcre2_ucd_records_) 1861 #define _pcre2_ucd_stage1 PCRE2_SUFFIX(_pcre2_ucd_stage1_) 1862 #define _pcre2_ucd_stage2 PCRE2_SUFFIX(_pcre2_ucd_stage2_) 1863 #define _pcre2_ucp_gbtable PCRE2_SUFFIX(_pcre2_ucp_gbtable_) 1864 #define _pcre2_ucp_gentype PCRE2_SUFFIX(_pcre2_ucp_gentype_) 1865 #define _pcre2_ucp_typerange PCRE2_SUFFIX(_pcre2_ucp_typerange_) 1866 #define _pcre2_unicode_version PCRE2_SUFFIX(_pcre2_unicode_version_) 1867 #define _pcre2_utt PCRE2_SUFFIX(_pcre2_utt_) 1868 #define _pcre2_utt_names PCRE2_SUFFIX(_pcre2_utt_names_) 1869 #define _pcre2_utt_size PCRE2_SUFFIX(_pcre2_utt_size_) 1870 1871 extern const uint8_t PRIV(OP_lengths)[]; 1872 extern const uint32_t PRIV(callout_end_delims)[]; 1873 extern const uint32_t PRIV(callout_start_delims)[]; 1874 extern const pcre2_compile_context PRIV(default_compile_context); 1875 extern const pcre2_match_context PRIV(default_match_context); 1876 extern const uint8_t PRIV(default_tables)[]; 1877 extern const uint32_t PRIV(hspace_list)[]; 1878 extern const uint32_t PRIV(vspace_list)[]; 1879 extern const uint32_t PRIV(ucd_caseless_sets)[]; 1880 extern const ucd_record PRIV(ucd_records)[]; 1881 extern const uint8_t PRIV(ucd_stage1)[]; 1882 extern const uint16_t PRIV(ucd_stage2)[]; 1883 extern const uint32_t PRIV(ucp_gbtable)[]; 1884 extern const uint32_t PRIV(ucp_gentype)[]; 1885 #ifdef SUPPORT_JIT 1886 extern const int PRIV(ucp_typerange)[]; 1887 #endif 1888 extern const char *PRIV(unicode_version); 1889 extern const ucp_type_table PRIV(utt)[]; 1890 extern const char PRIV(utt_names)[]; 1891 extern const size_t PRIV(utt_size); 1892 1893 /* Mode-dependent macros and hidden and private structures are defined in a 1894 separate file so that pcre2test can include them at all supported widths. When 1895 compiling the library, PCRE2_CODE_UNIT_WIDTH will be defined, and we can 1896 include them at the appropriate width, after setting up suffix macros for the 1897 private structures. */ 1898 1899 #define branch_chain PCRE2_SUFFIX(branch_chain_) 1900 #define compile_block PCRE2_SUFFIX(compile_block_) 1901 #define dfa_match_block PCRE2_SUFFIX(dfa_match_block_) 1902 #define match_block PCRE2_SUFFIX(match_block_) 1903 #define named_group PCRE2_SUFFIX(named_group_) 1904 1905 #include "pcre2_intmodedep.h" 1906 1907 /* Private "external" functions. These are internal functions that are called 1908 from modules other than the one in which they are defined. They have to be 1909 "external" in the C sense, but are not part of the PCRE2 public API. They are 1910 not referenced from pcre2test, and must not be defined when no code unit width 1911 is available. */ 1912 1913 #define _pcre2_auto_possessify PCRE2_SUFFIX(_pcre2_auto_possessify_) 1914 #define _pcre2_check_escape PCRE2_SUFFIX(_pcre2_check_escape_) 1915 #define _pcre2_find_bracket PCRE2_SUFFIX(_pcre2_find_bracket_) 1916 #define _pcre2_is_newline PCRE2_SUFFIX(_pcre2_is_newline_) 1917 #define _pcre2_jit_free_rodata PCRE2_SUFFIX(_pcre2_jit_free_rodata_) 1918 #define _pcre2_jit_free PCRE2_SUFFIX(_pcre2_jit_free_) 1919 #define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_) 1920 #define _pcre2_jit_get_target PCRE2_SUFFIX(_pcre2_jit_get_target_) 1921 #define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_) 1922 #define _pcre2_ord2utf PCRE2_SUFFIX(_pcre2_ord2utf_) 1923 #define _pcre2_strcmp PCRE2_SUFFIX(_pcre2_strcmp_) 1924 #define _pcre2_strcmp_c8 PCRE2_SUFFIX(_pcre2_strcmp_c8_) 1925 #define _pcre2_strcpy_c8 PCRE2_SUFFIX(_pcre2_strcpy_c8_) 1926 #define _pcre2_strlen PCRE2_SUFFIX(_pcre2_strlen_) 1927 #define _pcre2_strncmp PCRE2_SUFFIX(_pcre2_strncmp_) 1928 #define _pcre2_strncmp_c8 PCRE2_SUFFIX(_pcre2_strncmp_c8_) 1929 #define _pcre2_study PCRE2_SUFFIX(_pcre2_study_) 1930 #define _pcre2_valid_utf PCRE2_SUFFIX(_pcre2_valid_utf_) 1931 #define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_) 1932 #define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_) 1933 1934 extern int _pcre2_auto_possessify(PCRE2_UCHAR *, BOOL, 1935 const compile_block *); 1936 extern int _pcre2_check_escape(PCRE2_SPTR *, PCRE2_SPTR, uint32_t *, 1937 int *, uint32_t, BOOL, compile_block *); 1938 extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int); 1939 extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, 1940 uint32_t *, BOOL); 1941 extern void _pcre2_jit_free_rodata(void *, void *); 1942 extern void _pcre2_jit_free(void *, pcre2_memctl *); 1943 extern size_t _pcre2_jit_get_size(void *); 1944 const char * _pcre2_jit_get_target(void); 1945 extern void * _pcre2_memctl_malloc(size_t, pcre2_memctl *); 1946 extern unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *); 1947 extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR); 1948 extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *); 1949 extern PCRE2_SIZE _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *); 1950 extern PCRE2_SIZE _pcre2_strlen(PCRE2_SPTR); 1951 extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t); 1952 extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t); 1953 extern int _pcre2_study(pcre2_real_code *); 1954 extern int _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *); 1955 extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, 1956 uint32_t *, BOOL); 1957 extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, BOOL); 1958 #endif /* PCRE2_CODE_UNIT_WIDTH */ 1959 1960 /* End of pcre2_internal.h */ 1961