Compiling with --disalbe-stack-for-recursion is working. Introduce PCRE2_OFFSET
for offset values.
This commit is contained in:
parent
b33a39fb15
commit
0188214a63
|
@ -175,7 +175,7 @@ sure both macros are undefined; an emulation function will then be used. */
|
|||
recursion in the match() function; instead it creates its own stack by
|
||||
steam using memory from the heap. For more detail, see the comments and
|
||||
other stuff just above the match() function. */
|
||||
/* #undef NO_RECURSE */
|
||||
#define NO_RECURSE /**/
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "pcre2"
|
||||
|
|
114
src/pcre2.h
114
src/pcre2.h
|
@ -136,7 +136,7 @@ D is inspected during pcre2_dfa_match() execution
|
|||
#define PCRE2_DFA_RESTART 0x00000040
|
||||
#define PCRE2_DFA_SHORTEST 0x00000080
|
||||
|
||||
/* Newline and \R settings, for use in the compile and match contexts. The
|
||||
/* Newline and \R settings, for use in the compile and match contexts. The
|
||||
newline values must be kept in step with values set in config.h and both sets
|
||||
must all be greater than zero. */
|
||||
|
||||
|
@ -256,22 +256,22 @@ must all be greater than zero. */
|
|||
#define PCRE2_CONFIG_UTF 9
|
||||
#define PCRE2_CONFIG_VERSION 10
|
||||
|
||||
/* A value that is used to indicate 'unset' in unsigned size_t fields. In
|
||||
/* 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)
|
||||
#define PCRE2_UNSET (~(PCRE2_OFFSET)0)
|
||||
|
||||
/* Types for patterns and subject strings. */
|
||||
/* Types for patterns, subject strings, and offsets. */
|
||||
|
||||
typedef uint8_t PCRE2_UCHAR8;
|
||||
typedef uint16_t PCRE2_UCHAR16;
|
||||
typedef uint32_t PCRE2_UCHAR32;
|
||||
typedef uint32_t PCRE2_OFFSET;
|
||||
|
||||
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. */
|
||||
|
||||
|
@ -305,22 +305,22 @@ versions are generated from this macro below. */
|
|||
|
||||
#define PCRE2_STRUCTURE_LIST \
|
||||
typedef struct pcre2_callout_block { \
|
||||
int version; /* Identifies version of block */ \
|
||||
int version; /* Identifies version of block */ \
|
||||
/* ------------------------ Version 0 ------------------------------- */ \
|
||||
uint32_t callout_number; /* Number compiled into pattern */ \
|
||||
size_t *offset_vector; /* The offset vector */ \
|
||||
PCRE2_SPTR subject; /* The subject being matched */ \
|
||||
size_t subject_length; /* The length of the subject */ \
|
||||
size_t start_match; /* Offset to start of this match attempt */ \
|
||||
size_t current_position; /* Where we currently are in the subject */ \
|
||||
uint32_t capture_top; /* Max current capture */ \
|
||||
uint32_t capture_last; /* Most recently closed capture */ \
|
||||
void *callout_data; /* Data passed in with the call */ \
|
||||
uint32_t callout_number; /* Number compiled into pattern */ \
|
||||
PCRE2_OFFSET *offset_vector; /* The offset vector */ \
|
||||
PCRE2_SPTR subject; /* The subject being matched */ \
|
||||
size_t subject_length; /* The length of the subject */ \
|
||||
PCRE2_OFFSET start_match; /* Offset to start of this match attempt */ \
|
||||
PCRE2_OFFSET current_position; /* Where we currently are in the subject */ \
|
||||
uint32_t capture_top; /* Max current capture */ \
|
||||
uint32_t capture_last; /* Most recently closed capture */ \
|
||||
void *callout_data; /* Data passed in with the call */ \
|
||||
/* ------------------- Added for Version 1 -------------------------- */ \
|
||||
size_t pattern_position; /* Offset to next item in the pattern */ \
|
||||
size_t next_item_length; /* Length of next item in the pattern */ \
|
||||
PCRE2_OFFSET pattern_position; /* Offset to next item in the pattern */ \
|
||||
PCRE2_OFFSET next_item_length; /* Length of next item in the pattern */ \
|
||||
/* ------------------- Added for Version 2 -------------------------- */ \
|
||||
PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \
|
||||
PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \
|
||||
/* ------------------------------------------------------------------ */ \
|
||||
} pcre2_callout_block;
|
||||
|
||||
|
@ -339,8 +339,7 @@ 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);
|
||||
PCRE2_EXP_DECL int pcre2_config(int, void *, size_t);
|
||||
|
||||
|
||||
/* Functions for manipulating contexts. */
|
||||
|
@ -389,7 +388,7 @@ 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 *));
|
||||
void (*)(void *, void *), void *);
|
||||
|
||||
|
||||
/* Functions concerned with compiling a pattern to PCRE internal code. */
|
||||
|
@ -397,7 +396,7 @@ PCRE2_EXP_DECL int pcre2_set_recursion_memory_management( \
|
|||
#define PCRE2_COMPILE_FUNCTIONS \
|
||||
PCRE2_EXP_DECL \
|
||||
pcre2_code *pcre2_compile(PCRE2_SPTR, int, uint32_t, \
|
||||
int *, size_t *, pcre2_compile_context *); \
|
||||
int *, PCRE2_OFFSET *, pcre2_compile_context *); \
|
||||
PCRE2_EXP_DECL void pcre2_code_free(pcre2_code *);
|
||||
|
||||
|
||||
|
@ -412,26 +411,25 @@ PCRE2_EXP_DECL int pcre2_pattern_info(const pcre2_code *, uint32_t, \
|
|||
|
||||
#define PCRE2_MATCH_FUNCTIONS \
|
||||
PCRE2_EXP_DECL \
|
||||
pcre2_match_data *pcre2_match_data_create(size_t, \
|
||||
pcre2_match_data *pcre2_match_data_create(uint32_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_SPTR, int, PCRE2_OFFSET, uint32_t, \
|
||||
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_SPTR, int, PCRE2_OFFSET, uint32_t, \
|
||||
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 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 PCRE2_OFFSET pcre2_get_leftchar(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL uint32_t pcre2_get_ovector_count(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_OFFSET *pcre2_get_ovector_pointer(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_rightchar(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_startchar(pcre2_match_data *);
|
||||
|
||||
|
||||
/* Convenience functions for handling matched substrings. */
|
||||
|
@ -464,7 +462,7 @@ PCRE2_EXP_DECL int pcre2_substring_list_get(pcre2_match_data *, \
|
|||
#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_SPTR, int, PCRE2_OFFSET, uint32_t, \
|
||||
pcre2_match_data *, pcre2_jit_stack *); \
|
||||
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_general_context *);\
|
||||
PCRE2_EXP_DECL \
|
||||
|
@ -479,7 +477,6 @@ PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_jit_stack *);
|
|||
|
||||
#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(pcre2_general_context *); \
|
||||
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2_code *);
|
||||
|
@ -525,21 +522,20 @@ pcre2_compile are called by application code. */
|
|||
|
||||
/* Functions: the complete list in alphabetical order */
|
||||
|
||||
#define pcre2_code_free PCRE2_SUFFIX(pcre2_code_free_)
|
||||
#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_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_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_)
|
||||
|
@ -551,12 +547,12 @@ pcre2_compile are called by application code. */
|
|||
#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_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_compile PCRE2_SUFFIX(pcre2_set_bsr_compile_)
|
||||
|
@ -570,17 +566,17 @@ pcre2_compile are called by application code. */
|
|||
#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_)
|
||||
#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
|
||||
|
|
114
src/pcre2.h.in
114
src/pcre2.h.in
|
@ -136,7 +136,7 @@ D is inspected during pcre2_dfa_match() execution
|
|||
#define PCRE2_DFA_RESTART 0x00000040
|
||||
#define PCRE2_DFA_SHORTEST 0x00000080
|
||||
|
||||
/* Newline and \R settings, for use in the compile and match contexts. The
|
||||
/* Newline and \R settings, for use in the compile and match contexts. The
|
||||
newline values must be kept in step with values set in config.h and both sets
|
||||
must all be greater than zero. */
|
||||
|
||||
|
@ -256,22 +256,22 @@ must all be greater than zero. */
|
|||
#define PCRE2_CONFIG_UTF 9
|
||||
#define PCRE2_CONFIG_VERSION 10
|
||||
|
||||
/* A value that is used to indicate 'unset' in unsigned size_t fields. In
|
||||
/* 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)
|
||||
#define PCRE2_UNSET (~(PCRE2_OFFSET)0)
|
||||
|
||||
/* Types for patterns and subject strings. */
|
||||
/* Types for patterns, subject strings, and offsets. */
|
||||
|
||||
typedef uint8_t PCRE2_UCHAR8;
|
||||
typedef uint16_t PCRE2_UCHAR16;
|
||||
typedef uint32_t PCRE2_UCHAR32;
|
||||
typedef uint32_t PCRE2_OFFSET;
|
||||
|
||||
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. */
|
||||
|
||||
|
@ -305,22 +305,22 @@ versions are generated from this macro below. */
|
|||
|
||||
#define PCRE2_STRUCTURE_LIST \
|
||||
typedef struct pcre2_callout_block { \
|
||||
int version; /* Identifies version of block */ \
|
||||
int version; /* Identifies version of block */ \
|
||||
/* ------------------------ Version 0 ------------------------------- */ \
|
||||
uint32_t callout_number; /* Number compiled into pattern */ \
|
||||
size_t *offset_vector; /* The offset vector */ \
|
||||
PCRE2_SPTR subject; /* The subject being matched */ \
|
||||
size_t subject_length; /* The length of the subject */ \
|
||||
size_t start_match; /* Offset to start of this match attempt */ \
|
||||
size_t current_position; /* Where we currently are in the subject */ \
|
||||
uint32_t capture_top; /* Max current capture */ \
|
||||
uint32_t capture_last; /* Most recently closed capture */ \
|
||||
void *callout_data; /* Data passed in with the call */ \
|
||||
uint32_t callout_number; /* Number compiled into pattern */ \
|
||||
PCRE2_OFFSET *offset_vector; /* The offset vector */ \
|
||||
PCRE2_SPTR subject; /* The subject being matched */ \
|
||||
size_t subject_length; /* The length of the subject */ \
|
||||
PCRE2_OFFSET start_match; /* Offset to start of this match attempt */ \
|
||||
PCRE2_OFFSET current_position; /* Where we currently are in the subject */ \
|
||||
uint32_t capture_top; /* Max current capture */ \
|
||||
uint32_t capture_last; /* Most recently closed capture */ \
|
||||
void *callout_data; /* Data passed in with the call */ \
|
||||
/* ------------------- Added for Version 1 -------------------------- */ \
|
||||
size_t pattern_position; /* Offset to next item in the pattern */ \
|
||||
size_t next_item_length; /* Length of next item in the pattern */ \
|
||||
PCRE2_OFFSET pattern_position; /* Offset to next item in the pattern */ \
|
||||
PCRE2_OFFSET next_item_length; /* Length of next item in the pattern */ \
|
||||
/* ------------------- Added for Version 2 -------------------------- */ \
|
||||
PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \
|
||||
PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \
|
||||
/* ------------------------------------------------------------------ */ \
|
||||
} pcre2_callout_block;
|
||||
|
||||
|
@ -339,8 +339,7 @@ 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);
|
||||
PCRE2_EXP_DECL int pcre2_config(int, void *, size_t);
|
||||
|
||||
|
||||
/* Functions for manipulating contexts. */
|
||||
|
@ -389,7 +388,7 @@ 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 *));
|
||||
void (*)(void *, void *), void *);
|
||||
|
||||
|
||||
/* Functions concerned with compiling a pattern to PCRE internal code. */
|
||||
|
@ -397,7 +396,7 @@ PCRE2_EXP_DECL int pcre2_set_recursion_memory_management( \
|
|||
#define PCRE2_COMPILE_FUNCTIONS \
|
||||
PCRE2_EXP_DECL \
|
||||
pcre2_code *pcre2_compile(PCRE2_SPTR, int, uint32_t, \
|
||||
int *, size_t *, pcre2_compile_context *); \
|
||||
int *, PCRE2_OFFSET *, pcre2_compile_context *); \
|
||||
PCRE2_EXP_DECL void pcre2_code_free(pcre2_code *);
|
||||
|
||||
|
||||
|
@ -412,26 +411,25 @@ PCRE2_EXP_DECL int pcre2_pattern_info(const pcre2_code *, uint32_t, \
|
|||
|
||||
#define PCRE2_MATCH_FUNCTIONS \
|
||||
PCRE2_EXP_DECL \
|
||||
pcre2_match_data *pcre2_match_data_create(size_t, \
|
||||
pcre2_match_data *pcre2_match_data_create(uint32_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_SPTR, int, PCRE2_OFFSET, uint32_t, \
|
||||
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_SPTR, int, PCRE2_OFFSET, uint32_t, \
|
||||
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 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 PCRE2_OFFSET pcre2_get_leftchar(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL uint32_t pcre2_get_ovector_count(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_OFFSET *pcre2_get_ovector_pointer(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_rightchar(pcre2_match_data *); \
|
||||
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_startchar(pcre2_match_data *);
|
||||
|
||||
|
||||
/* Convenience functions for handling matched substrings. */
|
||||
|
@ -464,7 +462,7 @@ PCRE2_EXP_DECL int pcre2_substring_list_get(pcre2_match_data *, \
|
|||
#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_SPTR, int, PCRE2_OFFSET, uint32_t, \
|
||||
pcre2_match_data *, pcre2_jit_stack *); \
|
||||
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_general_context *);\
|
||||
PCRE2_EXP_DECL \
|
||||
|
@ -479,7 +477,6 @@ PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_jit_stack *);
|
|||
|
||||
#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(pcre2_general_context *); \
|
||||
PCRE2_EXP_DECL int pcre2_pattern_to_host_byte_order(pcre2_code *);
|
||||
|
@ -525,21 +522,20 @@ pcre2_compile are called by application code. */
|
|||
|
||||
/* Functions: the complete list in alphabetical order */
|
||||
|
||||
#define pcre2_code_free PCRE2_SUFFIX(pcre2_code_free_)
|
||||
#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_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_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_)
|
||||
|
@ -551,12 +547,12 @@ pcre2_compile are called by application code. */
|
|||
#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_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_compile PCRE2_SUFFIX(pcre2_set_bsr_compile_)
|
||||
|
@ -570,17 +566,17 @@ pcre2_compile are called by application code. */
|
|||
#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_)
|
||||
#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
|
||||
|
|
|
@ -7257,7 +7257,7 @@ Returns: pointer to compiled data block, or NULL on error,
|
|||
|
||||
PCRE2_EXP_DEFN pcre2_code * PCRE2_CALL_CONVENTION
|
||||
pcre2_compile(PCRE2_SPTR pattern, int patlen, uint32_t options,
|
||||
int *errorptr, size_t *erroroffset, pcre2_compile_context *ccontext)
|
||||
int *errorptr, PCRE2_OFFSET *erroroffset, pcre2_compile_context *ccontext)
|
||||
{
|
||||
BOOL utf; /* Set TRUE for UTF mode */
|
||||
pcre2_real_code *re = NULL; /* What we will return */
|
||||
|
|
|
@ -168,8 +168,7 @@ if (defmemctl)
|
|||
mcontext->memctl.memory_data = NULL;
|
||||
}
|
||||
#ifdef NO_RECURSE
|
||||
mcontext->stack_malloc = mcontext->malloc;
|
||||
mcontext->stack_free = mcontext->free;
|
||||
mcontext->stack_memctl = mcontext->memctl;
|
||||
#endif
|
||||
mcontext->callout = NULL;
|
||||
mcontext->callout_data = NULL;
|
||||
|
@ -392,16 +391,18 @@ return 1;
|
|||
|
||||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_set_recursion_memory_management(pcre2_match_context *mcontext,
|
||||
void *(*mymalloc)(size_t, void *),
|
||||
void (*myfree)(void *, void *))
|
||||
void *(*mymalloc)(size_t, void *), void (*myfree)(void *, void *),
|
||||
void *mydata)
|
||||
{
|
||||
#ifdef NORECURSE
|
||||
mcontext->stack_malloc = mymalloc;
|
||||
mcontext->stack_free = myfree;
|
||||
#ifdef NO_RECURSE
|
||||
mcontext->stack_memctl.malloc = mymalloc;
|
||||
mcontext->stack_memctl.free = myfree;
|
||||
mcontext->stack_memctl.memory_data = mydata;
|
||||
#else
|
||||
(void)mcontext;
|
||||
(void)mymalloc;
|
||||
(void)myfree;
|
||||
(void)mydata;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ Returns: > 0 => number of match offset pairs placed in offsets
|
|||
|
||||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_dfa_match(const pcre2_code *code, PCRE2_SPTR subject, int length,
|
||||
size_t startoffset, uint32_t options, pcre2_match_data *match_data,
|
||||
PCRE2_OFFSET startoffset, uint32_t options, pcre2_match_data *match_data,
|
||||
pcre2_match_context *mcontext, int *workspace, size_t wscount)
|
||||
{
|
||||
|
||||
|
|
|
@ -1859,7 +1859,7 @@ extern int _pcre2_strlen(PCRE2_SPTR);
|
|||
extern int _pcre2_strncmp(PCRE2_SPTR, PCRE2_SPTR, size_t);
|
||||
extern int _pcre2_strncmp_c8(PCRE2_SPTR, const char *, size_t);
|
||||
extern int _pcre2_study(pcre2_real_code *);
|
||||
extern int _pcre2_valid_utf(PCRE2_SPTR, int, size_t *);
|
||||
extern int _pcre2_valid_utf(PCRE2_SPTR, int, PCRE2_OFFSET *);
|
||||
extern BOOL _pcre2_was_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *,
|
||||
BOOL);
|
||||
extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, BOOL);
|
||||
|
|
|
@ -559,10 +559,9 @@ typedef struct pcre2_real_compile_context {
|
|||
/* The real match context structure. */
|
||||
|
||||
typedef struct pcre2_real_match_context {
|
||||
pcre2_memctl memctl;
|
||||
pcre2_memctl memctl;
|
||||
#ifdef NO_RECURSE
|
||||
void * (*stack_malloc)(size_t, void *);
|
||||
void (*stack_free)(void *, void *);
|
||||
pcre2_memctl stack_memctl;
|
||||
#endif
|
||||
int (*callout)(pcre2_callout_block *);
|
||||
void *callout_data;
|
||||
|
@ -605,12 +604,12 @@ typedef struct pcre2_real_match_data {
|
|||
const pcre2_real_code *code; /* The pattern used for the match */
|
||||
PCRE2_SPTR subject; /* The subject that was matched */
|
||||
int rc; /* The return code from the match */
|
||||
size_t leftchar; /* Offset to leftmost code unit */
|
||||
size_t rightchar; /* Offset to rightmost code unit */
|
||||
size_t startchar; /* Offset to starting code unit */
|
||||
PCRE2_OFFSET leftchar; /* Offset to leftmost code unit */
|
||||
PCRE2_OFFSET rightchar; /* Offset to rightmost code unit */
|
||||
PCRE2_OFFSET startchar; /* Offset to starting code unit */
|
||||
PCRE2_SPTR mark; /* Pointer to last mark */
|
||||
uint16_t oveccount; /* Number of pairs */
|
||||
size_t ovector[1]; /* The first field */
|
||||
PCRE2_OFFSET ovector[1]; /* The first field */
|
||||
} pcre2_real_match_data;
|
||||
|
||||
|
||||
|
@ -684,7 +683,7 @@ call within the pattern; used by pcre_match(). */
|
|||
typedef struct recursion_info {
|
||||
struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
|
||||
unsigned int group_num; /* Number of group that was called */
|
||||
size_t *offset_save; /* Pointer to start of saved offsets */
|
||||
PCRE2_OFFSET *offset_save; /* Pointer to start of saved offsets */
|
||||
uint32_t saved_max; /* Number of saved offsets */
|
||||
uint32_t saved_capture_last; /* Last capture number */
|
||||
PCRE2_SPTR subject_position; /* Position at start of recursion */
|
||||
|
@ -694,8 +693,8 @@ typedef struct recursion_info {
|
|||
|
||||
typedef struct dfa_recursion_info {
|
||||
struct dfa_recursion_info *prevrec;
|
||||
uint32_t group_num;
|
||||
PCRE2_SPTR subject_position;
|
||||
uint32_t group_num;
|
||||
} dfa_recursion_info;
|
||||
|
||||
/* Structure for building a chain of data for holding the values of the subject
|
||||
|
@ -712,20 +711,23 @@ typedef struct eptrblock {
|
|||
doing traditional NFA matching (pcre2_match() and friends). */
|
||||
|
||||
typedef struct match_block {
|
||||
pcre2_memctl memctl;
|
||||
unsigned long int match_call_count; /* As it says */
|
||||
unsigned long int match_limit; /* As it says */
|
||||
unsigned long int match_limit_recursion; /* As it says */
|
||||
pcre2_memctl memctl; /* For general use */
|
||||
#ifdef NO_RECURSE
|
||||
pcre2_memctl stack_memctl; /* For "stack" frames */
|
||||
#endif
|
||||
uint32_t match_call_count; /* As it says */
|
||||
uint32_t match_limit; /* As it says */
|
||||
uint32_t match_limit_recursion; /* As it says */
|
||||
BOOL hitend; /* Hit the end of the subject at some point */
|
||||
BOOL hasthen; /* Pattern contains (*THEN) */
|
||||
const uint8_t *lcc; /* Points to lower casing table */
|
||||
const uint8_t *fcc; /* Points to case-flipping table */
|
||||
const uint8_t *ctypes; /* Points to table of type maps */
|
||||
size_t *ovector; /* Pointer to the offset vector */
|
||||
size_t offset_end; /* One past the end */
|
||||
size_t offset_max; /* The maximum usable for return data */
|
||||
size_t start_offset; /* The start offset value */
|
||||
size_t end_offset_top; /* Highwater mark at end of match */
|
||||
PCRE2_OFFSET *ovector; /* Pointer to the offset vector */
|
||||
PCRE2_OFFSET offset_end; /* One past the end */
|
||||
PCRE2_OFFSET offset_max; /* The maximum usable for return data */
|
||||
PCRE2_OFFSET start_offset; /* The start offset value */
|
||||
PCRE2_OFFSET end_offset_top; /* Highwater mark at end of match */
|
||||
uint16_t partial; /* PARTIAL options */
|
||||
uint16_t bsr_convention; /* \R interpretation */
|
||||
uint16_t name_count; /* Number of names in name table */
|
||||
|
@ -768,8 +770,8 @@ typedef struct dfa_match_block {
|
|||
PCRE2_SPTR start_used_ptr; /* Earliest consulted character */
|
||||
const uint8_t *tables; /* Character tables */
|
||||
int start_offset; /* The start offset value */
|
||||
uint32_t moptions; /* Match options */
|
||||
uint32_t poptions; /* Pattern options */
|
||||
uint32_t moptions; /* Match options */
|
||||
uint32_t poptions; /* Pattern options */
|
||||
int nltype; /* Newline type */
|
||||
int nllen; /* Newline string length */
|
||||
PCRE2_UCHAR nl[4]; /* Newline string when fixed */
|
||||
|
|
|
@ -71,7 +71,7 @@ Returns: > 0 => success; value is the number of ovector pairs filled
|
|||
|
||||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_jit_match(const pcre2_code *code, PCRE2_SPTR subject, int length,
|
||||
size_t start_offset, uint32_t options, pcre2_match_data *match_data,
|
||||
PCRE2_OFFSET start_offset, uint32_t options, pcre2_match_data *match_data,
|
||||
pcre2_jit_stack *jit_stack)
|
||||
{
|
||||
#ifndef SUPPORT_JIT
|
||||
|
|
|
@ -144,7 +144,7 @@ register PCRE2_SPTR p = mb->start_subject + mb->ovector[offset];
|
|||
BOOL utf = (mb->poptions & PCRE2_UTF) != 0;
|
||||
#endif
|
||||
|
||||
/* Always fail if reference not set (unless PCRE2_MATCH_UNSET_BACKREF is set,
|
||||
/* Always fail if reference not set (unless PCRE2_MATCH_UNSET_BACKREF is set,
|
||||
in which case the length is passed as zero). */
|
||||
|
||||
if (length < 0) return -1;
|
||||
|
@ -292,7 +292,8 @@ argument of match(), which never changes. */
|
|||
heapframe *newframe = frame->Xnextframe;\
|
||||
if (newframe == NULL)\
|
||||
{\
|
||||
newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
|
||||
newframe = (heapframe *)(mb->stack_memctl.malloc)\
|
||||
(sizeof(heapframe), mb->stack_memctl.memory_data);\
|
||||
if (newframe == NULL) RRETURN(PCRE2_ERROR_NOMEMORY);\
|
||||
newframe->Xnextframe = NULL;\
|
||||
frame->Xnextframe = newframe;\
|
||||
|
@ -307,7 +308,7 @@ argument of match(), which never changes. */
|
|||
newframe->Xprevframe = frame;\
|
||||
frame = newframe;\
|
||||
goto HEAP_RECURSE;\
|
||||
L_##rw:\
|
||||
L_##rw:;\
|
||||
}
|
||||
|
||||
#define RRETURN(ra)\
|
||||
|
@ -323,67 +324,64 @@ argument of match(), which never changes. */
|
|||
}
|
||||
|
||||
|
||||
/* Structure for remembering the local variables in a private frame */
|
||||
/* Structure for remembering the local variables in a private frame. Arrange it
|
||||
so as to minimize the number of holes. */
|
||||
|
||||
typedef struct heapframe {
|
||||
struct heapframe *Xprevframe;
|
||||
struct heapframe *Xnextframe;
|
||||
|
||||
/* Function arguments that may change */
|
||||
|
||||
PCRE2_SPTR Xeptr;
|
||||
PCRE2_SPTR Xecode;
|
||||
PCRE2_SPTR Xmstart;
|
||||
int Xoffset_top;
|
||||
eptrblock *Xeptrb;
|
||||
unsigned int Xrdepth;
|
||||
|
||||
/* Function local variables */
|
||||
|
||||
PCRE2_SPTR Xcallpat;
|
||||
#ifdef SUPPORT_UTF
|
||||
PCRE2_SPTR Xcharptr;
|
||||
#endif
|
||||
PCRE2_SPTR Xeptr;
|
||||
PCRE2_SPTR Xecode;
|
||||
PCRE2_SPTR Xmstart;
|
||||
PCRE2_SPTR Xcallpat;
|
||||
PCRE2_SPTR Xdata;
|
||||
PCRE2_SPTR Xnext;
|
||||
PCRE2_SPTR Xpp;
|
||||
PCRE2_SPTR Xprev;
|
||||
PCRE2_SPTR Xsaved_eptr;
|
||||
|
||||
eptrblock *Xeptrb;
|
||||
|
||||
recursion_info Xnew_recursive;
|
||||
|
||||
BOOL Xcur_is_word;
|
||||
BOOL Xcondition;
|
||||
BOOL Xprev_is_word;
|
||||
PCRE2_OFFSET Xoffset;
|
||||
PCRE2_OFFSET Xoffset_top;
|
||||
PCRE2_OFFSET Xstacksave[REC_STACK_SAVE_MAX];
|
||||
PCRE2_OFFSET Xsave_offset1, Xsave_offset2, Xsave_offset3;
|
||||
|
||||
uint32_t Xfc;
|
||||
uint32_t Xnumber;
|
||||
uint32_t Xrdepth;
|
||||
uint32_t Xop;
|
||||
uint32_t Xsave_capture_last;
|
||||
|
||||
#ifdef SUPPORT_UTF
|
||||
uint32_t Xprop_value;
|
||||
int Xprop_type;
|
||||
unsigned int Xprop_value;
|
||||
int Xprop_fail_result;
|
||||
int Xoclength;
|
||||
PCRE2_UCHAR Xocchars[6];
|
||||
#endif
|
||||
|
||||
int Xcodelink;
|
||||
int Xctype;
|
||||
unsigned int Xfc;
|
||||
int Xfi;
|
||||
int Xlength;
|
||||
int Xmax;
|
||||
int Xmin;
|
||||
unsigned int Xnumber;
|
||||
int Xoffset;
|
||||
unsigned int Xop;
|
||||
uint32_t Xsave_capture_last;
|
||||
int Xsave_offset1, Xsave_offset2, Xsave_offset3;
|
||||
size_t Xstacksave[REC_STACK_SAVE_MAX];
|
||||
int Xwhere; /* Where to jump back to */
|
||||
|
||||
BOOL Xcondition;
|
||||
BOOL Xcur_is_word;
|
||||
BOOL Xprev_is_word;
|
||||
|
||||
eptrblock Xnewptrb;
|
||||
recursion_info Xnew_recursive;
|
||||
|
||||
/* Where to jump back to */
|
||||
|
||||
int Xwhere;
|
||||
|
||||
#ifdef SUPPORT_UTF
|
||||
PCRE2_UCHAR Xocchars[6];
|
||||
#endif
|
||||
} heapframe;
|
||||
|
||||
#endif
|
||||
|
@ -450,8 +448,8 @@ Returns: MATCH_MATCH if matched ) these values are >= 0
|
|||
|
||||
static int
|
||||
match(REGISTER PCRE2_SPTR eptr, REGISTER PCRE2_SPTR ecode,
|
||||
PCRE2_SPTR mstart, size_t offset_top, match_block *mb, eptrblock *eptrb,
|
||||
unsigned int rdepth)
|
||||
PCRE2_SPTR mstart, PCRE2_OFFSET offset_top, match_block *mb, eptrblock *eptrb,
|
||||
uint32_t rdepth)
|
||||
{
|
||||
/* These variables do not need to be preserved over recursion in this function,
|
||||
so they can be ordinary variables in all cases. Mark some of them with
|
||||
|
@ -459,7 +457,7 @@ so they can be ordinary variables in all cases. Mark some of them with
|
|||
|
||||
register int rrc; /* Returns from recursive calls */
|
||||
register int i; /* Used for loops not involving calls to RMATCH() */
|
||||
register uint32_t c; /* Character values not kept over RMATCH() calls */
|
||||
register uint32_t c; /* Character values not kept over RMATCH() calls */
|
||||
register BOOL utf; /* Local copy of UTF flag for speed */
|
||||
|
||||
BOOL minimize, possessive; /* Quantifier options */
|
||||
|
@ -502,7 +500,14 @@ HEAP_RECURSE:
|
|||
|
||||
#ifdef SUPPORT_UTF
|
||||
#define charptr frame->Xcharptr
|
||||
#define prop_value frame->Xprop_value
|
||||
#define prop_type frame->Xprop_type
|
||||
#define prop_fail_result frame->Xprop_fail_result
|
||||
#define oclength frame->Xoclength
|
||||
#define occhars frame->Xocchars
|
||||
#endif
|
||||
|
||||
|
||||
#define callpat frame->Xcallpat
|
||||
#define codelink frame->Xcodelink
|
||||
#define data frame->Xdata
|
||||
|
@ -513,18 +518,6 @@ HEAP_RECURSE:
|
|||
|
||||
#define new_recursive frame->Xnew_recursive
|
||||
|
||||
#define cur_is_word frame->Xcur_is_word
|
||||
#define condition frame->Xcondition
|
||||
#define prev_is_word frame->Xprev_is_word
|
||||
|
||||
#ifdef SUPPORT_UTF
|
||||
#define prop_type frame->Xprop_type
|
||||
#define prop_value frame->Xprop_value
|
||||
#define prop_fail_result frame->Xprop_fail_result
|
||||
#define oclength frame->Xoclength
|
||||
#define occhars frame->Xocchars
|
||||
#endif
|
||||
|
||||
#define ctype frame->Xctype
|
||||
#define fc frame->Xfc
|
||||
#define fi frame->Xfi
|
||||
|
@ -540,6 +533,10 @@ HEAP_RECURSE:
|
|||
#define save_offset3 frame->Xsave_offset3
|
||||
#define stacksave frame->Xstacksave
|
||||
|
||||
#define condition frame->Xcondition
|
||||
#define cur_is_word frame->Xcur_is_word
|
||||
#define prev_is_word frame->Xprev_is_word
|
||||
|
||||
#define newptrb frame->Xnewptrb
|
||||
|
||||
/* When recursion is being used, local variables are allocated on the stack and
|
||||
|
@ -564,19 +561,21 @@ PCRE2_SPTR charptr;
|
|||
PCRE2_SPTR callpat;
|
||||
PCRE2_SPTR data;
|
||||
PCRE2_SPTR next;
|
||||
PCRE2_SPTR pp;
|
||||
PCRE2_SPTR pp;
|
||||
PCRE2_SPTR prev;
|
||||
PCRE2_SPTR saved_eptr;
|
||||
PCRE2_SPTR saved_eptr;
|
||||
|
||||
recursion_info new_recursive;
|
||||
PCRE2_OFFSET offset;
|
||||
PCRE2_OFFSET stacksave[REC_STACK_SAVE_MAX];
|
||||
PCRE2_OFFSET save_offset1, save_offset2, save_offset3;
|
||||
|
||||
BOOL cur_is_word;
|
||||
BOOL condition;
|
||||
BOOL prev_is_word;
|
||||
uint32_t number;
|
||||
uint32_t op;
|
||||
uint32_t save_capture_last;
|
||||
|
||||
#ifdef SUPPORT_UTF
|
||||
uint32_t prop_value;
|
||||
int prop_type;
|
||||
unsigned int prop_value;
|
||||
int prop_fail_result;
|
||||
int oclength;
|
||||
PCRE2_UCHAR occhars[6];
|
||||
|
@ -587,32 +586,14 @@ int ctype;
|
|||
int length;
|
||||
int max;
|
||||
int min;
|
||||
unsigned int number;
|
||||
size_t offset;
|
||||
unsigned int op;
|
||||
uint32_t save_capture_last;
|
||||
int save_offset1, save_offset2, save_offset3;
|
||||
size_t stacksave[REC_STACK_SAVE_MAX];
|
||||
|
||||
BOOL condition;
|
||||
BOOL cur_is_word;
|
||||
BOOL prev_is_word;
|
||||
|
||||
eptrblock newptrb;
|
||||
|
||||
/* There is a special fudge for calling match() in a way that causes it to
|
||||
measure the size of its basic stack frame when the stack is being used for
|
||||
recursion. The second argument (ecode) being NULL triggers this behaviour. It
|
||||
cannot normally ever be NULL. The return is the negated value of the frame
|
||||
size. */
|
||||
|
||||
if (ecode == NULL)
|
||||
{
|
||||
if (rdepth == 0)
|
||||
return match((PCRE2_SPTR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
|
||||
else
|
||||
{
|
||||
int len = (char *)&rdepth - (char *)eptr;
|
||||
return (len > 0)? -len : len;
|
||||
}
|
||||
}
|
||||
#endif /* NO_RECURSE */
|
||||
recursion_info new_recursive;
|
||||
#endif /* NO_RECURSE not defined */
|
||||
|
||||
/* To save space on the stack and in the heap frame, I have doubled up on some
|
||||
of the local variables that are used only in localised parts of the code, but
|
||||
|
@ -1248,7 +1229,7 @@ for (;;)
|
|||
case OP_RREF: /* Numbered group recursion test */
|
||||
if (mb->recursive != NULL) /* Not recursing => FALSE */
|
||||
{
|
||||
unsigned int recno = GET2(ecode, 1); /* Recursion group number*/
|
||||
uint32_t recno = GET2(ecode, 1); /* Recursion group number*/
|
||||
condition = (recno == RREF_ANY || recno == mb->recursive->group_num);
|
||||
}
|
||||
break;
|
||||
|
@ -1260,7 +1241,7 @@ for (;;)
|
|||
PCRE2_SPTR slot = mb->name_table + GET2(ecode, 1) * mb->name_entry_size;
|
||||
while (count-- > 0)
|
||||
{
|
||||
unsigned int recno = GET2(slot, 0);
|
||||
uint32_t recno = GET2(slot, 0);
|
||||
condition = recno == mb->recursive->group_num;
|
||||
if (condition) break;
|
||||
slot += mb->name_entry_size;
|
||||
|
@ -1270,7 +1251,7 @@ for (;;)
|
|||
|
||||
case OP_CREF: /* Numbered group used test */
|
||||
offset = GET2(ecode, 1) << 1; /* Doubled ref number */
|
||||
condition = offset < offset_top &&
|
||||
condition = offset < offset_top &&
|
||||
mb->ovector[offset] != PCRE2_UNSET;
|
||||
break;
|
||||
|
||||
|
@ -1281,7 +1262,7 @@ for (;;)
|
|||
while (count-- > 0)
|
||||
{
|
||||
offset = GET2(slot, 0) << 1;
|
||||
condition = offset < offset_top &&
|
||||
condition = offset < offset_top &&
|
||||
mb->ovector[offset] != PCRE2_UNSET;
|
||||
if (condition) break;
|
||||
slot += mb->name_entry_size;
|
||||
|
@ -1638,7 +1619,7 @@ for (;;)
|
|||
case OP_RECURSE:
|
||||
{
|
||||
recursion_info *ri;
|
||||
unsigned int recno;
|
||||
uint32_t recno;
|
||||
|
||||
callpat = mb->start_code + GET(ecode, 1);
|
||||
recno = (callpat == mb->start_code)? 0 :
|
||||
|
@ -1671,13 +1652,13 @@ for (;;)
|
|||
new_recursive.offset_save = stacksave;
|
||||
else
|
||||
{
|
||||
new_recursive.offset_save = (size_t *)
|
||||
(mb->memctl.malloc(new_recursive.saved_max * sizeof(size_t),
|
||||
new_recursive.offset_save = (PCRE2_OFFSET *)
|
||||
(mb->memctl.malloc(new_recursive.saved_max * sizeof(PCRE2_OFFSET),
|
||||
mb->memctl.memory_data));
|
||||
if (new_recursive.offset_save == NULL) RRETURN(PCRE2_ERROR_NOMEMORY);
|
||||
}
|
||||
memcpy(new_recursive.offset_save, mb->ovector,
|
||||
new_recursive.saved_max * sizeof(size_t));
|
||||
new_recursive.saved_max * sizeof(PCRE2_OFFSET));
|
||||
|
||||
/* OK, now we can do the recursion. After processing each alternative,
|
||||
restore the offset data and the last captured value. If there were nested
|
||||
|
@ -1691,7 +1672,7 @@ for (;;)
|
|||
RMATCH(eptr, callpat + PRIV(OP_lengths)[*callpat], offset_top,
|
||||
mb, eptrb, RM6);
|
||||
memcpy(mb->ovector, new_recursive.offset_save,
|
||||
new_recursive.saved_max * sizeof(size_t));
|
||||
new_recursive.saved_max * sizeof(PCRE2_OFFSET));
|
||||
mb->capture_last = new_recursive.saved_capture_last;
|
||||
mb->recursive = new_recursive.prevrec;
|
||||
if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
|
||||
|
@ -1855,8 +1836,8 @@ for (;;)
|
|||
|
||||
if (offset > offset_top)
|
||||
{
|
||||
register size_t *iptr = mb->ovector + offset_top;
|
||||
register size_t *iend = mb->ovector + offset;
|
||||
register PCRE2_OFFSET *iptr = mb->ovector + offset_top;
|
||||
register PCRE2_OFFSET *iend = mb->ovector + offset;
|
||||
while (iptr < iend) *iptr++ = PCRE2_UNSET;
|
||||
}
|
||||
|
||||
|
@ -1948,7 +1929,7 @@ for (;;)
|
|||
/* Not multiline mode: start of subject assertion, unless notbol. */
|
||||
|
||||
case OP_CIRC:
|
||||
if ((mb->moptions & PCRE2_NOTBOL) != 0 && eptr == mb->start_subject)
|
||||
if ((mb->moptions & PCRE2_NOTBOL) != 0 && eptr == mb->start_subject)
|
||||
RRETURN(MATCH_NOMATCH);
|
||||
|
||||
/* Start of subject assertion */
|
||||
|
@ -1961,7 +1942,7 @@ for (;;)
|
|||
/* Multiline mode: start of subject unless notbol, or after any newline. */
|
||||
|
||||
case OP_CIRCM:
|
||||
if ((mb->moptions & PCRE2_NOTBOL) != 0 && eptr == mb->start_subject)
|
||||
if ((mb->moptions & PCRE2_NOTBOL) != 0 && eptr == mb->start_subject)
|
||||
RRETURN(MATCH_NOMATCH);
|
||||
if (eptr != mb->start_subject &&
|
||||
(eptr == mb->end_subject || !WAS_NEWLINE(eptr)))
|
||||
|
@ -3655,7 +3636,7 @@ for (;;)
|
|||
RRETURN(MATCH_NOMATCH);
|
||||
}
|
||||
GETCHARINC(d, eptr);
|
||||
if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
|
||||
if (fc == d || (uint32_t)foc == d) RRETURN(MATCH_NOMATCH);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3693,7 +3674,7 @@ for (;;)
|
|||
RRETURN(MATCH_NOMATCH);
|
||||
}
|
||||
GETCHARINC(d, eptr);
|
||||
if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
|
||||
if (fc == d || (uint32_t)foc == d) RRETURN(MATCH_NOMATCH);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3736,7 +3717,7 @@ for (;;)
|
|||
break;
|
||||
}
|
||||
GETCHARLEN(d, eptr, len);
|
||||
if (fc == d || (unsigned int)foc == d) break;
|
||||
if (fc == d || (uint32_t)foc == d) break;
|
||||
eptr += len;
|
||||
}
|
||||
if (possessive) continue; /* No backtracking */
|
||||
|
@ -5584,7 +5565,7 @@ for (;;)
|
|||
|
||||
case OP_ANYBYTE:
|
||||
c = max - min;
|
||||
if (c > (unsigned int)(mb->end_subject - eptr))
|
||||
if (c > (uint32_t)(mb->end_subject - eptr))
|
||||
{
|
||||
eptr = mb->end_subject;
|
||||
SCHECK_PARTIAL();
|
||||
|
@ -5803,7 +5784,7 @@ for (;;)
|
|||
case OP_ALLANY:
|
||||
case OP_ANYBYTE:
|
||||
c = max - min;
|
||||
if (c > (unsigned int)(mb->end_subject - eptr))
|
||||
if (c > (uint32_t)(mb->end_subject - eptr))
|
||||
{
|
||||
eptr = mb->end_subject;
|
||||
SCHECK_PARTIAL();
|
||||
|
@ -6109,8 +6090,7 @@ Undefine all the macros that were defined above to handle this. */
|
|||
#undef stacksave
|
||||
|
||||
#undef newptrb
|
||||
|
||||
#endif
|
||||
#endif /* NO_RECURSE */
|
||||
|
||||
/* These two are defined as macros in both cases */
|
||||
|
||||
|
@ -6129,46 +6109,28 @@ Undefine all the macros that were defined above to handle this. */
|
|||
/* This function releases all the allocated frames. The base frame is on the
|
||||
machine stack, and so must not be freed.
|
||||
|
||||
Argument: the address of the base frame
|
||||
Argument:
|
||||
frame_base the address of the base frame
|
||||
mb the match block
|
||||
|
||||
Returns: nothing
|
||||
*/
|
||||
|
||||
static void
|
||||
release_match_heapframes (heapframe *frame_base)
|
||||
release_match_heapframes (heapframe *frame_base, match_block *mb)
|
||||
{
|
||||
heapframe *nextframe = frame_base->Xnextframe;
|
||||
while (nextframe != NULL)
|
||||
{
|
||||
heapframe *oldframe = nextframe;
|
||||
nextframe = nextframe->Xnextframe;
|
||||
(PUBL(stack_free))(oldframe);
|
||||
mb->stack_memctl.free(oldframe, mb->stack_memctl.memory_data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* NO_RECURSE */
|
||||
|
||||
|
||||
|
||||
#ifdef FIXME
|
||||
|
||||
/* FIXME: This must be in a new function..... */
|
||||
|
||||
/* Check for the special magic call that measures the size of the stack used
|
||||
per recursive call of match(). Without the funny casting for sizeof, a Windows
|
||||
compiler gave this error: "unary minus operator applied to unsigned type,
|
||||
result still unsigned". Hopefully the cast fixes that. */
|
||||
|
||||
if (re == NULL && extra_data == NULL && subject == NULL && length == -999 &&
|
||||
start_offset == -999)
|
||||
#ifdef NO_RECURSE
|
||||
return -((int)sizeof(heapframe));
|
||||
#else
|
||||
return match(NULL, NULL, NULL, 0, NULL, NULL, 0);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FIXME */
|
||||
|
||||
|
||||
/*************************************************
|
||||
* Match a Regular Expression *
|
||||
*************************************************/
|
||||
|
@ -6195,7 +6157,7 @@ Returns: > 0 => success; value is the number of ovector pairs filled
|
|||
|
||||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_match(const pcre2_code *code, PCRE2_SPTR subject, int length,
|
||||
size_t start_offset, uint32_t options, pcre2_match_data *match_data,
|
||||
PCRE2_OFFSET start_offset, uint32_t options, pcre2_match_data *match_data,
|
||||
pcre2_match_context *mcontext)
|
||||
{
|
||||
int rc;
|
||||
|
@ -6207,7 +6169,6 @@ const uint8_t *start_bits = NULL;
|
|||
const pcre2_real_code *re = (const pcre2_real_code *)code;
|
||||
pcre2_match_context default_context; /* For use if no context given */
|
||||
|
||||
|
||||
BOOL anchored;
|
||||
BOOL firstline;
|
||||
BOOL has_first_cu = FALSE;
|
||||
|
@ -6227,7 +6188,7 @@ PCRE2_SPTR req_cu_ptr = start_match - 1;
|
|||
PCRE2_SPTR start_partial = NULL;
|
||||
PCRE2_SPTR match_partial = NULL;
|
||||
|
||||
/* We need to have mb pointing to a match block, because the IS_NEWLINE macro
|
||||
/* We need to have mb pointing to a match block, because the IS_NEWLINE macro
|
||||
is used below, and it expects NLBLOCK to be defined as a pointer. */
|
||||
|
||||
match_block actual_match_block;
|
||||
|
@ -6259,12 +6220,12 @@ means that the pattern is likely compiled with different endianness. */
|
|||
if (re->magic_number != MAGIC_NUMBER)
|
||||
return re->magic_number == REVERSED_MAGIC_NUMBER?
|
||||
PCRE2_ERROR_BADENDIANNESS:PCRE2_ERROR_BADMAGIC;
|
||||
|
||||
/* Check the code unit width. */
|
||||
|
||||
if ((re->flags & PCRE2_MODE_MASK) != PCRE2_CODE_UNIT_WIDTH/8)
|
||||
|
||||
/* Check the code unit width. */
|
||||
|
||||
if ((re->flags & PCRE2_MODE_MASK) != PCRE2_CODE_UNIT_WIDTH/8)
|
||||
return PCRE2_ERROR_BADMODE;
|
||||
|
||||
|
||||
/* A NULL match context means "use a default context" */
|
||||
|
||||
if (mcontext == NULL)
|
||||
|
@ -6282,8 +6243,8 @@ utf = (re->overall_options & PCRE2_UTF) != 0;
|
|||
mb->partial = ((options & PCRE2_PARTIAL_HARD) != 0)? 2 :
|
||||
((options & PCRE2_PARTIAL_SOFT) != 0)? 1 : 0;
|
||||
|
||||
/* Check a UTF string for validity if required. For 8-bit and 16-bit strings,
|
||||
we must also check that a starting offset does not point into the middle of a
|
||||
/* Check a UTF string for validity if required. For 8-bit and 16-bit strings,
|
||||
we must also check that a starting offset does not point into the middle of a
|
||||
multiunit character. */
|
||||
|
||||
#ifdef SUPPORT_UTF
|
||||
|
@ -6295,7 +6256,7 @@ if (utf && (options & PCRE2_NO_UTF_CHECK) == 0)
|
|||
match_data->leftchar = 0;
|
||||
return match_data->rc;
|
||||
}
|
||||
#if PCRE2_CODE_UNIT_WIDTH != 32
|
||||
#if PCRE2_CODE_UNIT_WIDTH != 32
|
||||
if (start_offset > 0 && (int)start_offset < length &&
|
||||
NOT_FIRSTCHAR(subject[start_offset]))
|
||||
return PCRE2_ERROR_BADUTFOFFSET;
|
||||
|
@ -6306,14 +6267,14 @@ if (utf && (options & PCRE2_NO_UTF_CHECK) == 0)
|
|||
/* If the pattern was successfully studied with JIT support, run the JIT
|
||||
executable instead of the rest of this function. Most options must be set at
|
||||
compile time for the JIT code to be usable. Fallback to the normal code path if
|
||||
an unsupported option is set or if JIT returns BADOPTION (which means that the
|
||||
an unsupported option is set or if JIT returns BADOPTION (which means that the
|
||||
selected normal or partial matching mode was not compiled). */
|
||||
|
||||
#ifdef SUPPORT_JIT
|
||||
if (re->executable_jit != NULL && (options & ~PUBLIC_JIT_EXEC_OPTIONS) == 0 &&
|
||||
mcontext->bsr_convention == 0 && mcontext->newline_convention == 0)
|
||||
{
|
||||
rc = PRIV(jit_exec)(subject, length, start_offset, options, match_data,
|
||||
rc = PRIV(jit_exec)(subject, length, start_offset, options, match_data,
|
||||
mcontext);
|
||||
if (rc != PCRE2_ERROR_JIT_BADOPTION) return rc;
|
||||
}
|
||||
|
@ -6326,18 +6287,24 @@ firstline = (re->overall_options & PCRE2_FIRSTLINE) != 0;
|
|||
startline = (re->flags & PCRE2_STARTLINE) != 0;
|
||||
|
||||
/* Fill in the fields in the match block. */
|
||||
|
||||
|
||||
if (mcontext == NULL)
|
||||
{
|
||||
mb->memctl = re->memctl;
|
||||
mb->callout = NULL;
|
||||
mb->memctl = re->memctl;
|
||||
#ifdef NO_RECURSE
|
||||
mb->stack_memctl = re->memctl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mb->memctl = mcontext->memctl;
|
||||
{
|
||||
mb->callout = mcontext->callout;
|
||||
mb->callout_data = mcontext->callout_data;
|
||||
}
|
||||
mb->memctl = mcontext->memctl;
|
||||
#ifdef NO_RECURSE
|
||||
mb->stack_memctl = mcontext->stack_memctl;
|
||||
#endif
|
||||
}
|
||||
|
||||
mb->start_subject = subject;
|
||||
mb->start_offset = start_offset;
|
||||
|
@ -6360,14 +6327,14 @@ mb->name_count = re->name_count;
|
|||
mb->name_entry_size = re->name_entry_size;
|
||||
mb->start_code = mb->name_table + re->name_count * re->name_entry_size;
|
||||
|
||||
/* Limits set in the pattern override the match context only if they are
|
||||
/* Limits set in the pattern override the match context only if they are
|
||||
smaller. */
|
||||
|
||||
mb->match_limit = (mcontext->match_limit < re->limit_match)?
|
||||
mcontext->match_limit : re->limit_match;
|
||||
mb->match_limit_recursion = (mcontext->recursion_limit > re->limit_recursion)?
|
||||
mcontext->recursion_limit : re->limit_recursion;
|
||||
|
||||
|
||||
/* Pointers to the individual character tables */
|
||||
|
||||
mb->lcc = re->tables + lcc_offset;
|
||||
|
@ -6413,26 +6380,26 @@ switch(newline)
|
|||
|
||||
default: return PCRE2_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
|
||||
/* If the expression has got more back references than the offsets supplied can
|
||||
hold, we get a temporary chunk of memory to use during the matching. Otherwise,
|
||||
we can use the vector supplied. The size of the ovector is three times the
|
||||
value in the oveccount field. Two-thirds of it is pairs for storing matching
|
||||
we can use the vector supplied. The size of the ovector is three times the
|
||||
value in the oveccount field. Two-thirds of it is pairs for storing matching
|
||||
offsets, and the top third is working space. */
|
||||
|
||||
if (re->top_backref >= match_data->oveccount)
|
||||
{
|
||||
ocount = re->top_backref * 3 + 3;
|
||||
mb->ovector = (size_t *)(mb->memctl.malloc(ocount * sizeof(size_t),
|
||||
mb->memctl.memory_data));
|
||||
mb->ovector = (PCRE2_OFFSET *)(mb->memctl.malloc(ocount * sizeof(PCRE2_OFFSET),
|
||||
mb->memctl.memory_data));
|
||||
if (mb->ovector == NULL) return PCRE2_ERROR_NOMEMORY;
|
||||
using_temporary_offsets = TRUE;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
ocount = 3 * match_data->oveccount;
|
||||
mb->ovector = match_data->ovector;
|
||||
}
|
||||
}
|
||||
|
||||
mb->offset_end = ocount;
|
||||
mb->offset_max = (2*ocount)/3;
|
||||
|
@ -6446,8 +6413,8 @@ in case they inspect these fields. */
|
|||
|
||||
if (ocount > 0)
|
||||
{
|
||||
register size_t *iptr = mb->ovector + ocount;
|
||||
register size_t *iend = iptr - re->top_bracket;
|
||||
register PCRE2_OFFSET *iptr = mb->ovector + ocount;
|
||||
register PCRE2_OFFSET *iend = iptr - re->top_bracket;
|
||||
if (iend < mb->ovector + 2) iend = mb->ovector + 2;
|
||||
while (--iptr >= iend) *iptr = PCRE2_UNSET;
|
||||
mb->ovector[0] = mb->ovector[1] = PCRE2_UNSET;
|
||||
|
@ -6514,13 +6481,13 @@ for(;;)
|
|||
if (((options | re->overall_options) & PCRE2_NO_START_OPTIMIZE) == 0)
|
||||
{
|
||||
PCRE2_SPTR save_end_subject = end_subject;
|
||||
|
||||
|
||||
/* If firstline is TRUE, the start of the match is constrained to the first
|
||||
line of a multiline string. That is, the match must be before or at the
|
||||
first newline. Implement this by temporarily adjusting end_subject so that
|
||||
we stop the optimization scans at a newline. If the match fails at the
|
||||
newline, later code breaks this loop. */
|
||||
|
||||
|
||||
if (firstline)
|
||||
{
|
||||
PCRE2_SPTR t = start_match;
|
||||
|
@ -6538,7 +6505,7 @@ for(;;)
|
|||
while (t < mb->end_subject && !IS_NEWLINE(t)) t++;
|
||||
end_subject = t;
|
||||
}
|
||||
|
||||
|
||||
/* Advance to a unique first code unit if there is one. */
|
||||
|
||||
if (has_first_cu)
|
||||
|
@ -6586,8 +6553,8 @@ for(;;)
|
|||
}
|
||||
}
|
||||
|
||||
/* Or to a non-unique first code unit if any have been identified. The
|
||||
bitmap contains only 256 bits. When code units are 16 or 32 bits wide, all
|
||||
/* Or to a non-unique first code unit if any have been identified. The
|
||||
bitmap contains only 256 bits. When code units are 16 or 32 bits wide, all
|
||||
code units greater than 254 set the 255 bit. */
|
||||
|
||||
else if (start_bits != NULL)
|
||||
|
@ -6615,13 +6582,13 @@ for(;;)
|
|||
length may actually match the pattern. Although the value is, strictly,
|
||||
in characters, we treat it as code units to avoid spending too much time
|
||||
in this optimization. */
|
||||
|
||||
|
||||
if (end_subject - start_match < re->minlength)
|
||||
{
|
||||
rc = MATCH_NOMATCH;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* If req_cu is set, we know that that code unit must appear in the
|
||||
subject for the match to succeed. If the first code unit is set, req_cu
|
||||
must be later in the subject; otherwise the test starts at the match
|
||||
|
@ -6629,20 +6596,20 @@ for(;;)
|
|||
patterns with nested unlimited repeats that aren't going to match.
|
||||
Writing separate code for cased/caseless versions makes it go faster, as
|
||||
does using an autoincrement and backing off on a match.
|
||||
|
||||
|
||||
HOWEVER: when the subject string is very, very long, searching to its end
|
||||
can take a long time, and give bad performance on quite ordinary
|
||||
patterns. This showed up when somebody was matching something like
|
||||
/^\d+C/ on a 32-megabyte string... so we don't do this when the string is
|
||||
sufficiently long. */
|
||||
|
||||
|
||||
if (has_req_cu && end_subject - start_match < REQ_CU_MAX)
|
||||
{
|
||||
register PCRE2_SPTR p = start_match + (has_first_cu? 1:0);
|
||||
|
||||
|
||||
/* We don't need to repeat the search if we haven't yet reached the
|
||||
place we found it at last time. */
|
||||
|
||||
|
||||
if (p > req_cu_ptr)
|
||||
{
|
||||
if (req_cu != req_cu2)
|
||||
|
@ -6660,25 +6627,25 @@ for(;;)
|
|||
if (UCHAR21INCTEST(p) == req_cu) { p--; break; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If we can't find the required code unit, break the matching loop,
|
||||
forcing a match failure. */
|
||||
|
||||
|
||||
if (p >= end_subject)
|
||||
{
|
||||
rc = MATCH_NOMATCH;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* If we have found the required code unit, save the point where we
|
||||
found it, so that we don't search again next time round the loop if
|
||||
the start hasn't passed this code unit yet. */
|
||||
|
||||
|
||||
req_cu_ptr = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------ End of start of match optimizations ------------ */
|
||||
|
||||
|
@ -6692,7 +6659,7 @@ for(;;)
|
|||
mb->end_offset_top = 0;
|
||||
mb->skip_arg_count = 0;
|
||||
rc = match(start_match, mb->start_code, start_match, 2, mb, NULL, 0);
|
||||
|
||||
|
||||
if (mb->hitend && start_partial == NULL)
|
||||
{
|
||||
start_partial = mb->start_used_ptr;
|
||||
|
@ -6804,15 +6771,15 @@ for(;;)
|
|||
(4) PCRE2_FIRSTLINE is set and we have failed to match at a newline, because
|
||||
this option requests that a match occur at or before the first newline in
|
||||
the subject.
|
||||
|
||||
(5) Some kind of error occurred.
|
||||
|
||||
*/
|
||||
(5) Some kind of error occurred.
|
||||
|
||||
*/
|
||||
|
||||
ENDLOOP:
|
||||
|
||||
#ifdef NO_RECURSE
|
||||
release_match_heapframes(&frame_zero);
|
||||
release_match_heapframes(&frame_zero, mb);
|
||||
#endif
|
||||
|
||||
/* Handle a fully successful match. */
|
||||
|
@ -6833,7 +6800,7 @@ if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
|
|||
if (arg_offset_max >= 4)
|
||||
{
|
||||
memcpy(match_data->ovector + 2, mb->ovector + 2,
|
||||
(arg_offset_max - 2) * sizeof(size_t));
|
||||
(arg_offset_max - 2) * sizeof(PCRE2_OFFSET));
|
||||
}
|
||||
if (mb->end_offset_top > arg_offset_max) mb->capture_last |= OVFLBIT;
|
||||
mb->memctl.free(mb->ovector, mb->memctl.memory_data);
|
||||
|
@ -6857,7 +6824,7 @@ if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
|
|||
|
||||
if (mb->end_offset_top/2 <= re->top_bracket)
|
||||
{
|
||||
register size_t *iptr, *iend;
|
||||
register PCRE2_OFFSET *iptr, *iend;
|
||||
int resetcount = re->top_bracket + 1;
|
||||
if (resetcount > match_data->oveccount) resetcount = match_data->oveccount;
|
||||
iptr = match_data->ovector + mb->end_offset_top;
|
||||
|
@ -6876,12 +6843,12 @@ if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
|
|||
}
|
||||
|
||||
/* Fill in the remaining fields that are returned in the match data. */
|
||||
|
||||
|
||||
match_data->code = re;
|
||||
match_data->subject = subject;
|
||||
match_data->leftchar = mb->start_used_ptr - subject;
|
||||
match_data->rightchar = 0; /* FIXME */
|
||||
match_data->startchar = start_match - subject;
|
||||
match_data->startchar = start_match - subject;
|
||||
match_data->mark = mb->mark;
|
||||
return match_data->rc;
|
||||
}
|
||||
|
@ -6892,7 +6859,7 @@ anything other than nomatch or partial match, just return the code. */
|
|||
|
||||
if (rc != MATCH_NOMATCH && rc != PCRE2_ERROR_PARTIAL)
|
||||
match_data->rc = rc;
|
||||
|
||||
|
||||
/* Handle a partial match. */
|
||||
|
||||
else if (match_partial != NULL)
|
||||
|
@ -6902,7 +6869,7 @@ else if (match_partial != NULL)
|
|||
match_data->ovector[0] = match_partial - subject;
|
||||
match_data->ovector[1] = end_subject - subject;
|
||||
}
|
||||
match_data->leftchar = start_partial - subject;
|
||||
match_data->leftchar = start_partial - subject;
|
||||
match_data->rc = PCRE2_ERROR_PARTIAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,10 +52,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
|
||||
pcre2_match_data_create(size_t oveccount, pcre2_general_context *gcontext)
|
||||
pcre2_match_data_create(uint32_t oveccount, pcre2_general_context *gcontext)
|
||||
{
|
||||
pcre2_match_data *yield = PRIV(memctl_malloc)(
|
||||
sizeof(pcre2_match_data) + 3*oveccount*sizeof(size_t),
|
||||
sizeof(pcre2_match_data) + 3*oveccount*sizeof(PCRE2_OFFSET),
|
||||
offsetof(pcre2_real_match_data, memctl), &(gcontext->memctl));
|
||||
yield->oveccount = oveccount;
|
||||
return yield;
|
||||
|
@ -94,7 +94,7 @@ if (match_data != NULL)
|
|||
* Get left-most code unit in match *
|
||||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
|
||||
PCRE2_EXP_DEFN PCRE2_OFFSET PCRE2_CALL_CONVENTION
|
||||
pcre2_get_leftchar(pcre2_match_data *match_data)
|
||||
{
|
||||
return match_data->leftchar;
|
||||
|
@ -118,7 +118,7 @@ return match_data->mark;
|
|||
* Get pointer to ovector *
|
||||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN size_t * PCRE2_CALL_CONVENTION
|
||||
PCRE2_EXP_DEFN PCRE2_OFFSET * PCRE2_CALL_CONVENTION
|
||||
pcre2_get_ovector_pointer(pcre2_match_data *match_data)
|
||||
{
|
||||
return match_data->ovector;
|
||||
|
@ -130,7 +130,7 @@ return match_data->ovector;
|
|||
* Get number of ovector slots *
|
||||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
|
||||
PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
|
||||
pcre2_get_ovector_count(pcre2_match_data *match_data)
|
||||
{
|
||||
return match_data->oveccount;
|
||||
|
@ -142,7 +142,7 @@ return match_data->oveccount;
|
|||
* Get right-most code unit in match *
|
||||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
|
||||
PCRE2_EXP_DEFN PCRE2_OFFSET PCRE2_CALL_CONVENTION
|
||||
pcre2_get_rightchar(pcre2_match_data *match_data)
|
||||
{
|
||||
return match_data->rightchar;
|
||||
|
@ -154,7 +154,7 @@ return match_data->rightchar;
|
|||
* Get starting code unit in match *
|
||||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN size_t PCRE2_CALL_CONVENTION
|
||||
PCRE2_EXP_DEFN PCRE2_OFFSET PCRE2_CALL_CONVENTION
|
||||
pcre2_get_startchar(pcre2_match_data *match_data)
|
||||
{
|
||||
return match_data->startchar;
|
||||
|
|
|
@ -282,7 +282,7 @@ pcre2_printint(pcre2_code *re, FILE *f, BOOL print_lengths)
|
|||
{
|
||||
PCRE2_SPTR codestart, nametable, code;
|
||||
uint32_t options = re->compile_options;
|
||||
size_t nesize = re->name_entry_size;
|
||||
uint32_t nesize = re->name_entry_size;
|
||||
BOOL utf = (options & PCRE2_UTF) != 0;
|
||||
|
||||
nametable = (PCRE2_SPTR)((uint8_t *)re + sizeof(pcre2_real_code));
|
||||
|
|
|
@ -768,7 +768,7 @@ do
|
|||
while (try_next) /* Loop for items in this branch */
|
||||
{
|
||||
int rc;
|
||||
uint8_t *classmap;
|
||||
uint8_t *classmap = NULL;
|
||||
|
||||
switch(*tcode)
|
||||
{
|
||||
|
|
|
@ -322,10 +322,11 @@ pcre2_substring_list_get(pcre2_match_data *match_data, PCRE2_UCHAR ***listptr,
|
|||
{
|
||||
int i, count, count2;
|
||||
size_t size;
|
||||
size_t *lensp, *ovector;
|
||||
size_t *lensp;
|
||||
pcre2_memctl *memp;
|
||||
PCRE2_UCHAR **listp;
|
||||
PCRE2_UCHAR *sp;
|
||||
PCRE2_OFFSET *ovector;
|
||||
|
||||
if ((count = match_data->rc) < 0) return count;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ strings. */
|
|||
/* This function should never be called when UTF is not supported. */
|
||||
|
||||
int
|
||||
PRIV(valid_utf)(PCRE2_SPTR string, int length, size_t *erroroffset)
|
||||
PRIV(valid_utf)(PCRE2_SPTR string, int length, PCRE2_OFFSET *erroroffset)
|
||||
{
|
||||
(void)string;
|
||||
(void)length;
|
||||
|
@ -89,7 +89,7 @@ Returns: == 0 if the string is a valid UTF string
|
|||
*/
|
||||
|
||||
int
|
||||
PRIV(valid_utf)(PCRE2_SPTR string, int length, size_t *erroroffset)
|
||||
PRIV(valid_utf)(PCRE2_SPTR string, int length, PCRE2_OFFSET *erroroffset)
|
||||
{
|
||||
register PCRE2_SPTR p;
|
||||
register uint32_t c;
|
||||
|
|
|
@ -77,10 +77,10 @@ int utf8;
|
|||
uint32_t option_bits;
|
||||
uint32_t newline;
|
||||
|
||||
size_t erroroffset;
|
||||
size_t *ovector;
|
||||
size_t subject_length;
|
||||
PCRE2_OFFSET erroroffset;
|
||||
PCRE2_OFFSET *ovector;
|
||||
|
||||
size_t subject_length;
|
||||
pcre2_match_data *match_data;
|
||||
|
||||
|
||||
|
@ -313,8 +313,8 @@ crlf_is_newline = newline == PCRE2_NEWLINE_ANY ||
|
|||
|
||||
for (;;)
|
||||
{
|
||||
uint32_t options = 0; /* Normally no options */
|
||||
size_t start_offset = ovector[1]; /* Start at end of previous match */
|
||||
uint32_t options = 0; /* Normally no options */
|
||||
PCRE2_OFFSET start_offset = ovector[1]; /* Start at end of previous match */
|
||||
|
||||
/* If the previous match was for an empty string, we are finished if we are
|
||||
at the end of the subject. Otherwise, arrange to run another match at the
|
||||
|
|
|
@ -205,7 +205,7 @@ Returns: 0 on success
|
|||
PCRE2POSIX_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
regcomp(regex_t *preg, const char *pattern, int cflags)
|
||||
{
|
||||
size_t erroffset;
|
||||
PCRE2_OFFSET erroffset;
|
||||
int errorcode;
|
||||
int options = 0;
|
||||
int re_nsub = 0;
|
||||
|
|
140
src/pcre2test.c
140
src/pcre2test.c
|
@ -45,8 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
/* FIXME: These are the as-yet-unimplemented features:
|
||||
. save code and #load
|
||||
. JIT - compile, time, verify
|
||||
. find match limit
|
||||
. show stack frame size
|
||||
. memory handling testing
|
||||
. stackguard testing
|
||||
*/
|
||||
|
@ -317,7 +315,7 @@ enum { MOD_CTB, /* Applies to a compile or a match context */
|
|||
MOD_CTL, /* Is a control bit */
|
||||
MOD_BSR, /* Is a BSR value */
|
||||
MOD_IN2, /* Is one or two unsigned integers */
|
||||
MOD_INS, /* Is a signed integer */
|
||||
MOD_INS, /* Is a signed integer */
|
||||
MOD_INT, /* Is an unsigned integer */
|
||||
MOD_IND, /* Is an unsigned integer, but no value => default */
|
||||
MOD_NL, /* Is a newline value */
|
||||
|
@ -377,7 +375,7 @@ typedef struct datctl { /* Structure for data line modifiers. */
|
|||
uint32_t options; /* Must be in same position as patctl */
|
||||
uint32_t control; /* Must be in same position as patctl */
|
||||
uint32_t cfail[2];
|
||||
int32_t callout_data;
|
||||
int32_t callout_data;
|
||||
int32_t copy_numbers[MAXCPYGET];
|
||||
int32_t get_numbers[MAXCPYGET];
|
||||
uint32_t jitstack;
|
||||
|
@ -407,11 +405,11 @@ enum { CTX_PAT, /* Active pattern context */
|
|||
name because it is searched by binary chop. */
|
||||
|
||||
typedef struct modstruct {
|
||||
const char *name;
|
||||
uint16_t which;
|
||||
uint16_t type;
|
||||
uint32_t value;
|
||||
size_t offset;
|
||||
const char *name;
|
||||
uint16_t which;
|
||||
uint16_t type;
|
||||
uint32_t value;
|
||||
PCRE2_OFFSET offset;
|
||||
} modstruct;
|
||||
|
||||
static modstruct modlist[] = {
|
||||
|
@ -847,7 +845,7 @@ are supported. */
|
|||
else if (test_mode == PCRE16_MODE) \
|
||||
pcre2_set_recursion_limit_16(G(a,16),b); \
|
||||
else \
|
||||
pcre2_set_match_limit_32(G(a,32),b)
|
||||
pcre2_set_recursion_limit_32(G(a,32),b)
|
||||
|
||||
#define PCRE2_SUBSTRING_COPY_BYNAME(a,b,c,d,e) \
|
||||
if (test_mode == PCRE8_MODE) \
|
||||
|
@ -1016,9 +1014,9 @@ the three different cases. */
|
|||
|
||||
#define PCHARS(lv, p, offset, len, utf, f) \
|
||||
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
||||
lv = G(pchars,BITONE)(p, offset, len, utf, f); \
|
||||
lv = G(pchars,BITONE)((G(PCRE2_SPTR,BITONE))(p)+offset, len, utf, f); \
|
||||
else \
|
||||
lv = G(PCHARS,BITTWO)(p, offset, len, utf, f)
|
||||
lv = G(PCHARS,BITTWO)((G(PCRE2_SPTR,BITTWO))(p)+offset, len, utf, f)
|
||||
|
||||
#define PCHARSV(p, offset, len, utf, f) \
|
||||
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
||||
|
@ -1229,7 +1227,7 @@ the three different cases. */
|
|||
#define FLD(a,b) G(a,8)->b
|
||||
#define PATCTXCPY(a,b) memcpy(G(a,8),G(b,8),sizeof(pcre2_compile_context_8))
|
||||
#define PCHARS(lv, p, offset, len, utf, f) \
|
||||
lv = pchars8(p, offset, len, utf, f)
|
||||
lv = pchars8((PCRE2_SPTR8)(p)+offset, len, utf, f)
|
||||
#define PCHARSV(p, offset, len, utf, f) \
|
||||
(void)pchars8((PCRE2_SPTR8)(p)+offset, len, utf, f)
|
||||
#define PCRE2_COMPILE(a,b,c,d,e,f,g) \
|
||||
|
@ -1286,7 +1284,7 @@ the three different cases. */
|
|||
#define FLD(a,b) G(a,16)->b
|
||||
#define PATCTXCPY(a,b) memcpy(G(a,16),G(b,16),sizeof(pcre2_compile_context_16))
|
||||
#define PCHARS(lv, p, offset, len, utf, f) \
|
||||
lv = pchars16(p, offset, len, utf, f)
|
||||
lv = pchars16((PCRE2_SPTR16)(p)+offset, len, utf, f)
|
||||
#define PCHARSV(p, offset, len, utf, f) \
|
||||
(void)pchars16((PCRE2_SPTR16)(p)+offset, len, utf, f)
|
||||
#define PCRE2_COMPILE(a,b,c,d,e,f,g) \
|
||||
|
@ -1343,7 +1341,7 @@ the three different cases. */
|
|||
#define FLD(a,b) G(a,32)->b
|
||||
#define PATCTXCPY(a,b) memcpy(G(a,32),G(b,32),sizeof(pcre2_compile_context_32))
|
||||
#define PCHARS(lv, p, offset, len, utf, f) \
|
||||
lv = pchars32(p, offset, len, utf, f)
|
||||
lv = pchars32((PCRE2_SPTR32)(p)+offset, len, utf, f)
|
||||
#define PCHARSV(p, offset, len, utf, f) \
|
||||
(void)pchars32((PCRE2_SPTR32)(p)+offset, len, utf, f)
|
||||
#define PCRE2_COMPILE(a,b,c,d,e,f,g) \
|
||||
|
@ -1748,23 +1746,24 @@ free(block);
|
|||
|
||||
/* For recursion malloc/free, to test stacking calls */
|
||||
|
||||
#ifdef FIXME
|
||||
static void *stack_malloc(size_t size)
|
||||
#ifdef NO_RECURSE
|
||||
static void *my_stack_malloc(size_t size, void *data)
|
||||
{
|
||||
void *block = malloc(size);
|
||||
(void)data;
|
||||
if (show_memory)
|
||||
fprintf(outfile, "stack_malloc %3d %p\n", (int)size, block);
|
||||
return block;
|
||||
}
|
||||
|
||||
static void stack_free(void *block)
|
||||
static void my_stack_free(void *block, void *data)
|
||||
{
|
||||
(void)data;
|
||||
if (show_memory)
|
||||
fprintf(outfile, "stack_free %p\n", block);
|
||||
free(block);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NO_RECURSE */
|
||||
|
||||
|
||||
/*************************************************
|
||||
|
@ -1834,7 +1833,7 @@ return i+1;
|
|||
* Print one character *
|
||||
*************************************************/
|
||||
|
||||
/* Print a single character either literally, or as a hex escape, and count how
|
||||
/* Print a single character either literally, or as a hex escape, and count how
|
||||
many printed characters are used.
|
||||
|
||||
Arguments:
|
||||
|
@ -2383,7 +2382,7 @@ static void *
|
|||
check_modifier(modstruct *m, int ctx, patctl *pctl, datctl *dctl, uint32_t c)
|
||||
{
|
||||
void *field = NULL;
|
||||
size_t offset = m->offset;
|
||||
PCRE2_OFFSET offset = m->offset;
|
||||
|
||||
if (restrict_for_perl_test) switch(m->which)
|
||||
{
|
||||
|
@ -2409,7 +2408,7 @@ switch (m->which)
|
|||
/* Fall through for something that can also be in a match context. In this
|
||||
case the offset is taken from the other field. */
|
||||
|
||||
offset = (size_t)(m->value);
|
||||
offset = (PCRE2_OFFSET)(m->value);
|
||||
|
||||
case MOD_CTM: /* Match context modifier */
|
||||
if (ctx == CTX_DEFDAT || ctx == CTX_DEFANY) field = PTR(default_dat_context);
|
||||
|
@ -3373,7 +3372,7 @@ uint8_t *p = buffer;
|
|||
const uint8_t *use_tables;
|
||||
unsigned int delimiter = *p++;
|
||||
int patlen, errorcode;
|
||||
size_t erroroffset;
|
||||
PCRE2_OFFSET erroroffset;
|
||||
|
||||
/* Initialize the context and pattern/data controls for this test from the
|
||||
defaults. */
|
||||
|
@ -3761,18 +3760,21 @@ uint32_t min = 0;
|
|||
uint32_t mid = 64;
|
||||
uint32_t max = UINT32_MAX;
|
||||
|
||||
PCRE2_SET_MATCH_LIMIT(dat_context, max);
|
||||
PCRE2_SET_RECURSION_LIMIT(dat_context, max);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (errnumber == PCRE2_ERROR_MATCHLIMIT)
|
||||
{
|
||||
{
|
||||
PCRE2_SET_MATCH_LIMIT(dat_context, mid);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
PCRE2_SET_RECURSION_LIMIT(dat_context, mid);
|
||||
}
|
||||
}
|
||||
|
||||
PCRE2_MATCH(capcount, compiled_code, pp, ulen, dat_datctl.offset,
|
||||
PCRE2_MATCH(capcount, compiled_code, pp, ulen, dat_datctl.offset,
|
||||
dat_datctl.options, match_data, dat_context);
|
||||
|
||||
if (capcount == errnumber)
|
||||
|
@ -3781,13 +3783,13 @@ for (;;)
|
|||
mid = (mid == max - 1)? max : (max != UINT32_MAX)? (min + max)/2 : mid*2;
|
||||
}
|
||||
|
||||
else if (capcount >= 0 ||
|
||||
else if (capcount >= 0 ||
|
||||
capcount == PCRE2_ERROR_NOMATCH ||
|
||||
capcount == PCRE2_ERROR_PARTIAL)
|
||||
{
|
||||
if (mid == min + 1)
|
||||
{
|
||||
if (capcount != PCRE2_ERROR_NOMATCH)
|
||||
if (capcount != PCRE2_ERROR_NOMATCH)
|
||||
fprintf(outfile, "Minimum %s limit = %d\n", msg, mid);
|
||||
break;
|
||||
}
|
||||
|
@ -3823,7 +3825,7 @@ uint32_t i, pre_start, post_start, subject_length;
|
|||
BOOL utf = (FLD(compiled_code, compile_options) & PCRE2_UTF) != 0;
|
||||
BOOL callout_capture = (dat_datctl.control & CTL_CALLOUT_CAPTURE) != 0;
|
||||
FILE *f = (first_callout || callout_capture)? outfile : NULL;
|
||||
|
||||
|
||||
if (callout_capture)
|
||||
{
|
||||
fprintf(f, "Callout %d: last capture = %d\n",
|
||||
|
@ -3887,7 +3889,7 @@ if (post_start > 0)
|
|||
for (i = 0; i < subject_length - pre_start - post_start + 4; i++)
|
||||
fprintf(outfile, " ");
|
||||
|
||||
fprintf(outfile, "%.*s",
|
||||
fprintf(outfile, "%.*s",
|
||||
(int)((cb->next_item_length == 0)? 1 : cb->next_item_length),
|
||||
pbuffer8 + cb->pattern_position);
|
||||
|
||||
|
@ -3906,7 +3908,7 @@ if (cb->mark != last_callout_mark)
|
|||
}
|
||||
last_callout_mark = cb->mark;
|
||||
}
|
||||
|
||||
|
||||
if (cb->callout_data != NULL)
|
||||
{
|
||||
int callout_data = *((int32_t *)(cb->callout_data));
|
||||
|
@ -3948,13 +3950,13 @@ size_t needlen;
|
|||
BOOL utf;
|
||||
|
||||
#ifdef SUPPORT_PCRE8
|
||||
uint8_t *q8;
|
||||
uint8_t *q8 = NULL;
|
||||
#endif
|
||||
#ifdef SUPPORT_PCRE16
|
||||
uint16_t *q16;
|
||||
uint16_t *q16 = NULL;
|
||||
#endif
|
||||
#ifdef SUPPORT_PCRE32
|
||||
uint32_t *q32;
|
||||
uint32_t *q32 = NULL;
|
||||
#endif
|
||||
|
||||
/* Copy the default context and data control blocks to the active ones. Then
|
||||
|
@ -4378,10 +4380,10 @@ if ((dat_datctl.control & CTL_ANYGLOB) != 0 && dat_datctl.oveccount < 1)
|
|||
printf("** Global matching requires a non-zero ovector count: ignored\n");
|
||||
dat_datctl.control &= ~CTL_ANYGLOB;
|
||||
}
|
||||
|
||||
/* Enable display of malloc/free if wanted. */
|
||||
|
||||
show_memory = (dat_datctl.control & CTL_MEMORY) != 0;
|
||||
|
||||
/* Enable display of malloc/free if wanted. */
|
||||
|
||||
show_memory = (dat_datctl.control & CTL_MEMORY) != 0;
|
||||
|
||||
/* Ensure that there is a JIT callback if we want to verify that JIT was
|
||||
actually used. If jit_stack == NULL, no stack has yet been assigned. */
|
||||
|
@ -4465,27 +4467,27 @@ set in the datctl block.
|
|||
capcount = check_match_limit(pp, ulen, PCRE2_ERROR_RECURSIONLIMIT,
|
||||
"recursion");
|
||||
}
|
||||
|
||||
/* Otherwise just run a single match, setting up a callout if required (the
|
||||
|
||||
/* Otherwise just run a single match, setting up a callout if required (the
|
||||
default). */
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
{
|
||||
if ((dat_datctl.control & CTL_CALLOUT_NONE) == 0)
|
||||
{
|
||||
PCRE2_SET_CALLOUT(dat_context, callout_function,
|
||||
PCRE2_SET_CALLOUT(dat_context, callout_function,
|
||||
(void *)(&dat_datctl.callout_data));
|
||||
first_callout = TRUE;
|
||||
last_callout_mark = NULL;
|
||||
callout_count = 0;
|
||||
callout_count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PCRE2_SET_CALLOUT(dat_context, NULL, NULL); /* No callout */
|
||||
}
|
||||
|
||||
|
||||
/* Run a single DFA or NFA match. */
|
||||
|
||||
|
||||
if ((dat_datctl.control & CTL_DFA) != 0)
|
||||
{
|
||||
if (dfa_workspace == NULL)
|
||||
|
@ -4511,7 +4513,7 @@ set in the datctl block.
|
|||
capcount = dat_datctl.oveccount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The result of the match is in now capcount. First handle a successful
|
||||
match. */
|
||||
|
@ -4520,7 +4522,7 @@ set in the datctl block.
|
|||
{
|
||||
int i;
|
||||
uint8_t *nptr;
|
||||
size_t *ovector;
|
||||
PCRE2_OFFSET *ovector;
|
||||
|
||||
/* This is a check against a lunatic return value. */
|
||||
|
||||
|
@ -4555,8 +4557,8 @@ set in the datctl block.
|
|||
ovector = FLD(match_data, ovector);
|
||||
for (i = 0; i < 2*capcount; i += 2)
|
||||
{
|
||||
size_t start = ovector[i];
|
||||
size_t end = ovector[i+1];
|
||||
PCRE2_OFFSET start = ovector[i];
|
||||
PCRE2_OFFSET end = ovector[i+1];
|
||||
|
||||
if (start > end)
|
||||
{
|
||||
|
@ -4738,7 +4740,7 @@ set in the datctl block.
|
|||
|
||||
else if (capcount == PCRE2_ERROR_PARTIAL)
|
||||
{
|
||||
size_t leftchar = FLD(match_data, leftchar);
|
||||
PCRE2_OFFSET leftchar = FLD(match_data, leftchar);
|
||||
|
||||
fprintf(outfile, "Partial match");
|
||||
if (leftchar != FLD(match_data, startchar))
|
||||
|
@ -4781,8 +4783,8 @@ set in the datctl block.
|
|||
else if (g_notempty != 0) /* There was a previous null match */
|
||||
{
|
||||
uint16_t nl = FLD(compiled_code, newline_convention);
|
||||
size_t start_offset = dat_datctl.offset; /* Where the match was */
|
||||
size_t end_offset = start_offset + 1;
|
||||
PCRE2_OFFSET start_offset = dat_datctl.offset; /* Where the match was */
|
||||
PCRE2_OFFSET end_offset = start_offset + 1;
|
||||
|
||||
if ((nl == PCRE2_NEWLINE_CRLF || nl == PCRE2_NEWLINE_ANY ||
|
||||
nl == PCRE2_NEWLINE_ANYCRLF) &&
|
||||
|
@ -4857,7 +4859,7 @@ set in the datctl block.
|
|||
|
||||
if ((dat_datctl.control & CTL_ANYGLOB) == 0) break; else
|
||||
{
|
||||
size_t end_offset = FLD(match_data, ovector)[1];
|
||||
PCRE2_OFFSET end_offset = FLD(match_data, ovector)[1];
|
||||
|
||||
/* We must now set up for the next iteration of a global search. If we have
|
||||
matched an empty string, first check to see if we are at the end of the
|
||||
|
@ -5069,7 +5071,7 @@ if (arg != NULL)
|
|||
/* No argument for -C: output all configuration information. */
|
||||
|
||||
print_version(stdout);
|
||||
printf("\nCompiled with\n");
|
||||
printf("Compiled with\n");
|
||||
|
||||
#ifdef EBCDIC
|
||||
printf(" EBCDIC code support: LF is 0x%02x\n", CHAR_LF);
|
||||
|
@ -5117,14 +5119,6 @@ printf(" Default recursion depth limit = %ld\n", lrc);
|
|||
(void)PCRE2_CONFIG(PCRE2_CONFIG_STACKRECURSE, &rc, sizeof(rc));
|
||||
printf(" Match recursion uses %s", rc? "stack" : "heap");
|
||||
|
||||
#ifdef FIXME
|
||||
if (showstore)
|
||||
{
|
||||
PCRE_EXEC(stack_size, NULL, NULL, NULL, -999, -999, 0, NULL, 0);
|
||||
printf(": %sframe size = %d bytes", rc? "approximate " : "", -stack_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -5361,32 +5355,44 @@ if (test_mode == PCRE8_MODE)
|
|||
default_dat_context8 = pcre2_match_context_create_8(general_context8);
|
||||
dat_context8 = pcre2_match_context_create_8(general_context8);
|
||||
match_data8 = pcre2_match_data_create_8(max_oveccount, general_context8);
|
||||
#ifdef NO_RECURSE
|
||||
(void)pcre2_set_recursion_memory_management_8(default_dat_context8,
|
||||
&my_stack_malloc, &my_stack_free, NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_PCRE16
|
||||
if (test_mode == PCRE16_MODE)
|
||||
{
|
||||
general_context16 = pcre2_general_context_create_16(&my_malloc, &my_free,
|
||||
general_context16 = pcre2_general_context_create_16(&my_malloc, &my_free,
|
||||
NULL);
|
||||
default_pat_context16 = pcre2_compile_context_create_16(general_context16);
|
||||
pat_context16 = pcre2_compile_context_create_16(general_context16);
|
||||
default_dat_context16 = pcre2_match_context_create_16(general_context16);
|
||||
dat_context16 = pcre2_match_context_create_16(general_context16);
|
||||
match_data16 = pcre2_match_data_create_16(max_oveccount, general_context16);
|
||||
#ifdef NO_RECURSE
|
||||
(void)pcre2_set_recursion_memory_management_16(default_dat_context16,
|
||||
&my_stack_malloc, &my_stack_free, NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_PCRE32
|
||||
if (test_mode == PCRE32_MODE)
|
||||
{
|
||||
general_context32 = pcre2_general_context_create_32(&my_malloc, &my_free,
|
||||
general_context32 = pcre2_general_context_create_32(&my_malloc, &my_free,
|
||||
NULL);
|
||||
default_pat_context32 = pcre2_compile_context_create_32(general_context32);
|
||||
pat_context32 = pcre2_compile_context_create_32(general_context32);
|
||||
default_dat_context32 = pcre2_match_context_create_32(general_context32);
|
||||
dat_context32 = pcre2_match_context_create_32(general_context32);
|
||||
match_data32 = pcre2_match_data_create_32(max_oveccount, general_context32);
|
||||
#ifdef NO_RECURSE
|
||||
(void)pcre2_set_recursion_memory_management_32(default_dat_context32,
|
||||
&my_stack_malloc, &my_stack_free, NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue