Path: blob/master/thirdparty/pcre2/src/pcre2_internal.h
9898 views
/*************************************************1* Perl-Compatible Regular Expressions *2*************************************************/34/* PCRE2 is a library of functions to support regular expressions whose syntax5and semantics are as close as possible to those of the Perl 5 language.67Written by Philip Hazel8Original API code Copyright (c) 1997-2012 University of Cambridge9New API code Copyright (c) 2016-2024 University of Cambridge1011-----------------------------------------------------------------------------12Redistribution and use in source and binary forms, with or without13modification, are permitted provided that the following conditions are met:1415* Redistributions of source code must retain the above copyright notice,16this list of conditions and the following disclaimer.1718* Redistributions in binary form must reproduce the above copyright19notice, this list of conditions and the following disclaimer in the20documentation and/or other materials provided with the distribution.2122* Neither the name of the University of Cambridge nor the names of its23contributors may be used to endorse or promote products derived from24this software without specific prior written permission.2526THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"27AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE28IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE29ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE30LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR31CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF32SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS33INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN34CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)35ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE36POSSIBILITY OF SUCH DAMAGE.37-----------------------------------------------------------------------------38*/3940#ifndef PCRE2_INTERNAL_H_IDEMPOTENT_GUARD41#define PCRE2_INTERNAL_H_IDEMPOTENT_GUARD4243/* We do not support both EBCDIC and Unicode at the same time. The "configure"44script prevents both being selected, but not everybody uses "configure". EBCDIC45is only supported for the 8-bit library, but the check for this has to be later46in this file, because the first part is not width-dependent, and is included by47pcre2test.c with CODE_UNIT_WIDTH == 0. */4849#if defined EBCDIC && defined SUPPORT_UNICODE50#error The use of both EBCDIC and SUPPORT_UNICODE is not supported.51#endif5253/* When compiling one of the libraries, the value of PCRE2_CODE_UNIT_WIDTH must54be 8, 16, or 32. AutoTools and CMake ensure that this is always the case, but55other other building methods may not, so here is a check. It is cut out when56building pcre2test, bcause that sets the value to zero. No other source should57be including this file. There is no explicit way of forcing a compile to be58abandoned, but trying to include a non-existent file seems cleanest. Otherwise59there will be many irrelevant consequential errors. */6061#if (!defined PCRE2_BUILDING_PCRE2TEST && !defined PCRE2_DFTABLES) && \62(!defined PCRE2_CODE_UNIT_WIDTH || \63(PCRE2_CODE_UNIT_WIDTH != 8 && \64PCRE2_CODE_UNIT_WIDTH != 16 && \65PCRE2_CODE_UNIT_WIDTH != 32))66#error PCRE2_CODE_UNIT_WIDTH must be defined as 8, 16, or 32.67#include <AbandonCompile>68#endif697071/* Standard C headers */7273#include <ctype.h>74#include <limits.h>75#include <stddef.h>76#include <stdio.h>77#include <stdlib.h>78#include <string.h>7980/* Macros to make boolean values more obvious. The #ifndef is to pacify81compiler warnings in environments where these macros are defined elsewhere.82Unfortunately, there is no way to do the same for the typedef. */8384typedef int BOOL;85#ifndef FALSE86#define FALSE 087#define TRUE 188#endif8990/* Helper macro for static (compile-time) assertions. Can be used inside91functions, or at the top-level of a file. */92#define STATIC_ASSERT_JOIN(a,b) a ## b93#define STATIC_ASSERT(cond, msg) \94typedef int STATIC_ASSERT_JOIN(static_assertion_,msg)[(cond)?1:-1]9596/* Valgrind (memcheck) support */9798#ifdef SUPPORT_VALGRIND99#include <valgrind/memcheck.h>100#endif101102/* -ftrivial-auto-var-init support supports initializing all local variables103to avoid some classes of bug, but this can cause an unacceptable slowdown104for large on-stack arrays in hot functions. This macro lets us annotate105such arrays. */106107#ifdef HAVE_ATTRIBUTE_UNINITIALIZED108#define PCRE2_KEEP_UNINITIALIZED __attribute__((uninitialized))109#else110#define PCRE2_KEEP_UNINITIALIZED111#endif112113/* Older versions of MSVC lack snprintf(). This define allows for114warning/error-free compilation and testing with MSVC compilers back to at least115MSVC 10/2010. Except for VC6 (which is missing some fundamentals and fails). */116117#if defined(_MSC_VER) && (_MSC_VER < 1900)118#define snprintf _snprintf119#endif120121/* When compiling a DLL for Windows, the exported symbols have to be declared122using some MS magic. I found some useful information on this web page:123http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the124information there, using __declspec(dllexport) without "extern" we have a125definition; with "extern" we have a declaration. The settings here override the126setting in pcre2.h (which is included below); it defines only PCRE2_EXP_DECL,127which is all that is needed for applications (they just import the symbols). We128use:129130PCRE2_EXP_DECL for declarations131PCRE2_EXP_DEFN for definitions132133The reason for wrapping this in #ifndef PCRE2_EXP_DECL is so that pcre2test,134which is an application, but needs to import this file in order to "peek" at135internals, can #include pcre2.h first to get an application's-eye view.136137In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,138special-purpose environments) might want to stick other stuff in front of139exported symbols. That's why, in the non-Windows case, we set PCRE2_EXP_DEFN140only if it is not already set. */141142#ifndef PCRE2_EXP_DECL143# ifdef _WIN32144# ifndef PCRE2_STATIC145# define PCRE2_EXP_DECL extern __declspec(dllexport)146# define PCRE2_EXP_DEFN __declspec(dllexport)147# else148# define PCRE2_EXP_DECL extern PCRE2_EXPORT149# define PCRE2_EXP_DEFN150# endif151# else152# ifdef __cplusplus153# define PCRE2_EXP_DECL extern "C" PCRE2_EXPORT154# else155# define PCRE2_EXP_DECL extern PCRE2_EXPORT156# endif157# ifndef PCRE2_EXP_DEFN158# define PCRE2_EXP_DEFN PCRE2_EXP_DECL159# endif160# endif161#endif162163/* Include the public PCRE2 header and the definitions of UCP character164property values. This must follow the setting of PCRE2_EXP_DECL above. */165166#include "pcre2.h"167#include "pcre2_ucp.h"168169/* When PCRE2 is compiled as a C++ library, the subject pointer can be replaced170with a custom type. This makes it possible, for example, to allow pcre2_match()171to process subject strings that are discontinuous by using a smart pointer172class. It must always be possible to inspect all of the subject string in173pcre2_match() because of the way it backtracks. */174175/* WARNING: This is as yet untested for PCRE2. */176177#ifdef CUSTOM_SUBJECT_PTR178#undef PCRE2_SPTR179#define PCRE2_SPTR CUSTOM_SUBJECT_PTR180#endif181182/* When checking for integer overflow, we need to handle large integers.183If a 64-bit integer type is available, we can use that.184Otherwise we have to cast to double, which of course requires floating point185arithmetic. Handle this by defining a macro for the appropriate type. */186187#if defined INT64_MAX || defined int64_t188#define INT64_OR_DOUBLE int64_t189#else190#define INT64_OR_DOUBLE double191#endif192193/* External (in the C sense) functions and tables that are private to the194libraries are always referenced using the PRIV macro. This makes it possible195for pcre2test.c to include some of the source files from the libraries using a196different PRIV definition to avoid name clashes. It also makes it clear in the197code that a non-static object is being referenced. */198199#ifndef PRIV200#define PRIV(name) _pcre2_##name201#endif202203/* When compiling for use with the Virtual Pascal compiler, these functions204need to have their names changed. PCRE2 must be compiled with the -DVPCOMPAT205option on the command line. */206207#ifdef VPCOMPAT208#define strlen(s) _strlen(s)209#define strncmp(s1,s2,m) _strncmp(s1,s2,m)210#define memcmp(s,c,n) _memcmp(s,c,n)211#define memcpy(d,s,n) _memcpy(d,s,n)212#define memmove(d,s,n) _memmove(d,s,n)213#define memset(s,c,n) _memset(s,c,n)214#else /* VPCOMPAT */215216/* Otherwise, to cope with SunOS4 and other systems that lack memmove(), define217a macro that calls an emulating function. */218219#ifndef HAVE_MEMMOVE220#undef memmove /* Some systems may have a macro */221#define memmove(a, b, c) PRIV(memmove)(a, b, c)222#endif /* not HAVE_MEMMOVE */223#endif /* not VPCOMPAT */224225/* This is an unsigned int value that no UTF character can ever have, as226Unicode doesn't go beyond 0x0010ffff. */227228#define NOTACHAR 0xffffffff229230/* This is the largest valid UTF/Unicode code point. */231232#define MAX_UTF_CODE_POINT 0x10ffff233234/* Compile-time positive error numbers (all except UTF errors, which are235negative) start at this value. It should probably never be changed, in case236some application is checking for specific numbers. There is a copy of this237#define in pcre2posix.c (which now no longer includes this file). Ideally, a238way of having a single definition should be found, but as the number is239unlikely to change, this is not a pressing issue. The original reason for240having a base other than 0 was to keep the absolute values of compile-time and241run-time error numbers numerically different, but in the event the code does242not rely on this. */243244#define COMPILE_ERROR_BASE 100245246/* The initial frames vector for remembering pcre2_match() backtracking points247is allocated on the heap, of this size (bytes) or ten times the frame size if248larger, unless the heap limit is smaller. Typical frame sizes are a few hundred249bytes (it depends on the number of capturing parentheses) so 20KiB handles250quite a few frames. A larger vector on the heap is obtained for matches that251need more frames, subject to the heap limit. */252253#define START_FRAMES_SIZE 20480254255/* For DFA matching, an initial internal workspace vector is allocated on the256stack. The heap is used only if this turns out to be too small. */257258#define DFA_START_RWS_SIZE 30720259260/* Define the default BSR convention. */261262#ifdef BSR_ANYCRLF263#define BSR_DEFAULT PCRE2_BSR_ANYCRLF264#else265#define BSR_DEFAULT PCRE2_BSR_UNICODE266#endif267268269/* ---------------- Basic UTF-8 macros ---------------- */270271/* These UTF-8 macros are always defined because they are used in pcre2test for272handling wide characters in 16-bit and 32-bit modes, even if an 8-bit library273is not supported. */274275/* Tests whether a UTF-8 code point needs extra bytes to decode. */276277#define HASUTF8EXTRALEN(c) ((c) >= 0xc0)278279/* The following macros were originally written in the form of loops that used280data from the tables whose names start with PRIV(utf8_table). They were281rewritten by a user so as not to use loops, because in some environments this282gives a significant performance advantage, and it seems never to do any harm.283*/284285/* Base macro to pick up the remaining bytes of a UTF-8 character, not286advancing the pointer. */287288#define GETUTF8(c, eptr) \289{ \290if ((c & 0x20u) == 0) \291c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \292else if ((c & 0x10u) == 0) \293c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \294else if ((c & 0x08u) == 0) \295c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \296((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \297else if ((c & 0x04u) == 0) \298c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \299((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \300(eptr[4] & 0x3fu); \301else \302c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \303((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \304((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \305}306307/* Base macro to pick up the remaining bytes of a UTF-8 character, advancing308the pointer. */309310#define GETUTF8INC(c, eptr) \311{ \312if ((c & 0x20u) == 0) \313c = ((c & 0x1fu) << 6) | (*eptr++ & 0x3fu); \314else if ((c & 0x10u) == 0) \315{ \316c = ((c & 0x0fu) << 12) | ((*eptr & 0x3fu) << 6) | (eptr[1] & 0x3fu); \317eptr += 2; \318} \319else if ((c & 0x08u) == 0) \320{ \321c = ((c & 0x07u) << 18) | ((*eptr & 0x3fu) << 12) | \322((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \323eptr += 3; \324} \325else if ((c & 0x04u) == 0) \326{ \327c = ((c & 0x03u) << 24) | ((*eptr & 0x3fu) << 18) | \328((eptr[1] & 0x3fu) << 12) | ((eptr[2] & 0x3fu) << 6) | \329(eptr[3] & 0x3fu); \330eptr += 4; \331} \332else \333{ \334c = ((c & 0x01u) << 30) | ((*eptr & 0x3fu) << 24) | \335((eptr[1] & 0x3fu) << 18) | ((eptr[2] & 0x3fu) << 12) | \336((eptr[3] & 0x3fu) << 6) | (eptr[4] & 0x3fu); \337eptr += 5; \338} \339}340341/* Base macro to pick up the remaining bytes of a UTF-8 character, not342advancing the pointer, incrementing the length. */343344#define GETUTF8LEN(c, eptr, len) \345{ \346if ((c & 0x20u) == 0) \347{ \348c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \349len++; \350} \351else if ((c & 0x10u) == 0) \352{ \353c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \354len += 2; \355} \356else if ((c & 0x08u) == 0) \357{\358c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \359((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \360len += 3; \361} \362else if ((c & 0x04u) == 0) \363{ \364c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \365((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \366(eptr[4] & 0x3fu); \367len += 4; \368} \369else \370{\371c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \372((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \373((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \374len += 5; \375} \376}377378/* --------------- Whitespace macros ---------------- */379380/* Tests for Unicode horizontal and vertical whitespace characters must check a381number of different values. Using a switch statement for this generates the382fastest code (no loop, no memory access), and there are several places in the383interpreter code where this happens. In order to ensure that all the case lists384remain in step, we use macros so that there is only one place where the lists385are defined.386387These values are also required as lists in pcre2_compile.c when processing \h,388\H, \v and \V in a character class. The lists are defined in pcre2_tables.c,389but macros that define the values are here so that all the definitions are390together. The lists must be in ascending character order, terminated by391NOTACHAR (which is 0xffffffff).392393Any changes should ensure that the various macros are kept in step with each394other. NOTE: The values also appear in pcre2_jit_compile.c. */395396/* -------------- ASCII/Unicode environments -------------- */397398#ifndef EBCDIC399400/* Character U+180E (Mongolian Vowel Separator) is not included in the list of401spaces in the Unicode file PropList.txt, and Perl does not recognize it as a402space. However, in many other sources it is listed as a space and has been in403PCRE (both APIs) for a long time. */404405#define HSPACE_LIST \406CHAR_HT, CHAR_SPACE, CHAR_NBSP, \4070x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \4080x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202f, 0x205f, 0x3000, \409NOTACHAR410411#define HSPACE_MULTIBYTE_CASES \412case 0x1680: /* OGHAM SPACE MARK */ \413case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ \414case 0x2000: /* EN QUAD */ \415case 0x2001: /* EM QUAD */ \416case 0x2002: /* EN SPACE */ \417case 0x2003: /* EM SPACE */ \418case 0x2004: /* THREE-PER-EM SPACE */ \419case 0x2005: /* FOUR-PER-EM SPACE */ \420case 0x2006: /* SIX-PER-EM SPACE */ \421case 0x2007: /* FIGURE SPACE */ \422case 0x2008: /* PUNCTUATION SPACE */ \423case 0x2009: /* THIN SPACE */ \424case 0x200A: /* HAIR SPACE */ \425case 0x202f: /* NARROW NO-BREAK SPACE */ \426case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ \427case 0x3000 /* IDEOGRAPHIC SPACE */428429#define HSPACE_BYTE_CASES \430case CHAR_HT: \431case CHAR_SPACE: \432case CHAR_NBSP433434#define HSPACE_CASES \435HSPACE_BYTE_CASES: \436HSPACE_MULTIBYTE_CASES437438#define VSPACE_LIST \439CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, 0x2028, 0x2029, NOTACHAR440441#define VSPACE_MULTIBYTE_CASES \442case 0x2028: /* LINE SEPARATOR */ \443case 0x2029 /* PARAGRAPH SEPARATOR */444445#define VSPACE_BYTE_CASES \446case CHAR_LF: \447case CHAR_VT: \448case CHAR_FF: \449case CHAR_CR: \450case CHAR_NEL451452#define VSPACE_CASES \453VSPACE_BYTE_CASES: \454VSPACE_MULTIBYTE_CASES455456/* -------------- EBCDIC environments -------------- */457458#else459#define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR460461#define HSPACE_BYTE_CASES \462case CHAR_HT: \463case CHAR_SPACE: \464case CHAR_NBSP465466#define HSPACE_CASES HSPACE_BYTE_CASES467468#ifdef EBCDIC_NL25469#define VSPACE_LIST \470CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, CHAR_LF, NOTACHAR471#else472#define VSPACE_LIST \473CHAR_VT, CHAR_FF, CHAR_CR, CHAR_LF, CHAR_NEL, NOTACHAR474#endif475476#define VSPACE_BYTE_CASES \477case CHAR_LF: \478case CHAR_VT: \479case CHAR_FF: \480case CHAR_CR: \481case CHAR_NEL482483#define VSPACE_CASES VSPACE_BYTE_CASES484#endif /* EBCDIC */485486/* -------------- End of whitespace macros -------------- */487488489/* PCRE2 is able to support several different kinds of newline (CR, LF, CRLF,490"any" and "anycrlf" at present). The following macros are used to package up491testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various492modules to indicate in which datablock the parameters exist, and what the493start/end of string field names are. */494495#define NLTYPE_FIXED 0 /* Newline is a fixed length string */496#define NLTYPE_ANY 1 /* Newline is any Unicode line ending */497#define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */498499/* This macro checks for a newline at the given position */500501#define IS_NEWLINE(p) \502((NLBLOCK->nltype != NLTYPE_FIXED)? \503((p) < NLBLOCK->PSEND && \504PRIV(is_newline)((p), NLBLOCK->nltype, NLBLOCK->PSEND, \505&(NLBLOCK->nllen), utf)) \506: \507((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \508UCHAR21TEST(p) == NLBLOCK->nl[0] && \509(NLBLOCK->nllen == 1 || UCHAR21TEST(p+1) == NLBLOCK->nl[1]) \510) \511)512513/* This macro checks for a newline immediately preceding the given position */514515#define WAS_NEWLINE(p) \516((NLBLOCK->nltype != NLTYPE_FIXED)? \517((p) > NLBLOCK->PSSTART && \518PRIV(was_newline)((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \519&(NLBLOCK->nllen), utf)) \520: \521((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \522UCHAR21TEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \523(NLBLOCK->nllen == 1 || UCHAR21TEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \524) \525)526527/* Private flags containing information about the compiled pattern. The first528three must not be changed, because whichever is set is actually the number of529bytes in a code unit in that mode. */530531#define PCRE2_MODE8 0x00000001u /* compiled in 8 bit mode */532#define PCRE2_MODE16 0x00000002u /* compiled in 16 bit mode */533#define PCRE2_MODE32 0x00000004u /* compiled in 32 bit mode */534#define PCRE2_FIRSTSET 0x00000010u /* first_code unit is set */535#define PCRE2_FIRSTCASELESS 0x00000020u /* caseless first code unit */536#define PCRE2_FIRSTMAPSET 0x00000040u /* bitmap of first code units is set */537#define PCRE2_LASTSET 0x00000080u /* last code unit is set */538#define PCRE2_LASTCASELESS 0x00000100u /* caseless last code unit */539#define PCRE2_STARTLINE 0x00000200u /* start after \n for multiline */540#define PCRE2_JCHANGED 0x00000400u /* j option used in pattern */541#define PCRE2_HASCRORLF 0x00000800u /* explicit \r or \n in pattern */542#define PCRE2_HASTHEN 0x00001000u /* pattern contains (*THEN) */543#define PCRE2_MATCH_EMPTY 0x00002000u /* pattern can match empty string */544#define PCRE2_BSR_SET 0x00004000u /* BSR was set in the pattern */545#define PCRE2_NL_SET 0x00008000u /* newline was set in the pattern */546#define PCRE2_NOTEMPTY_SET 0x00010000u /* (*NOTEMPTY) used ) keep */547#define PCRE2_NE_ATST_SET 0x00020000u /* (*NOTEMPTY_ATSTART) used) together */548#define PCRE2_DEREF_TABLES 0x00040000u /* release character tables */549#define PCRE2_NOJIT 0x00080000u /* (*NOJIT) used */550#define PCRE2_HASBKPORX 0x00100000u /* contains \P, \p, or \X */551#define PCRE2_DUPCAPUSED 0x00200000u /* contains (?| */552#define PCRE2_HASBKC 0x00400000u /* contains \C */553#define PCRE2_HASACCEPT 0x00800000u /* contains (*ACCEPT) */554555#define PCRE2_MODE_MASK (PCRE2_MODE8 | PCRE2_MODE16 | PCRE2_MODE32)556557/* Values for the matchedby field in a match data block. */558559enum { PCRE2_MATCHEDBY_INTERPRETER, /* pcre2_match() */560PCRE2_MATCHEDBY_DFA_INTERPRETER, /* pcre2_dfa_match() */561PCRE2_MATCHEDBY_JIT }; /* pcre2_jit_match() */562563/* Values for the flags field in a match data block. */564565#define PCRE2_MD_COPIED_SUBJECT 0x01u566567/* Magic number to provide a small check against being handed junk. */568569#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */570571/* The maximum remaining length of subject we are prepared to search for a572req_unit match from an anchored pattern. In 8-bit mode, memchr() is used and is573much faster than the search loop that has to be used in 16-bit and 32-bit574modes. */575576#if PCRE2_CODE_UNIT_WIDTH == 8577#define REQ_CU_MAX 5000578#else579#define REQ_CU_MAX 2000580#endif581582/* The maximum nesting depth for Unicode character class sets.583Currently fixed. Warning: the interpreter relies on this so it can encode584the operand stack in a uint32_t. A nesting limit of 15 implies (15*2+1)=31585stack operands required, due to the fact that we have two (and only two)586levels of operator precedence. In the UTS#18 syntax, you can write 'x&&y[z]'587and in Perl syntax you can write '(?[ x - y & (z) ])', both of which imply588pushing the match results for x & y to the stack. */589590#define ECLASS_NEST_LIMIT 15591592/* Offsets for the bitmap tables in the cbits set of tables. Each table593contains a set of bits for a class map. Some classes are built by combining594these tables. */595596#define cbit_space 0 /* [:space:] or \s */597#define cbit_xdigit 32 /* [:xdigit:] */598#define cbit_digit 64 /* [:digit:] or \d */599#define cbit_upper 96 /* [:upper:] */600#define cbit_lower 128 /* [:lower:] */601#define cbit_word 160 /* [:word:] or \w */602#define cbit_graph 192 /* [:graph:] */603#define cbit_print 224 /* [:print:] */604#define cbit_punct 256 /* [:punct:] */605#define cbit_cntrl 288 /* [:cntrl:] */606#define cbit_length 320 /* Length of the cbits table */607608/* Bit definitions for entries in the ctypes table. Do not change these values609without checking pcre2_jit_compile.c, which has an assertion to ensure that610ctype_word has the value 16. */611612#define ctype_space 0x01613#define ctype_letter 0x02614#define ctype_lcletter 0x04615#define ctype_digit 0x08616#define ctype_word 0x10 /* alphanumeric or '_' */617618/* Offsets of the various tables from the base tables pointer, and619total length of the tables. */620621#define lcc_offset 0 /* Lower case */622#define fcc_offset 256 /* Flip case */623#define cbits_offset 512 /* Character classes */624#define ctypes_offset (cbits_offset + cbit_length) /* Character types */625#define TABLES_LENGTH (ctypes_offset + 256)626627/* Private flags used in compile_context.optimization_flags */628629#define PCRE2_OPTIM_AUTO_POSSESS 0x00000001u630#define PCRE2_OPTIM_DOTSTAR_ANCHOR 0x00000002u631#define PCRE2_OPTIM_START_OPTIMIZE 0x00000004u632633#define PCRE2_OPTIMIZATION_ALL 0x00000007u634635/* -------------------- Character and string names ------------------------ */636637/* If PCRE2 is to support UTF-8 on EBCDIC platforms, we cannot use normal638character constants like '*' because the compiler would emit their EBCDIC code,639which is different from their ASCII/UTF-8 code. Instead we define macros for640the characters so that they always use the ASCII/UTF-8 code when UTF-8 support641is enabled. When UTF-8 support is not enabled, the definitions use character642literals. Both character and string versions of each character are needed, and643there are some longer strings as well.644645This means that, on EBCDIC platforms, the PCRE2 library can handle either646EBCDIC, or UTF-8, but not both. To support both in the same compiled library647would need different lookups depending on whether PCRE2_UTF was set or not.648This would make it impossible to use characters in switch/case statements,649which would reduce performance. For a theoretical use (which nobody has asked650for) in a minority area (EBCDIC platforms), this is not sensible. Any651application that did need both could compile two versions of the library, using652macros to give the functions distinct names. */653654#ifndef SUPPORT_UNICODE655656/* UTF-8 support is not enabled; use the platform-dependent character literals657so that PCRE2 works in both ASCII and EBCDIC environments, but only in non-UTF658mode. Newline characters are problematic in EBCDIC. Though it has CR and LF659characters, a common practice has been to use its NL (0x15) character as the660line terminator in C-like processing environments. However, sometimes the LF661(0x25) character is used instead, according to this Unicode document:662663http://unicode.org/standard/reports/tr13/tr13-5.html664665PCRE2 defaults EBCDIC NL to 0x15, but has a build-time option to select 0x25666instead. Whichever is *not* chosen is defined as NEL.667668In both ASCII and EBCDIC environments, CHAR_NL and CHAR_LF are synonyms for the669same code point. */670671#ifdef EBCDIC672673#ifndef EBCDIC_NL25674#define CHAR_NL '\x15'675#define CHAR_NEL '\x25'676#define STR_NL "\x15"677#define STR_NEL "\x25"678#else679#define CHAR_NL '\x25'680#define CHAR_NEL '\x15'681#define STR_NL "\x25"682#define STR_NEL "\x15"683#endif684685#define CHAR_LF CHAR_NL686#define STR_LF STR_NL687688#define CHAR_ESC '\047'689#define CHAR_DEL '\007'690#define CHAR_NBSP ((unsigned char)'\x41')691#define STR_ESC "\047"692#define STR_DEL "\007"693694#else /* Not EBCDIC */695696/* In ASCII/Unicode, linefeed is '\n' and we equate this to NL for697compatibility. NEL is the Unicode newline character; make sure it is698a positive value. */699700#define CHAR_LF '\n'701#define CHAR_NL CHAR_LF702#define CHAR_NEL ((unsigned char)'\x85')703#define CHAR_ESC '\033'704#define CHAR_DEL '\177'705#define CHAR_NBSP ((unsigned char)'\xa0')706707#define STR_LF "\n"708#define STR_NL STR_LF709#define STR_NEL "\x85"710#define STR_ESC "\033"711#define STR_DEL "\177"712713#endif /* EBCDIC */714715/* The remaining definitions work in both environments. */716717#define CHAR_NUL '\0'718#define CHAR_HT '\t'719#define CHAR_VT '\v'720#define CHAR_FF '\f'721#define CHAR_CR '\r'722#define CHAR_BS '\b'723#define CHAR_BEL '\a'724725#define CHAR_SPACE ' '726#define CHAR_EXCLAMATION_MARK '!'727#define CHAR_QUOTATION_MARK '"'728#define CHAR_NUMBER_SIGN '#'729#define CHAR_DOLLAR_SIGN '$'730#define CHAR_PERCENT_SIGN '%'731#define CHAR_AMPERSAND '&'732#define CHAR_APOSTROPHE '\''733#define CHAR_LEFT_PARENTHESIS '('734#define CHAR_RIGHT_PARENTHESIS ')'735#define CHAR_ASTERISK '*'736#define CHAR_PLUS '+'737#define CHAR_COMMA ','738#define CHAR_MINUS '-'739#define CHAR_DOT '.'740#define CHAR_SLASH '/'741#define CHAR_0 '0'742#define CHAR_1 '1'743#define CHAR_2 '2'744#define CHAR_3 '3'745#define CHAR_4 '4'746#define CHAR_5 '5'747#define CHAR_6 '6'748#define CHAR_7 '7'749#define CHAR_8 '8'750#define CHAR_9 '9'751#define CHAR_COLON ':'752#define CHAR_SEMICOLON ';'753#define CHAR_LESS_THAN_SIGN '<'754#define CHAR_EQUALS_SIGN '='755#define CHAR_GREATER_THAN_SIGN '>'756#define CHAR_QUESTION_MARK '?'757#define CHAR_COMMERCIAL_AT '@'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_SQUARE_BRACKET '['785#define CHAR_BACKSLASH '\\'786#define CHAR_RIGHT_SQUARE_BRACKET ']'787#define CHAR_CIRCUMFLEX_ACCENT '^'788#define CHAR_UNDERSCORE '_'789#define CHAR_GRAVE_ACCENT '`'790#define CHAR_a 'a'791#define CHAR_b 'b'792#define CHAR_c 'c'793#define CHAR_d 'd'794#define CHAR_e 'e'795#define CHAR_f 'f'796#define CHAR_g 'g'797#define CHAR_h 'h'798#define CHAR_i 'i'799#define CHAR_j 'j'800#define CHAR_k 'k'801#define CHAR_l 'l'802#define CHAR_m 'm'803#define CHAR_n 'n'804#define CHAR_o 'o'805#define CHAR_p 'p'806#define CHAR_q 'q'807#define CHAR_r 'r'808#define CHAR_s 's'809#define CHAR_t 't'810#define CHAR_u 'u'811#define CHAR_v 'v'812#define CHAR_w 'w'813#define CHAR_x 'x'814#define CHAR_y 'y'815#define CHAR_z 'z'816#define CHAR_LEFT_CURLY_BRACKET '{'817#define CHAR_VERTICAL_LINE '|'818#define CHAR_RIGHT_CURLY_BRACKET '}'819#define CHAR_TILDE '~'820821#define STR_HT "\t"822#define STR_VT "\v"823#define STR_FF "\f"824#define STR_CR "\r"825#define STR_BS "\b"826#define STR_BEL "\a"827828#define STR_SPACE " "829#define STR_EXCLAMATION_MARK "!"830#define STR_QUOTATION_MARK "\""831#define STR_NUMBER_SIGN "#"832#define STR_DOLLAR_SIGN "$"833#define STR_PERCENT_SIGN "%"834#define STR_AMPERSAND "&"835#define STR_APOSTROPHE "'"836#define STR_LEFT_PARENTHESIS "("837#define STR_RIGHT_PARENTHESIS ")"838#define STR_ASTERISK "*"839#define STR_PLUS "+"840#define STR_COMMA ","841#define STR_MINUS "-"842#define STR_DOT "."843#define STR_SLASH "/"844#define STR_0 "0"845#define STR_1 "1"846#define STR_2 "2"847#define STR_3 "3"848#define STR_4 "4"849#define STR_5 "5"850#define STR_6 "6"851#define STR_7 "7"852#define STR_8 "8"853#define STR_9 "9"854#define STR_COLON ":"855#define STR_SEMICOLON ";"856#define STR_LESS_THAN_SIGN "<"857#define STR_EQUALS_SIGN "="858#define STR_GREATER_THAN_SIGN ">"859#define STR_QUESTION_MARK "?"860#define STR_COMMERCIAL_AT "@"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_SQUARE_BRACKET "["888#define STR_BACKSLASH "\\"889#define STR_RIGHT_SQUARE_BRACKET "]"890#define STR_CIRCUMFLEX_ACCENT "^"891#define STR_UNDERSCORE "_"892#define STR_GRAVE_ACCENT "`"893#define STR_a "a"894#define STR_b "b"895#define STR_c "c"896#define STR_d "d"897#define STR_e "e"898#define STR_f "f"899#define STR_g "g"900#define STR_h "h"901#define STR_i "i"902#define STR_j "j"903#define STR_k "k"904#define STR_l "l"905#define STR_m "m"906#define STR_n "n"907#define STR_o "o"908#define STR_p "p"909#define STR_q "q"910#define STR_r "r"911#define STR_s "s"912#define STR_t "t"913#define STR_u "u"914#define STR_v "v"915#define STR_w "w"916#define STR_x "x"917#define STR_y "y"918#define STR_z "z"919#define STR_LEFT_CURLY_BRACKET "{"920#define STR_VERTICAL_LINE "|"921#define STR_RIGHT_CURLY_BRACKET "}"922#define STR_TILDE "~"923924#define STRING_ACCEPT0 "ACCEPT\0"925#define STRING_COMMIT0 "COMMIT\0"926#define STRING_F0 "F\0"927#define STRING_FAIL0 "FAIL\0"928#define STRING_MARK0 "MARK\0"929#define STRING_PRUNE0 "PRUNE\0"930#define STRING_SKIP0 "SKIP\0"931#define STRING_THEN "THEN"932933#define STRING_atomic0 "atomic\0"934#define STRING_pla0 "pla\0"935#define STRING_plb0 "plb\0"936#define STRING_napla0 "napla\0"937#define STRING_naplb0 "naplb\0"938#define STRING_nla0 "nla\0"939#define STRING_nlb0 "nlb\0"940#define STRING_scs0 "scs\0"941#define STRING_sr0 "sr\0"942#define STRING_asr0 "asr\0"943#define STRING_positive_lookahead0 "positive_lookahead\0"944#define STRING_positive_lookbehind0 "positive_lookbehind\0"945#define STRING_non_atomic_positive_lookahead0 "non_atomic_positive_lookahead\0"946#define STRING_non_atomic_positive_lookbehind0 "non_atomic_positive_lookbehind\0"947#define STRING_negative_lookahead0 "negative_lookahead\0"948#define STRING_negative_lookbehind0 "negative_lookbehind\0"949#define STRING_script_run0 "script_run\0"950#define STRING_atomic_script_run "atomic_script_run"951#define STRING_scan_substring0 "scan_substring\0"952953#define STRING_alpha0 "alpha\0"954#define STRING_lower0 "lower\0"955#define STRING_upper0 "upper\0"956#define STRING_alnum0 "alnum\0"957#define STRING_ascii0 "ascii\0"958#define STRING_blank0 "blank\0"959#define STRING_cntrl0 "cntrl\0"960#define STRING_digit0 "digit\0"961#define STRING_graph0 "graph\0"962#define STRING_print0 "print\0"963#define STRING_punct0 "punct\0"964#define STRING_space0 "space\0"965#define STRING_word0 "word\0"966#define STRING_xdigit "xdigit"967968#define STRING_DEFINE "DEFINE"969#define STRING_VERSION "VERSION"970#define STRING_WEIRD_STARTWORD "[:<:]]"971#define STRING_WEIRD_ENDWORD "[:>:]]"972973#define STRING_CR_RIGHTPAR "CR)"974#define STRING_LF_RIGHTPAR "LF)"975#define STRING_CRLF_RIGHTPAR "CRLF)"976#define STRING_ANY_RIGHTPAR "ANY)"977#define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)"978#define STRING_NUL_RIGHTPAR "NUL)"979#define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"980#define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"981#define STRING_UTF8_RIGHTPAR "UTF8)"982#define STRING_UTF16_RIGHTPAR "UTF16)"983#define STRING_UTF32_RIGHTPAR "UTF32)"984#define STRING_UTF_RIGHTPAR "UTF)"985#define STRING_UCP_RIGHTPAR "UCP)"986#define STRING_NO_AUTO_POSSESS_RIGHTPAR "NO_AUTO_POSSESS)"987#define STRING_NO_DOTSTAR_ANCHOR_RIGHTPAR "NO_DOTSTAR_ANCHOR)"988#define STRING_NO_JIT_RIGHTPAR "NO_JIT)"989#define STRING_NO_START_OPT_RIGHTPAR "NO_START_OPT)"990#define STRING_NOTEMPTY_RIGHTPAR "NOTEMPTY)"991#define STRING_NOTEMPTY_ATSTART_RIGHTPAR "NOTEMPTY_ATSTART)"992#define STRING_CASELESS_RESTRICT_RIGHTPAR "CASELESS_RESTRICT)"993#define STRING_TURKISH_CASING_RIGHTPAR "TURKISH_CASING)"994#define STRING_LIMIT_HEAP_EQ "LIMIT_HEAP="995#define STRING_LIMIT_MATCH_EQ "LIMIT_MATCH="996#define STRING_LIMIT_DEPTH_EQ "LIMIT_DEPTH="997#define STRING_LIMIT_RECURSION_EQ "LIMIT_RECURSION="998#define STRING_MARK "MARK"9991000#define STRING_bc "bc"1001#define STRING_bidiclass "bidiclass"1002#define STRING_sc "sc"1003#define STRING_script "script"1004#define STRING_scriptextensions "scriptextensions"1005#define STRING_scx "scx"10061007#else /* SUPPORT_UNICODE */10081009/* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This1010works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode1011only. */10121013#define CHAR_HT '\011'1014#define CHAR_VT '\013'1015#define CHAR_FF '\014'1016#define CHAR_CR '\015'1017#define CHAR_LF '\012'1018#define CHAR_NL CHAR_LF1019#define CHAR_NEL ((unsigned char)'\x85')1020#define CHAR_BS '\010'1021#define CHAR_BEL '\007'1022#define CHAR_ESC '\033'1023#define CHAR_DEL '\177'10241025#define CHAR_NUL '\0'1026#define CHAR_SPACE '\040'1027#define CHAR_EXCLAMATION_MARK '\041'1028#define CHAR_QUOTATION_MARK '\042'1029#define CHAR_NUMBER_SIGN '\043'1030#define CHAR_DOLLAR_SIGN '\044'1031#define CHAR_PERCENT_SIGN '\045'1032#define CHAR_AMPERSAND '\046'1033#define CHAR_APOSTROPHE '\047'1034#define CHAR_LEFT_PARENTHESIS '\050'1035#define CHAR_RIGHT_PARENTHESIS '\051'1036#define CHAR_ASTERISK '\052'1037#define CHAR_PLUS '\053'1038#define CHAR_COMMA '\054'1039#define CHAR_MINUS '\055'1040#define CHAR_DOT '\056'1041#define CHAR_SLASH '\057'1042#define CHAR_0 '\060'1043#define CHAR_1 '\061'1044#define CHAR_2 '\062'1045#define CHAR_3 '\063'1046#define CHAR_4 '\064'1047#define CHAR_5 '\065'1048#define CHAR_6 '\066'1049#define CHAR_7 '\067'1050#define CHAR_8 '\070'1051#define CHAR_9 '\071'1052#define CHAR_COLON '\072'1053#define CHAR_SEMICOLON '\073'1054#define CHAR_LESS_THAN_SIGN '\074'1055#define CHAR_EQUALS_SIGN '\075'1056#define CHAR_GREATER_THAN_SIGN '\076'1057#define CHAR_QUESTION_MARK '\077'1058#define CHAR_COMMERCIAL_AT '\100'1059#define CHAR_A '\101'1060#define CHAR_B '\102'1061#define CHAR_C '\103'1062#define CHAR_D '\104'1063#define CHAR_E '\105'1064#define CHAR_F '\106'1065#define CHAR_G '\107'1066#define CHAR_H '\110'1067#define CHAR_I '\111'1068#define CHAR_J '\112'1069#define CHAR_K '\113'1070#define CHAR_L '\114'1071#define CHAR_M '\115'1072#define CHAR_N '\116'1073#define CHAR_O '\117'1074#define CHAR_P '\120'1075#define CHAR_Q '\121'1076#define CHAR_R '\122'1077#define CHAR_S '\123'1078#define CHAR_T '\124'1079#define CHAR_U '\125'1080#define CHAR_V '\126'1081#define CHAR_W '\127'1082#define CHAR_X '\130'1083#define CHAR_Y '\131'1084#define CHAR_Z '\132'1085#define CHAR_LEFT_SQUARE_BRACKET '\133'1086#define CHAR_BACKSLASH '\134'1087#define CHAR_RIGHT_SQUARE_BRACKET '\135'1088#define CHAR_CIRCUMFLEX_ACCENT '\136'1089#define CHAR_UNDERSCORE '\137'1090#define CHAR_GRAVE_ACCENT '\140'1091#define CHAR_a '\141'1092#define CHAR_b '\142'1093#define CHAR_c '\143'1094#define CHAR_d '\144'1095#define CHAR_e '\145'1096#define CHAR_f '\146'1097#define CHAR_g '\147'1098#define CHAR_h '\150'1099#define CHAR_i '\151'1100#define CHAR_j '\152'1101#define CHAR_k '\153'1102#define CHAR_l '\154'1103#define CHAR_m '\155'1104#define CHAR_n '\156'1105#define CHAR_o '\157'1106#define CHAR_p '\160'1107#define CHAR_q '\161'1108#define CHAR_r '\162'1109#define CHAR_s '\163'1110#define CHAR_t '\164'1111#define CHAR_u '\165'1112#define CHAR_v '\166'1113#define CHAR_w '\167'1114#define CHAR_x '\170'1115#define CHAR_y '\171'1116#define CHAR_z '\172'1117#define CHAR_LEFT_CURLY_BRACKET '\173'1118#define CHAR_VERTICAL_LINE '\174'1119#define CHAR_RIGHT_CURLY_BRACKET '\175'1120#define CHAR_TILDE '\176'1121#define CHAR_NBSP ((unsigned char)'\xa0')11221123#define STR_HT "\011"1124#define STR_VT "\013"1125#define STR_FF "\014"1126#define STR_CR "\015"1127#define STR_NL "\012"1128#define STR_BS "\010"1129#define STR_BEL "\007"1130#define STR_ESC "\033"1131#define STR_DEL "\177"11321133#define STR_SPACE "\040"1134#define STR_EXCLAMATION_MARK "\041"1135#define STR_QUOTATION_MARK "\042"1136#define STR_NUMBER_SIGN "\043"1137#define STR_DOLLAR_SIGN "\044"1138#define STR_PERCENT_SIGN "\045"1139#define STR_AMPERSAND "\046"1140#define STR_APOSTROPHE "\047"1141#define STR_LEFT_PARENTHESIS "\050"1142#define STR_RIGHT_PARENTHESIS "\051"1143#define STR_ASTERISK "\052"1144#define STR_PLUS "\053"1145#define STR_COMMA "\054"1146#define STR_MINUS "\055"1147#define STR_DOT "\056"1148#define STR_SLASH "\057"1149#define STR_0 "\060"1150#define STR_1 "\061"1151#define STR_2 "\062"1152#define STR_3 "\063"1153#define STR_4 "\064"1154#define STR_5 "\065"1155#define STR_6 "\066"1156#define STR_7 "\067"1157#define STR_8 "\070"1158#define STR_9 "\071"1159#define STR_COLON "\072"1160#define STR_SEMICOLON "\073"1161#define STR_LESS_THAN_SIGN "\074"1162#define STR_EQUALS_SIGN "\075"1163#define STR_GREATER_THAN_SIGN "\076"1164#define STR_QUESTION_MARK "\077"1165#define STR_COMMERCIAL_AT "\100"1166#define STR_A "\101"1167#define STR_B "\102"1168#define STR_C "\103"1169#define STR_D "\104"1170#define STR_E "\105"1171#define STR_F "\106"1172#define STR_G "\107"1173#define STR_H "\110"1174#define STR_I "\111"1175#define STR_J "\112"1176#define STR_K "\113"1177#define STR_L "\114"1178#define STR_M "\115"1179#define STR_N "\116"1180#define STR_O "\117"1181#define STR_P "\120"1182#define STR_Q "\121"1183#define STR_R "\122"1184#define STR_S "\123"1185#define STR_T "\124"1186#define STR_U "\125"1187#define STR_V "\126"1188#define STR_W "\127"1189#define STR_X "\130"1190#define STR_Y "\131"1191#define STR_Z "\132"1192#define STR_LEFT_SQUARE_BRACKET "\133"1193#define STR_BACKSLASH "\134"1194#define STR_RIGHT_SQUARE_BRACKET "\135"1195#define STR_CIRCUMFLEX_ACCENT "\136"1196#define STR_UNDERSCORE "\137"1197#define STR_GRAVE_ACCENT "\140"1198#define STR_a "\141"1199#define STR_b "\142"1200#define STR_c "\143"1201#define STR_d "\144"1202#define STR_e "\145"1203#define STR_f "\146"1204#define STR_g "\147"1205#define STR_h "\150"1206#define STR_i "\151"1207#define STR_j "\152"1208#define STR_k "\153"1209#define STR_l "\154"1210#define STR_m "\155"1211#define STR_n "\156"1212#define STR_o "\157"1213#define STR_p "\160"1214#define STR_q "\161"1215#define STR_r "\162"1216#define STR_s "\163"1217#define STR_t "\164"1218#define STR_u "\165"1219#define STR_v "\166"1220#define STR_w "\167"1221#define STR_x "\170"1222#define STR_y "\171"1223#define STR_z "\172"1224#define STR_LEFT_CURLY_BRACKET "\173"1225#define STR_VERTICAL_LINE "\174"1226#define STR_RIGHT_CURLY_BRACKET "\175"1227#define STR_TILDE "\176"12281229#define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"1230#define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"1231#define STRING_F0 STR_F "\0"1232#define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"1233#define STRING_MARK0 STR_M STR_A STR_R STR_K "\0"1234#define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"1235#define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"1236#define STRING_THEN STR_T STR_H STR_E STR_N12371238#define STRING_atomic0 STR_a STR_t STR_o STR_m STR_i STR_c "\0"1239#define STRING_pla0 STR_p STR_l STR_a "\0"1240#define STRING_plb0 STR_p STR_l STR_b "\0"1241#define STRING_napla0 STR_n STR_a STR_p STR_l STR_a "\0"1242#define STRING_naplb0 STR_n STR_a STR_p STR_l STR_b "\0"1243#define STRING_nla0 STR_n STR_l STR_a "\0"1244#define STRING_nlb0 STR_n STR_l STR_b "\0"1245#define STRING_scs0 STR_s STR_c STR_s "\0"1246#define STRING_sr0 STR_s STR_r "\0"1247#define STRING_asr0 STR_a STR_s STR_r "\0"1248#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"1249#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"1250#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"1251#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"1252#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"1253#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"1254#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"1255#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_n1256#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"12571258#define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"1259#define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"1260#define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"1261#define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"1262#define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"1263#define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"1264#define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"1265#define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"1266#define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"1267#define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"1268#define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"1269#define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"1270#define STRING_word0 STR_w STR_o STR_r STR_d "\0"1271#define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t12721273#define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E1274#define STRING_VERSION STR_V STR_E STR_R STR_S STR_I STR_O STR_N1275#define STRING_WEIRD_STARTWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_LESS_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET1276#define STRING_WEIRD_ENDWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_GREATER_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET12771278#define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS1279#define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS1280#define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS1281#define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS1282#define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS1283#define STRING_NUL_RIGHTPAR STR_N STR_U STR_L STR_RIGHT_PARENTHESIS1284#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_PARENTHESIS1285#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_PARENTHESIS1286#define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS1287#define STRING_UTF16_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS1288#define STRING_UTF32_RIGHTPAR STR_U STR_T STR_F STR_3 STR_2 STR_RIGHT_PARENTHESIS1289#define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_RIGHT_PARENTHESIS1290#define STRING_UCP_RIGHTPAR STR_U STR_C STR_P STR_RIGHT_PARENTHESIS1291#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_PARENTHESIS1292#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_PARENTHESIS1293#define STRING_NO_JIT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_J STR_I STR_T STR_RIGHT_PARENTHESIS1294#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_PARENTHESIS1295#define STRING_NOTEMPTY_RIGHTPAR STR_N STR_O STR_T STR_E STR_M STR_P STR_T STR_Y STR_RIGHT_PARENTHESIS1296#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_PARENTHESIS1297#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_PARENTHESIS1298#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_PARENTHESIS1299#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_SIGN1300#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_SIGN1301#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_SIGN1302#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_SIGN1303#define STRING_MARK STR_M STR_A STR_R STR_K13041305#define STRING_bc STR_b STR_c1306#define STRING_bidiclass STR_b STR_i STR_d STR_i STR_c STR_l STR_a STR_s STR_s1307#define STRING_sc STR_s STR_c1308#define STRING_script STR_s STR_c STR_r STR_i STR_p STR_t1309#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_s1310#define STRING_scx STR_s STR_c STR_x131113121313#endif /* SUPPORT_UNICODE */13141315/* -------------------- End of character and string names -------------------*/13161317/* -------------------- Definitions for compiled patterns -------------------*/13181319/* Codes for different types of Unicode property. If these definitions are1320changed, the autopossessifying table in pcre2_auto_possess.c must be updated to1321match. */13221323#define PT_LAMP 0 /* L& - the union of Lu, Ll, Lt */1324#define PT_GC 1 /* Specified general characteristic (e.g. L) */1325#define PT_PC 2 /* Specified particular characteristic (e.g. Lu) */1326#define PT_SC 3 /* Script only (e.g. Han) */1327#define PT_SCX 4 /* Script extensions (includes SC) */1328#define PT_ALNUM 5 /* Alphanumeric - the union of L and N */1329#define PT_SPACE 6 /* Perl space - general category Z plus 9,10,12,13 */1330#define PT_PXSPACE 7 /* POSIX space - Z plus 9,10,11,12,13 */1331#define PT_WORD 8 /* Word - L, N, Mn, or Pc */1332#define PT_CLIST 9 /* Pseudo-property: match character list */1333#define PT_UCNC 10 /* Universal Character nameable character */1334#define PT_BIDICL 11 /* Specified bidi class */1335#define PT_BOOL 12 /* Boolean property */1336#define PT_ANY 13 /* Must be the last entry!1337Any property - matches all chars */1338#define PT_TABSIZE PT_ANY /* Size of square table for autopossessify tests */13391340/* The following special properties are used only in XCLASS items, when POSIX1341classes are specified and PCRE2_UCP is set - in other words, for Unicode1342handling of these classes. They are not available via the \p or \P escapes like1343those in the above list, and so they do not take part in the autopossessifying1344table. */13451346#define PT_PXGRAPH 14 /* [:graph:] - characters that mark the paper */1347#define PT_PXPRINT 15 /* [:print:] - [:graph:] plus non-control spaces */1348#define PT_PXPUNCT 16 /* [:punct:] - punctuation characters */1349#define PT_PXXDIGIT 17 /* [:xdigit:] - hex digits */13501351/* This value is used when parsing \p and \P escapes to indicate that neither1352\p{script:...} nor \p{scx:...} has been encountered. */13531354#define PT_NOTSCRIPT 25513551356/* Flag bits and data types for the extended class (OP_XCLASS) for classes that1357contain characters with values greater than 255. */13581359#define XCL_NOT 0x01 /* Flag: this is a negative class */1360#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */1361#define XCL_HASPROP 0x04 /* Flag: property checks are present. */13621363#define XCL_END 0 /* Marks end of individual items */1364#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */1365#define XCL_RANGE 2 /* A range (two multibyte chars) follows */1366#define XCL_PROP 3 /* Unicode property (2-byte property code follows) */1367#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */1368/* This value represents the beginning of character lists. The value1369is 16 bit long, and stored as a high and low byte pair in 8 bit mode.1370The lower 12 bit contains information about character lists (see later). */1371#define XCL_LIST (sizeof(PCRE2_UCHAR) == 1 ? 0x10 : 0x1000)13721373/* When a character class contains many characters/ranges,1374they are stored in character lists. There are four character1375lists which contain characters/ranges within a given range.13761377The name, character range and item size for each list:1378Low16 [0x100 - 0x7fff] 16 bit items1379High16 [0x8000 - 0xffff] 16 bit items1380Low32 [0x10000 - 0x7fffffff] 32 bit items1381High32 [0x80000000 - 0xffffffff] 32 bit items13821383The Low32 character list is used only when utf encoding or 32 bit1384character width is enabled, and the High32 character is used only1385when 32 bit character width is enabled.13861387Each character list contain items. The lowest bit represents that1388an item is the beginning of a range (bit is cleared), or not (bit1389is set). The other bits represent the character shifted left by1390one, so its highest bit is discarded. Due to the layout of character1391lists, the highest bit of a character is always known:13921393Low16 and Low32: the highest bit is always zero1394High16 and High32: the highest bit is always one13951396The items are ordered in increasing order, so binary search can be1397used to find the lower bound of an input character. The lower bound1398is the highest item, which value is less or equal than the input1399character. If the lower bit of the item is cleard, or the character1400stored in the item equals to the input character, the input1401character is in the character list. */14021403/* Character list constants. */1404#define XCL_CHAR_LIST_LOW_16_START 0x1001405#define XCL_CHAR_LIST_LOW_16_END 0x7fff1406#define XCL_CHAR_LIST_LOW_16_ADD 0x014071408#define XCL_CHAR_LIST_HIGH_16_START 0x80001409#define XCL_CHAR_LIST_HIGH_16_END 0xffff1410#define XCL_CHAR_LIST_HIGH_16_ADD 0x800014111412#define XCL_CHAR_LIST_LOW_32_START 0x100001413#define XCL_CHAR_LIST_LOW_32_END 0x7fffffff1414#define XCL_CHAR_LIST_LOW_32_ADD 0x014151416#define XCL_CHAR_LIST_HIGH_32_START 0x800000001417#define XCL_CHAR_LIST_HIGH_32_END 0xffffffff1418#define XCL_CHAR_LIST_HIGH_32_ADD 0x8000000014191420/* Mask for getting the descriptors of character list ranges.1421Each descriptor has XCL_TYPE_BIT_LEN bits, and can be processed1422by XCL_BEGIN_WITH_RANGE and XCL_ITEM_COUNT_MASK macros. */1423#define XCL_TYPE_MASK 0xfff1424#define XCL_TYPE_BIT_LEN 31425/* If this bit is set, the first item of the character list is the1426end of a range, which started before the starting character of the1427character list. */1428#define XCL_BEGIN_WITH_RANGE 0x41429/* Number of items in the character list: 0, 1, or 2. The value 31430represents that the item count is stored at the begining of the1431character list. The item count has the same width as the items1432in the character list (e.g. 16 bit for Low16 and High16 lists). */1433#define XCL_ITEM_COUNT_MASK 0x31434/* Shift and flag for constructing character list items. The XCL_CHAR_END1435is set, when the item is not the beginning of a range. The XCL_CHAR_SHIFT1436can be used to encode / decode the character value stored in an item. */1437#define XCL_CHAR_END 0x11438#define XCL_CHAR_SHIFT 114391440/* Flag bits for an extended class (OP_ECLASS), which is used for complex1441character matches such as [\p{Greek} && \p{Ll}]. */14421443#define ECL_MAP 0x01 /* Flag: a 32-byte map is present */14441445/* Type tags for the items stored in an extended class (OP_ECLASS). These items1446follow the OP_ECLASS's flag char and bitmap, and represent a Reverse Polish1447Notation list of operands and operators manipulating a stack of bits. */14481449#define ECL_AND 1 /* Pop two from the stack, AND, and push result. */1450#define ECL_OR 2 /* Pop two from the stack, OR, and push result. */1451#define ECL_XOR 3 /* Pop two from the stack, XOR, and push result. */1452#define ECL_NOT 4 /* Pop one from the stack, NOT, and push result. */1453#define ECL_XCLASS 5 /* XCLASS nested within ECLASS; match and push result. */1454#define ECL_ANY 6 /* Temporary, only used during compilation. */1455#define ECL_NONE 7 /* Temporary, only used during compilation. */14561457/* These are escaped items that aren't just an encoding of a particular data1458value such as \n. They must have non-zero values, as check_escape() returns 01459for a data character. In the escapes[] table in pcre2_compile.c their values1460are negated in order to distinguish them from data values.14611462They must appear here in the same order as in the opcode definitions below, up1463to ESC_z. There's a dummy for OP_ALLANY because it corresponds to "." in DOTALL1464mode rather than an escape sequence. It is also used for [^] in JavaScript1465compatibility mode, and for \C in non-utf mode. In non-DOTALL mode, "." behaves1466like \N.14671468ESC_ub is a special return from check_escape() when, in BSUX mode, \u{ is not1469followed by hex digits and }, in which case it should mean a literal "u"1470followed by a literal "{". This hack is necessary for cases like \u{ 12}1471because without it, this is interpreted as u{12} now that spaces are allowed in1472quantifiers.14731474Negative numbers are used to encode a backreference (\1, \2, \3, etc.) in1475check_escape(). There are tests in the code for an escape greater than ESC_b1476and less than ESC_Z to detect the types that may be repeated. These are the1477types that consume characters. If any new escapes are put in between that don't1478consume a character, that code will have to change. */14791480enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,1481ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,1482ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,1483ESC_E, ESC_Q, ESC_g, ESC_k, ESC_ub };148414851486/********************** Opcode definitions ******************/14871488/****** NOTE NOTE NOTE ******14891490Starting from 1 (i.e. after OP_END), the values up to OP_EOD must correspond in1491order to the list of escapes immediately above. Furthermore, values up to1492OP_DOLLM must not be changed without adjusting the table called autoposstab in1493pcre2_auto_possess.c.14941495Whenever this list is updated, the two macro definitions that follow must be1496updated to match. The possessification table called "opcode_possessify" in1497pcre2_compile.c must also be updated, and also the tables called "coptable"1498and "poptable" in pcre2_dfa_match.c.14991500****** NOTE NOTE NOTE ******/150115021503/* The values between FIRST_AUTOTAB_OP and LAST_AUTOTAB_RIGHT_OP, inclusive,1504are used in a table for deciding whether a repeated character type can be1505auto-possessified. */15061507#define FIRST_AUTOTAB_OP OP_NOT_DIGIT1508#define LAST_AUTOTAB_LEFT_OP OP_EXTUNI1509#define LAST_AUTOTAB_RIGHT_OP OP_DOLLM15101511enum {1512OP_END, /* 0 End of pattern */15131514/* Values corresponding to backslashed metacharacters */15151516OP_SOD, /* 1 Start of data: \A */1517OP_SOM, /* 2 Start of match (subject + offset): \G */1518OP_SET_SOM, /* 3 Set start of match (\K) */1519OP_NOT_WORD_BOUNDARY, /* 4 \B -- see also OP_NOT_UCP_WORD_BOUNDARY */1520OP_WORD_BOUNDARY, /* 5 \b -- see also OP_UCP_WORD_BOUNDARY */1521OP_NOT_DIGIT, /* 6 \D */1522OP_DIGIT, /* 7 \d */1523OP_NOT_WHITESPACE, /* 8 \S */1524OP_WHITESPACE, /* 9 \s */1525OP_NOT_WORDCHAR, /* 10 \W */1526OP_WORDCHAR, /* 11 \w */15271528OP_ANY, /* 12 Match any character except newline (\N) */1529OP_ALLANY, /* 13 Match any character */1530OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */1531OP_NOTPROP, /* 15 \P (not Unicode property) */1532OP_PROP, /* 16 \p (Unicode property) */1533OP_ANYNL, /* 17 \R (any newline sequence) */1534OP_NOT_HSPACE, /* 18 \H (not horizontal whitespace) */1535OP_HSPACE, /* 19 \h (horizontal whitespace) */1536OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */1537OP_VSPACE, /* 21 \v (vertical whitespace) */1538OP_EXTUNI, /* 22 \X (extended Unicode sequence */1539OP_EODN, /* 23 End of data or \n at end of data (\Z) */1540OP_EOD, /* 24 End of data (\z) */15411542/* Line end assertions */15431544OP_DOLL, /* 25 End of line - not multiline */1545OP_DOLLM, /* 26 End of line - multiline */1546OP_CIRC, /* 27 Start of line - not multiline */1547OP_CIRCM, /* 28 Start of line - multiline */15481549/* Single characters; caseful must precede the caseless ones, and these1550must remain in this order, and adjacent. */15511552OP_CHAR, /* 29 Match one character, casefully */1553OP_CHARI, /* 30 Match one character, caselessly */1554OP_NOT, /* 31 Match one character, not the given one, casefully */1555OP_NOTI, /* 32 Match one character, not the given one, caselessly */15561557/* The following sets of 13 opcodes must always be kept in step because1558the offset from the first one is used to generate the others. */15591560/* Repeated characters; caseful must precede the caseless ones */15611562OP_STAR, /* 33 The maximizing and minimizing versions of */1563OP_MINSTAR, /* 34 these six opcodes must come in pairs, with */1564OP_PLUS, /* 35 the minimizing one second. */1565OP_MINPLUS, /* 36 */1566OP_QUERY, /* 37 */1567OP_MINQUERY, /* 38 */15681569OP_UPTO, /* 39 From 0 to n matches of one character, caseful*/1570OP_MINUPTO, /* 40 */1571OP_EXACT, /* 41 Exactly n matches */15721573OP_POSSTAR, /* 42 Possessified star, caseful */1574OP_POSPLUS, /* 43 Possessified plus, caseful */1575OP_POSQUERY, /* 44 Posesssified query, caseful */1576OP_POSUPTO, /* 45 Possessified upto, caseful */15771578/* Repeated characters; caseless must follow the caseful ones */15791580OP_STARI, /* 46 */1581OP_MINSTARI, /* 47 */1582OP_PLUSI, /* 48 */1583OP_MINPLUSI, /* 49 */1584OP_QUERYI, /* 50 */1585OP_MINQUERYI, /* 51 */15861587OP_UPTOI, /* 52 From 0 to n matches of one character, caseless */1588OP_MINUPTOI, /* 53 */1589OP_EXACTI, /* 54 */15901591OP_POSSTARI, /* 55 Possessified star, caseless */1592OP_POSPLUSI, /* 56 Possessified plus, caseless */1593OP_POSQUERYI, /* 57 Posesssified query, caseless */1594OP_POSUPTOI, /* 58 Possessified upto, caseless */15951596/* The negated ones must follow the non-negated ones, and match them */1597/* Negated repeated character, caseful; must precede the caseless ones */15981599OP_NOTSTAR, /* 59 The maximizing and minimizing versions of */1600OP_NOTMINSTAR, /* 60 these six opcodes must come in pairs, with */1601OP_NOTPLUS, /* 61 the minimizing one second. They must be in */1602OP_NOTMINPLUS, /* 62 exactly the same order as those above. */1603OP_NOTQUERY, /* 63 */1604OP_NOTMINQUERY, /* 64 */16051606OP_NOTUPTO, /* 65 From 0 to n matches, caseful */1607OP_NOTMINUPTO, /* 66 */1608OP_NOTEXACT, /* 67 Exactly n matches */16091610OP_NOTPOSSTAR, /* 68 Possessified versions, caseful */1611OP_NOTPOSPLUS, /* 69 */1612OP_NOTPOSQUERY, /* 70 */1613OP_NOTPOSUPTO, /* 71 */16141615/* Negated repeated character, caseless; must follow the caseful ones */16161617OP_NOTSTARI, /* 72 */1618OP_NOTMINSTARI, /* 73 */1619OP_NOTPLUSI, /* 74 */1620OP_NOTMINPLUSI, /* 75 */1621OP_NOTQUERYI, /* 76 */1622OP_NOTMINQUERYI, /* 77 */16231624OP_NOTUPTOI, /* 78 From 0 to n matches, caseless */1625OP_NOTMINUPTOI, /* 79 */1626OP_NOTEXACTI, /* 80 Exactly n matches */16271628OP_NOTPOSSTARI, /* 81 Possessified versions, caseless */1629OP_NOTPOSPLUSI, /* 82 */1630OP_NOTPOSQUERYI, /* 83 */1631OP_NOTPOSUPTOI, /* 84 */16321633/* Character types */16341635OP_TYPESTAR, /* 85 The maximizing and minimizing versions of */1636OP_TYPEMINSTAR, /* 86 these six opcodes must come in pairs, with */1637OP_TYPEPLUS, /* 87 the minimizing one second. These codes must */1638OP_TYPEMINPLUS, /* 88 be in exactly the same order as those above. */1639OP_TYPEQUERY, /* 89 */1640OP_TYPEMINQUERY, /* 90 */16411642OP_TYPEUPTO, /* 91 From 0 to n matches */1643OP_TYPEMINUPTO, /* 92 */1644OP_TYPEEXACT, /* 93 Exactly n matches */16451646OP_TYPEPOSSTAR, /* 94 Possessified versions */1647OP_TYPEPOSPLUS, /* 95 */1648OP_TYPEPOSQUERY, /* 96 */1649OP_TYPEPOSUPTO, /* 97 */16501651/* These are used for character classes and back references; only the1652first six are the same as the sets above. */16531654OP_CRSTAR, /* 98 The maximizing and minimizing versions of */1655OP_CRMINSTAR, /* 99 all these opcodes must come in pairs, with */1656OP_CRPLUS, /* 100 the minimizing one second. These codes must */1657OP_CRMINPLUS, /* 101 be in exactly the same order as those above. */1658OP_CRQUERY, /* 102 */1659OP_CRMINQUERY, /* 103 */16601661OP_CRRANGE, /* 104 These are different to the three sets above. */1662OP_CRMINRANGE, /* 105 */16631664OP_CRPOSSTAR, /* 106 Possessified versions */1665OP_CRPOSPLUS, /* 107 */1666OP_CRPOSQUERY, /* 108 */1667OP_CRPOSRANGE, /* 109 */16681669/* End of quantifier opcodes */16701671OP_CLASS, /* 110 Match a character class, chars < 256 only */1672OP_NCLASS, /* 111 Same, but the bitmap was created from a negative1673class - the difference is relevant only when a1674character > 255 is encountered. */1675OP_XCLASS, /* 112 Extended class for handling > 255 chars within the1676class. This does both positive and negative. */1677OP_ECLASS, /* 113 Really-extended class, for handling logical1678expressions computed over characters. */1679OP_REF, /* 114 Match a back reference, casefully */1680OP_REFI, /* 115 Match a back reference, caselessly */1681OP_DNREF, /* 116 Match a duplicate name backref, casefully */1682OP_DNREFI, /* 117 Match a duplicate name backref, caselessly */1683OP_RECURSE, /* 118 Match a numbered subpattern (possibly recursive) */1684OP_CALLOUT, /* 119 Call out to external function if provided */1685OP_CALLOUT_STR, /* 120 Call out with string argument */16861687OP_ALT, /* 121 Start of alternation */1688OP_KET, /* 122 End of group that doesn't have an unbounded repeat */1689OP_KETRMAX, /* 123 These two must remain together and in this */1690OP_KETRMIN, /* 124 order. They are for groups the repeat for ever. */1691OP_KETRPOS, /* 125 Possessive unlimited repeat. */16921693/* The assertions must come before BRA, CBRA, ONCE, and COND. */16941695OP_REVERSE, /* 126 Move pointer back - used in lookbehind assertions */1696OP_VREVERSE, /* 127 Move pointer back - variable */1697OP_ASSERT, /* 128 Positive lookahead */1698OP_ASSERT_NOT, /* 129 Negative lookahead */1699OP_ASSERTBACK, /* 130 Positive lookbehind */1700OP_ASSERTBACK_NOT, /* 131 Negative lookbehind */1701OP_ASSERT_NA, /* 132 Positive non-atomic lookahead */1702OP_ASSERTBACK_NA, /* 133 Positive non-atomic lookbehind */1703OP_ASSERT_SCS, /* 134 Scan substring */17041705/* ONCE, SCRIPT_RUN, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come1706immediately after the assertions, with ONCE first, as there's a test for >=1707ONCE for a subpattern that isn't an assertion. The POS versions must1708immediately follow the non-POS versions in each case. */17091710OP_ONCE, /* 135 Atomic group, contains captures */1711OP_SCRIPT_RUN, /* 136 Non-capture, but check characters' scripts */1712OP_BRA, /* 137 Start of non-capturing bracket */1713OP_BRAPOS, /* 138 Ditto, with unlimited, possessive repeat */1714OP_CBRA, /* 139 Start of capturing bracket */1715OP_CBRAPOS, /* 140 Ditto, with unlimited, possessive repeat */1716OP_COND, /* 141 Conditional group */17171718/* These five must follow the previous five, in the same order. There's a1719check for >= SBRA to distinguish the two sets. */17201721OP_SBRA, /* 142 Start of non-capturing bracket, check empty */1722OP_SBRAPOS, /* 143 Ditto, with unlimited, possessive repeat */1723OP_SCBRA, /* 144 Start of capturing bracket, check empty */1724OP_SCBRAPOS, /* 145 Ditto, with unlimited, possessive repeat */1725OP_SCOND, /* 146 Conditional group, check empty */17261727/* The next two pairs must (respectively) be kept together. */17281729OP_CREF, /* 147 Used to hold a capture number as condition */1730OP_DNCREF, /* 148 Used to point to duplicate names as a condition */1731OP_RREF, /* 149 Used to hold a recursion number as condition */1732OP_DNRREF, /* 150 Used to point to duplicate names as a condition */1733OP_FALSE, /* 151 Always false (used by DEFINE and VERSION) */1734OP_TRUE, /* 152 Always true (used by VERSION) */17351736OP_BRAZERO, /* 153 These two must remain together and in this */1737OP_BRAMINZERO, /* 154 order. */1738OP_BRAPOSZERO, /* 155 */17391740/* These are backtracking control verbs */17411742OP_MARK, /* 156 always has an argument */1743OP_PRUNE, /* 157 */1744OP_PRUNE_ARG, /* 158 same, but with argument */1745OP_SKIP, /* 159 */1746OP_SKIP_ARG, /* 160 same, but with argument */1747OP_THEN, /* 161 */1748OP_THEN_ARG, /* 162 same, but with argument */1749OP_COMMIT, /* 163 */1750OP_COMMIT_ARG, /* 164 same, but with argument */17511752/* These are forced failure and success verbs. FAIL and ACCEPT do accept an1753argument, but these cases can be compiled as, for example, (*MARK:X)(*FAIL)1754without the need for a special opcode. */17551756OP_FAIL, /* 165 */1757OP_ACCEPT, /* 166 */1758OP_ASSERT_ACCEPT, /* 167 Used inside assertions */1759OP_CLOSE, /* 168 Used before OP_ACCEPT to close open captures */17601761/* This is used to skip a subpattern with a {0} quantifier */17621763OP_SKIPZERO, /* 169 */17641765/* This is used to identify a DEFINE group during compilation so that it can1766be checked for having only one branch. It is changed to OP_FALSE before1767compilation finishes. */17681769OP_DEFINE, /* 170 */17701771/* These opcodes replace their normal counterparts in UCP mode when1772PCRE2_EXTRA_ASCII_BSW is not set. */17731774OP_NOT_UCP_WORD_BOUNDARY, /* 171 */1775OP_UCP_WORD_BOUNDARY, /* 172 */17761777/* This is not an opcode, but is used to check that tables indexed by opcode1778are the correct length, in order to catch updating errors - there have been1779some in the past. */17801781OP_TABLE_LENGTH17821783};17841785/* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro1786definitions that follow must also be updated to match. There are also tables1787called "opcode_possessify" in pcre2_compile.c and "coptable" and "poptable" in1788pcre2_dfa_match.c that must be updated. */178917901791/* This macro defines textual names for all the opcodes. These are used only1792for debugging, and some of them are only partial names. The macro is referenced1793only in pcre2_printint.c, which fills out the full names in many cases (and in1794some cases doesn't actually use these names at all). */17951796#define OP_NAME_LIST \1797"End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \1798"\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte", \1799"notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \1800"extuni", "\\Z", "\\z", \1801"$", "$", "^", "^", "char", "chari", "not", "noti", \1802"*", "*?", "+", "+?", "?", "??", \1803"{", "{", "{", \1804"*+","++", "?+", "{", \1805"*", "*?", "+", "+?", "?", "??", \1806"{", "{", "{", \1807"*+","++", "?+", "{", \1808"*", "*?", "+", "+?", "?", "??", \1809"{", "{", "{", \1810"*+","++", "?+", "{", \1811"*", "*?", "+", "+?", "?", "??", \1812"{", "{", "{", \1813"*+","++", "?+", "{", \1814"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \1815"*+","++", "?+", "{", \1816"*", "*?", "+", "+?", "?", "??", "{", "{", \1817"*+","++", "?+", "{", \1818"class", "nclass", "xclass", "eclass", \1819"Ref", "Refi", "DnRef", "DnRefi", \1820"Recurse", "Callout", "CalloutStr", \1821"Alt", "Ket", "KetRmax", "KetRmin", "KetRpos", \1822"Reverse", "VReverse", "Assert", "Assert not", \1823"Assert back", "Assert back not", \1824"Non-atomic assert", "Non-atomic assert back", \1825"Scan substring", \1826"Once", \1827"Script run", \1828"Bra", "BraPos", "CBra", "CBraPos", \1829"Cond", \1830"SBra", "SBraPos", "SCBra", "SCBraPos", \1831"SCond", \1832"Capture ref", "Capture dnref", "Cond rec", "Cond dnrec", \1833"Cond false", "Cond true", \1834"Brazero", "Braminzero", "Braposzero", \1835"*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP", \1836"*THEN", "*THEN", "*COMMIT", "*COMMIT", "*FAIL", \1837"*ACCEPT", "*ASSERT_ACCEPT", \1838"Close", "Skip zero", "Define", "\\B (ucp)", "\\b (ucp)"183918401841/* This macro defines the length of fixed length operations in the compiled1842regex. The lengths are used when searching for specific things, and also in the1843debugging printing of a compiled regex. We use a macro so that it can be1844defined close to the definitions of the opcodes themselves.18451846As things have been extended, some of these are no longer fixed lenths, but are1847minima instead. For example, the length of a single-character repeat may vary1848in UTF-8 mode. The code that uses this table must know about such things. */18491850#define OP_LENGTHS \18511, /* End */ \18521, 1, 1, 1, 1, /* \A, \G, \K, \B, \b */ \18531, 1, 1, 1, 1, 1, /* \D, \d, \S, \s, \W, \w */ \18541, 1, 1, /* Any, AllAny, Anybyte */ \18553, 3, /* \P, \p */ \18561, 1, 1, 1, 1, /* \R, \H, \h, \V, \v */ \18571, /* \X */ \18581, 1, 1, 1, 1, 1, /* \Z, \z, $, $M ^, ^M */ \18592, /* Char - the minimum length */ \18602, /* Chari - the minimum length */ \18612, /* not */ \18622, /* noti */ \1863/* Positive single-char repeats ** These are */ \18642, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \18652+IMM2_SIZE, 2+IMM2_SIZE, /* upto, minupto ** mode */ \18662+IMM2_SIZE, /* exact */ \18672, 2, 2, 2+IMM2_SIZE, /* *+, ++, ?+, upto+ */ \18682, 2, 2, 2, 2, 2, /* *I, *?I, +I, +?I, ?I, ??I ** UTF-8 */ \18692+IMM2_SIZE, 2+IMM2_SIZE, /* upto I, minupto I */ \18702+IMM2_SIZE, /* exact I */ \18712, 2, 2, 2+IMM2_SIZE, /* *+I, ++I, ?+I, upto+I */ \1872/* Negative single-char repeats - only for chars < 256 */ \18732, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \18742+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto, minupto */ \18752+IMM2_SIZE, /* NOT exact */ \18762, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *, +, ?, upto */ \18772, 2, 2, 2, 2, 2, /* NOT *I, *?I, +I, +?I, ?I, ??I */ \18782+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto I, minupto I */ \18792+IMM2_SIZE, /* NOT exact I */ \18802, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *I, +I, ?I, upto I */ \1881/* Positive type repeats */ \18822, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \18832+IMM2_SIZE, 2+IMM2_SIZE, /* Type upto, minupto */ \18842+IMM2_SIZE, /* Type exact */ \18852, 2, 2, 2+IMM2_SIZE, /* Possessive *+, ++, ?+, upto+ */ \1886/* Character class & ref repeats */ \18871, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \18881+2*IMM2_SIZE, 1+2*IMM2_SIZE, /* CRRANGE, CRMINRANGE */ \18891, 1, 1, 1+2*IMM2_SIZE, /* Possessive *+, ++, ?+, CRPOSRANGE */ \18901+(32/sizeof(PCRE2_UCHAR)), /* CLASS */ \18911+(32/sizeof(PCRE2_UCHAR)), /* NCLASS */ \18920, /* XCLASS - variable length */ \18930, /* ECLASS - variable length */ \18941+IMM2_SIZE, /* REF */ \18951+IMM2_SIZE+1, /* REFI */ \18961+2*IMM2_SIZE, /* DNREF */ \18971+2*IMM2_SIZE+1, /* DNREFI */ \18981+LINK_SIZE, /* RECURSE */ \18991+2*LINK_SIZE+1, /* CALLOUT */ \19000, /* CALLOUT_STR - variable length */ \19011+LINK_SIZE, /* Alt */ \19021+LINK_SIZE, /* Ket */ \19031+LINK_SIZE, /* KetRmax */ \19041+LINK_SIZE, /* KetRmin */ \19051+LINK_SIZE, /* KetRpos */ \19061+IMM2_SIZE, /* Reverse */ \19071+2*IMM2_SIZE, /* VReverse */ \19081+LINK_SIZE, /* Assert */ \19091+LINK_SIZE, /* Assert not */ \19101+LINK_SIZE, /* Assert behind */ \19111+LINK_SIZE, /* Assert behind not */ \19121+LINK_SIZE, /* NA Assert */ \19131+LINK_SIZE, /* NA Assert behind */ \19141+LINK_SIZE, /* Scan substring */ \19151+LINK_SIZE, /* ONCE */ \19161+LINK_SIZE, /* SCRIPT_RUN */ \19171+LINK_SIZE, /* BRA */ \19181+LINK_SIZE, /* BRAPOS */ \19191+LINK_SIZE+IMM2_SIZE, /* CBRA */ \19201+LINK_SIZE+IMM2_SIZE, /* CBRAPOS */ \19211+LINK_SIZE, /* COND */ \19221+LINK_SIZE, /* SBRA */ \19231+LINK_SIZE, /* SBRAPOS */ \19241+LINK_SIZE+IMM2_SIZE, /* SCBRA */ \19251+LINK_SIZE+IMM2_SIZE, /* SCBRAPOS */ \19261+LINK_SIZE, /* SCOND */ \19271+IMM2_SIZE, 1+2*IMM2_SIZE, /* CREF, DNCREF */ \19281+IMM2_SIZE, 1+2*IMM2_SIZE, /* RREF, DNRREF */ \19291, 1, /* FALSE, TRUE */ \19301, 1, 1, /* BRAZERO, BRAMINZERO, BRAPOSZERO */ \19313, 1, 3, /* MARK, PRUNE, PRUNE_ARG */ \19321, 3, /* SKIP, SKIP_ARG */ \19331, 3, /* THEN, THEN_ARG */ \19341, 3, /* COMMIT, COMMIT_ARG */ \19351, 1, 1, /* FAIL, ACCEPT, ASSERT_ACCEPT */ \19361+IMM2_SIZE, 1, /* CLOSE, SKIPZERO */ \19371, /* DEFINE */ \19381, 1 /* \B and \b in UCP mode */19391940/* A magic value for OP_RREF to indicate the "any recursion" condition. */19411942#define RREF_ANY 0xffff19431944/* Constants used by OP_REFI and OP_DNREFI to control matching behaviour. */19451946#define REFI_FLAG_CASELESS_RESTRICT 0x11947#define REFI_FLAG_TURKISH_CASING 0x2194819491950/* ---------- Private structures that are mode-independent. ---------- */19511952/* Structure to hold data for custom memory management. */19531954typedef struct pcre2_memctl {1955void * (*malloc)(size_t, void *);1956void (*free)(void *, void *);1957void *memory_data;1958} pcre2_memctl;19591960/* Structure for building a chain of open capturing subpatterns during1961compiling, so that instructions to close them can be compiled when (*ACCEPT) is1962encountered. */19631964typedef struct open_capitem {1965struct open_capitem *next; /* Chain link */1966uint16_t number; /* Capture number */1967uint16_t assert_depth; /* Assertion depth when opened */1968} open_capitem;19691970/* Layout of the UCP type table that translates property names into types and1971codes. Each entry used to point directly to a name, but to reduce the number of1972relocations in shared libraries, it now has an offset into a single string1973instead. */19741975typedef struct {1976uint16_t name_offset;1977uint16_t type;1978uint16_t value;1979} ucp_type_table;19801981/* Unicode character database (UCD) record format */19821983typedef struct {1984uint8_t script; /* ucp_Arabic, etc. */1985uint8_t chartype; /* ucp_Cc, etc. (general categories) */1986uint8_t gbprop; /* ucp_gbControl, etc. (grapheme break property) */1987uint8_t caseset; /* offset to multichar other cases or zero */1988int32_t other_case; /* offset to other case, or zero if none */1989uint16_t scriptx_bidiclass; /* script extension (11 bit) and bidi class (5 bit) values */1990uint16_t bprops; /* binary properties offset */1991} ucd_record;19921993/* UCD access macros */19941995#define UCD_BLOCK_SIZE 1281996#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \1997PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \1998UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])19992000#if PCRE2_CODE_UNIT_WIDTH == 322001#define GET_UCD(ch) ((ch > MAX_UTF_CODE_POINT)? \2002PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))2003#else2004#define GET_UCD(ch) REAL_GET_UCD(ch)2005#endif20062007#define UCD_SCRIPTX_MASK 0x3ff2008#define UCD_BIDICLASS_SHIFT 112009#define UCD_BPROPS_MASK 0xfff20102011#define UCD_SCRIPTX_PROP(prop) ((prop)->scriptx_bidiclass & UCD_SCRIPTX_MASK)2012#define UCD_BIDICLASS_PROP(prop) ((prop)->scriptx_bidiclass >> UCD_BIDICLASS_SHIFT)2013#define UCD_BPROPS_PROP(prop) ((prop)->bprops & UCD_BPROPS_MASK)20142015#define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype2016#define UCD_SCRIPT(ch) GET_UCD(ch)->script2017#define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]2018#define UCD_GRAPHBREAK(ch) GET_UCD(ch)->gbprop2019#define UCD_CASESET(ch) GET_UCD(ch)->caseset2020#define UCD_OTHERCASE(ch) ((uint32_t)((int)ch + (int)(GET_UCD(ch)->other_case)))2021#define UCD_SCRIPTX(ch) UCD_SCRIPTX_PROP(GET_UCD(ch))2022#define UCD_BPROPS(ch) UCD_BPROPS_PROP(GET_UCD(ch))2023#define UCD_BIDICLASS(ch) UCD_BIDICLASS_PROP(GET_UCD(ch))2024#define UCD_ANY_I(ch) \2025/* match any of the four characters 'i', 'I', U+0130, U+0131 */ \2026(((uint32_t)(ch) | 0x20u) == 0x69u || ((uint32_t)(ch) | 1u) == 0x0131u)2027#define UCD_DOTTED_I(ch) \2028((uint32_t)(ch) == 0x69u || (uint32_t)(ch) == 0x0130u)2029#define UCD_FOLD_I_TURKISH(ch) \2030((uint32_t)(ch) == 0x0130u ? 0x69u : \2031(uint32_t)(ch) == 0x49u ? 0x0131u : (uint32_t)(ch))20322033/* The "scriptx" and bprops fields contain offsets into vectors of 32-bit words2034that form a bitmap representing a list of scripts or boolean properties. These2035macros test or set a bit in the map by number. */20362037#define MAPBIT(map,n) ((map)[(n)/32]&(1u<<((n)%32)))2038#define MAPSET(map,n) ((map)[(n)/32]|=(1u<<((n)%32)))20392040/* Header for serialized pcre2 codes. */20412042typedef struct pcre2_serialized_data {2043uint32_t magic;2044uint32_t version;2045uint32_t config;2046int32_t number_of_codes;2047} pcre2_serialized_data;2048204920502051/* ----------------- Items that need PCRE2_CODE_UNIT_WIDTH ----------------- */20522053/* When this file is included by pcre2test, PCRE2_CODE_UNIT_WIDTH is defined as20540, so the following items are omitted. */20552056#if defined PCRE2_CODE_UNIT_WIDTH && PCRE2_CODE_UNIT_WIDTH != 020572058/* EBCDIC is supported only for the 8-bit library. */20592060#if defined EBCDIC && PCRE2_CODE_UNIT_WIDTH != 82061#error EBCDIC is not supported for the 16-bit or 32-bit libraries2062#endif20632064/* This is the largest non-UTF code point. */20652066#define MAX_NON_UTF_CHAR (0xffffffffU >> (32 - PCRE2_CODE_UNIT_WIDTH))20672068/* Internal shared data tables and variables. These are used by more than one2069of the exported public functions. They have to be "external" in the C sense,2070but are not part of the PCRE2 public API. Although the data for some of them is2071identical in all libraries, they must have different names so that multiple2072libraries can be simultaneously linked to a single application. However, UTF-82073tables are needed only when compiling the 8-bit library. */20742075#if PCRE2_CODE_UNIT_WIDTH == 82076extern const int PRIV(utf8_table1)[];2077extern const int PRIV(utf8_table1_size);2078extern const int PRIV(utf8_table2)[];2079extern const int PRIV(utf8_table3)[];2080extern const uint8_t PRIV(utf8_table4)[];2081#endif20822083#define _pcre2_OP_lengths PCRE2_SUFFIX(_pcre2_OP_lengths_)2084#define _pcre2_callout_end_delims PCRE2_SUFFIX(_pcre2_callout_end_delims_)2085#define _pcre2_callout_start_delims PCRE2_SUFFIX(_pcre2_callout_start_delims_)2086#define _pcre2_default_compile_context PCRE2_SUFFIX(_pcre2_default_compile_context_)2087#define _pcre2_default_convert_context PCRE2_SUFFIX(_pcre2_default_convert_context_)2088#define _pcre2_default_match_context PCRE2_SUFFIX(_pcre2_default_match_context_)2089#define _pcre2_default_tables PCRE2_SUFFIX(_pcre2_default_tables_)2090#if PCRE2_CODE_UNIT_WIDTH == 322091#define _pcre2_dummy_ucd_record PCRE2_SUFFIX(_pcre2_dummy_ucd_record_)2092#endif2093#define _pcre2_hspace_list PCRE2_SUFFIX(_pcre2_hspace_list_)2094#define _pcre2_vspace_list PCRE2_SUFFIX(_pcre2_vspace_list_)2095#define _pcre2_ucd_boolprop_sets PCRE2_SUFFIX(_pcre2_ucd_boolprop_sets_)2096#define _pcre2_ucd_caseless_sets PCRE2_SUFFIX(_pcre2_ucd_caseless_sets_)2097#define _pcre2_ucd_turkish_dotted_i_caseset PCRE2_SUFFIX(_pcre2_ucd_turkish_dotted_i_caseset_)2098#define _pcre2_ucd_nocase_ranges PCRE2_SUFFIX(_pcre2_ucd_nocase_ranges_)2099#define _pcre2_ucd_nocase_ranges_size PCRE2_SUFFIX(_pcre2_ucd_nocase_ranges_size_)2100#define _pcre2_ucd_digit_sets PCRE2_SUFFIX(_pcre2_ucd_digit_sets_)2101#define _pcre2_ucd_script_sets PCRE2_SUFFIX(_pcre2_ucd_script_sets_)2102#define _pcre2_ucd_records PCRE2_SUFFIX(_pcre2_ucd_records_)2103#define _pcre2_ucd_stage1 PCRE2_SUFFIX(_pcre2_ucd_stage1_)2104#define _pcre2_ucd_stage2 PCRE2_SUFFIX(_pcre2_ucd_stage2_)2105#define _pcre2_ucp_gbtable PCRE2_SUFFIX(_pcre2_ucp_gbtable_)2106#define _pcre2_ucp_gentype PCRE2_SUFFIX(_pcre2_ucp_gentype_)2107#define _pcre2_ucp_typerange PCRE2_SUFFIX(_pcre2_ucp_typerange_)2108#define _pcre2_unicode_version PCRE2_SUFFIX(_pcre2_unicode_version_)2109#define _pcre2_utt PCRE2_SUFFIX(_pcre2_utt_)2110#define _pcre2_utt_names PCRE2_SUFFIX(_pcre2_utt_names_)2111#define _pcre2_utt_size PCRE2_SUFFIX(_pcre2_utt_size_)21122113extern const uint8_t PRIV(OP_lengths)[];2114extern const uint32_t PRIV(callout_end_delims)[];2115extern const uint32_t PRIV(callout_start_delims)[];2116extern pcre2_compile_context PRIV(default_compile_context);2117extern pcre2_convert_context PRIV(default_convert_context);2118extern pcre2_match_context PRIV(default_match_context);2119extern const uint8_t PRIV(default_tables)[];2120extern const uint32_t PRIV(hspace_list)[];2121extern const uint32_t PRIV(vspace_list)[];2122extern const uint32_t PRIV(ucd_boolprop_sets)[];2123extern const uint32_t PRIV(ucd_caseless_sets)[];2124extern const uint32_t PRIV(ucd_turkish_dotted_i_caseset);2125extern const uint32_t PRIV(ucd_nocase_ranges)[];2126extern const uint32_t PRIV(ucd_nocase_ranges_size);2127extern const uint32_t PRIV(ucd_digit_sets)[];2128extern const uint32_t PRIV(ucd_script_sets)[];2129extern const ucd_record PRIV(ucd_records)[];2130#if PCRE2_CODE_UNIT_WIDTH == 322131extern const ucd_record PRIV(dummy_ucd_record)[];2132#endif2133extern const uint16_t PRIV(ucd_stage1)[];2134extern const uint16_t PRIV(ucd_stage2)[];2135extern const uint32_t PRIV(ucp_gbtable)[];2136extern const uint32_t PRIV(ucp_gentype)[];2137#ifdef SUPPORT_JIT2138extern const int PRIV(ucp_typerange)[];2139#endif2140extern const char *PRIV(unicode_version);2141extern const ucp_type_table PRIV(utt)[];2142extern const char PRIV(utt_names)[];2143extern const size_t PRIV(utt_size);21442145/* Mode-dependent macros and hidden and private structures are defined in a2146separate file so that pcre2test can include them at all supported widths. When2147compiling the library, PCRE2_CODE_UNIT_WIDTH will be defined, and we can2148include them at the appropriate width, after setting up suffix macros for the2149private structures. */21502151#define branch_chain PCRE2_SUFFIX(branch_chain_)2152#define compile_block PCRE2_SUFFIX(compile_block_)2153#define dfa_match_block PCRE2_SUFFIX(dfa_match_block_)2154#define match_block PCRE2_SUFFIX(match_block_)2155#define named_group PCRE2_SUFFIX(named_group_)21562157#include "pcre2_intmodedep.h"21582159/* Private "external" functions. These are internal functions that are called2160from modules other than the one in which they are defined. They have to be2161"external" in the C sense, but are not part of the PCRE2 public API. They are2162not referenced from pcre2test, and must not be defined when no code unit width2163is available. */21642165#define _pcre2_auto_possessify PCRE2_SUFFIX(_pcre2_auto_possessify_)2166#define _pcre2_check_escape PCRE2_SUFFIX(_pcre2_check_escape_)2167#define _pcre2_extuni PCRE2_SUFFIX(_pcre2_extuni_)2168#define _pcre2_find_bracket PCRE2_SUFFIX(_pcre2_find_bracket_)2169#define _pcre2_is_newline PCRE2_SUFFIX(_pcre2_is_newline_)2170#define _pcre2_jit_free_rodata PCRE2_SUFFIX(_pcre2_jit_free_rodata_)2171#define _pcre2_jit_free PCRE2_SUFFIX(_pcre2_jit_free_)2172#define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_)2173#define _pcre2_jit_get_target PCRE2_SUFFIX(_pcre2_jit_get_target_)2174#define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_)2175#define _pcre2_ord2utf PCRE2_SUFFIX(_pcre2_ord2utf_)2176#define _pcre2_script_run PCRE2_SUFFIX(_pcre2_script_run_)2177#define _pcre2_strcmp PCRE2_SUFFIX(_pcre2_strcmp_)2178#define _pcre2_strcmp_c8 PCRE2_SUFFIX(_pcre2_strcmp_c8_)2179#define _pcre2_strcpy_c8 PCRE2_SUFFIX(_pcre2_strcpy_c8_)2180#define _pcre2_strlen PCRE2_SUFFIX(_pcre2_strlen_)2181#define _pcre2_strncmp PCRE2_SUFFIX(_pcre2_strncmp_)2182#define _pcre2_strncmp_c8 PCRE2_SUFFIX(_pcre2_strncmp_c8_)2183#define _pcre2_study PCRE2_SUFFIX(_pcre2_study_)2184#define _pcre2_valid_utf PCRE2_SUFFIX(_pcre2_valid_utf_)2185#define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_)2186#define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_)2187#define _pcre2_eclass PCRE2_SUFFIX(_pcre2_eclass_)21882189extern int _pcre2_auto_possessify(PCRE2_UCHAR *,2190const compile_block *);2191extern int _pcre2_check_escape(PCRE2_SPTR *, PCRE2_SPTR, uint32_t *,2192int *, uint32_t, uint32_t, uint32_t, BOOL, compile_block *);2193extern PCRE2_SPTR _pcre2_extuni(uint32_t, PCRE2_SPTR, PCRE2_SPTR, PCRE2_SPTR,2194BOOL, int *);2195extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);2196extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,2197uint32_t *, BOOL);2198extern void _pcre2_jit_free_rodata(void *, void *);2199extern void _pcre2_jit_free(void *, pcre2_memctl *);2200extern size_t _pcre2_jit_get_size(void *);2201const char * _pcre2_jit_get_target(void);2202extern void * _pcre2_memctl_malloc(size_t, pcre2_memctl *);2203extern unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *);2204extern BOOL _pcre2_script_run(PCRE2_SPTR, PCRE2_SPTR, BOOL);2205extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);2206extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *);2207extern PCRE2_SIZE _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *);2208extern PCRE2_SIZE _pcre2_strlen(PCRE2_SPTR);2209extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);2210extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);2211extern int _pcre2_study(pcre2_real_code *);2212extern int _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *);2213extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,2214uint32_t *, BOOL);2215extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, const uint8_t *, BOOL);2216extern BOOL _pcre2_eclass(uint32_t, PCRE2_SPTR, PCRE2_SPTR,2217const uint8_t *, BOOL);22182219/* This function is needed only when memmove() is not available. */22202221#if !defined(VPCOMPAT) && !defined(HAVE_MEMMOVE)2222#define _pcre2_memmove PCRE2_SUFFIX(_pcre2_memmove)2223extern void * _pcre2_memmove(void *, const void *, size_t);2224#endif22252226#endif /* PCRE2_CODE_UNIT_WIDTH */22272228extern BOOL PRIV(ckd_smul)(PCRE2_SIZE *, int, int);22292230#include "pcre2_util.h"22312232#endif /* PCRE2_INTERNAL_H_IDEMPOTENT_GUARD */22332234/* End of pcre2_internal.h */223522362237