Abolish pcre2_version(); add PCRE2_CONFIG_VERSION.

This commit is contained in:
Philip.Hazel 2014-06-23 16:41:29 +00:00
parent e8bbba897d
commit 2a1dc104ed
8 changed files with 483 additions and 500 deletions

View File

@ -286,7 +286,6 @@ COMMON_SOURCES = \
src/pcre2_ucd.c \
src/pcre2_ucp.h \
src/pcre2_valid_utf.c \
src/pcre2_version.c \
src/pcre2_xclass.c
if WITH_PCRE8

View File

@ -255,6 +255,7 @@ D is inspected during pcre2_dfa_match() execution
#define PCRE2_CONFIG_PARENS_LIMIT 7
#define PCRE2_CONFIG_STACKRECURSE 8
#define PCRE2_CONFIG_UTF 9
#define PCRE2_CONFIG_VERSION 10
/* A value that is used to indicate 'unset' in unsigned size_t fields. In
particular, this value is used in the ovector. */
@ -339,9 +340,8 @@ expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_config(int, void *); \
PCRE2_EXP_DECL size_t pcre2_get_match_frame_size(void); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
PCRE2_EXP_DECL int pcre2_config(int, void *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_match_frame_size(void);
/* Functions for manipulating contexts. */
@ -576,7 +576,6 @@ pcre2_compile are called by application code. */
#define pcre2_substring_list_free PCRE2_SUFFIX(pcre2_substring_list_free_)
#define pcre2_substring_nametable_scan PCRE2_SUFFIX(pcre2_substring_nametable_scan_)
#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_)
#define pcre2_version PCRE2_SUFFIX(pcre2_version_)
/* Now generate all three sets of width-specific structures and function

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
/* The current PCRE version information. */
#define PCRE2_MAJOR 9
#define PCRE2_MAJOR 10
#define PCRE2_MINOR 00
#define PCRE2_PRERELEASE -DEV
#define PCRE2_DATE 2014-99-99
@ -67,7 +67,7 @@ don't change existing definitions of PCRE2_EXP_DECL. */
# endif
#endif
/* Have to include stdlib.h and stdint.h to ensure that size_t and uint8_t etc
/* Have to include stdlib.h and stdint.h to ensure that size_t and uint8_t etc
are defined. */
#include <stdlib.h>
@ -79,180 +79,169 @@ are defined. */
extern "C" {
#endif
/* Public options. Those in the context may affect compilation, JIT
compilation, and/or interpretive execution. The following tags indicate which:
C alters what is compiled
J alters what JIT compiles
E affects pcre_exec() execution
D affects pcre_dfa_exec() execution
*/
/* The first group of options are those that are set in the context. */
#define PCRE2_ALT_BSUX 0x00000001 /* C */
#define PCRE2_DOLLAR_ENDONLY 0x00000002 /* J E D */
#define PCRE2_DUPNAMES 0x00000004 /* C */
#define PCRE2_ALLOW_EMPTY_CLASS 0x00000008 /* C */
#define PCRE2_MATCH_UNSET_BACKREF 0x00000010 /* C J E */
#define PCRE2_NEVER_UTF 0x00000020 /* C */
#define PCRE2_NEVER_UCP 0x00000040 /* C */
#define PCRE2_UTF 0x00000080 /* C J E D */
#define PCRE2_UCP 0x00000100 /* C J E D */
/* The following can be passed to pcre2_compile(), pcre2_exec(), or
pcre2_dfa_exec(). PCRE2_NO_UTF_CHECK affects only the function to which it is
/* The following options can be passed to pcre2_compile(), pcre2_match(), or
pcre2_dfa_match(). PCRE2_NO_UTF_CHECK affects only the function to which it is
passed. */
#define PCRE2_ANCHORED 0x00000001
#define PCRE2_NO_START_OPTIMIZE 0x00000002
#define PCRE2_NO_UTF_CHECK 0x00000004
/* These are for pcre2_compile() only, affecting what is compiled, but not
otherwise affecting execution. */
/* Other options that can be passed to pcre2_compile(). They may affect
compilation, JIT compilation, and/or interpretive execution. The following tags
indicate which:
#define PCRE2_AUTO_CALLOUT 0x00000100
#define PCRE2_CASELESS 0x00000200
#define PCRE2_DOTALL 0x00000400
#define PCRE2_EXTENDED 0x00000800
#define PCRE2_MULTILINE 0x00001000
#define PCRE2_NO_AUTO_CAPTURE 0x00002000
#define PCRE2_NO_AUTO_POSSESS 0x00004000
#define PCRE2_UNGREEDY 0x00008000
C alters what is compiled
J alters what JIT compiles
E is inspected during pcre2_match() execution
D is inspected during pcre2_dfa_match() execution
*/
/* This pcre2_compile() option affects JIT compilation and interpretive
execution. */
#define PCRE2_FIRSTLINE 0x00010000
#define PCRE2_ALLOW_EMPTY_CLASS 0x00000008 /* C */
#define PCRE2_ALT_BSUX 0x00000010 /* C */
#define PCRE2_AUTO_CALLOUT 0x00000020 /* C */
#define PCRE2_CASELESS 0x00000040 /* C */
#define PCRE2_DOLLAR_ENDONLY 0x00000080 /* J E D */
#define PCRE2_DOTALL 0x00000100 /* C */
#define PCRE2_DUPNAMES 0x00000200 /* C */
#define PCRE2_EXTENDED 0x00000400 /* C */
#define PCRE2_FIRSTLINE 0x00000800 /* J E D */
#define PCRE2_MATCH_UNSET_BACKREF 0x00001000 /* C J E */
#define PCRE2_MULTILINE 0x00002000 /* C */
#define PCRE2_NEVER_UCP 0x00004000 /* C */
#define PCRE2_NEVER_UTF 0x00008000 /* C */
#define PCRE2_NO_AUTO_CAPTURE 0x00010000 /* C */
#define PCRE2_NO_AUTO_POSSESS 0x00020000 /* C */
#define PCRE2_UCP 0x00040000 /* C J E D */
#define PCRE2_UNGREEDY 0x00080000 /* C */
#define PCRE2_UTF 0x00100000 /* C J E D */
/* These are for pcre2_jit_compile(). */
#define PCRE2_JIT 0x00020000
#define PCRE2_JIT_PARTIAL_SOFT 0x00040000
#define PCRE2_JIT_PARTIAL_HARD 0x00080000
#define PCRE2_JIT 0x00000001 /* For full matching */
#define PCRE2_JIT_PARTIAL_SOFT 0x00000002
#define PCRE2_JIT_PARTIAL_HARD 0x00000004
/* These are for pcre2_exec() and pcre2_dfa_exec(). */
/* These are for pcre2_match() and pcre2_dfa_match(). */
#define PCRE2_NOTBOL 0x00000100
#define PCRE2_NOTEOL 0x00000200
#define PCRE2_NOTEMPTY 0x00000400
#define PCRE2_NOTEMPTY_ATSTART 0x00000800
#define PCRE2_PARTIAL_SOFT 0x00001000
#define PCRE2_PARTIAL_HARD 0x00002000
#define PCRE2_NOTBOL 0x00000001
#define PCRE2_NOTEOL 0x00000002
#define PCRE2_NOTEMPTY 0x00000004
#define PCRE2_NOTEMPTY_ATSTART 0x00000008
#define PCRE2_PARTIAL_SOFT 0x00000010
#define PCRE2_PARTIAL_HARD 0x00000020
/* These are additional options for pcre2_dfa_exec(). */
/* These are additional options for pcre2_dfa_match(). */
#define PCRE2_DFA_RESTART 0x00010000
#define PCRE2_DFA_SHORTEST 0x00020000
#define PCRE2_DFA_RESTART 0x00000040
#define PCRE2_DFA_SHORTEST 0x00000080
/* Newline and \R settings, for use in the context. */
/* Newline and \R settings, for use in the compile context. */
#define PCRE2_NEWLINE_CR 0x00000001
#define PCRE2_NEWLINE_LF 0x00000002
#define PCRE2_NEWLINE_CRLF 0x00000004
#define PCRE2_NEWLINE_ANY 0x00000008
#define PCRE2_NEWLINE_ANYCRLF 0x00000010
#define PCRE2_NEWLINE_CR 1
#define PCRE2_NEWLINE_LF 2
#define PCRE2_NEWLINE_CRLF 3
#define PCRE2_NEWLINE_ANY 4
#define PCRE2_NEWLINE_ANYCRLF 5
#define PCRE2_BSR_ANYCRLF 0x00000020
#define PCRE2_BSR_UNICODE 0x00000040
#define PCRE2_BSR_UNICODE 1
#define PCRE2_BSR_ANYCRLF 2
/* Exec-time and get/set-time error codes */
/* Error codes: no match and partial match are "expected" errors. */
#define PCRE2_ERROR_NOMATCH (-1)
#define PCRE2_ERROR_NULL (-2)
#define PCRE2_ERROR_BADOPTION (-3)
#define PCRE2_ERROR_BADMAGIC (-4)
#define PCRE2_ERROR_UNKNOWN_OPCODE (-5)
#define PCRE2_ERROR_NOMEMORY (-6)
#define PCRE2_ERROR_NOSUBSTRING (-7)
#define PCRE2_ERROR_MATCHLIMIT (-8)
#define PCRE2_ERROR_CALLOUT (-9) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_BADUTF (-10)
#define PCRE2_ERROR_BADUTF_OFFSET (-11)
#define PCRE2_ERROR_PARTIAL (-12)
#define PCRE2_ERROR_BADPARTIAL (-13)
#define PCRE2_ERROR_INTERNAL (-14)
#define PCRE2_ERROR_BADCOUNT (-15)
#define PCRE2_ERROR_DFA_UITEM (-16)
#define PCRE2_ERROR_DFA_UCOND (-17)
#define PCRE2_ERROR_DFA_UMLIMIT (-18)
#define PCRE2_ERROR_DFA_WSSIZE (-19)
#define PCRE2_ERROR_DFA_RECURSE (-20)
#define PCRE2_ERROR_RECURSIONLIMIT (-21)
#define PCRE2_ERROR_BADNEWLINE (-22)
#define PCRE2_ERROR_BADOFFSET (-23)
#define PCRE2_ERROR_SHORTUTF (-24)
#define PCRE2_ERROR_RECURSELOOP (-25)
#define PCRE2_ERROR_JIT_STACKLIMIT (-26)
#define PCRE2_ERROR_BADMODE (-27)
#define PCRE2_ERROR_BADENDIANNESS (-28)
#define PCRE2_ERROR_DFA_BADRESTART (-29)
#define PCRE2_ERROR_JIT_BADOPTION (-30)
#define PCRE2_ERROR_PARTIAL (-2)
/* Error codes for UTF-8 validity checks */
#define PCRE2_ERROR_UTF8_ERR1 (-3)
#define PCRE2_ERROR_UTF8_ERR2 (-4)
#define PCRE2_ERROR_UTF8_ERR3 (-5)
#define PCRE2_ERROR_UTF8_ERR4 (-6)
#define PCRE2_ERROR_UTF8_ERR5 (-7)
#define PCRE2_ERROR_UTF8_ERR6 (-8)
#define PCRE2_ERROR_UTF8_ERR7 (-9)
#define PCRE2_ERROR_UTF8_ERR8 (-10)
#define PCRE2_ERROR_UTF8_ERR9 (-11)
#define PCRE2_ERROR_UTF8_ERR10 (-12)
#define PCRE2_ERROR_UTF8_ERR11 (-13)
#define PCRE2_ERROR_UTF8_ERR12 (-14)
#define PCRE2_ERROR_UTF8_ERR13 (-15)
#define PCRE2_ERROR_UTF8_ERR14 (-16)
#define PCRE2_ERROR_UTF8_ERR15 (-17)
#define PCRE2_ERROR_UTF8_ERR16 (-18)
#define PCRE2_ERROR_UTF8_ERR17 (-19)
#define PCRE2_ERROR_UTF8_ERR18 (-20)
#define PCRE2_ERROR_UTF8_ERR19 (-21)
#define PCRE2_ERROR_UTF8_ERR20 (-22)
#define PCRE2_ERROR_UTF8_ERR21 (-23)
/* Error codes for UTF-16 validity checks */
#define PCRE2_ERROR_UTF16_ERR1 (-24)
#define PCRE2_ERROR_UTF16_ERR2 (-25)
#define PCRE2_ERROR_UTF16_ERR3 (-26)
/* Error codes for UTF-32 validity checks */
#define PCRE2_ERROR_UTF32_ERR1 (-27)
#define PCRE2_ERROR_UTF32_ERR2 (-28)
/* Error codes for pcre2[_dfa]_match() */
#define PCRE2_ERROR_BADCOUNT (-29)
#define PCRE2_ERROR_BADENDIANNESS (-30)
#define PCRE2_ERROR_BADLENGTH (-31)
#define PCRE2_ERROR_UNSET (-32)
#define PCRE2_ERROR_BADMAGIC (-32)
#define PCRE2_ERROR_BADMODE (-33)
#define PCRE2_ERROR_BADOFFSET (-34)
#define PCRE2_ERROR_BADOPTION (-35)
#define PCRE2_ERROR_BADUTF_OFFSET (-36)
#define PCRE2_ERROR_CALLOUT (-37) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_DFA_BADRESTART (-38)
#define PCRE2_ERROR_DFA_RECURSE (-39)
#define PCRE2_ERROR_DFA_UCOND (-40)
#define PCRE2_ERROR_DFA_UITEM (-41)
#define PCRE2_ERROR_DFA_UMLIMIT (-42)
#define PCRE2_ERROR_DFA_WSSIZE (-43)
#define PCRE2_ERROR_INTERNAL (-44)
#define PCRE2_ERROR_JIT_BADOPTION (-45)
#define PCRE2_ERROR_JIT_STACKLIMIT (-46)
#define PCRE2_ERROR_MATCHLIMIT (-47)
#define PCRE2_ERROR_NOMEMORY (-48)
#define PCRE2_ERROR_NOSUBSTRING (-49)
#define PCRE2_ERROR_NULL (-50)
#define PCRE2_ERROR_RECURSELOOP (-51)
#define PCRE2_ERROR_RECURSIONLIMIT (-52)
#define PCRE2_ERROR_UNKNOWN_OPCODE (-53)
#define PCRE2_ERROR_UNSET (-54)
/* Specific error codes for UTF-8 validity checks */
/* Request types for pcre2_pattern_info() */
#define PCRE2_UTF8_ERR0 0
#define PCRE2_UTF8_ERR1 1
#define PCRE2_UTF8_ERR2 2
#define PCRE2_UTF8_ERR3 3
#define PCRE2_UTF8_ERR4 4
#define PCRE2_UTF8_ERR5 5
#define PCRE2_UTF8_ERR6 6
#define PCRE2_UTF8_ERR7 7
#define PCRE2_UTF8_ERR8 8
#define PCRE2_UTF8_ERR9 9
#define PCRE2_UTF8_ERR10 10
#define PCRE2_UTF8_ERR11 11
#define PCRE2_UTF8_ERR12 12
#define PCRE2_UTF8_ERR13 13
#define PCRE2_UTF8_ERR14 14
#define PCRE2_UTF8_ERR15 15
#define PCRE2_UTF8_ERR16 16
#define PCRE2_UTF8_ERR17 17
#define PCRE2_UTF8_ERR18 18
#define PCRE2_UTF8_ERR19 19
#define PCRE2_UTF8_ERR20 20
#define PCRE2_UTF8_ERR21 21
/* Specific error codes for UTF-16 validity checks */
#define PCRE2_UTF16_ERR0 0
#define PCRE2_UTF16_ERR1 1
#define PCRE2_UTF16_ERR2 2
#define PCRE2_UTF16_ERR3 3
/* Specific error codes for UTF-32 validity checks */
#define PCRE2_UTF32_ERR0 0
#define PCRE2_UTF32_ERR1 1
#define PCRE2_UTF32_ERR3 2
/* Request types for pcre2_get_info() */
#define PCRE2_INFO_BACKREFMAX 0
#define PCRE2_INFO_CAPTURECOUNT 1
#define PCRE2_INFO_COMPILE_OPTIONS 2
#define PCRE2_INFO_FIRSTCODEUNIT 3
#define PCRE2_INFO_FIRSTCODETYPE 4
#define PCRE2_INFO_FIRSTTABLE 5
#define PCRE2_INFO_HASCRORLF 6
#define PCRE2_INFO_JCHANGED 7
#define PCRE2_INFO_JIT 8
#define PCRE2_INFO_JITSIZE 9
#define PCRE2_INFO_LASTCODEUNIT 10
#define PCRE2_INFO_LASTCODETYPE 11
#define PCRE2_INFO_MATCH_EMPTY 12
#define PCRE2_INFO_MATCHLIMIT 13
#define PCRE2_INFO_MAXLOOKBEHIND 14
#define PCRE2_INFO_MINLENGTH 15
#define PCRE2_INFO_NAMECOUNT 16
#define PCRE2_INFO_NAMEENTRYSIZE 17
#define PCRE2_INFO_NAMETABLE 18
#define PCRE2_INFO_PATTERN_OPTIONS 19
#define PCRE2_INFO_RECURSIONLIMIT 20
#define PCRE2_INFO_SIZE 21
#define PCRE2_INFO_BACKREFMAX 0
#define PCRE2_INFO_BSR_CONVENTION 1
#define PCRE2_INFO_CAPTURECOUNT 2
#define PCRE2_INFO_COMPILE_OPTIONS 3
#define PCRE2_INFO_FIRSTCODEUNIT 4
#define PCRE2_INFO_FIRSTCODETYPE 5
#define PCRE2_INFO_FIRSTBITMAP 6
#define PCRE2_INFO_HASCRORLF 7
#define PCRE2_INFO_JCHANGED 8
#define PCRE2_INFO_JIT 9
#define PCRE2_INFO_JITSIZE 10
#define PCRE2_INFO_LASTCODEUNIT 11
#define PCRE2_INFO_LASTCODETYPE 12
#define PCRE2_INFO_MATCH_EMPTY 13
#define PCRE2_INFO_MATCH_LIMIT 14
#define PCRE2_INFO_MAXLOOKBEHIND 15
#define PCRE2_INFO_MINLENGTH 16
#define PCRE2_INFO_NAMECOUNT 17
#define PCRE2_INFO_NAMEENTRYSIZE 18
#define PCRE2_INFO_NAMETABLE 19
#define PCRE2_INFO_NEWLINE_CONVENTION 20
#define PCRE2_INFO_PATTERN_OPTIONS 21
#define PCRE2_INFO_RECURSION_LIMIT 22
#define PCRE2_INFO_SIZE 23
/* Request types for pcre2_config(). */
@ -264,9 +253,14 @@ execution. */
#define PCRE2_CONFIG_MATCH_LIMIT_RECURSION 5
#define PCRE2_CONFIG_NEWLINE 6
#define PCRE2_CONFIG_PARENS_LIMIT 7
#define PCRE2_CONFIG_POSIX_MALLOC_THRESHOLD 8
#define PCRE2_CONFIG_STACKRECURSE 9
#define PCRE2_CONFIG_UTF 10
#define PCRE2_CONFIG_STACKRECURSE 8
#define PCRE2_CONFIG_UTF 9
#define PCRE2_CONFIG_VERSION 10
/* A value that is used to indicate 'unset' in unsigned size_t fields. In
particular, this value is used in the ovector. */
#define PCRE2_UNSET (~(size_t)0)
/* Types for patterns and subject strings. */
@ -278,15 +272,22 @@ typedef const PCRE2_UCHAR8 *PCRE2_SPTR8;
typedef const PCRE2_UCHAR16 *PCRE2_SPTR16;
typedef const PCRE2_UCHAR32 *PCRE2_SPTR32;
/* Generic types for opaque structures and JIT callback functions. These
declarations are defined in a macro that is expanded for each width later. */
#define PCRE2_TYPES_LIST \
struct pcre2_real_context; \
typedef struct pcre2_real_context pcre2_context; \
struct pcre2_real_general_context; \
typedef struct pcre2_real_general_context pcre2_general_context; \
\
struct pcre2_real; \
typedef struct pcre2_real pcre2; \
struct pcre2_real_compile_context; \
typedef struct pcre2_real_compile_context pcre2_compile_context; \
\
struct pcre2_real_match_context; \
typedef struct pcre2_real_match_context pcre2_match_context; \
\
struct pcre2_real_code; \
typedef struct pcre2_real_code pcre2_code; \
\
struct pcre2_real_match_data; \
typedef struct pcre2_real_match_data pcre2_match_data; \
@ -296,6 +297,7 @@ typedef struct pcre2_real_jit_stack pcre2_jit_stack; \
\
typedef pcre2_jit_stack *(*pcre2_jit_callback)(void *);
/* The structure for passing out data via the pcre_callout_function. We use a
structure so that new fields can be added on the end in future versions,
without changing the API of the function, thereby allowing old clients to work
@ -323,6 +325,7 @@ typedef struct pcre2_callout_block { \
/* ------------------------------------------------------------------ */ \
} pcre2_callout_block;
/* Utility functions for byte order swaps. These are not generic functions;
each appears only its own library. */
@ -331,262 +334,314 @@ PCRE2_EXP_DECL int pcre2_utf16_to_host_byte_order(PCRE2_UCHAR16 *,
PCRE2_EXP_DECL int pcre2_utf32_to_host_byte_order(PCRE2_UCHAR32 *,
PCRE2_SPTR32, int, int *, int);
/* List the generic forms of all other functions in a macro. */
#define PCRE2_FUNCTION_LIST \
PCRE2_EXP_DECL pcre2 *pcre2_compile(pcre2_context *, PCRE2_SPTR, int, \
uint32_t, int *, size_t *); \
PCRE2_EXP_DECL int pcre2_config(int, void *); \
PCRE2_EXP_DECL size_t pcre2_context_size(void); \
/* List the generic forms of all other functions in macros, which will be
expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_config(int, void *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_match_frame_size(void);
/* Functions for manipulating contexts. */
#define PCRE2_GENERAL_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_context *pcre2_copy_context(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_copy_named_substring(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_copy_substring(pcre2_match_data *, int, \
PCRE2_UCHAR *, size_t); \
pcre2_general_context *pcre2_general_context_copy(pcre2_general_context *); \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_create_match_data(pcre2_context *, size_t); \
PCRE2_EXP_DECL int pcre2_dfa_exec(pcre2_context *, const pcre2 *, \
pcre2_general_context *pcre2_general_context_create( \
void *(*)(size_t, void *), \
void (*)(void *, void *), void *); \
PCRE2_EXP_DECL void pcre2_general_context_free(pcre2_general_context *);
#define PCRE2_COMPILE_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_compile_context *pcre2_compile_context_copy(pcre2_compile_context *); \
PCRE2_EXP_DECL \
pcre2_compile_context *pcre2_compile_context_create(pcre2_general_context *);\
PCRE2_EXP_DECL void pcre2_compile_context_free(pcre2_compile_context *); \
PCRE2_EXP_DECL int pcre2_set_bsr_convention(pcre2_compile_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_character_tables(pcre2_compile_context *, \
const unsigned char *); \
PCRE2_EXP_DECL int pcre2_set_newline_convention(pcre2_compile_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_parens_nest_limit(pcre2_compile_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_compile_recursion_guard(\
pcre2_compile_context *, int (*)(uint32_t)); \
#define PCRE2_MATCH_CONTEXT_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_match_context *pcre2_match_context_copy(pcre2_match_context *); \
PCRE2_EXP_DECL \
pcre2_match_context *pcre2_match_context_create(pcre2_general_context *); \
PCRE2_EXP_DECL void pcre2_match_context_free(pcre2_match_context *); \
PCRE2_EXP_DECL int pcre2_set_callout(pcre2_match_context *, \
int (*)(pcre2_callout_block *, void *)); \
PCRE2_EXP_DECL int pcre2_set_match_limit(pcre2_match_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_limit(pcre2_match_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_memory_management( \
pcre2_match_context *, void *(*)(size_t, void *), \
void (*)(void *, void *));
/* Functions concerned with compiling a pattern to PCRE internal code. */
#define PCRE2_COMPILE_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_code *pcre2_compile(PCRE2_SPTR, int, uint32_t, \
int *, size_t *, pcre2_compile_context *); \
PCRE2_EXP_DECL void pcre2_code_free(pcre2_code *);
/* Functions that give information about a compiled pattern. */
#define PCRE2_PATTERN_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_pattern_info(const pcre2_code *, uint32_t, \
void *);
/* Functions for running a match and inspecting the result. */
#define PCRE2_MATCH_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_match_data_create(size_t, \
pcre2_general_context *); \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_match_data_create_from_pattern(pcre2_code *, \
pcre2_general_context *); \
PCRE2_EXP_DECL int pcre2_dfa_match(const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, int *, size_t); \
PCRE2_EXP_DECL int pcre2_exec(pcre2_context *, const pcre2 *, \
pcre2_match_data *, pcre2_match_context *, int *, \
size_t); \
PCRE2_EXP_DECL int pcre2_match(const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_compiled_code(pcre2_context *, pcre2 *); \
PCRE2_EXP_DECL void pcre2_free_context(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_free_match_data(pcre2_context *, \
pcre2_match_data *); \
PCRE2_EXP_DECL void pcre2_free_substring(pcre2_context *, PCRE2_SPTR); \
PCRE2_EXP_DECL void pcre2_free_substring_list(pcre2_context *, \
PCRE2_SPTR *); \
PCRE2_EXP_DECL uint32_t pcre2_get_bsr_convention(pcre2_context *); \
PCRE2_EXP_DECL int (*pcre2_get_callout(pcre2_context *)) \
(pcre2_callout_block *, void *); \
PCRE2_EXP_DECL \
unsigned char *pcre2_get_character_tables(pcre2_context *); \
PCRE2_EXP_DECL uint32_t pcre2_get_context_options(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_error_offset(pcre2_match_data *); \
PCRE2_EXP_DECL int pcre2_get_error_reason(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_exec_frame_size(void); \
PCRE2_EXP_DECL int pcre2_get_info(const pcre2 *, uint32_t, void *); \
pcre2_match_data *, pcre2_match_context *); \
PCRE2_EXP_DECL void pcre2_match_data_free(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_leftchar(pcre2_match_data *); \
PCRE2_EXP_DECL \
PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_match_limit(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_get_memory_management(pcre2_context *, \
void *(**)(size_t, void *), \
void (**)(void *, void *)); \
PCRE2_EXP_DECL int pcre2_get_named_substring(pcre2_context *, \
pcre2_match_data *, PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_named_substring_length(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL uint32_t pcre2_get_newline_convention(pcre2_context *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector(pcre2_match_data *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector_slots(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_parens_nest_limit(pcre2_context *); \
PCRE2_EXP_DECL int (*pcre2_get_recursion_guard(pcre2_context *)) \
(int, void *); \
PCRE2_EXP_DECL uint32_t pcre2_get_recursion_limit(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_get_recursion_memory_management(\
pcre2_context *, \
void *(**)(size_t, void *), \
void (**)(void *, void *)); \
PCRE2_EXP_DECL size_t pcre2_get_ovector_count(pcre2_match_data *); \
PCRE2_EXP_DECL size_t *pcre2_get_ovector_pointer(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_rightchar(pcre2_match_data *); \
PCRE2_EXP_DECL size_t pcre2_get_startchar(pcre2_match_data *); \
PCRE2_EXP_DECL int pcre2_get_stringtable_entries(const pcre2 *, \
PCRE2_SPTR, PCRE2_UCHAR **, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_substring(pcre2_context *, \
pcre2_match_data *, int, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_get_substring_length(pcre2_match_data *, int); \
PCRE2_EXP_DECL int pcre2_get_substring_list(pcre2_context *, \
pcre2_match_data *, PCRE2_UCHAR ***); \
PCRE2_EXP_DECL int pcre2_get_substring_number(const pcre2 *, \
PCRE2_EXP_DECL size_t pcre2_get_startchar(pcre2_match_data *);
/* Convenience functions for handling matched substrings. */
#define PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_substring_copy_byname(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_substring_copy_bynumber(pcre2_match_data *, \
int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL void pcre2_substring_free(PCRE2_UCHAR *); \
PCRE2_EXP_DECL int pcre2_substring_get_byname(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_substring_get_bynumber(pcre2_match_data *, \
int, PCRE2_UCHAR **); \
PCRE2_EXP_DECL int pcre2_substring_length_byname(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_EXP_DECL void *pcre2_get_user_data(pcre2_context *); \
PCRE2_EXP_DECL \
pcre2_context *pcre2_init_context(pcre2_context *); \
PCRE2_EXP_DECL int pcre2_jit_compile(pcre2_context *, pcre2 *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_jit_exec(pcre2_context *, const pcre2 *, \
PCRE2_EXP_DECL int pcre2_substring_length_bynumber(pcre2_match_data *, \
int); \
PCRE2_EXP_DECL int pcre2_substring_nametable_scan(const pcre2_code *, \
PCRE2_SPTR, PCRE2_SPTR *, PCRE2_SPTR *); \
PCRE2_EXP_DECL int pcre2_substring_number_from_name(\
const pcre2_code *, PCRE2_SPTR); \
PCRE2_EXP_DECL void pcre2_substring_list_free(PCRE2_SPTR *); \
PCRE2_EXP_DECL int pcre2_substring_list_get(pcre2_match_data *, \
PCRE2_UCHAR ***, size_t **);
/* Functions for JIT processing */
#define PCRE2_JIT_FUNCTIONS \
PCRE2_EXP_DECL void pcre2_jit_compile(pcre2_code *, uint32_t); \
PCRE2_EXP_DECL int pcre2_jit_match(const pcre2_code *, \
PCRE2_SPTR, int, size_t, uint32_t, \
pcre2_match_data *, pcre2_jit_stack *); \
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_context *); \
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_general_context *);\
PCRE2_EXP_DECL \
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_context *, size_t, \
size_t); \
PCRE2_EXP_DECL void pcre2_jit_stack_assign(pcre2_context *, \
const pcre2 *, pcre2_jit_callback, void *); \
PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_context *, \
pcre2_jit_stack *); \
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *, \
size_t, size_t); \
PCRE2_EXP_DECL void pcre2_jit_stack_assign(const pcre2_code *, \
pcre2_jit_callback, void *); \
PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_jit_stack *);
/* Other miscellaneous functions. */
#define PCRE2_OTHER_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_match_frame_size(void); \
PCRE2_EXP_DECL \
const unsigned char *pcre2_maketables(void); \
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2 *); \
PCRE2_EXP_DECL void pcre2_set_bsr_convention(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_callout(pcre2_context *, \
int (*)(pcre2_callout_block *, void *)); \
PCRE2_EXP_DECL void pcre2_set_character_tables(pcre2_context *, \
unsigned char *); \
PCRE2_EXP_DECL void pcre2_set_context_options(pcre2_context *, uint32_t, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_match_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_memory_management(pcre2_context *, \
void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL void pcre2_set_newline_convention(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_parens_nest_limit(pcre2_context *, \
uint32_t); \
PCRE2_EXP_DECL void pcre2_set_recursion_guard(pcre2_context *, \
int (*)(uint32_t, void *)); \
PCRE2_EXP_DECL void pcre2_set_recursion_limit(pcre2_context *, uint32_t); \
PCRE2_EXP_DECL void pcre2_set_recursion_memory_management(\
pcre2_context *, void * (*)(size_t, void *), \
void (*)(void *, void *)); \
PCRE2_EXP_DECL void pcre2_set_user_data(pcre2_context *, void *); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
const unsigned char *pcre2_maketables(pcre2_general_context *); \
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2_code *);
/* Define macros that generate width-specific names from generic versions. The
three-level macro scheme is necessary to get the macros expanded when we want
them to be. First we get the width from PCRE2_LOCAL_WIDTH, which is used for
generating three versions of each external function below. After that,
PCRE2_ADDWIDTH will be re-defined to use PCRE2_DATA_WIDTH, for use when macros
such as pcre2_compile are called by application code. */
generating three versions of everything below. After that, PCRE2_SUFFIX will be
re-defined to use PCRE2_CODE_UNIT_WIDTH, for use when macros such as
pcre2_compile are called by application code. */
#define PCRE2_JOIN(a,b) a ## b
#define PCRE2_GLUE(a,b) PCRE2_JOIN(a,b)
#define PCRE2_ADDWIDTH(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
/* Data types */
#define PCRE2_UCHAR PCRE2_ADDWIDTH(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_ADDWIDTH(PCRE2_SPTR)
#define PCRE2_UCHAR PCRE2_SUFFIX(PCRE2_UCHAR)
#define PCRE2_SPTR PCRE2_SUFFIX(PCRE2_SPTR)
#define pcre2 PCRE2_ADDWIDTH(pcre2_)
#define pcre2_jit_callback PCRE2_ADDWIDTH(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_ADDWIDTH(pcre2_jit_stack_)
#define pcre2_code PCRE2_SUFFIX(pcre2_code_)
#define pcre2_jit_callback PCRE2_SUFFIX(pcre2_jit_callback_)
#define pcre2_jit_stack PCRE2_SUFFIX(pcre2_jit_stack_)
#define pcre2_real_code PCRE2_SUFFIX(pcre2_real_code_)
#define pcre2_real_general_context PCRE2_SUFFIX(pcre2_real_general_context_)
#define pcre2_real_compile_context PCRE2_SUFFIX(pcre2_real_compile_context_)
#define pcre2_real_match_context PCRE2_SUFFIX(pcre2_real_match_context_)
#define pcre2_real_jit_stack PCRE2_SUFFIX(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_SUFFIX(pcre2_real_match_data_)
#define pcre2_real PCRE2_ADDWIDTH(pcre2_real_)
#define pcre2_real_context PCRE2_ADDWIDTH(pcre2_real_context_)
#define pcre2_real_jit_stack PCRE2_ADDWIDTH(pcre2_real_jit_stack_)
#define pcre2_real_match_data PCRE2_ADDWIDTH(pcre2_real_match_data_)
/* Data blocks */
#define pcre2_callout_block PCRE2_ADDWIDTH(pcre2_callout_block_)
#define pcre2_context PCRE2_ADDWIDTH(pcre2_context_)
#define pcre2_match_data PCRE2_ADDWIDTH(pcre2_match_data_)
#define pcre2_callout_block PCRE2_SUFFIX(pcre2_callout_block_)
#define pcre2_general_context PCRE2_SUFFIX(pcre2_general_context_)
#define pcre2_compile_context PCRE2_SUFFIX(pcre2_compile_context_)
#define pcre2_match_context PCRE2_SUFFIX(pcre2_match_context_)
#define pcre2_match_data PCRE2_SUFFIX(pcre2_match_data_)
/* Functions */
#define pcre2_compile PCRE2_ADDWIDTH(pcre2_compile_)
#define pcre2_config PCRE2_ADDWIDTH(pcre2_config_)
#define pcre2_context_size PCRE2_ADDWIDTH(pcre2_context_size_)
#define pcre2_copy_context PCRE2_ADDWIDTH(pcre2_copy_context_)
#define pcre2_copy_named_substring PCRE2_ADDWIDTH(pcre2_copy_named_substring_)
#define pcre2_copy_substring PCRE2_ADDWIDTH(pcre2_copy_substring_)
#define pcre2_create_match_data PCRE2_ADDWIDTH(pcre2_create_match_data_)
#define pcre2_dfa_exec PCRE2_ADDWIDTH(pcre2_dfa_exec_)
#define pcre2_exec PCRE2_ADDWIDTH(pcre2_exec_)
#define pcre2_free_compiled_code PCRE2_ADDWIDTH(pcre2_free_compiled_code_)
#define pcre2_free_context PCRE2_ADDWIDTH(pcre2_free_context_)
#define pcre2_free_match_data PCRE2_ADDWIDTH(pcre2_free_match_data_)
#define pcre2_free_substring PCRE2_ADDWIDTH(pcre2_free_substring_)
#define pcre2_free_substring_list PCRE2_ADDWIDTH(pcre2_free_substring_list_)
#define pcre2_get_bsr_convention PCRE2_ADDWIDTH(pcre2_get_bsr_convention_)
#define pcre2_get_callout PCRE2_ADDWIDTH(pcre2_get_callout_)
#define pcre2_get_character_tables PCRE2_ADDWIDTH(pcre2_get_character_tables_)
#define pcre2_get_context_options PCRE2_ADDWIDTH(pcre2_get_context_options_)
#define pcre2_get_error_message PCRE2_ADDWIDTH(pcre2_get_error_message_)
#define pcre2_get_error_offset PCRE2_ADDWIDTH(pcre2_get_error_offset_)
#define pcre2_get_error_reason PCRE2_ADDWIDTH(pcre2_get_error_reason_)
#define pcre2_get_info PCRE2_ADDWIDTH(pcre2_get_info_)
#define pcre2_get_leftchar PCRE2_ADDWIDTH(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_ADDWIDTH(pcre2_get_mark_)
#define pcre2_get_match_limit PCRE2_ADDWIDTH(pcre2_get_match_limit_)
#define pcre2_get_memory_management PCRE2_ADDWIDTH(pcre2_get_memory_management_)
#define pcre2_get_named_substring PCRE2_ADDWIDTH(pcre2_get_named_substring_)
#define pcre2_get_named_substring_length PCRE2_ADDWIDTH(pcre2_get_named_substring_length_)
#define pcre2_get_newline_convention PCRE2_ADDWIDTH(pcre2_get_newline_convention_)
#define pcre2_get_ovector PCRE2_ADDWIDTH(pcre2_get_ovector_)
#define pcre2_get_ovector_slots PCRE2_ADDWIDTH(pcre2_get_ovector_slots_)
#define pcre2_get_parens_nest_limit PCRE2_ADDWIDTH(pcre2_get_parens_nest_limit_)
#define pcre2_get_recursion_guard PCRE2_ADDWIDTH(pcre2_get_recursion_guard_)
#define pcre2_get_recursion_limit PCRE2_ADDWIDTH(pcre2_get_recursion_limit_)
#define pcre2_get_recursion_memory_management PCRE2_ADDWIDTH(pcre2_get_recursion_memory_management_)
#define pcre2_get_rightchar PCRE2_ADDWIDTH(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_ADDWIDTH(pcre2_get_startchar_)
#define pcre2_get_stringtable_entries PCRE2_ADDWIDTH(pcre2_get_stringtable_entries_)
#define pcre2_get_substring PCRE2_ADDWIDTH(pcre2_get_substring_)
#define pcre2_get_substring_length PCRE2_ADDWIDTH(pcre2_get_substring_length_)
#define pcre2_get_substring_list PCRE2_ADDWIDTH(pcre2_get_substring_list_)
#define pcre2_get_substring_number PCRE2_ADDWIDTH(pcre2_get_substring_number_)
#define pcre2_get_user_data PCRE2_ADDWIDTH(pcre2_get_user_data_)
#define pcre2_init_context PCRE2_ADDWIDTH(pcre2_init_context_)
#define pcre2_jit_compile PCRE2_ADDWIDTH(pcre2_jit_compile_)
#define pcre2_jit_exec PCRE2_ADDWIDTH(pcre2_jit_exec_)
#define pcre2_jit_free_unused_memory PCRE2_ADDWIDTH(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_ADDWIDTH(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_ADDWIDTH(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_free PCRE2_ADDWIDTH(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_ADDWIDTH(pcre2_maketables_)
#define pcre2_pattern_to_host_byte_order PCRE2_ADDWIDTH(pcre2_pattern_to_host_byte_order_)
#define pcre2_set_bsr_convention PCRE2_ADDWIDTH(pcre2_set_bsr_convention_)
#define pcre2_set_callout PCRE2_ADDWIDTH(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_ADDWIDTH(pcre2_set_character_tables_)
#define pcre2_set_context_options PCRE2_ADDWIDTH(pcre2_set_context_options_)
#define pcre2_set_match_limit PCRE2_ADDWIDTH(pcre2_set_match_limit_)
#define pcre2_set_memory_management PCRE2_ADDWIDTH(pcre2_set_memory_management_)
#define pcre2_set_newline_convention PCRE2_ADDWIDTH(pcre2_set_newline_convention_)
#define pcre2_set_recursion_guard PCRE2_ADDWIDTH(pcre2_set_recursion_guard_)
#define pcre2_set_parens_nest_limit PCRE2_ADDWIDTH(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_ADDWIDTH(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_ADDWIDTH(pcre2_set_recursion_memory_management_)
#define pcre2_set_user_data PCRE2_ADDWIDTH(pcre2_set_user_data_)
#define pcre2_version PCRE2_ADDWIDTH(pcre2_version_)
/* Functions: the complete list in alphabetical order */
#define pcre2_code_free PCRE2_SUFFIX(pcre2_code_free_)
#define pcre2_compile PCRE2_SUFFIX(pcre2_compile_)
#define pcre2_compile_context_copy PCRE2_SUFFIX(pcre2_compile_context_copy_)
#define pcre2_compile_context_create PCRE2_SUFFIX(pcre2_compile_context_create_)
#define pcre2_compile_context_free PCRE2_SUFFIX(pcre2_compile_context_free_)
#define pcre2_config PCRE2_SUFFIX(pcre2_config_)
#define pcre2_dfa_match PCRE2_SUFFIX(pcre2_dfa_match_)
#define pcre2_match PCRE2_SUFFIX(pcre2_match_)
#define pcre2_general_context_copy PCRE2_SUFFIX(pcre2_general_context_copy_)
#define pcre2_general_context_create PCRE2_SUFFIX(pcre2_general_context_create_)
#define pcre2_general_context_free PCRE2_SUFFIX(pcre2_general_context_free_)
#define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_)
#define pcre2_get_leftchar PCRE2_SUFFIX(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_)
#define pcre2_get_match_frame_size PCRE2_SUFFIX(pcre2_get_match_frame_size_)
#define pcre2_get_ovector_pointer PCRE2_SUFFIX(pcre2_get_ovector_pointer_)
#define pcre2_get_ovector_count PCRE2_SUFFIX(pcre2_get_ovector_count_)
#define pcre2_get_rightchar PCRE2_SUFFIX(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_)
#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_)
#define pcre2_jit_match PCRE2_SUFFIX(pcre2_jit_match_)
#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_SUFFIX(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_)
#define pcre2_match_context_copy PCRE2_SUFFIX(pcre2_match_context_copy_)
#define pcre2_match_context_create PCRE2_SUFFIX(pcre2_match_context_create_)
#define pcre2_match_context_free PCRE2_SUFFIX(pcre2_match_context_free_)
#define pcre2_match_data_create PCRE2_SUFFIX(pcre2_match_data_create_)
#define pcre2_match_data_create_from_pattern PCRE2_SUFFIX(pcre2_match_data_create_from_pattern_)
#define pcre2_match_data_free PCRE2_SUFFIX(pcre2_match_data_free_)
#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_)
#define pcre2_pattern_to_host_byte_order PCRE2_SUFFIX(pcre2_pattern_to_host_byte_order_)
#define pcre2_set_bsr_convention PCRE2_SUFFIX(pcre2_set_bsr_convention_)
#define pcre2_set_callout PCRE2_SUFFIX(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_SUFFIX(pcre2_set_character_tables_)
#define pcre2_set_compile_recursion_guard PCRE2_SUFFIX(pcre2_set_compile_recursion_guard_)
#define pcre2_set_match_limit PCRE2_SUFFIX(pcre2_set_match_limit_)
#define pcre2_set_newline_convention PCRE2_SUFFIX(pcre2_set_newline_convention_)
#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
#define pcre2_substring_copy_byname PCRE2_SUFFIX(pcre2_substring_copy_byname_)
#define pcre2_substring_copy_bynumber PCRE2_SUFFIX(pcre2_substring_copy_bynumber_)
#define pcre2_substring_free PCRE2_SUFFIX(pcre2_substring_free_)
#define pcre2_substring_get_byname PCRE2_SUFFIX(pcre2_substring_get_byname_)
#define pcre2_substring_get_bynumber PCRE2_SUFFIX(pcre2_substring_get_bynumber_)
#define pcre2_substring_length_byname PCRE2_SUFFIX(pcre2_substring_length_byname_)
#define pcre2_substring_length_bynumber PCRE2_SUFFIX(pcre2_substring_length_bynumber_)
#define pcre2_substring_list_get PCRE2_SUFFIX(pcre2_substring_list_get_)
#define pcre2_substring_list_free PCRE2_SUFFIX(pcre2_substring_list_free_)
#define pcre2_substring_nametable_scan PCRE2_SUFFIX(pcre2_substring_nametable_scan_)
#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_)
/* Now generate all three sets of width-specific structures and function
prototypes. */
#define PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS \
PCRE2_TYPES_LIST \
PCRE2_STRUCTURE_LIST \
PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_GENERAL_CONTEXT_FUNCTIONS \
PCRE2_COMPILE_CONTEXT_FUNCTIONS \
PCRE2_MATCH_CONTEXT_FUNCTIONS \
PCRE2_COMPILE_FUNCTIONS \
PCRE2_PATTERN_INFO_FUNCTIONS \
PCRE2_MATCH_FUNCTIONS \
PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_JIT_FUNCTIONS \
PCRE2_OTHER_FUNCTIONS
#define PCRE2_LOCAL_WIDTH 8
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 16
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
#define PCRE2_LOCAL_WIDTH 32
PCRE2_TYPES_LIST
PCRE2_STRUCTURE_LIST
PCRE2_FUNCTION_LIST
PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_LOCAL_WIDTH
/* Undefine the list macros; they are no longer needed. */
#undef PCRE2_TYPES_LIST
#undef PCRE2_STRUCTURE_LIST
#undef PCRE2_FUNCTION_LIST
#undef PCRE2_ADDWIDTH
#undef PCRE2_GENERAL_INFO_FUNCTIONS
#undef PCRE2_GENERAL_CONTEXT_FUNCTIONS
#undef PCRE2_COMPILE_CONTEXT_FUNCTIONS
#undef PCRE2_MATCH_CONTEXT_FUNCTIONS
#undef PCRE2_COMPILE_FUNCTIONS
#undef PCRE2_PATTERN_INFO_FUNCTIONS
#undef PCRE2_MATCH_FUNCTIONS
#undef PCRE2_SUBSTRING_FUNCTIONS
#undef PCRE2_JIT_FUNCTIONS
#undef PCRE2_OTHER_FUNCTIONS
#undef PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
/* Re-define PCRE2_ADDWIDTH to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_ADDWIDTH a no-op, to reduce
/* Re-define PCRE2_SUFFIX to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_SUFFIX a no-op, to reduce
confusion. */
#ifdef PCRE2_DATA_WIDTH
#if PCRE2_DATA_WIDTH != 8 && PCRE2_DATA_WIDTH != 16 && PCRE2_DATA_WIDTH != 32
#error PCRE2_DATA_WIDTH must be 8, 16, or 32
#undef PCRE2_SUFFIX
#ifdef PCRE2_CODE_UNIT_WIDTH
#if PCRE2_CODE_UNIT_WIDTH != 8 && \
PCRE2_CODE_UNIT_WIDTH != 16 && \
PCRE2_CODE_UNIT_WIDTH != 32
#error PCRE2_CODE_UNIT_WIDTH must be 8, 16, or 32
#endif
#define PCRE2_ADDWIDTH(a) PCRE2_GLUE(a,PCRE2_DATA_WIDTH)
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH)
#else
#undef PCRE2_JOIN
#undef PCRE2_GLUE
#define PCRE2_ADDWIDTH(a) a
#define PCRE2_SUFFIX(a) a
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -255,6 +255,7 @@ D is inspected during pcre2_dfa_match() execution
#define PCRE2_CONFIG_PARENS_LIMIT 7
#define PCRE2_CONFIG_STACKRECURSE 8
#define PCRE2_CONFIG_UTF 9
#define PCRE2_CONFIG_VERSION 10
/* A value that is used to indicate 'unset' in unsigned size_t fields. In
particular, this value is used in the ovector. */
@ -339,9 +340,8 @@ expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_config(int, void *); \
PCRE2_EXP_DECL size_t pcre2_get_match_frame_size(void); \
PCRE2_EXP_DECL int pcre2_version(PCRE2_UCHAR *, size_t);
PCRE2_EXP_DECL int pcre2_config(int, void *, size_t); \
PCRE2_EXP_DECL size_t pcre2_get_match_frame_size(void);
/* Functions for manipulating contexts. */
@ -576,7 +576,6 @@ pcre2_compile are called by application code. */
#define pcre2_substring_list_free PCRE2_SUFFIX(pcre2_substring_list_free_)
#define pcre2_substring_nametable_scan PCRE2_SUFFIX(pcre2_substring_nametable_scan_)
#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_)
#define pcre2_version PCRE2_SUFFIX(pcre2_version_)
/* Now generate all three sets of width-specific structures and function

View File

@ -44,27 +44,41 @@ POSSIBILITY OF SUCH DAMAGE.
#include "pcre2_internal.h"
/* These macros are the standard way of turning unquoted text into C strings.
They allow macros like PCRE2_MAJOR to be defined without quotes, which is
convenient for user programs that want to test their values. */
#define STRING(a) # a
#define XSTRING(s) STRING(s)
/*************************************************
* Return info about what features are configured *
*************************************************/
/* This function has an extensible interface so that additional items can be
added compatibly.
/* Most of the requests return an int value; others require more memory and do
their own checks.
Arguments:
what what information is required
where where to put the information
length length of "where" in bytes
Returns: 0 if data returned, negative on error
Returns: 0 if data returned
PCRE2_ERROR_BADLENGTH if not enough memory
PCRE2_ERROR_BADOPTION if "where" not recognized
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_config(int what, void *where)
pcre2_config(int what, void *where, size_t length)
{
if (length < sizeof(int)) return PCRE2_ERROR_BADLENGTH;
switch (what)
{
default:
return PCRE2_ERROR_BADOPTION;
case PCRE2_CONFIG_BSR:
#ifdef BSR_ANYCRLF
*((int *)where) = 1;
@ -83,6 +97,7 @@ switch (what)
case PCRE2_CONFIG_JITTARGET:
#ifdef SUPPORT_JIT
FIXME: This needs re-design.
*((const char **)where) = PRIV(jit_get_target)();
#else
*((const char **)where) = NULL;
@ -94,10 +109,12 @@ switch (what)
break;
case PCRE2_CONFIG_MATCH_LIMIT:
if (length < sizeof(unsigned long int)) return PCRE2_ERROR_BADLENGTH;
*((unsigned long int *)where) = MATCH_LIMIT;
break;
case PCRE2_CONFIG_MATCH_LIMIT_RECURSION:
if (length < sizeof(unsigned long int)) return PCRE2_ERROR_BADLENGTH;
*((unsigned long int *)where) = MATCH_LIMIT_RECURSION;
break;
@ -106,6 +123,7 @@ switch (what)
break;
case PCRE2_CONFIG_PARENS_LIMIT:
if (length < sizeof(unsigned long int)) return PCRE2_ERROR_BADLENGTH;
*((unsigned long int *)where) = PARENS_NEST_LIMIT;
break;
@ -124,8 +142,22 @@ switch (what)
*((int *)where) = 0;
#endif
break;
default: return PCRE2_ERROR_BADOPTION;
case PCRE2_CONFIG_VERSION:
{
PCRE2_UCHAR *t = (PCRE2_UCHAR *)where;
/*
const char *v = (XSTRING(Z PCRE2_PRERELEASE)[1] == 0)?
XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) :
XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
*/
const char *v = XSTRING(PCRE2_MAJOR.PCRE2_MINOR)
XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
if (strlen(v) >= BYTES2CU(length) - 1) return PCRE2_ERROR_BADLENGTH;
while (*v != 0) *t++ = *v++;
*t = 0;
return t - (PCRE2_UCHAR *)where;
}
}
return 0;

View File

@ -48,11 +48,12 @@ to have access to the hidden structures at all supported widths.
Some of the mode-dependent macros are required at different widths for
different parts of the pcre2test code (in particular, the included
pcre_printint.c file). We undefine them here so that they can be re-defined for
multiple inclusions. Not all of these are used in pcretest, but it's easier
multiple inclusions. Not all of these are used in pcre2test, but it's easier
just to undefine them all. */
#undef ACROSSCHAR
#undef BACKCHAR
#undef BYTES2CU
#undef CU2BYTES
#undef FORWARDCHAR
#undef GET
@ -522,7 +523,8 @@ These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */
/* Mode-dependent macros that have the same definition in all modes. */
#define CU2BYTES(x) (x)*((PCRE2_CODE_UNIT_WIDTH/8))
#define CU2BYTES(x) ((x)*((PCRE2_CODE_UNIT_WIDTH/8)))
#define BYTES2CU(x) ((x)/((PCRE2_CODE_UNIT_WIDTH/8)))
#define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
#define PUT2INC(a,n,d) PUT2(a,n,d), a += IMM2_SIZE

View File

@ -1,104 +0,0 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* PCRE is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
New API code Copyright (c) 2014 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This module contains the external function pcre2_version(), which returns a
string that identifies the PCRE version that is in use. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "pcre2_internal.h"
/*************************************************
* Return version string *
*************************************************/
/* These macros are the standard way of turning unquoted text into C strings.
They allow macros like PCRE_MAJOR to be defined without quotes, which is
convenient for user programs that want to test its value. */
#define STRING(a) # a
#define XSTRING(s) STRING(s)
/* A problem turned up with PCRE_PRERELEASE, which is defined empty for
production releases. Originally, it was used naively in this code:
return XSTRING(PCRE_MAJOR)
"." XSTRING(PCRE_MINOR)
XSTRING(PCRE_PRERELEASE)
" " XSTRING(PCRE_DATE);
However, when PCRE_PRERELEASE is empty, this leads to an attempted expansion of
STRING(). The C standard states: "If (before argument substitution) any
argument consists of no preprocessing tokens, the behavior is undefined." It
turns out the gcc treats this case as a single empty string - which is what we
really want - but Visual C grumbles about the lack of an argument for the
macro. Unfortunately, both are within their rights. To cope with both ways of
handling this, I had resort to some messy hackery that does a test at run time.
I could find no way of detecting that a macro is defined as an empty string at
pre-processor time. This hack uses a standard trick for avoiding calling
the STRING macro with an empty argument when doing the test.
Arguments:
buffer where to return the version string
size size of buffer
Returns: number of characters, excluding trailing zero
or PCRE_ERROR_BADLENGTH if buffer too small
*/
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
pcre2_version(PCRE2_UCHAR *buffer, size_t size)
{
PCRE2_UCHAR *t = buffer;
const char *v = (XSTRING(Z PCRE2_PRERELEASE)[1] == 0)?
XSTRING(PCRE2_MAJOR.PCRE2_MINOR PCRE2_DATE) :
XSTRING(PCRE2_MAJOR.PCRE2_MINOR) XSTRING(PCRE2_PRERELEASE PCRE2_DATE);
if (strlen(v) >= size) return PCRE2_ERROR_BADLENGTH;
while (*v != 0) *t++ = *v++;
*t = 0;
return t - buffer;
}
/* End of pcre2_version.c */

View File

@ -266,33 +266,31 @@ modes, so use the form of the first that is available. */
#if defined SUPPORT_PCRE8
#define DEFAULT_TEST_MODE PCRE8_MODE
#define VERSION_TYPE PCRE2_UCHAR8
#define PCRE2_CONFIG pcre2_config_8
#define PCRE2_JIT_STACK pcre2_jit_stack_8
#define PCRE2_REAL_GENERAL_CONTEXT pcre2_real_general_context_8
#define PCRE2_REAL_COMPILE_CONTEXT pcre2_real_compile_context_8
#define PCRE2_REAL_MATCH_CONTEXT pcre2_real_match_context_8
#define PCRE2_VERSION pcre2_version_8
#define VERSION_TYPE PCRE2_UCHAR8
#elif defined SUPPORT_PCRE16
#define DEFAULT_TEST_MODE PCRE16_MODE
#define VERSION_TYPE PCRE2_UCHAR16
#define PCRE2_CONFIG pcre2_config_16
#define PCRE2_JIT_STACK pcre2_jit_stack_16
#define PCRE2_REAL_GENERAL_CONTEXT pcre2_real_general_context_16
#define PCRE2_REAL_COMPILE_CONTEXT pcre2_real_compile_context_16
#define PCRE2_REAL_MATCH_CONTEXT pcre2_real_match_context_16
#define PCRE2_VERSION pcre2_version_16
#define VERSION_TYPE PCRE2_UCHAR16
#elif defined SUPPORT_PCRE32
#define DEFAULT_TEST_MODE PCRE32_MODE
#define VERSION_TYPE PCRE2_UCHAR32
#define PCRE2_CONFIG pcre2_config_32
#define PCRE2_JIT_STACK pcre2_jit_stack_32
#define PCRE2_REAL_GENERAL_CONTEXT pcre2_real_general_context_32
#define PCRE2_REAL_COMPILE_CONTEXT pcre2_real_compile_context_32
#define PCRE2_REAL_MATCH_CONTEXT pcre2_real_match_context_32
#define PCRE2_VERSION pcre2_version_32
#define VERSION_TYPE PCRE2_UCHAR32
#endif
@ -610,7 +608,7 @@ clock_t total_match_time = 0;
static uint32_t dfa_matched;
static uint32_t max_oveccount;
static VERSION_TYPE version[64];
static VERSION_TYPE version[VERSION_SIZE];
static patctl def_patctl;
static patctl pat_patctl;
@ -4743,7 +4741,7 @@ if (arg != NULL)
switch (coptlist[i].type)
{
case CONF_BSR:
(void)PCRE2_CONFIG(coptlist[i].value, &rc);
(void)PCRE2_CONFIG(coptlist[i].value, &rc, sizeof(rc));
printf("%s\n", rc? "ANYCRLF" : "ANY");
break;
@ -4758,12 +4756,12 @@ if (arg != NULL)
break;
case CONF_INT:
(void)PCRE2_CONFIG(coptlist[i].value, &yield);
(void)PCRE2_CONFIG(coptlist[i].value, &yield, sizeof(yield));
printf("%d\n", yield);
break;
case CONF_NL:
(void)PCRE2_CONFIG(coptlist[i].value, &rc);
(void)PCRE2_CONFIG(coptlist[i].value, &rc, sizeof(rc));
print_newline_config(rc, TRUE);
break;
}
@ -4802,33 +4800,36 @@ printf(" 16-bit support\n");
printf(" 32-bit support\n");
#endif
(void)PCRE2_CONFIG(PCRE2_CONFIG_UTF, &rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_UTF, &rc, sizeof(rc));
printf (" %sUTF support\n", rc ? "" : "No ");
(void)PCRE2_CONFIG(PCRE2_CONFIG_JIT, &rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_JIT, &rc, sizeof(rc));
if (rc != 0)
{
/* FIXME: config needs sorting for jit target
const char *arch;
(void)PCRE2_CONFIG(PCRE2_CONFIG_JITTARGET, (void *)(&arch));
printf(" Just-in-time compiler support: %s\n", arch);
*/
printf(" Just-in-time compiler support: FIXME\n");
}
else
{
printf(" No just-in-time compiler support\n");
}
(void)PCRE2_CONFIG(PCRE2_CONFIG_NEWLINE, &rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_NEWLINE, &rc, sizeof(rc));
print_newline_config(rc, FALSE);
(void)PCRE2_CONFIG(PCRE2_CONFIG_BSR, &rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_BSR, &rc, sizeof(rc));
printf(" \\R matches %s\n", rc? "CR, LF, or CRLF only" :
"all Unicode newlines");
(void)PCRE2_CONFIG(PCRE2_CONFIG_LINK_SIZE, &rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_LINK_SIZE, &rc, sizeof(rc));
printf(" Internal link size = %d\n", rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_PARENS_LIMIT, &lrc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_PARENS_LIMIT, &lrc, sizeof(lrc));
printf(" Parentheses nest limit = %ld\n", lrc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_MATCH_LIMIT, &lrc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_MATCH_LIMIT, &lrc, sizeof(lrc));
printf(" Default match limit = %ld\n", lrc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_MATCH_LIMIT_RECURSION, &lrc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_MATCH_LIMIT_RECURSION, &lrc, sizeof(lrc));
printf(" Default recursion depth limit = %ld\n", lrc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_STACKRECURSE, &rc);
(void)PCRE2_CONFIG(PCRE2_CONFIG_STACKRECURSE, &rc, sizeof(rc));
printf(" Match recursion uses %s", rc? "stack" : "heap");
#ifdef FIXME
@ -4877,9 +4878,9 @@ if (PO(options) != DO(options) || PO(control) != DO(control))
return 1;
}
/* Get the PCRE version number. */
/* Get the PCRE version number information. */
PCRE2_VERSION(version, VERSION_SIZE);
PCRE2_CONFIG(PCRE2_CONFIG_VERSION, version, sizeof(VERSION_TYPE)*VERSION_SIZE);
/* Get buffers from malloc() so that valgrind will check their misuse when
debugging. They grow automatically when very long lines are read. The 16-