Path: blob/master/thirdparty/pcre2/src/pcre2_internal.h
21770 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 assume that the config.h file has an idempotent include guard,44since it may well be written by clients. The standard Autoheader config.h does45not have an include guard (although we could customise that). */4647#if defined HAVE_CONFIG_H && !defined PCRE2_CONFIG_H_IDEMPOTENT_GUARD48#define PCRE2_CONFIG_H_IDEMPOTENT_GUARD49#include "config.h"50#endif5152/* We do not support both EBCDIC and Unicode at the same time. The "configure"53script prevents both being selected, but not everybody uses "configure". EBCDIC54is only supported for the 8-bit library, but the check for this has to be later55in this file, because the first part is not width-dependent, and is included by56pcre2test.c with CODE_UNIT_WIDTH == 0. */5758#if defined EBCDIC && defined SUPPORT_UNICODE59#error The use of both EBCDIC and SUPPORT_UNICODE is not supported.60#endif6162/* When compiling one of the libraries, the value of PCRE2_CODE_UNIT_WIDTH must63be 8, 16, or 32. AutoTools and CMake ensure that this is always the case, but64other other building methods may not, so here is a check. It is cut out when65building pcre2test, bcause that sets the value to zero. No other source should66be including this file. There is no explicit way of forcing a compile to be67abandoned, but trying to include a non-existent file seems cleanest. Otherwise68there will be many irrelevant consequential errors. */6970#if (!defined PCRE2_PCRE2TEST && !defined PCRE2_DFTABLES) && \71(!defined PCRE2_CODE_UNIT_WIDTH || \72(PCRE2_CODE_UNIT_WIDTH != 8 && \73PCRE2_CODE_UNIT_WIDTH != 16 && \74PCRE2_CODE_UNIT_WIDTH != 32))75#error PCRE2_CODE_UNIT_WIDTH must be defined as 8, 16, or 32.76#endif777879/* Standard C headers */8081#include <ctype.h>82#include <limits.h>83#include <stddef.h>84#include <stdio.h>85#include <stdlib.h>86#include <string.h>8788/* Macros to make boolean values more obvious. The #ifndef is to pacify89compiler warnings in environments where these macros are defined elsewhere.90Unfortunately, there is no way to do the same for the typedef. */9192typedef int BOOL;93#ifndef FALSE94#define FALSE 095#define TRUE 196#endif9798/* Helper macro for static (compile-time) assertions. Can be used inside99functions, or at the top-level of a file. */100#define STATIC_ASSERT_JOIN(a,b) a ## b101#define STATIC_ASSERT(cond, msg) \102typedef int STATIC_ASSERT_JOIN(static_assertion_,msg)[(cond)?1:-1]103104/* Valgrind (memcheck) support */105106#ifdef SUPPORT_VALGRIND107#include <valgrind/memcheck.h>108#endif109110/* -ftrivial-auto-var-init support supports initializing all local variables111to avoid some classes of bug, but this can cause an unacceptable slowdown112for large on-stack arrays in hot functions. This macro lets us annotate113such arrays. */114115#ifdef HAVE_ATTRIBUTE_UNINITIALIZED116#define PCRE2_KEEP_UNINITIALIZED __attribute__((uninitialized))117#else118#define PCRE2_KEEP_UNINITIALIZED119#endif120121/* Older versions of MSVC lack snprintf(). This define allows for122warning/error-free compilation and testing with MSVC compilers back to at least123MSVC 10/2010. Except for VC6 (which is missing some fundamentals and fails). */124125#if defined(_MSC_VER) && (_MSC_VER < 1900)126#define snprintf _snprintf127#endif128129/* When compiling a DLL for Windows, the exported symbols have to be declared130using some MS magic, as documented here:131https://learn.microsoft.com/en-us/cpp/build/exporting-from-a-dll-using-declspec-dllexport132133In pcre2.h (which is included below), we define only PCRE2_EXP_DECL,134which is all that is needed for applications (they just import the symbols). To135compile the library, we use:136137PCRE2_EXP_DECL for declarations138PCRE2_EXP_DEFN for definitions139140The reason for wrapping this in #ifndef PCRE2_EXP_DECL is so that pcre2test,141which is an application, but needs to import this file in order to "peek" at142internals, can #include pcre2.h first to get an application's-eye view.143144In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,145special-purpose environments) might want to stick other stuff in front of146exported symbols. That's why, in the non-Windows case, we set PCRE2_EXP_DEFN147only if it is not already set. */148149#if defined __cplusplus150#error This project uses C99. C++ is not supported.151#endif152153#ifndef PCRE2_EXP_DECL154# if defined(_WIN32) && !defined(PCRE2_STATIC)155# define PCRE2_EXP_DECL extern __declspec(dllexport)156# else157# define PCRE2_EXP_DECL extern PCRE2_EXPORT158# endif159#endif160161#ifndef PCRE2_EXP_DEFN162# if defined(_WIN32) && !defined(PCRE2_STATIC)163# define PCRE2_EXP_DEFN extern __declspec(dllexport)164# else165# define PCRE2_EXP_DEFN extern PCRE2_EXPORT166# endif167#endif168169/* Include the public PCRE2 header and the definitions of UCP character170property values. This must follow the setting of PCRE2_EXP_DECL above. */171172#include "pcre2.h"173#include "pcre2_ucp.h"174175/* When checking for integer overflow, we need to handle large integers.176If a 64-bit integer type is available, we can use that.177Otherwise we have to cast to double, which of course requires floating point178arithmetic. Handle this by defining a macro for the appropriate type. */179180#if defined INT64_MAX || defined int64_t181#define INT64_OR_DOUBLE int64_t182#else183#define INT64_OR_DOUBLE double184#endif185186/* External (in the C sense) functions and tables that are private to the187libraries are always referenced using the PRIV macro. This makes it possible188for pcre2test.c to include some of the source files from the libraries using a189different PRIV definition to avoid name clashes. It also makes it clear in the190code that a non-static object is being referenced. */191192#ifndef PRIV193#define PRIV(name) _pcre2_##name194#endif195196/* This is an unsigned int value that no UTF character can ever have, as197Unicode doesn't go beyond 0x0010ffff. */198199#define NOTACHAR 0xffffffff200201/* This is the largest valid UTF/Unicode code point. */202203#define MAX_UTF_CODE_POINT 0x10ffff204205/* Compile-time positive error numbers (all except UTF errors, which are206negative) start at this value. It should probably never be changed, in case207some application is checking for specific numbers. There is a copy of this208#define in pcre2posix.c (which now no longer includes this file). Ideally, a209way of having a single definition should be found, but as the number is210unlikely to change, this is not a pressing issue. The original reason for211having a base other than 0 was to keep the absolute values of compile-time and212run-time error numbers numerically different, but in the event the code does213not rely on this. */214215#define COMPILE_ERROR_BASE 100216217/* The initial frames vector for remembering pcre2_match() backtracking points218is allocated on the heap, of this size (bytes) or ten times the frame size if219larger, unless the heap limit is smaller. Typical frame sizes are a few hundred220bytes (it depends on the number of capturing parentheses) so 20KiB handles221quite a few frames. A larger vector on the heap is obtained for matches that222need more frames, subject to the heap limit. */223224#define START_FRAMES_SIZE 20480225226/* For DFA matching, an initial internal workspace vector is allocated on the227stack. The heap is used only if this turns out to be too small. */228229#define DFA_START_RWS_SIZE 30720230231/* Define the default BSR convention. */232233#ifdef BSR_ANYCRLF234#define BSR_DEFAULT PCRE2_BSR_ANYCRLF235#else236#define BSR_DEFAULT PCRE2_BSR_UNICODE237#endif238239240/* ---------------- Basic UTF-8 macros ---------------- */241242/* These UTF-8 macros are always defined because they are used in pcre2test for243handling wide characters in 16-bit and 32-bit modes, even if an 8-bit library244is not supported. */245246/* Tests whether a UTF-8 code point needs extra bytes to decode. */247248#define HASUTF8EXTRALEN(c) ((c) >= 0xc0)249250/* The following macros were originally written in the form of loops that used251data from the tables whose names start with PRIV(utf8_table). They were252rewritten by a user so as not to use loops, because in some environments this253gives a significant performance advantage, and it seems never to do any harm.254*/255256/* Base macro to pick up the remaining bytes of a UTF-8 character, not257advancing the pointer. */258259#define GETUTF8(c, eptr) \260{ \261if ((c & 0x20u) == 0) \262c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \263else if ((c & 0x10u) == 0) \264c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \265else if ((c & 0x08u) == 0) \266c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \267((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \268else if ((c & 0x04u) == 0) \269c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \270((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \271(eptr[4] & 0x3fu); \272else \273c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \274((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \275((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \276}277278/* Base macro to pick up the remaining bytes of a UTF-8 character, advancing279the pointer. */280281#define GETUTF8INC(c, eptr) \282{ \283if ((c & 0x20u) == 0) \284c = ((c & 0x1fu) << 6) | (*eptr++ & 0x3fu); \285else if ((c & 0x10u) == 0) \286{ \287c = ((c & 0x0fu) << 12) | ((*eptr & 0x3fu) << 6) | (eptr[1] & 0x3fu); \288eptr += 2; \289} \290else if ((c & 0x08u) == 0) \291{ \292c = ((c & 0x07u) << 18) | ((*eptr & 0x3fu) << 12) | \293((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \294eptr += 3; \295} \296else if ((c & 0x04u) == 0) \297{ \298c = ((c & 0x03u) << 24) | ((*eptr & 0x3fu) << 18) | \299((eptr[1] & 0x3fu) << 12) | ((eptr[2] & 0x3fu) << 6) | \300(eptr[3] & 0x3fu); \301eptr += 4; \302} \303else \304{ \305c = ((c & 0x01u) << 30) | ((*eptr & 0x3fu) << 24) | \306((eptr[1] & 0x3fu) << 18) | ((eptr[2] & 0x3fu) << 12) | \307((eptr[3] & 0x3fu) << 6) | (eptr[4] & 0x3fu); \308eptr += 5; \309} \310}311312/* Base macro to pick up the remaining bytes of a UTF-8 character, not313advancing the pointer, incrementing the length. */314315#define GETUTF8LEN(c, eptr, len) \316{ \317if ((c & 0x20u) == 0) \318{ \319c = ((c & 0x1fu) << 6) | (eptr[1] & 0x3fu); \320len++; \321} \322else if ((c & 0x10u) == 0) \323{ \324c = ((c & 0x0fu) << 12) | ((eptr[1] & 0x3fu) << 6) | (eptr[2] & 0x3fu); \325len += 2; \326} \327else if ((c & 0x08u) == 0) \328{\329c = ((c & 0x07u) << 18) | ((eptr[1] & 0x3fu) << 12) | \330((eptr[2] & 0x3fu) << 6) | (eptr[3] & 0x3fu); \331len += 3; \332} \333else if ((c & 0x04u) == 0) \334{ \335c = ((c & 0x03u) << 24) | ((eptr[1] & 0x3fu) << 18) | \336((eptr[2] & 0x3fu) << 12) | ((eptr[3] & 0x3fu) << 6) | \337(eptr[4] & 0x3fu); \338len += 4; \339} \340else \341{\342c = ((c & 0x01u) << 30) | ((eptr[1] & 0x3fu) << 24) | \343((eptr[2] & 0x3fu) << 18) | ((eptr[3] & 0x3fu) << 12) | \344((eptr[4] & 0x3fu) << 6) | (eptr[5] & 0x3fu); \345len += 5; \346} \347}348349/* --------------- Whitespace macros ---------------- */350351/* Tests for Unicode horizontal and vertical whitespace characters must check a352number of different values. Using a switch statement for this generates the353fastest code (no loop, no memory access), and there are several places in the354interpreter code where this happens. In order to ensure that all the case lists355remain in step, we use macros so that there is only one place where the lists356are defined.357358These values are also required as lists in pcre2_compile.c when processing \h,359\H, \v and \V in a character class. The lists are defined in pcre2_tables.c,360but macros that define the values are here so that all the definitions are361together. The lists must be in ascending character order, terminated by362NOTACHAR (which is 0xffffffff).363364Any changes should ensure that the various macros are kept in step with each365other. NOTE: The values also appear in pcre2_jit_compile.c. */366367/* -------------- ASCII/Unicode environments -------------- */368369#ifndef EBCDIC370371/* Character U+180E (Mongolian Vowel Separator) is not included in the list of372spaces in the Unicode file PropList.txt, and Perl does not recognize it as a373space. However, in many other sources it is listed as a space and has been in374PCRE (both APIs) for a long time. */375376#define HSPACE_LIST \377CHAR_HT, CHAR_SPACE, CHAR_NBSP, \3780x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \3790x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f, 0x205f, 0x3000, \380NOTACHAR381382#define HSPACE_MULTIBYTE_CASES \383case 0x1680: /* OGHAM SPACE MARK */ \384case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ \385case 0x2000: /* EN QUAD */ \386case 0x2001: /* EM QUAD */ \387case 0x2002: /* EN SPACE */ \388case 0x2003: /* EM SPACE */ \389case 0x2004: /* THREE-PER-EM SPACE */ \390case 0x2005: /* FOUR-PER-EM SPACE */ \391case 0x2006: /* SIX-PER-EM SPACE */ \392case 0x2007: /* FIGURE SPACE */ \393case 0x2008: /* PUNCTUATION SPACE */ \394case 0x2009: /* THIN SPACE */ \395case 0x200a: /* HAIR SPACE */ \396case 0x202f: /* NARROW NO-BREAK SPACE */ \397case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ \398case 0x3000 /* IDEOGRAPHIC SPACE */399400#define HSPACE_BYTE_CASES \401case CHAR_HT: \402case CHAR_SPACE: \403case CHAR_NBSP404405#define HSPACE_CASES \406HSPACE_BYTE_CASES: \407HSPACE_MULTIBYTE_CASES408409#define VSPACE_LIST \410CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, 0x2028, 0x2029, NOTACHAR411412#define VSPACE_MULTIBYTE_CASES \413case 0x2028: /* LINE SEPARATOR */ \414case 0x2029 /* PARAGRAPH SEPARATOR */415416#define VSPACE_BYTE_CASES \417case CHAR_LF: \418case CHAR_VT: \419case CHAR_FF: \420case CHAR_CR: \421case CHAR_NEL422423#define VSPACE_CASES \424VSPACE_BYTE_CASES: \425VSPACE_MULTIBYTE_CASES426427/* -------------- EBCDIC environments -------------- */428429#else430#define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR431432#define HSPACE_BYTE_CASES \433case CHAR_HT: \434case CHAR_SPACE: \435case CHAR_NBSP436437#define HSPACE_CASES HSPACE_BYTE_CASES438439#ifdef EBCDIC_NL25440#define VSPACE_LIST \441CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, CHAR_LF, NOTACHAR442#else443#define VSPACE_LIST \444CHAR_VT, CHAR_FF, CHAR_CR, CHAR_LF, CHAR_NEL, NOTACHAR445#endif446447#define VSPACE_BYTE_CASES \448case CHAR_LF: \449case CHAR_VT: \450case CHAR_FF: \451case CHAR_CR: \452case CHAR_NEL453454#define VSPACE_CASES VSPACE_BYTE_CASES455#endif /* EBCDIC */456457/* -------------- End of whitespace macros -------------- */458459460/* PCRE2 is able to support several different kinds of newline (CR, LF, CRLF,461"any" and "anycrlf" at present). The following macros are used to package up462testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various463modules to indicate in which datablock the parameters exist, and what the464start/end of string field names are. */465466#define NLTYPE_FIXED 0 /* Newline is a fixed length string */467#define NLTYPE_ANY 1 /* Newline is any Unicode line ending */468#define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */469470/* This macro checks for a newline at the given position */471472#define IS_NEWLINE(p) \473((NLBLOCK->nltype != NLTYPE_FIXED)? \474((p) < NLBLOCK->PSEND && \475PRIV(is_newline)((p), NLBLOCK->nltype, NLBLOCK->PSEND, \476&(NLBLOCK->nllen), utf)) \477: \478((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \479UCHAR21TEST(p) == NLBLOCK->nl[0] && \480(NLBLOCK->nllen == 1 || UCHAR21TEST(p+1) == NLBLOCK->nl[1]) \481) \482)483484/* This macro checks for a newline immediately preceding the given position */485486#define WAS_NEWLINE(p) \487((NLBLOCK->nltype != NLTYPE_FIXED)? \488((p) > NLBLOCK->PSSTART && \489PRIV(was_newline)((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \490&(NLBLOCK->nllen), utf)) \491: \492((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \493UCHAR21TEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \494(NLBLOCK->nllen == 1 || UCHAR21TEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \495) \496)497498/* Private flags containing information about the compiled pattern. The first499three must not be changed, because whichever is set is actually the number of500bytes in a code unit in that mode. */501502#define PCRE2_MODE8 0x00000001u /* compiled in 8 bit mode */503#define PCRE2_MODE16 0x00000002u /* compiled in 16 bit mode */504#define PCRE2_MODE32 0x00000004u /* compiled in 32 bit mode */505#define PCRE2_FIRSTSET 0x00000010u /* first_code unit is set */506#define PCRE2_FIRSTCASELESS 0x00000020u /* caseless first code unit */507#define PCRE2_FIRSTMAPSET 0x00000040u /* bitmap of first code units is set */508#define PCRE2_LASTSET 0x00000080u /* last code unit is set */509#define PCRE2_LASTCASELESS 0x00000100u /* caseless last code unit */510#define PCRE2_STARTLINE 0x00000200u /* start after \n for multiline */511#define PCRE2_JCHANGED 0x00000400u /* j option used in pattern */512#define PCRE2_HASCRORLF 0x00000800u /* explicit \r or \n in pattern */513#define PCRE2_HASTHEN 0x00001000u /* pattern contains (*THEN) */514#define PCRE2_MATCH_EMPTY 0x00002000u /* pattern can match empty string */515#define PCRE2_BSR_SET 0x00004000u /* BSR was set in the pattern */516#define PCRE2_NL_SET 0x00008000u /* newline was set in the pattern */517#define PCRE2_NOTEMPTY_SET 0x00010000u /* (*NOTEMPTY) used ) keep */518#define PCRE2_NE_ATST_SET 0x00020000u /* (*NOTEMPTY_ATSTART) used) together */519#define PCRE2_DEREF_TABLES 0x00040000u /* release character tables */520#define PCRE2_NOJIT 0x00080000u /* (*NOJIT) used */521#define PCRE2_HASBKPORX 0x00100000u /* contains \P, \p, or \X */522#define PCRE2_DUPCAPUSED 0x00200000u /* contains (?| */523#define PCRE2_HASBKC 0x00400000u /* contains \C */524#define PCRE2_HASACCEPT 0x00800000u /* contains (*ACCEPT) */525#define PCRE2_HASBSK 0x01000000u /* contains \K */526527#define PCRE2_MODE_MASK (PCRE2_MODE8 | PCRE2_MODE16 | PCRE2_MODE32)528529/* Values for the matchedby field in a match data block. */530531enum { PCRE2_MATCHEDBY_INTERPRETER, /* pcre2_match() */532PCRE2_MATCHEDBY_DFA_INTERPRETER, /* pcre2_dfa_match() */533PCRE2_MATCHEDBY_JIT }; /* pcre2_jit_match() */534535/* Values for the flags field in a match data block. */536537#define PCRE2_MD_COPIED_SUBJECT 0x01u538539/* Magic number to provide a small check against being handed junk. */540541#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */542543/* The maximum remaining length of subject we are prepared to search for a544req_unit match from an anchored pattern. In 8-bit mode, memchr() is used and is545much faster than the search loop that has to be used in 16-bit and 32-bit546modes. */547548#if PCRE2_CODE_UNIT_WIDTH == 8549#define REQ_CU_MAX 5000550#else551#define REQ_CU_MAX 2000552#endif553554/* The maximum nesting depth for Unicode character class sets.555Currently fixed. Warning: the interpreter relies on this so it can encode556the operand stack in a uint32_t. A nesting limit of 15 implies (15*2+1)=31557stack operands required, due to the fact that we have two (and only two)558levels of operator precedence. In the UTS#18 syntax, you can write 'x&&y[z]'559and in Perl syntax you can write '(?[ x - y & (z) ])', both of which imply560pushing the match results for x & y to the stack. */561562#define ECLASS_NEST_LIMIT 15563564/* Offsets for the bitmap tables in the cbits set of tables. Each table565contains a set of bits for a class map. Some classes are built by combining566these tables. */567568#define cbit_space 0 /* [:space:] or \s */569#define cbit_xdigit 32 /* [:xdigit:] */570#define cbit_digit 64 /* [:digit:] or \d */571#define cbit_upper 96 /* [:upper:] */572#define cbit_lower 128 /* [:lower:] */573#define cbit_word 160 /* [:word:] or \w */574#define cbit_graph 192 /* [:graph:] */575#define cbit_print 224 /* [:print:] */576#define cbit_punct 256 /* [:punct:] */577#define cbit_cntrl 288 /* [:cntrl:] */578#define cbit_length 320 /* Length of the cbits table */579580/* Bit definitions for entries in the ctypes table. Do not change these values581without checking pcre2_jit_compile.c, which has an assertion to ensure that582ctype_word has the value 16. */583584#define ctype_space 0x01585#define ctype_letter 0x02586#define ctype_lcletter 0x04587#define ctype_digit 0x08588#define ctype_word 0x10 /* alphanumeric or '_' */589590/* Offsets of the various tables from the base tables pointer, and591total length of the tables. */592593#define lcc_offset 0 /* Lower case */594#define fcc_offset 256 /* Flip case */595#define cbits_offset 512 /* Character classes */596#define ctypes_offset (cbits_offset + cbit_length) /* Character types */597#define TABLES_LENGTH (ctypes_offset + 256)598599/* Private flags used in compile_context.optimization_flags */600601#define PCRE2_OPTIM_AUTO_POSSESS 0x00000001u602#define PCRE2_OPTIM_DOTSTAR_ANCHOR 0x00000002u603#define PCRE2_OPTIM_START_OPTIMIZE 0x00000004u604605#define PCRE2_OPTIMIZATION_ALL 0x00000007u606607/* -------------------- Character and string names ------------------------ */608609/* If PCRE2 is to support UTF-8 on EBCDIC platforms, we cannot use normal610character constants like '*' because the compiler would emit their EBCDIC code,611which is different from their ASCII/UTF-8 code. Instead we define macros for612the characters so that they always use the ASCII/UTF-8 code when UTF-8 support613is enabled. When UTF-8 support is not enabled, the definitions use character614literals. Both character and string versions of each character are needed, and615there are some longer strings as well.616617This means that, on EBCDIC platforms, the PCRE2 library can handle either618EBCDIC, or UTF-8, but not both. To support both in the same compiled library619would need different lookups depending on whether PCRE2_UTF was set or not.620This would make it impossible to use characters in switch/case statements,621which would reduce performance. For a theoretical use (which nobody has asked622for) in a minority area (EBCDIC platforms), this is not sensible. Any623application that did need both could compile two versions of the library, using624macros to give the functions distinct names. */625626#ifndef SUPPORT_UNICODE627628/* UTF-8 support is not enabled; use the platform-dependent character literals629so that PCRE2 works in both ASCII and EBCDIC environments, but only in non-UTF630mode. Newline characters are problematic in EBCDIC. Though it has CR and LF631characters, a common practice has been to use its NL (0x15) character as the632line terminator in C-like processing environments. However, sometimes the LF633(0x25) character is used instead, according to this Unicode document:634635http://unicode.org/standard/reports/tr13/tr13-5.html636637PCRE2 defaults EBCDIC NL to 0x15, but has a build-time option to select 0x25638instead. Whichever is *not* chosen is defined as NEL.639640In both ASCII and EBCDIC environments, CHAR_NL and CHAR_LF are synonyms for the641same code point. */642643#ifdef EBCDIC644645#ifndef EBCDIC_NL25646#define CHAR_NL '\x15'647#define CHAR_NEL '\x25'648#define STR_NL "\x15"649#define STR_NEL "\x25"650#else651#define CHAR_NL '\x25'652#define CHAR_NEL '\x15'653#define STR_NL "\x25"654#define STR_NEL "\x15"655#endif656657#define CHAR_LF CHAR_NL658#define STR_LF STR_NL659660#define CHAR_ESC '\047'661#define CHAR_DEL '\007'662#define CHAR_NBSP ((unsigned char)'\x41')663#define STR_ESC "\047"664#define STR_DEL "\007"665666#else /* Not EBCDIC */667668/* In ASCII/Unicode, linefeed is '\n' and we equate this to NL for669compatibility. NEL is the Unicode newline character; make sure it is670a positive value. */671672#if '\n' != 0x0a673#error "ASCII character '\n' is not 0x0a"674#endif675676#define CHAR_LF '\n'677#define CHAR_NL CHAR_LF678#define CHAR_NEL ((unsigned char)'\x85')679#define CHAR_ESC '\033'680#define CHAR_DEL '\177'681#define CHAR_NBSP ((unsigned char)'\xa0')682683#define STR_LF "\n"684#define STR_NL STR_LF685#define STR_NEL "\x85"686#define STR_ESC "\033"687#define STR_DEL "\177"688689#endif /* EBCDIC */690691/* When we want to use EBCDIC with an ASCII compiler, for testing EBCDIC on692ASCII platforms, then we can hardcode an EBCDIC codepage (IBM-1047). */693694#ifdef EBCDIC_IGNORING_COMPILER695696#define CHAR_NUL '\000'697#define CHAR_HT '\005'698#define CHAR_VT '\013'699#define CHAR_FF '\014'700#define CHAR_CR '\015'701#define CHAR_BS '\026'702#define CHAR_BEL '\057'703704#define CHAR_SPACE '\100'705#define CHAR_EXCLAMATION_MARK '\132'706#define CHAR_QUOTATION_MARK '\177'707#define CHAR_NUMBER_SIGN '\173'708#define CHAR_DOLLAR_SIGN '\133'709#define CHAR_PERCENT_SIGN '\154'710#define CHAR_AMPERSAND '\120'711#define CHAR_APOSTROPHE '\175'712#define CHAR_LEFT_PARENTHESIS '\115'713#define CHAR_RIGHT_PARENTHESIS '\135'714#define CHAR_ASTERISK '\134'715#define CHAR_PLUS '\116'716#define CHAR_COMMA '\153'717#define CHAR_MINUS '\140'718#define CHAR_DOT '\113'719#define CHAR_SLASH '\141'720#define CHAR_0 ((unsigned char)'\xf0')721#define CHAR_1 ((unsigned char)'\xf1')722#define CHAR_2 ((unsigned char)'\xf2')723#define CHAR_3 ((unsigned char)'\xf3')724#define CHAR_4 ((unsigned char)'\xf4')725#define CHAR_5 ((unsigned char)'\xf5')726#define CHAR_6 ((unsigned char)'\xf6')727#define CHAR_7 ((unsigned char)'\xf7')728#define CHAR_8 ((unsigned char)'\xf8')729#define CHAR_9 ((unsigned char)'\xf9')730#define CHAR_COLON '\172'731#define CHAR_SEMICOLON '\136'732#define CHAR_LESS_THAN_SIGN '\114'733#define CHAR_EQUALS_SIGN '\176'734#define CHAR_GREATER_THAN_SIGN '\156'735#define CHAR_QUESTION_MARK '\157'736#define CHAR_COMMERCIAL_AT '\174'737#define CHAR_A ((unsigned char)'\xc1')738#define CHAR_B ((unsigned char)'\xc2')739#define CHAR_C ((unsigned char)'\xc3')740#define CHAR_D ((unsigned char)'\xc4')741#define CHAR_E ((unsigned char)'\xc5')742#define CHAR_F ((unsigned char)'\xc6')743#define CHAR_G ((unsigned char)'\xc7')744#define CHAR_H ((unsigned char)'\xc8')745#define CHAR_I ((unsigned char)'\xc9')746#define CHAR_J ((unsigned char)'\xd1')747#define CHAR_K ((unsigned char)'\xd2')748#define CHAR_L ((unsigned char)'\xd3')749#define CHAR_M ((unsigned char)'\xd4')750#define CHAR_N ((unsigned char)'\xd5')751#define CHAR_O ((unsigned char)'\xd6')752#define CHAR_P ((unsigned char)'\xd7')753#define CHAR_Q ((unsigned char)'\xd8')754#define CHAR_R ((unsigned char)'\xd9')755#define CHAR_S ((unsigned char)'\xe2')756#define CHAR_T ((unsigned char)'\xe3')757#define CHAR_U ((unsigned char)'\xe4')758#define CHAR_V ((unsigned char)'\xe5')759#define CHAR_W ((unsigned char)'\xe6')760#define CHAR_X ((unsigned char)'\xe7')761#define CHAR_Y ((unsigned char)'\xe8')762#define CHAR_Z ((unsigned char)'\xe9')763#define CHAR_LEFT_SQUARE_BRACKET ((unsigned char)'\xad')764#define CHAR_BACKSLASH ((unsigned char)'\xe0')765#define CHAR_RIGHT_SQUARE_BRACKET ((unsigned char)'\xbd')766#define CHAR_CIRCUMFLEX_ACCENT '\137'767#define CHAR_UNDERSCORE '\155'768#define CHAR_GRAVE_ACCENT '\171'769#define CHAR_a ((unsigned char)'\x81')770#define CHAR_b ((unsigned char)'\x82')771#define CHAR_c ((unsigned char)'\x83')772#define CHAR_d ((unsigned char)'\x84')773#define CHAR_e ((unsigned char)'\x85')774#define CHAR_f ((unsigned char)'\x86')775#define CHAR_g ((unsigned char)'\x87')776#define CHAR_h ((unsigned char)'\x88')777#define CHAR_i ((unsigned char)'\x89')778#define CHAR_j ((unsigned char)'\x91')779#define CHAR_k ((unsigned char)'\x92')780#define CHAR_l ((unsigned char)'\x93')781#define CHAR_m ((unsigned char)'\x94')782#define CHAR_n ((unsigned char)'\x95')783#define CHAR_o ((unsigned char)'\x96')784#define CHAR_p ((unsigned char)'\x97')785#define CHAR_q ((unsigned char)'\x98')786#define CHAR_r ((unsigned char)'\x99')787#define CHAR_s ((unsigned char)'\xa2')788#define CHAR_t ((unsigned char)'\xa3')789#define CHAR_u ((unsigned char)'\xa4')790#define CHAR_v ((unsigned char)'\xa5')791#define CHAR_w ((unsigned char)'\xa6')792#define CHAR_x ((unsigned char)'\xa7')793#define CHAR_y ((unsigned char)'\xa8')794#define CHAR_z ((unsigned char)'\xa9')795#define CHAR_LEFT_CURLY_BRACKET ((unsigned char)'\xc0')796#define CHAR_VERTICAL_LINE '\117'797#define CHAR_RIGHT_CURLY_BRACKET ((unsigned char)'\xd0')798#define CHAR_TILDE ((unsigned char)'\xa1')799800#define STR_HT "\005"801#define STR_VT "\013"802#define STR_FF "\014"803#define STR_CR "\015"804#define STR_BS "\026"805#define STR_BEL "\057"806807#define STR_SPACE "\100"808#define STR_EXCLAMATION_MARK "\132"809#define STR_QUOTATION_MARK "\177"810#define STR_NUMBER_SIGN "\173"811#define STR_DOLLAR_SIGN "\133"812#define STR_PERCENT_SIGN "\154"813#define STR_AMPERSAND "\120"814#define STR_APOSTROPHE "\175"815#define STR_LEFT_PARENTHESIS "\115"816#define STR_RIGHT_PARENTHESIS "\135"817#define STR_ASTERISK "\134"818#define STR_PLUS "\116"819#define STR_COMMA "\153"820#define STR_MINUS "\140"821#define STR_DOT "\113"822#define STR_SLASH "\141"823#define STR_0 "\360"824#define STR_1 "\361"825#define STR_2 "\362"826#define STR_3 "\363"827#define STR_4 "\364"828#define STR_5 "\365"829#define STR_6 "\366"830#define STR_7 "\367"831#define STR_8 "\370"832#define STR_9 "\371"833#define STR_COLON "\172"834#define STR_SEMICOLON "\136"835#define STR_LESS_THAN_SIGN "\114"836#define STR_EQUALS_SIGN "\176"837#define STR_GREATER_THAN_SIGN "\156"838#define STR_QUESTION_MARK "\157"839#define STR_COMMERCIAL_AT "\174"840#define STR_A "\301"841#define STR_B "\302"842#define STR_C "\303"843#define STR_D "\304"844#define STR_E "\305"845#define STR_F "\306"846#define STR_G "\307"847#define STR_H "\310"848#define STR_I "\311"849#define STR_J "\321"850#define STR_K "\322"851#define STR_L "\323"852#define STR_M "\324"853#define STR_N "\325"854#define STR_O "\326"855#define STR_P "\327"856#define STR_Q "\330"857#define STR_R "\331"858#define STR_S "\342"859#define STR_T "\343"860#define STR_U "\344"861#define STR_V "\345"862#define STR_W "\346"863#define STR_X "\347"864#define STR_Y "\350"865#define STR_Z "\351"866#define STR_LEFT_SQUARE_BRACKET "\255"867#define STR_BACKSLASH "\340"868#define STR_RIGHT_SQUARE_BRACKET "\275"869#define STR_CIRCUMFLEX_ACCENT "\137"870#define STR_UNDERSCORE "\155"871#define STR_GRAVE_ACCENT "\171"872#define STR_a "\201"873#define STR_b "\202"874#define STR_c "\203"875#define STR_d "\204"876#define STR_e "\205"877#define STR_f "\206"878#define STR_g "\207"879#define STR_h "\210"880#define STR_i "\211"881#define STR_j "\221"882#define STR_k "\222"883#define STR_l "\223"884#define STR_m "\224"885#define STR_n "\225"886#define STR_o "\226"887#define STR_p "\227"888#define STR_q "\230"889#define STR_r "\231"890#define STR_s "\242"891#define STR_t "\243"892#define STR_u "\244"893#define STR_v "\245"894#define STR_w "\246"895#define STR_x "\247"896#define STR_y "\250"897#define STR_z "\251"898#define STR_LEFT_CURLY_BRACKET "\300"899#define STR_VERTICAL_LINE "\117"900#define STR_RIGHT_CURLY_BRACKET "\320"901#define STR_TILDE "\241"902903#else /* EBCDIC_IGNORING_COMPILER */904905/* Otherwise, on a real EBCDIC compiler or an ASCII compiler, we can use simple906string and character literals. */907908#ifdef EBCDIC909#if 'a' != 0x81910#error "EBCDIC character 'a' is not 0x81"911#endif912#else913#if 'a' != 0x61914#error "ASCII character 'a' is not 0x61"915#endif916#endif917918#define CHAR_NUL '\0'919#define CHAR_HT '\t'920#define CHAR_VT '\v'921#define CHAR_FF '\f'922#define CHAR_CR '\r'923#define CHAR_BS '\b'924#define CHAR_BEL '\a'925926#define CHAR_SPACE ' '927#define CHAR_EXCLAMATION_MARK '!'928#define CHAR_QUOTATION_MARK '"'929#define CHAR_NUMBER_SIGN '#'930#define CHAR_DOLLAR_SIGN '$'931#define CHAR_PERCENT_SIGN '%'932#define CHAR_AMPERSAND '&'933#define CHAR_APOSTROPHE '\''934#define CHAR_LEFT_PARENTHESIS '('935#define CHAR_RIGHT_PARENTHESIS ')'936#define CHAR_ASTERISK '*'937#define CHAR_PLUS '+'938#define CHAR_COMMA ','939#define CHAR_MINUS '-'940#define CHAR_DOT '.'941#define CHAR_SLASH '/'942#define CHAR_0 '0'943#define CHAR_1 '1'944#define CHAR_2 '2'945#define CHAR_3 '3'946#define CHAR_4 '4'947#define CHAR_5 '5'948#define CHAR_6 '6'949#define CHAR_7 '7'950#define CHAR_8 '8'951#define CHAR_9 '9'952#define CHAR_COLON ':'953#define CHAR_SEMICOLON ';'954#define CHAR_LESS_THAN_SIGN '<'955#define CHAR_EQUALS_SIGN '='956#define CHAR_GREATER_THAN_SIGN '>'957#define CHAR_QUESTION_MARK '?'958#define CHAR_COMMERCIAL_AT '@'959#define CHAR_A 'A'960#define CHAR_B 'B'961#define CHAR_C 'C'962#define CHAR_D 'D'963#define CHAR_E 'E'964#define CHAR_F 'F'965#define CHAR_G 'G'966#define CHAR_H 'H'967#define CHAR_I 'I'968#define CHAR_J 'J'969#define CHAR_K 'K'970#define CHAR_L 'L'971#define CHAR_M 'M'972#define CHAR_N 'N'973#define CHAR_O 'O'974#define CHAR_P 'P'975#define CHAR_Q 'Q'976#define CHAR_R 'R'977#define CHAR_S 'S'978#define CHAR_T 'T'979#define CHAR_U 'U'980#define CHAR_V 'V'981#define CHAR_W 'W'982#define CHAR_X 'X'983#define CHAR_Y 'Y'984#define CHAR_Z 'Z'985#define CHAR_LEFT_SQUARE_BRACKET '['986#define CHAR_BACKSLASH '\\'987#define CHAR_RIGHT_SQUARE_BRACKET ']'988#define CHAR_CIRCUMFLEX_ACCENT '^'989#define CHAR_UNDERSCORE '_'990#define CHAR_GRAVE_ACCENT '`'991#define CHAR_a 'a'992#define CHAR_b 'b'993#define CHAR_c 'c'994#define CHAR_d 'd'995#define CHAR_e 'e'996#define CHAR_f 'f'997#define CHAR_g 'g'998#define CHAR_h 'h'999#define CHAR_i 'i'1000#define CHAR_j 'j'1001#define CHAR_k 'k'1002#define CHAR_l 'l'1003#define CHAR_m 'm'1004#define CHAR_n 'n'1005#define CHAR_o 'o'1006#define CHAR_p 'p'1007#define CHAR_q 'q'1008#define CHAR_r 'r'1009#define CHAR_s 's'1010#define CHAR_t 't'1011#define CHAR_u 'u'1012#define CHAR_v 'v'1013#define CHAR_w 'w'1014#define CHAR_x 'x'1015#define CHAR_y 'y'1016#define CHAR_z 'z'1017#define CHAR_LEFT_CURLY_BRACKET '{'1018#define CHAR_VERTICAL_LINE '|'1019#define CHAR_RIGHT_CURLY_BRACKET '}'1020#define CHAR_TILDE '~'10211022#define STR_HT "\t"1023#define STR_VT "\v"1024#define STR_FF "\f"1025#define STR_CR "\r"1026#define STR_BS "\b"1027#define STR_BEL "\a"10281029#define STR_SPACE " "1030#define STR_EXCLAMATION_MARK "!"1031#define STR_QUOTATION_MARK "\""1032#define STR_NUMBER_SIGN "#"1033#define STR_DOLLAR_SIGN "$"1034#define STR_PERCENT_SIGN "%"1035#define STR_AMPERSAND "&"1036#define STR_APOSTROPHE "'"1037#define STR_LEFT_PARENTHESIS "("1038#define STR_RIGHT_PARENTHESIS ")"1039#define STR_ASTERISK "*"1040#define STR_PLUS "+"1041#define STR_COMMA ","1042#define STR_MINUS "-"1043#define STR_DOT "."1044#define STR_SLASH "/"1045#define STR_0 "0"1046#define STR_1 "1"1047#define STR_2 "2"1048#define STR_3 "3"1049#define STR_4 "4"1050#define STR_5 "5"1051#define STR_6 "6"1052#define STR_7 "7"1053#define STR_8 "8"1054#define STR_9 "9"1055#define STR_COLON ":"1056#define STR_SEMICOLON ";"1057#define STR_LESS_THAN_SIGN "<"1058#define STR_EQUALS_SIGN "="1059#define STR_GREATER_THAN_SIGN ">"1060#define STR_QUESTION_MARK "?"1061#define STR_COMMERCIAL_AT "@"1062#define STR_A "A"1063#define STR_B "B"1064#define STR_C "C"1065#define STR_D "D"1066#define STR_E "E"1067#define STR_F "F"1068#define STR_G "G"1069#define STR_H "H"1070#define STR_I "I"1071#define STR_J "J"1072#define STR_K "K"1073#define STR_L "L"1074#define STR_M "M"1075#define STR_N "N"1076#define STR_O "O"1077#define STR_P "P"1078#define STR_Q "Q"1079#define STR_R "R"1080#define STR_S "S"1081#define STR_T "T"1082#define STR_U "U"1083#define STR_V "V"1084#define STR_W "W"1085#define STR_X "X"1086#define STR_Y "Y"1087#define STR_Z "Z"1088#define STR_LEFT_SQUARE_BRACKET "["1089#define STR_BACKSLASH "\\"1090#define STR_RIGHT_SQUARE_BRACKET "]"1091#define STR_CIRCUMFLEX_ACCENT "^"1092#define STR_UNDERSCORE "_"1093#define STR_GRAVE_ACCENT "`"1094#define STR_a "a"1095#define STR_b "b"1096#define STR_c "c"1097#define STR_d "d"1098#define STR_e "e"1099#define STR_f "f"1100#define STR_g "g"1101#define STR_h "h"1102#define STR_i "i"1103#define STR_j "j"1104#define STR_k "k"1105#define STR_l "l"1106#define STR_m "m"1107#define STR_n "n"1108#define STR_o "o"1109#define STR_p "p"1110#define STR_q "q"1111#define STR_r "r"1112#define STR_s "s"1113#define STR_t "t"1114#define STR_u "u"1115#define STR_v "v"1116#define STR_w "w"1117#define STR_x "x"1118#define STR_y "y"1119#define STR_z "z"1120#define STR_LEFT_CURLY_BRACKET "{"1121#define STR_VERTICAL_LINE "|"1122#define STR_RIGHT_CURLY_BRACKET "}"1123#define STR_TILDE "~"11241125#endif /* EBCDIC_WITH_ASCII_COMPILER */11261127#else /* SUPPORT_UNICODE */11281129/* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This1130works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode1131only. */11321133#define CHAR_HT '\011'1134#define CHAR_VT '\013'1135#define CHAR_FF '\014'1136#define CHAR_CR '\015'1137#define CHAR_LF '\012'1138#define CHAR_NL CHAR_LF1139#define CHAR_NEL ((unsigned char)'\x85')1140#define CHAR_BS '\010'1141#define CHAR_BEL '\007'1142#define CHAR_ESC '\033'1143#define CHAR_DEL '\177'11441145#define CHAR_NUL '\0'1146#define CHAR_SPACE '\040'1147#define CHAR_EXCLAMATION_MARK '\041'1148#define CHAR_QUOTATION_MARK '\042'1149#define CHAR_NUMBER_SIGN '\043'1150#define CHAR_DOLLAR_SIGN '\044'1151#define CHAR_PERCENT_SIGN '\045'1152#define CHAR_AMPERSAND '\046'1153#define CHAR_APOSTROPHE '\047'1154#define CHAR_LEFT_PARENTHESIS '\050'1155#define CHAR_RIGHT_PARENTHESIS '\051'1156#define CHAR_ASTERISK '\052'1157#define CHAR_PLUS '\053'1158#define CHAR_COMMA '\054'1159#define CHAR_MINUS '\055'1160#define CHAR_DOT '\056'1161#define CHAR_SLASH '\057'1162#define CHAR_0 '\060'1163#define CHAR_1 '\061'1164#define CHAR_2 '\062'1165#define CHAR_3 '\063'1166#define CHAR_4 '\064'1167#define CHAR_5 '\065'1168#define CHAR_6 '\066'1169#define CHAR_7 '\067'1170#define CHAR_8 '\070'1171#define CHAR_9 '\071'1172#define CHAR_COLON '\072'1173#define CHAR_SEMICOLON '\073'1174#define CHAR_LESS_THAN_SIGN '\074'1175#define CHAR_EQUALS_SIGN '\075'1176#define CHAR_GREATER_THAN_SIGN '\076'1177#define CHAR_QUESTION_MARK '\077'1178#define CHAR_COMMERCIAL_AT '\100'1179#define CHAR_A '\101'1180#define CHAR_B '\102'1181#define CHAR_C '\103'1182#define CHAR_D '\104'1183#define CHAR_E '\105'1184#define CHAR_F '\106'1185#define CHAR_G '\107'1186#define CHAR_H '\110'1187#define CHAR_I '\111'1188#define CHAR_J '\112'1189#define CHAR_K '\113'1190#define CHAR_L '\114'1191#define CHAR_M '\115'1192#define CHAR_N '\116'1193#define CHAR_O '\117'1194#define CHAR_P '\120'1195#define CHAR_Q '\121'1196#define CHAR_R '\122'1197#define CHAR_S '\123'1198#define CHAR_T '\124'1199#define CHAR_U '\125'1200#define CHAR_V '\126'1201#define CHAR_W '\127'1202#define CHAR_X '\130'1203#define CHAR_Y '\131'1204#define CHAR_Z '\132'1205#define CHAR_LEFT_SQUARE_BRACKET '\133'1206#define CHAR_BACKSLASH '\134'1207#define CHAR_RIGHT_SQUARE_BRACKET '\135'1208#define CHAR_CIRCUMFLEX_ACCENT '\136'1209#define CHAR_UNDERSCORE '\137'1210#define CHAR_GRAVE_ACCENT '\140'1211#define CHAR_a '\141'1212#define CHAR_b '\142'1213#define CHAR_c '\143'1214#define CHAR_d '\144'1215#define CHAR_e '\145'1216#define CHAR_f '\146'1217#define CHAR_g '\147'1218#define CHAR_h '\150'1219#define CHAR_i '\151'1220#define CHAR_j '\152'1221#define CHAR_k '\153'1222#define CHAR_l '\154'1223#define CHAR_m '\155'1224#define CHAR_n '\156'1225#define CHAR_o '\157'1226#define CHAR_p '\160'1227#define CHAR_q '\161'1228#define CHAR_r '\162'1229#define CHAR_s '\163'1230#define CHAR_t '\164'1231#define CHAR_u '\165'1232#define CHAR_v '\166'1233#define CHAR_w '\167'1234#define CHAR_x '\170'1235#define CHAR_y '\171'1236#define CHAR_z '\172'1237#define CHAR_LEFT_CURLY_BRACKET '\173'1238#define CHAR_VERTICAL_LINE '\174'1239#define CHAR_RIGHT_CURLY_BRACKET '\175'1240#define CHAR_TILDE '\176'1241#define CHAR_NBSP ((unsigned char)'\xa0')12421243#define STR_HT "\011"1244#define STR_VT "\013"1245#define STR_FF "\014"1246#define STR_CR "\015"1247#define STR_NL "\012"1248#define STR_BS "\010"1249#define STR_BEL "\007"1250#define STR_ESC "\033"1251#define STR_DEL "\177"12521253#define STR_SPACE "\040"1254#define STR_EXCLAMATION_MARK "\041"1255#define STR_QUOTATION_MARK "\042"1256#define STR_NUMBER_SIGN "\043"1257#define STR_DOLLAR_SIGN "\044"1258#define STR_PERCENT_SIGN "\045"1259#define STR_AMPERSAND "\046"1260#define STR_APOSTROPHE "\047"1261#define STR_LEFT_PARENTHESIS "\050"1262#define STR_RIGHT_PARENTHESIS "\051"1263#define STR_ASTERISK "\052"1264#define STR_PLUS "\053"1265#define STR_COMMA "\054"1266#define STR_MINUS "\055"1267#define STR_DOT "\056"1268#define STR_SLASH "\057"1269#define STR_0 "\060"1270#define STR_1 "\061"1271#define STR_2 "\062"1272#define STR_3 "\063"1273#define STR_4 "\064"1274#define STR_5 "\065"1275#define STR_6 "\066"1276#define STR_7 "\067"1277#define STR_8 "\070"1278#define STR_9 "\071"1279#define STR_COLON "\072"1280#define STR_SEMICOLON "\073"1281#define STR_LESS_THAN_SIGN "\074"1282#define STR_EQUALS_SIGN "\075"1283#define STR_GREATER_THAN_SIGN "\076"1284#define STR_QUESTION_MARK "\077"1285#define STR_COMMERCIAL_AT "\100"1286#define STR_A "\101"1287#define STR_B "\102"1288#define STR_C "\103"1289#define STR_D "\104"1290#define STR_E "\105"1291#define STR_F "\106"1292#define STR_G "\107"1293#define STR_H "\110"1294#define STR_I "\111"1295#define STR_J "\112"1296#define STR_K "\113"1297#define STR_L "\114"1298#define STR_M "\115"1299#define STR_N "\116"1300#define STR_O "\117"1301#define STR_P "\120"1302#define STR_Q "\121"1303#define STR_R "\122"1304#define STR_S "\123"1305#define STR_T "\124"1306#define STR_U "\125"1307#define STR_V "\126"1308#define STR_W "\127"1309#define STR_X "\130"1310#define STR_Y "\131"1311#define STR_Z "\132"1312#define STR_LEFT_SQUARE_BRACKET "\133"1313#define STR_BACKSLASH "\134"1314#define STR_RIGHT_SQUARE_BRACKET "\135"1315#define STR_CIRCUMFLEX_ACCENT "\136"1316#define STR_UNDERSCORE "\137"1317#define STR_GRAVE_ACCENT "\140"1318#define STR_a "\141"1319#define STR_b "\142"1320#define STR_c "\143"1321#define STR_d "\144"1322#define STR_e "\145"1323#define STR_f "\146"1324#define STR_g "\147"1325#define STR_h "\150"1326#define STR_i "\151"1327#define STR_j "\152"1328#define STR_k "\153"1329#define STR_l "\154"1330#define STR_m "\155"1331#define STR_n "\156"1332#define STR_o "\157"1333#define STR_p "\160"1334#define STR_q "\161"1335#define STR_r "\162"1336#define STR_s "\163"1337#define STR_t "\164"1338#define STR_u "\165"1339#define STR_v "\166"1340#define STR_w "\167"1341#define STR_x "\170"1342#define STR_y "\171"1343#define STR_z "\172"1344#define STR_LEFT_CURLY_BRACKET "\173"1345#define STR_VERTICAL_LINE "\174"1346#define STR_RIGHT_CURLY_BRACKET "\175"1347#define STR_TILDE "\176"13481349#endif /* SUPPORT_UNICODE */135013511352#define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"1353#define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"1354#define STRING_F0 STR_F "\0"1355#define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"1356#define STRING_MARK0 STR_M STR_A STR_R STR_K "\0"1357#define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"1358#define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"1359#define STRING_THEN STR_T STR_H STR_E STR_N13601361#define STRING_atomic0 STR_a STR_t STR_o STR_m STR_i STR_c "\0"1362#define STRING_pla0 STR_p STR_l STR_a "\0"1363#define STRING_plb0 STR_p STR_l STR_b "\0"1364#define STRING_napla0 STR_n STR_a STR_p STR_l STR_a "\0"1365#define STRING_naplb0 STR_n STR_a STR_p STR_l STR_b "\0"1366#define STRING_nla0 STR_n STR_l STR_a "\0"1367#define STRING_nlb0 STR_n STR_l STR_b "\0"1368#define STRING_scs0 STR_s STR_c STR_s "\0"1369#define STRING_sr0 STR_s STR_r "\0"1370#define STRING_asr0 STR_a STR_s STR_r "\0"1371#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"1372#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"1373#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"1374#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"1375#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"1376#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"1377#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"1378#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_n1379#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"13801381#define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"1382#define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"1383#define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"1384#define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"1385#define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"1386#define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"1387#define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"1388#define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"1389#define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"1390#define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"1391#define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"1392#define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"1393#define STRING_word0 STR_w STR_o STR_r STR_d "\0"1394#define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t13951396#define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E1397#define STRING_VERSION STR_V STR_E STR_R STR_S STR_I STR_O STR_N1398#define STRING_WEIRD_STARTWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_LESS_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET1399#define STRING_WEIRD_ENDWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_GREATER_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET14001401#define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS1402#define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS1403#define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS1404#define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS1405#define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS1406#define STRING_NUL_RIGHTPAR STR_N STR_U STR_L STR_RIGHT_PARENTHESIS1407#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_PARENTHESIS1408#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_PARENTHESIS1409#define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS1410#define STRING_UTF16_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS1411#define STRING_UTF32_RIGHTPAR STR_U STR_T STR_F STR_3 STR_2 STR_RIGHT_PARENTHESIS1412#define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_RIGHT_PARENTHESIS1413#define STRING_UCP_RIGHTPAR STR_U STR_C STR_P STR_RIGHT_PARENTHESIS1414#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_PARENTHESIS1415#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_PARENTHESIS1416#define STRING_NO_JIT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_J STR_I STR_T STR_RIGHT_PARENTHESIS1417#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_PARENTHESIS1418#define STRING_NOTEMPTY_RIGHTPAR STR_N STR_O STR_T STR_E STR_M STR_P STR_T STR_Y STR_RIGHT_PARENTHESIS1419#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_PARENTHESIS1420#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_PARENTHESIS1421#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_PARENTHESIS1422#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_SIGN1423#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_SIGN1424#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_SIGN1425#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_SIGN1426#define STRING_MARK STR_M STR_A STR_R STR_K14271428#define STRING_bc STR_b STR_c1429#define STRING_bidiclass STR_b STR_i STR_d STR_i STR_c STR_l STR_a STR_s STR_s1430#define STRING_sc STR_s STR_c1431#define STRING_script STR_s STR_c STR_r STR_i STR_p STR_t1432#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_s1433#define STRING_scx STR_s STR_c STR_x143414351436/* -------------------- End of character and string names -------------------*/14371438/* -------------------- Definitions for compiled patterns -------------------*/14391440/* Codes for different types of Unicode property. If these definitions are1441changed, the autopossessifying table in pcre2_auto_possess.c must be updated to1442match. */14431444#define PT_LAMP 0 /* L& - the union of Lu, Ll, Lt */1445#define PT_GC 1 /* Specified general characteristic (e.g. L) */1446#define PT_PC 2 /* Specified particular characteristic (e.g. Lu) */1447#define PT_SC 3 /* Script only (e.g. Han) */1448#define PT_SCX 4 /* Script extensions (includes SC) */1449#define PT_ALNUM 5 /* Alphanumeric - the union of L and N */1450#define PT_SPACE 6 /* Perl space - general category Z plus 9,10,12,13 */1451#define PT_PXSPACE 7 /* POSIX space - Z plus 9,10,11,12,13 */1452#define PT_WORD 8 /* Word - L, N, Mn, or Pc */1453#define PT_CLIST 9 /* Pseudo-property: match character list */1454#define PT_UCNC 10 /* Universal Character nameable character */1455#define PT_BIDICL 11 /* Specified bidi class */1456#define PT_BOOL 12 /* Boolean property */1457#define PT_ANY 13 /* Must be the last entry!1458Any property - matches all chars */1459#define PT_TABSIZE PT_ANY /* Size of square table for autopossessify tests */14601461/* The following special properties are used only in XCLASS items, when POSIX1462classes are specified and PCRE2_UCP is set - in other words, for Unicode1463handling of these classes. They are not available via the \p or \P escapes like1464those in the above list, and so they do not take part in the autopossessifying1465table. */14661467#define PT_PXGRAPH 14 /* [:graph:] - characters that mark the paper */1468#define PT_PXPRINT 15 /* [:print:] - [:graph:] plus non-control spaces */1469#define PT_PXPUNCT 16 /* [:punct:] - punctuation characters */1470#define PT_PXXDIGIT 17 /* [:xdigit:] - hex digits */14711472/* This value is used when parsing \p and \P escapes to indicate that neither1473\p{script:...} nor \p{scx:...} has been encountered. */14741475#define PT_NOTSCRIPT 25514761477/* Flag bits and data types for the extended class (OP_XCLASS) for classes that1478contain characters with values greater than 255. */14791480#define XCL_NOT 0x01 /* Flag: this is a negative class */1481#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */1482#define XCL_HASPROP 0x04 /* Flag: property checks are present. */14831484#define XCL_END 0 /* Marks end of individual items */1485#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */1486#define XCL_RANGE 2 /* A range (two multibyte chars) follows */1487#define XCL_PROP 3 /* Unicode property (2-byte property code follows) */1488#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */1489/* This value represents the beginning of character lists. The value1490is 16 bit long, and stored as a high and low byte pair in 8 bit mode.1491The lower 12 bit contains information about character lists (see later). */1492#define XCL_LIST (sizeof(PCRE2_UCHAR) == 1 ? 0x10 : 0x1000)14931494/* When a character class contains many characters/ranges,1495they are stored in character lists. There are four character1496lists which contain characters/ranges within a given range.14971498The name, character range and item size for each list:1499Low16 [0x100 - 0x7fff] 16 bit items1500High16 [0x8000 - 0xffff] 16 bit items1501Low32 [0x10000 - 0x7fffffff] 32 bit items1502High32 [0x80000000 - 0xffffffff] 32 bit items15031504The Low32 character list is used only when utf encoding or 32 bit1505character width is enabled, and the High32 character is used only1506when 32 bit character width is enabled.15071508Each character list contain items. The lowest bit represents that1509an item is the beginning of a range (bit is cleared), or not (bit1510is set). The other bits represent the character shifted left by1511one, so its highest bit is discarded. Due to the layout of character1512lists, the highest bit of a character is always known:15131514Low16 and Low32: the highest bit is always zero1515High16 and High32: the highest bit is always one15161517The items are ordered in increasing order, so binary search can be1518used to find the lower bound of an input character. The lower bound1519is the highest item, which value is less or equal than the input1520character. If the lower bit of the item is cleard, or the character1521stored in the item equals to the input character, the input1522character is in the character list. */15231524/* Character list constants. */1525#define XCL_CHAR_LIST_LOW_16_START 0x1001526#define XCL_CHAR_LIST_LOW_16_END 0x7fff1527#define XCL_CHAR_LIST_LOW_16_ADD 0x015281529#define XCL_CHAR_LIST_HIGH_16_START 0x80001530#define XCL_CHAR_LIST_HIGH_16_END 0xffff1531#define XCL_CHAR_LIST_HIGH_16_ADD 0x800015321533#define XCL_CHAR_LIST_LOW_32_START 0x100001534#define XCL_CHAR_LIST_LOW_32_END 0x7fffffff1535#define XCL_CHAR_LIST_LOW_32_ADD 0x015361537#define XCL_CHAR_LIST_HIGH_32_START 0x800000001538#define XCL_CHAR_LIST_HIGH_32_END 0xffffffff1539#define XCL_CHAR_LIST_HIGH_32_ADD 0x8000000015401541/* Mask for getting the descriptors of character list ranges.1542Each descriptor has XCL_TYPE_BIT_LEN bits, and can be processed1543by XCL_BEGIN_WITH_RANGE and XCL_ITEM_COUNT_MASK macros. */1544#define XCL_TYPE_MASK 0xfff1545#define XCL_TYPE_BIT_LEN 31546/* If this bit is set, the first item of the character list is the1547end of a range, which started before the starting character of the1548character list. */1549#define XCL_BEGIN_WITH_RANGE 0x41550/* Number of items in the character list: 0, 1, or 2. The value 31551represents that the item count is stored at the begining of the1552character list. The item count has the same width as the items1553in the character list (e.g. 16 bit for Low16 and High16 lists). */1554#define XCL_ITEM_COUNT_MASK 0x31555/* Shift and flag for constructing character list items. The XCL_CHAR_END1556is set, when the item is not the beginning of a range. The XCL_CHAR_SHIFT1557can be used to encode / decode the character value stored in an item. */1558#define XCL_CHAR_END 0x11559#define XCL_CHAR_SHIFT 115601561/* Flag bits for an extended class (OP_ECLASS), which is used for complex1562character matches such as [\p{Greek} && \p{Ll}]. */15631564#define ECL_MAP 0x01 /* Flag: a 32-byte map is present */15651566/* Type tags for the items stored in an extended class (OP_ECLASS). These items1567follow the OP_ECLASS's flag char and bitmap, and represent a Reverse Polish1568Notation list of operands and operators manipulating a stack of bits. */15691570#define ECL_AND 1 /* Pop two from the stack, AND, and push result. */1571#define ECL_OR 2 /* Pop two from the stack, OR, and push result. */1572#define ECL_XOR 3 /* Pop two from the stack, XOR, and push result. */1573#define ECL_NOT 4 /* Pop one from the stack, NOT, and push result. */1574#define ECL_XCLASS 5 /* XCLASS nested within ECLASS; match and push result. */1575#define ECL_ANY 6 /* Temporary, only used during compilation. */1576#define ECL_NONE 7 /* Temporary, only used during compilation. */15771578/* These are escaped items that aren't just an encoding of a particular data1579value such as \n. They must have non-zero values, as check_escape() returns 01580for a data character. In the escapes[] table in pcre2_compile.c their values1581are negated in order to distinguish them from data values.15821583They must appear here in the same order as in the opcode definitions below, up1584to ESC_z. There's a dummy for OP_ALLANY because it corresponds to "." in DOTALL1585mode rather than an escape sequence. It is also used for [^] in JavaScript1586compatibility mode, and for \C in non-utf mode. In non-DOTALL mode, "." behaves1587like \N.15881589ESC_ub is a special return from check_escape() when, in BSUX mode, \u{ is not1590followed by hex digits and }, in which case it should mean a literal "u"1591followed by a literal "{". This hack is necessary for cases like \u{ 12}1592because without it, this is interpreted as u{12} now that spaces are allowed in1593quantifiers.15941595Negative numbers are used to encode a backreference (\1, \2, \3, etc.) in1596check_escape(). There are tests in the code for an escape greater than ESC_b1597and less than ESC_Z to detect the types that may be repeated. These are the1598types that consume characters. If any new escapes are put in between that don't1599consume a character, that code will have to change. */16001601enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,1602ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,1603ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,1604ESC_E, ESC_Q, ESC_g, ESC_k, ESC_ub };160516061607/********************** Opcode definitions ******************/16081609/****** NOTE NOTE NOTE ******16101611Starting from 1 (i.e. after OP_END), the values up to OP_EOD must correspond in1612order to the list of escapes immediately above. Furthermore, values up to1613OP_DOLLM must not be changed without adjusting the table called autoposstab in1614pcre2_auto_possess.c.16151616Whenever this list is updated, the two macro definitions that follow must be1617updated to match. The possessification table called "opcode_possessify" in1618pcre2_compile.c must also be updated, and also the tables called "coptable"1619and "poptable" in pcre2_dfa_match.c.16201621****** NOTE NOTE NOTE ******/162216231624/* The values between FIRST_AUTOTAB_OP and LAST_AUTOTAB_RIGHT_OP, inclusive,1625are used in a table for deciding whether a repeated character type can be1626auto-possessified. */16271628#define FIRST_AUTOTAB_OP OP_NOT_DIGIT1629#define LAST_AUTOTAB_LEFT_OP OP_EXTUNI1630#define LAST_AUTOTAB_RIGHT_OP OP_DOLLM16311632enum {1633OP_END, /* 0 End of pattern */16341635/* Values corresponding to backslashed metacharacters */16361637OP_SOD, /* 1 Start of data: \A */1638OP_SOM, /* 2 Start of match (subject + offset): \G */1639OP_SET_SOM, /* 3 Set start of match (\K) */1640OP_NOT_WORD_BOUNDARY, /* 4 \B -- see also OP_NOT_UCP_WORD_BOUNDARY */1641OP_WORD_BOUNDARY, /* 5 \b -- see also OP_UCP_WORD_BOUNDARY */1642OP_NOT_DIGIT, /* 6 \D */1643OP_DIGIT, /* 7 \d */1644OP_NOT_WHITESPACE, /* 8 \S */1645OP_WHITESPACE, /* 9 \s */1646OP_NOT_WORDCHAR, /* 10 \W */1647OP_WORDCHAR, /* 11 \w */16481649OP_ANY, /* 12 Match any character except newline (\N) */1650OP_ALLANY, /* 13 Match any character */1651OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */1652OP_NOTPROP, /* 15 \P (not Unicode property) */1653OP_PROP, /* 16 \p (Unicode property) */1654OP_ANYNL, /* 17 \R (any newline sequence) */1655OP_NOT_HSPACE, /* 18 \H (not horizontal whitespace) */1656OP_HSPACE, /* 19 \h (horizontal whitespace) */1657OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */1658OP_VSPACE, /* 21 \v (vertical whitespace) */1659OP_EXTUNI, /* 22 \X (extended Unicode sequence */1660OP_EODN, /* 23 End of data or \n at end of data (\Z) */1661OP_EOD, /* 24 End of data (\z) */16621663/* Line end assertions */16641665OP_DOLL, /* 25 End of line - not multiline */1666OP_DOLLM, /* 26 End of line - multiline */1667OP_CIRC, /* 27 Start of line - not multiline */1668OP_CIRCM, /* 28 Start of line - multiline */16691670/* Single characters; caseful must precede the caseless ones, and these1671must remain in this order, and adjacent. */16721673OP_CHAR, /* 29 Match one character, casefully */1674OP_CHARI, /* 30 Match one character, caselessly */1675OP_NOT, /* 31 Match one character, not the given one, casefully */1676OP_NOTI, /* 32 Match one character, not the given one, caselessly */16771678/* The following sets of 13 opcodes must always be kept in step because1679the offset from the first one is used to generate the others. */16801681/* Repeated characters; caseful must precede the caseless ones */16821683OP_STAR, /* 33 The maximizing and minimizing versions of */1684OP_MINSTAR, /* 34 these six opcodes must come in pairs, with */1685OP_PLUS, /* 35 the minimizing one second. */1686OP_MINPLUS, /* 36 */1687OP_QUERY, /* 37 */1688OP_MINQUERY, /* 38 */16891690OP_UPTO, /* 39 From 0 to n matches of one character, caseful*/1691OP_MINUPTO, /* 40 */1692OP_EXACT, /* 41 Exactly n matches */16931694OP_POSSTAR, /* 42 Possessified star, caseful */1695OP_POSPLUS, /* 43 Possessified plus, caseful */1696OP_POSQUERY, /* 44 Posesssified query, caseful */1697OP_POSUPTO, /* 45 Possessified upto, caseful */16981699/* Repeated characters; caseless must follow the caseful ones */17001701OP_STARI, /* 46 */1702OP_MINSTARI, /* 47 */1703OP_PLUSI, /* 48 */1704OP_MINPLUSI, /* 49 */1705OP_QUERYI, /* 50 */1706OP_MINQUERYI, /* 51 */17071708OP_UPTOI, /* 52 From 0 to n matches of one character, caseless */1709OP_MINUPTOI, /* 53 */1710OP_EXACTI, /* 54 */17111712OP_POSSTARI, /* 55 Possessified star, caseless */1713OP_POSPLUSI, /* 56 Possessified plus, caseless */1714OP_POSQUERYI, /* 57 Posesssified query, caseless */1715OP_POSUPTOI, /* 58 Possessified upto, caseless */17161717/* The negated ones must follow the non-negated ones, and match them */1718/* Negated repeated character, caseful; must precede the caseless ones */17191720OP_NOTSTAR, /* 59 The maximizing and minimizing versions of */1721OP_NOTMINSTAR, /* 60 these six opcodes must come in pairs, with */1722OP_NOTPLUS, /* 61 the minimizing one second. They must be in */1723OP_NOTMINPLUS, /* 62 exactly the same order as those above. */1724OP_NOTQUERY, /* 63 */1725OP_NOTMINQUERY, /* 64 */17261727OP_NOTUPTO, /* 65 From 0 to n matches, caseful */1728OP_NOTMINUPTO, /* 66 */1729OP_NOTEXACT, /* 67 Exactly n matches */17301731OP_NOTPOSSTAR, /* 68 Possessified versions, caseful */1732OP_NOTPOSPLUS, /* 69 */1733OP_NOTPOSQUERY, /* 70 */1734OP_NOTPOSUPTO, /* 71 */17351736/* Negated repeated character, caseless; must follow the caseful ones */17371738OP_NOTSTARI, /* 72 */1739OP_NOTMINSTARI, /* 73 */1740OP_NOTPLUSI, /* 74 */1741OP_NOTMINPLUSI, /* 75 */1742OP_NOTQUERYI, /* 76 */1743OP_NOTMINQUERYI, /* 77 */17441745OP_NOTUPTOI, /* 78 From 0 to n matches, caseless */1746OP_NOTMINUPTOI, /* 79 */1747OP_NOTEXACTI, /* 80 Exactly n matches */17481749OP_NOTPOSSTARI, /* 81 Possessified versions, caseless */1750OP_NOTPOSPLUSI, /* 82 */1751OP_NOTPOSQUERYI, /* 83 */1752OP_NOTPOSUPTOI, /* 84 */17531754/* Character types */17551756OP_TYPESTAR, /* 85 The maximizing and minimizing versions of */1757OP_TYPEMINSTAR, /* 86 these six opcodes must come in pairs, with */1758OP_TYPEPLUS, /* 87 the minimizing one second. These codes must */1759OP_TYPEMINPLUS, /* 88 be in exactly the same order as those above. */1760OP_TYPEQUERY, /* 89 */1761OP_TYPEMINQUERY, /* 90 */17621763OP_TYPEUPTO, /* 91 From 0 to n matches */1764OP_TYPEMINUPTO, /* 92 */1765OP_TYPEEXACT, /* 93 Exactly n matches */17661767OP_TYPEPOSSTAR, /* 94 Possessified versions */1768OP_TYPEPOSPLUS, /* 95 */1769OP_TYPEPOSQUERY, /* 96 */1770OP_TYPEPOSUPTO, /* 97 */17711772/* These are used for character classes and back references; only the1773first six are the same as the sets above. */17741775OP_CRSTAR, /* 98 The maximizing and minimizing versions of */1776OP_CRMINSTAR, /* 99 all these opcodes must come in pairs, with */1777OP_CRPLUS, /* 100 the minimizing one second. These codes must */1778OP_CRMINPLUS, /* 101 be in exactly the same order as those above. */1779OP_CRQUERY, /* 102 */1780OP_CRMINQUERY, /* 103 */17811782OP_CRRANGE, /* 104 These are different to the three sets above. */1783OP_CRMINRANGE, /* 105 */17841785OP_CRPOSSTAR, /* 106 Possessified versions */1786OP_CRPOSPLUS, /* 107 */1787OP_CRPOSQUERY, /* 108 */1788OP_CRPOSRANGE, /* 109 */17891790/* End of quantifier opcodes */17911792OP_CLASS, /* 110 Match a character class, chars < 256 only */1793OP_NCLASS, /* 111 Same, but the bitmap was created from a negative1794class - the difference is relevant only when a1795character > 255 is encountered. */1796OP_XCLASS, /* 112 Extended class for handling > 255 chars within the1797class. This does both positive and negative. */1798OP_ECLASS, /* 113 Really-extended class, for handling logical1799expressions computed over characters. */1800OP_REF, /* 114 Match a back reference, casefully */1801OP_REFI, /* 115 Match a back reference, caselessly */1802OP_DNREF, /* 116 Match a duplicate name backref, casefully */1803OP_DNREFI, /* 117 Match a duplicate name backref, caselessly */1804OP_RECURSE, /* 118 Match a numbered subpattern (possibly recursive) */1805OP_CALLOUT, /* 119 Call out to external function if provided */1806OP_CALLOUT_STR, /* 120 Call out with string argument */18071808OP_ALT, /* 121 Start of alternation */1809OP_KET, /* 122 End of group that doesn't have an unbounded repeat */1810OP_KETRMAX, /* 123 These two must remain together and in this */1811OP_KETRMIN, /* 124 order. They are for groups the repeat for ever. */1812OP_KETRPOS, /* 125 Possessive unlimited repeat. */18131814/* The assertions must come before BRA, CBRA, ONCE, and COND. */18151816OP_REVERSE, /* 126 Move pointer back - used in lookbehind assertions */1817OP_VREVERSE, /* 127 Move pointer back - variable */1818OP_ASSERT, /* 128 Positive lookahead */1819OP_ASSERT_NOT, /* 129 Negative lookahead */1820OP_ASSERTBACK, /* 130 Positive lookbehind */1821OP_ASSERTBACK_NOT, /* 131 Negative lookbehind */1822OP_ASSERT_NA, /* 132 Positive non-atomic lookahead */1823OP_ASSERTBACK_NA, /* 133 Positive non-atomic lookbehind */1824OP_ASSERT_SCS, /* 134 Scan substring */18251826/* ONCE, SCRIPT_RUN, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come1827immediately after the assertions, with ONCE first, as there's a test for >=1828ONCE for a subpattern that isn't an assertion. The POS versions must1829immediately follow the non-POS versions in each case. */18301831OP_ONCE, /* 135 Atomic group, contains captures */1832OP_SCRIPT_RUN, /* 136 Non-capture, but check characters' scripts */1833OP_BRA, /* 137 Start of non-capturing bracket */1834OP_BRAPOS, /* 138 Ditto, with unlimited, possessive repeat */1835OP_CBRA, /* 139 Start of capturing bracket */1836OP_CBRAPOS, /* 140 Ditto, with unlimited, possessive repeat */1837OP_COND, /* 141 Conditional group */18381839/* These five must follow the previous five, in the same order. There's a1840check for >= SBRA to distinguish the two sets. */18411842OP_SBRA, /* 142 Start of non-capturing bracket, check empty */1843OP_SBRAPOS, /* 143 Ditto, with unlimited, possessive repeat */1844OP_SCBRA, /* 144 Start of capturing bracket, check empty */1845OP_SCBRAPOS, /* 145 Ditto, with unlimited, possessive repeat */1846OP_SCOND, /* 146 Conditional group, check empty */18471848/* The next two pairs must (respectively) be kept together. */18491850OP_CREF, /* 147 Used to hold a capture number as condition */1851OP_DNCREF, /* 148 Used to point to duplicate names as a condition */1852OP_RREF, /* 149 Used to hold a recursion number as condition */1853OP_DNRREF, /* 150 Used to point to duplicate names as a condition */1854OP_FALSE, /* 151 Always false (used by DEFINE and VERSION) */1855OP_TRUE, /* 152 Always true (used by VERSION) */18561857OP_BRAZERO, /* 153 These two must remain together and in this */1858OP_BRAMINZERO, /* 154 order. */1859OP_BRAPOSZERO, /* 155 */18601861/* These are backtracking control verbs */18621863OP_MARK, /* 156 always has an argument */1864OP_PRUNE, /* 157 */1865OP_PRUNE_ARG, /* 158 same, but with argument */1866OP_SKIP, /* 159 */1867OP_SKIP_ARG, /* 160 same, but with argument */1868OP_THEN, /* 161 */1869OP_THEN_ARG, /* 162 same, but with argument */1870OP_COMMIT, /* 163 */1871OP_COMMIT_ARG, /* 164 same, but with argument */18721873/* These are forced failure and success verbs. FAIL and ACCEPT do accept an1874argument, but these cases can be compiled as, for example, (*MARK:X)(*FAIL)1875without the need for a special opcode. */18761877OP_FAIL, /* 165 */1878OP_ACCEPT, /* 166 */1879OP_ASSERT_ACCEPT, /* 167 Used inside assertions */1880OP_CLOSE, /* 168 Used before OP_ACCEPT to close open captures */18811882/* This is used to skip a subpattern with a {0} quantifier */18831884OP_SKIPZERO, /* 169 */18851886/* This is used to identify a DEFINE group during compilation so that it can1887be checked for having only one branch. It is changed to OP_FALSE before1888compilation finishes. */18891890OP_DEFINE, /* 170 */18911892/* These opcodes replace their normal counterparts in UCP mode when1893PCRE2_EXTRA_ASCII_BSW is not set. */18941895OP_NOT_UCP_WORD_BOUNDARY, /* 171 */1896OP_UCP_WORD_BOUNDARY, /* 172 */18971898/* This is not an opcode, but is used to check that tables indexed by opcode1899are the correct length, in order to catch updating errors - there have been1900some in the past. */19011902OP_TABLE_LENGTH19031904};19051906/* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro1907definitions that follow must also be updated to match. There are also tables1908called "opcode_possessify" in pcre2_compile.c and "coptable" and "poptable" in1909pcre2_dfa_match.c that must be updated. */191019111912/* This macro defines textual names for all the opcodes. These are used only1913for debugging, and some of them are only partial names. The macro is referenced1914only in pcre2_printint_inc.h, which fills out the full names in many cases (and in1915some cases doesn't actually use these names at all). */19161917#define OP_NAME_LIST \1918"End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \1919"\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte", \1920"notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \1921"extuni", "\\Z", "\\z", \1922"$", "$", "^", "^", "char", "chari", "not", "noti", \1923"*", "*?", "+", "+?", "?", "??", \1924"{", "{", "{", \1925"*+","++", "?+", "{", \1926"*", "*?", "+", "+?", "?", "??", \1927"{", "{", "{", \1928"*+","++", "?+", "{", \1929"*", "*?", "+", "+?", "?", "??", \1930"{", "{", "{", \1931"*+","++", "?+", "{", \1932"*", "*?", "+", "+?", "?", "??", \1933"{", "{", "{", \1934"*+","++", "?+", "{", \1935"*", "*?", "+", "+?", "?", "??", "{", "{", "{", \1936"*+","++", "?+", "{", \1937"*", "*?", "+", "+?", "?", "??", "{", "{", \1938"*+","++", "?+", "{", \1939"class", "nclass", "xclass", "eclass", \1940"Ref", "Refi", "DnRef", "DnRefi", \1941"Recurse", "Callout", "CalloutStr", \1942"Alt", "Ket", "KetRmax", "KetRmin", "KetRpos", \1943"Reverse", "VReverse", "Assert", "Assert not", \1944"Assert back", "Assert back not", \1945"Non-atomic assert", "Non-atomic assert back", \1946"Scan substring", \1947"Once", \1948"Script run", \1949"Bra", "BraPos", "CBra", "CBraPos", \1950"Cond", \1951"SBra", "SBraPos", "SCBra", "SCBraPos", \1952"SCond", \1953"Capture ref", "Capture dnref", "Cond rec", "Cond dnrec", \1954"Cond false", "Cond true", \1955"Brazero", "Braminzero", "Braposzero", \1956"*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP", \1957"*THEN", "*THEN", "*COMMIT", "*COMMIT", "*FAIL", \1958"*ACCEPT", "*ASSERT_ACCEPT", \1959"Close", "Skip zero", "Define", "\\B (ucp)", "\\b (ucp)"196019611962/* This macro defines the length of fixed length operations in the compiled1963regex. The lengths are used when searching for specific things, and also in the1964debugging printing of a compiled regex. We use a macro so that it can be1965defined close to the definitions of the opcodes themselves.19661967As things have been extended, some of these are no longer fixed lenths, but are1968minima instead. For example, the length of a single-character repeat may vary1969in UTF-8 mode. The code that uses this table must know about such things. */19701971#define OP_LENGTHS \19721, /* End */ \19731, 1, 1, 1, 1, /* \A, \G, \K, \B, \b */ \19741, 1, 1, 1, 1, 1, /* \D, \d, \S, \s, \W, \w */ \19751, 1, 1, /* Any, AllAny, Anybyte */ \19763, 3, /* \P, \p */ \19771, 1, 1, 1, 1, /* \R, \H, \h, \V, \v */ \19781, /* \X */ \19791, 1, 1, 1, 1, 1, /* \Z, \z, $, $M ^, ^M */ \19802, /* Char - the minimum length */ \19812, /* Chari - the minimum length */ \19822, /* not */ \19832, /* noti */ \1984/* Positive single-char repeats ** These are */ \19852, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \19862+IMM2_SIZE, 2+IMM2_SIZE, /* upto, minupto ** mode */ \19872+IMM2_SIZE, /* exact */ \19882, 2, 2, 2+IMM2_SIZE, /* *+, ++, ?+, upto+ */ \19892, 2, 2, 2, 2, 2, /* *I, *?I, +I, +?I, ?I, ??I ** UTF-8 */ \19902+IMM2_SIZE, 2+IMM2_SIZE, /* upto I, minupto I */ \19912+IMM2_SIZE, /* exact I */ \19922, 2, 2, 2+IMM2_SIZE, /* *+I, ++I, ?+I, upto+I */ \1993/* Negative single-char repeats - only for chars < 256 */ \19942, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \19952+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto, minupto */ \19962+IMM2_SIZE, /* NOT exact */ \19972, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *, +, ?, upto */ \19982, 2, 2, 2, 2, 2, /* NOT *I, *?I, +I, +?I, ?I, ??I */ \19992+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto I, minupto I */ \20002+IMM2_SIZE, /* NOT exact I */ \20012, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *I, +I, ?I, upto I */ \2002/* Positive type repeats */ \20032, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \20042+IMM2_SIZE, 2+IMM2_SIZE, /* Type upto, minupto */ \20052+IMM2_SIZE, /* Type exact */ \20062, 2, 2, 2+IMM2_SIZE, /* Possessive *+, ++, ?+, upto+ */ \2007/* Character class & ref repeats */ \20081, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \20091+2*IMM2_SIZE, 1+2*IMM2_SIZE, /* CRRANGE, CRMINRANGE */ \20101, 1, 1, 1+2*IMM2_SIZE, /* Possessive *+, ++, ?+, CRPOSRANGE */ \20111+(32/sizeof(PCRE2_UCHAR)), /* CLASS */ \20121+(32/sizeof(PCRE2_UCHAR)), /* NCLASS */ \20130, /* XCLASS - variable length */ \20140, /* ECLASS - variable length */ \20151+IMM2_SIZE, /* REF */ \20161+IMM2_SIZE+1, /* REFI */ \20171+2*IMM2_SIZE, /* DNREF */ \20181+2*IMM2_SIZE+1, /* DNREFI */ \20191+LINK_SIZE, /* RECURSE */ \20201+2*LINK_SIZE+1, /* CALLOUT */ \20210, /* CALLOUT_STR - variable length */ \20221+LINK_SIZE, /* Alt */ \20231+LINK_SIZE, /* Ket */ \20241+LINK_SIZE, /* KetRmax */ \20251+LINK_SIZE, /* KetRmin */ \20261+LINK_SIZE, /* KetRpos */ \20271+IMM2_SIZE, /* Reverse */ \20281+2*IMM2_SIZE, /* VReverse */ \20291+LINK_SIZE, /* Assert */ \20301+LINK_SIZE, /* Assert not */ \20311+LINK_SIZE, /* Assert behind */ \20321+LINK_SIZE, /* Assert behind not */ \20331+LINK_SIZE, /* NA Assert */ \20341+LINK_SIZE, /* NA Assert behind */ \20351+LINK_SIZE, /* Scan substring */ \20361+LINK_SIZE, /* ONCE */ \20371+LINK_SIZE, /* SCRIPT_RUN */ \20381+LINK_SIZE, /* BRA */ \20391+LINK_SIZE, /* BRAPOS */ \20401+LINK_SIZE+IMM2_SIZE, /* CBRA */ \20411+LINK_SIZE+IMM2_SIZE, /* CBRAPOS */ \20421+LINK_SIZE, /* COND */ \20431+LINK_SIZE, /* SBRA */ \20441+LINK_SIZE, /* SBRAPOS */ \20451+LINK_SIZE+IMM2_SIZE, /* SCBRA */ \20461+LINK_SIZE+IMM2_SIZE, /* SCBRAPOS */ \20471+LINK_SIZE, /* SCOND */ \20481+IMM2_SIZE, 1+2*IMM2_SIZE, /* CREF, DNCREF */ \20491+IMM2_SIZE, 1+2*IMM2_SIZE, /* RREF, DNRREF */ \20501, 1, /* FALSE, TRUE */ \20511, 1, 1, /* BRAZERO, BRAMINZERO, BRAPOSZERO */ \20523, 1, 3, /* MARK, PRUNE, PRUNE_ARG */ \20531, 3, /* SKIP, SKIP_ARG */ \20541, 3, /* THEN, THEN_ARG */ \20551, 3, /* COMMIT, COMMIT_ARG */ \20561, 1, 1, /* FAIL, ACCEPT, ASSERT_ACCEPT */ \20571+IMM2_SIZE, 1, /* CLOSE, SKIPZERO */ \20581, /* DEFINE */ \20591, 1 /* \B and \b in UCP mode */20602061/* A magic value for OP_RREF to indicate the "any recursion" condition. */20622063#define RREF_ANY 0xffff20642065/* Constants used by OP_REFI and OP_DNREFI to control matching behaviour. */20662067#define REFI_FLAG_CASELESS_RESTRICT 0x12068#define REFI_FLAG_TURKISH_CASING 0x2206920702071/* ---------- Private structures that are mode-independent. ---------- */20722073/* Structure to hold data for custom memory management. */20742075typedef struct pcre2_memctl {2076void * (*malloc)(size_t, void *);2077void (*free)(void *, void *);2078void *memory_data;2079} pcre2_memctl;20802081/* Structure for building a chain of open capturing subpatterns during2082compiling, so that instructions to close them can be compiled when (*ACCEPT) is2083encountered. */20842085typedef struct open_capitem {2086struct open_capitem *next; /* Chain link */2087uint16_t number; /* Capture number */2088uint16_t assert_depth; /* Assertion depth when opened */2089} open_capitem;20902091/* Layout of the UCP type table that translates property names into types and2092codes. Each entry used to point directly to a name, but to reduce the number of2093relocations in shared libraries, it now has an offset into a single string2094instead. */20952096typedef struct {2097uint16_t name_offset;2098uint16_t type;2099uint16_t value;2100} ucp_type_table;21012102/* Unicode character database (UCD) record format */21032104typedef struct {2105uint8_t script; /* ucp_Arabic, etc. */2106uint8_t chartype; /* ucp_Cc, etc. (general categories) */2107uint8_t gbprop; /* ucp_gbControl, etc. (grapheme break property) */2108uint8_t caseset; /* offset to multichar other cases or zero */2109int32_t other_case; /* offset to other case, or zero if none */2110uint16_t scriptx_bidiclass; /* script extension (11 bit) and bidi class (5 bit) values */2111uint16_t bprops; /* binary properties offset */2112} ucd_record;21132114/* UCD access macros */21152116#define UCD_BLOCK_SIZE 1282117#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \2118PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \2119UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])21202121#if PCRE2_CODE_UNIT_WIDTH == 322122#define GET_UCD(ch) ((ch > MAX_UTF_CODE_POINT)? \2123PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))2124#else2125#define GET_UCD(ch) REAL_GET_UCD(ch)2126#endif21272128#define UCD_SCRIPTX_MASK 0x3ff2129#define UCD_BIDICLASS_SHIFT 112130#define UCD_BPROPS_MASK 0xfff21312132#define UCD_SCRIPTX_PROP(prop) ((prop)->scriptx_bidiclass & UCD_SCRIPTX_MASK)2133#define UCD_BIDICLASS_PROP(prop) ((prop)->scriptx_bidiclass >> UCD_BIDICLASS_SHIFT)2134#define UCD_BPROPS_PROP(prop) ((prop)->bprops & UCD_BPROPS_MASK)21352136#define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype2137#define UCD_SCRIPT(ch) GET_UCD(ch)->script2138#define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]2139#define UCD_GRAPHBREAK(ch) GET_UCD(ch)->gbprop2140#define UCD_CASESET(ch) GET_UCD(ch)->caseset2141#define UCD_OTHERCASE(ch) ((uint32_t)((int)ch + (int)(GET_UCD(ch)->other_case)))2142#define UCD_SCRIPTX(ch) UCD_SCRIPTX_PROP(GET_UCD(ch))2143#define UCD_BPROPS(ch) UCD_BPROPS_PROP(GET_UCD(ch))2144#define UCD_BIDICLASS(ch) UCD_BIDICLASS_PROP(GET_UCD(ch))2145#define UCD_ANY_I(ch) \2146/* match any of the four characters 'i', 'I', U+0130, U+0131 */ \2147(((uint32_t)(ch) | 0x20u) == 0x69u || ((uint32_t)(ch) | 1u) == 0x0131u)2148#define UCD_DOTTED_I(ch) \2149((uint32_t)(ch) == 0x69u || (uint32_t)(ch) == 0x0130u)2150#define UCD_FOLD_I_TURKISH(ch) \2151((uint32_t)(ch) == 0x0130u ? 0x69u : \2152(uint32_t)(ch) == 0x49u ? 0x0131u : (uint32_t)(ch))21532154/* The "scriptx" and bprops fields contain offsets into vectors of 32-bit words2155that form a bitmap representing a list of scripts or boolean properties. These2156macros test or set a bit in the map by number. */21572158#define MAPBIT(map,n) ((map)[(n)/32]&(1u<<((n)%32)))2159#define MAPSET(map,n) ((map)[(n)/32]|=(1u<<((n)%32)))21602161/* Header for serialized pcre2 codes. */21622163typedef struct pcre2_serialized_data {2164uint32_t magic;2165uint32_t version;2166uint32_t config;2167int32_t number_of_codes;2168} pcre2_serialized_data;2169217021712172/* ----------------- Items that need PCRE2_CODE_UNIT_WIDTH ----------------- */21732174/* When this file is included by pcre2test, PCRE2_CODE_UNIT_WIDTH is defined as21750, so the following items are omitted. */21762177#if defined PCRE2_CODE_UNIT_WIDTH && PCRE2_CODE_UNIT_WIDTH != 021782179/* EBCDIC is supported only for the 8-bit library. */21802181#if defined EBCDIC && PCRE2_CODE_UNIT_WIDTH != 82182#error EBCDIC is not supported for the 16-bit or 32-bit libraries2183#endif21842185/* This is the largest non-UTF code point. */21862187#define MAX_NON_UTF_CHAR (0xffffffffU >> (32 - PCRE2_CODE_UNIT_WIDTH))21882189/* Internal shared data tables and variables. These are used by more than one2190of the exported public functions. They have to be "external" in the C sense,2191but are not part of the PCRE2 public API. Although the data for some of them is2192identical in all libraries, they must have different names so that multiple2193libraries can be simultaneously linked to a single application. However, UTF-82194tables are needed only when compiling the 8-bit library. */21952196#if PCRE2_CODE_UNIT_WIDTH == 82197extern const int PRIV(utf8_table1)[];2198extern const unsigned PRIV(utf8_table1_size);2199extern const int PRIV(utf8_table2)[];2200extern const int PRIV(utf8_table3)[];2201extern const uint8_t PRIV(utf8_table4)[];2202#endif22032204#define _pcre2_OP_lengths PCRE2_SUFFIX(_pcre2_OP_lengths_)2205#define _pcre2_callout_end_delims PCRE2_SUFFIX(_pcre2_callout_end_delims_)2206#define _pcre2_callout_start_delims PCRE2_SUFFIX(_pcre2_callout_start_delims_)2207#define _pcre2_default_compile_context PCRE2_SUFFIX(_pcre2_default_compile_context_)2208#define _pcre2_default_convert_context PCRE2_SUFFIX(_pcre2_default_convert_context_)2209#define _pcre2_default_match_context PCRE2_SUFFIX(_pcre2_default_match_context_)2210#define _pcre2_default_tables PCRE2_SUFFIX(_pcre2_default_tables_)2211#if PCRE2_CODE_UNIT_WIDTH == 322212#define _pcre2_dummy_ucd_record PCRE2_SUFFIX(_pcre2_dummy_ucd_record_)2213#endif2214#define _pcre2_hspace_list PCRE2_SUFFIX(_pcre2_hspace_list_)2215#define _pcre2_vspace_list PCRE2_SUFFIX(_pcre2_vspace_list_)2216#define _pcre2_ucd_boolprop_sets PCRE2_SUFFIX(_pcre2_ucd_boolprop_sets_)2217#define _pcre2_ucd_caseless_sets PCRE2_SUFFIX(_pcre2_ucd_caseless_sets_)2218#define _pcre2_ucd_turkish_dotted_i_caseset PCRE2_SUFFIX(_pcre2_ucd_turkish_dotted_i_caseset_)2219#define _pcre2_ucd_nocase_ranges PCRE2_SUFFIX(_pcre2_ucd_nocase_ranges_)2220#define _pcre2_ucd_nocase_ranges_size PCRE2_SUFFIX(_pcre2_ucd_nocase_ranges_size_)2221#define _pcre2_ucd_digit_sets PCRE2_SUFFIX(_pcre2_ucd_digit_sets_)2222#define _pcre2_ucd_script_sets PCRE2_SUFFIX(_pcre2_ucd_script_sets_)2223#define _pcre2_ucd_records PCRE2_SUFFIX(_pcre2_ucd_records_)2224#define _pcre2_ucd_stage1 PCRE2_SUFFIX(_pcre2_ucd_stage1_)2225#define _pcre2_ucd_stage2 PCRE2_SUFFIX(_pcre2_ucd_stage2_)2226#define _pcre2_ucp_gbtable PCRE2_SUFFIX(_pcre2_ucp_gbtable_)2227#define _pcre2_ucp_gentype PCRE2_SUFFIX(_pcre2_ucp_gentype_)2228#define _pcre2_ucp_typerange PCRE2_SUFFIX(_pcre2_ucp_typerange_)2229#define _pcre2_unicode_version PCRE2_SUFFIX(_pcre2_unicode_version_)2230#define _pcre2_utt PCRE2_SUFFIX(_pcre2_utt_)2231#define _pcre2_utt_names PCRE2_SUFFIX(_pcre2_utt_names_)2232#define _pcre2_utt_size PCRE2_SUFFIX(_pcre2_utt_size_)2233#define _pcre2_ebcdic_1047_to_ascii PCRE2_SUFFIX(_pcre2_ebcdic_1047_to_ascii_)2234#define _pcre2_ascii_to_ebcdic_1047 PCRE2_SUFFIX(_pcre2_ascii_to_ebcdic_1047_)22352236extern const uint8_t PRIV(OP_lengths)[];2237extern const uint32_t PRIV(callout_end_delims)[];2238extern const uint32_t PRIV(callout_start_delims)[];2239extern pcre2_compile_context PRIV(default_compile_context);2240extern pcre2_convert_context PRIV(default_convert_context);2241extern pcre2_match_context PRIV(default_match_context);2242extern const uint8_t PRIV(default_tables)[];2243extern const uint32_t PRIV(hspace_list)[];2244extern const uint32_t PRIV(vspace_list)[];2245extern const uint32_t PRIV(ucd_boolprop_sets)[];2246extern const uint32_t PRIV(ucd_caseless_sets)[];2247extern const uint32_t PRIV(ucd_turkish_dotted_i_caseset);2248extern const uint32_t PRIV(ucd_nocase_ranges)[];2249extern const uint32_t PRIV(ucd_nocase_ranges_size);2250extern const uint32_t PRIV(ucd_digit_sets)[];2251extern const uint32_t PRIV(ucd_script_sets)[];2252extern const ucd_record PRIV(ucd_records)[];2253#if PCRE2_CODE_UNIT_WIDTH == 322254extern const ucd_record PRIV(dummy_ucd_record)[];2255#endif2256extern const uint16_t PRIV(ucd_stage1)[];2257extern const uint16_t PRIV(ucd_stage2)[];2258extern const uint32_t PRIV(ucp_gbtable)[];2259extern const uint32_t PRIV(ucp_gentype)[];2260#ifdef SUPPORT_JIT2261extern const int PRIV(ucp_typerange)[];2262#endif2263extern const char *PRIV(unicode_version);2264extern const ucp_type_table PRIV(utt)[];2265extern const char PRIV(utt_names)[];2266extern const size_t PRIV(utt_size);2267extern const uint8_t PRIV(ebcdic_1047_to_ascii)[];2268extern const uint8_t PRIV(ascii_to_ebcdic_1047)[];22692270/* Mode-dependent macros and hidden and private structures are defined in a2271separate file so that pcre2test can include them at all supported widths. When2272compiling the library, PCRE2_CODE_UNIT_WIDTH will be defined, and we can2273include them at the appropriate width, after setting up suffix macros for the2274private structures. */22752276#define branch_chain PCRE2_SUFFIX(branch_chain_)2277#define compile_block PCRE2_SUFFIX(compile_block_)2278#define dfa_match_block PCRE2_SUFFIX(dfa_match_block_)2279#define match_block PCRE2_SUFFIX(match_block_)2280#define named_group PCRE2_SUFFIX(named_group_)22812282#include "pcre2_intmodedep.h"22832284/* Private "external" functions. These are internal functions that are called2285from modules other than the one in which they are defined. They have to be2286"external" in the C sense, but are not part of the PCRE2 public API. They are2287not referenced from pcre2test, and must not be defined when no code unit width2288is available. */22892290#define _pcre2_auto_possessify PCRE2_SUFFIX(_pcre2_auto_possessify_)2291#define _pcre2_check_escape PCRE2_SUFFIX(_pcre2_check_escape_)2292#define _pcre2_ckd_smul PCRE2_SUFFIX(_pcre2_ckd_smul_)2293#define _pcre2_extuni PCRE2_SUFFIX(_pcre2_extuni_)2294#define _pcre2_find_bracket PCRE2_SUFFIX(_pcre2_find_bracket_)2295#define _pcre2_is_newline PCRE2_SUFFIX(_pcre2_is_newline_)2296#define _pcre2_jit_free_rodata PCRE2_SUFFIX(_pcre2_jit_free_rodata_)2297#define _pcre2_jit_free PCRE2_SUFFIX(_pcre2_jit_free_)2298#define _pcre2_jit_get_size PCRE2_SUFFIX(_pcre2_jit_get_size_)2299#define _pcre2_jit_get_target PCRE2_SUFFIX(_pcre2_jit_get_target_)2300#define _pcre2_memctl_malloc PCRE2_SUFFIX(_pcre2_memctl_malloc_)2301#define _pcre2_ord2utf PCRE2_SUFFIX(_pcre2_ord2utf_)2302#define _pcre2_script_run PCRE2_SUFFIX(_pcre2_script_run_)2303#define _pcre2_strcmp PCRE2_SUFFIX(_pcre2_strcmp_)2304#define _pcre2_strcmp_c8 PCRE2_SUFFIX(_pcre2_strcmp_c8_)2305#define _pcre2_strcpy_c8 PCRE2_SUFFIX(_pcre2_strcpy_c8_)2306#define _pcre2_strlen PCRE2_SUFFIX(_pcre2_strlen_)2307#define _pcre2_strncmp PCRE2_SUFFIX(_pcre2_strncmp_)2308#define _pcre2_strncmp_c8 PCRE2_SUFFIX(_pcre2_strncmp_c8_)2309#define _pcre2_study PCRE2_SUFFIX(_pcre2_study_)2310#define _pcre2_valid_utf PCRE2_SUFFIX(_pcre2_valid_utf_)2311#define _pcre2_was_newline PCRE2_SUFFIX(_pcre2_was_newline_)2312#define _pcre2_xclass PCRE2_SUFFIX(_pcre2_xclass_)2313#define _pcre2_eclass PCRE2_SUFFIX(_pcre2_eclass_)23142315extern int _pcre2_auto_possessify(PCRE2_UCHAR *,2316const compile_block *);2317extern int _pcre2_check_escape(PCRE2_SPTR *, PCRE2_SPTR, uint32_t *,2318int *, uint32_t, uint32_t, uint32_t, BOOL, compile_block *);2319extern BOOL _pcre2_ckd_smul(PCRE2_SIZE *, int, int);2320extern PCRE2_SPTR _pcre2_extuni(uint32_t, PCRE2_SPTR, PCRE2_SPTR, PCRE2_SPTR,2321BOOL, int *);2322extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);2323extern BOOL _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,2324uint32_t *, BOOL);2325extern void _pcre2_jit_free_rodata(void *, void *);2326extern void _pcre2_jit_free(void *, pcre2_memctl *);2327extern size_t _pcre2_jit_get_size(void *);2328const char * _pcre2_jit_get_target(void);2329extern void * _pcre2_memctl_malloc(size_t, pcre2_memctl *);2330extern unsigned int _pcre2_ord2utf(uint32_t, PCRE2_UCHAR *);2331extern BOOL _pcre2_script_run(PCRE2_SPTR, PCRE2_SPTR, BOOL);2332extern int _pcre2_strcmp(PCRE2_SPTR, PCRE2_SPTR);2333extern int _pcre2_strcmp_c8(PCRE2_SPTR, const char *);2334extern PCRE2_SIZE _pcre2_strcpy_c8(PCRE2_UCHAR *, const char *);2335extern PCRE2_SIZE _pcre2_strlen(PCRE2_SPTR);2336extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);2337extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);2338extern int _pcre2_study(pcre2_real_code *);2339extern int _pcre2_valid_utf(PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE *);2340extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR,2341uint32_t *, BOOL);2342extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, const uint8_t *, BOOL);2343extern BOOL _pcre2_eclass(uint32_t, PCRE2_SPTR, PCRE2_SPTR,2344const uint8_t *, BOOL);23452346#endif /* PCRE2_CODE_UNIT_WIDTH */23472348#include "pcre2_util.h"23492350#endif /* PCRE2_INTERNAL_H_IDEMPOTENT_GUARD */23512352/* End of pcre2_internal.h */235323542355