version 1.1.1.3, 2012/10/09 09:19:17
|
version 1.1.1.4, 2013/07/22 08:25:55
|
Line 36 POSSIBILITY OF SUCH DAMAGE.
|
Line 36 POSSIBILITY OF SUCH DAMAGE.
|
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
*/ |
*/ |
|
|
/* This program now supports the testing of both the 8-bit and 16-bit PCRE | /* This program now supports the testing of all of the 8-bit, 16-bit, and |
libraries in a single program. This is different from the modules such as | 32-bit PCRE libraries in a single program. This is different from the modules |
pcre_compile.c in the library itself, which are compiled separately for each | such as pcre_compile.c in the library itself, which are compiled separately for |
mode. If both modes are enabled, for example, pcre_compile.c is compiled twice | each mode. If two modes are enabled, for example, pcre_compile.c is compiled |
(the second time with COMPILE_PCRE16 defined). By contrast, pcretest.c is | twice. By contrast, pcretest.c is compiled only once. Therefore, it must not |
compiled only once. Therefore, it must not make use of any of the macros from | make use of any of the macros from pcre_internal.h that depend on |
pcre_internal.h that depend on COMPILE_PCRE8 or COMPILE_PCRE16. It does, | COMPILE_PCRE8, COMPILE_PCRE16, or COMPILE_PCRE32. It does, however, make use of |
however, make use of SUPPORT_PCRE8 and SUPPORT_PCRE16 to ensure that it calls | SUPPORT_PCRE8, SUPPORT_PCRE16, and SUPPORT_PCRE32 to ensure that it calls only |
only supported library functions. */ | supported library functions. */ |
|
|
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
#include "config.h" |
#include "config.h" |
Line 112 input mode under Windows. */
|
Line 112 input mode under Windows. */
|
#else |
#else |
#include <sys/time.h> /* These two includes are needed */ |
#include <sys/time.h> /* These two includes are needed */ |
#include <sys/resource.h> /* for setrlimit(). */ |
#include <sys/resource.h> /* for setrlimit(). */ |
|
#if defined NATIVE_ZOS /* z/OS uses non-binary I/O */ |
|
#define INPUT_MODE "r" |
|
#define OUTPUT_MODE "w" |
|
#else |
#define INPUT_MODE "rb" |
#define INPUT_MODE "rb" |
#define OUTPUT_MODE "wb" |
#define OUTPUT_MODE "wb" |
#endif |
#endif |
|
#endif |
|
|
|
#ifdef __VMS |
|
#include <ssdef.h> |
|
void vms_setsymbol( char *, char *, int ); |
|
#endif |
|
|
|
|
#define PRIV(name) name |
#define PRIV(name) name |
|
|
/* We have to include pcre_internal.h because we need the internal info for |
/* We have to include pcre_internal.h because we need the internal info for |
Line 128 here before pcre_internal.h so that the PCRE_EXP_xxx m
|
Line 139 here before pcre_internal.h so that the PCRE_EXP_xxx m
|
appropriately for an application, not for building PCRE. */ |
appropriately for an application, not for building PCRE. */ |
|
|
#include "pcre.h" |
#include "pcre.h" |
|
|
#if defined SUPPORT_PCRE16 && !defined SUPPORT_PCRE8 |
|
/* Configure internal macros to 16 bit mode. */ |
|
#define COMPILE_PCRE16 |
|
#endif |
|
|
|
#include "pcre_internal.h" |
#include "pcre_internal.h" |
|
|
/* The pcre_printint() function, which prints the internal form of a compiled |
/* The pcre_printint() function, which prints the internal form of a compiled |
regex, is held in a separate file so that (a) it can be compiled in either |
regex, is held in a separate file so that (a) it can be compiled in either |
8-bit or 16-bit mode, and (b) it can be #included directly in pcre_compile.c | 8-, 16- or 32-bit mode, and (b) it can be #included directly in pcre_compile.c |
when that is compiled in debug mode. */ |
when that is compiled in debug mode. */ |
|
|
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
Line 147 void pcre_printint(pcre *external_re, FILE *f, BOOL pr
|
Line 152 void pcre_printint(pcre *external_re, FILE *f, BOOL pr
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths); |
void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths); |
#endif |
#endif |
|
#ifdef SUPPORT_PCRE32 |
|
void pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths); |
|
#endif |
|
|
/* We need access to some of the data tables that PCRE uses. So as not to have |
/* We need access to some of the data tables that PCRE uses. So as not to have |
to keep two copies, we include the source file here, changing the names of the | to keep two copies, we include the source files here, changing the names of the |
external symbols to prevent clashes. */ |
external symbols to prevent clashes. */ |
|
|
#define PCRE_INCLUDED |
#define PCRE_INCLUDED |
|
|
#include "pcre_tables.c" |
#include "pcre_tables.c" |
|
#include "pcre_ucd.c" |
|
|
/* The definition of the macro PRINTABLE, which determines whether to print an |
/* The definition of the macro PRINTABLE, which determines whether to print an |
output character as-is or as a hex value when showing compiled patterns, is |
output character as-is or as a hex value when showing compiled patterns, is |
Line 170 that differ in their output from isprint() even in the
|
Line 179 that differ in their output from isprint() even in the
|
|
|
#define PRINTOK(c) (locale_set? isprint(c) : PRINTABLE(c)) |
#define PRINTOK(c) (locale_set? isprint(c) : PRINTABLE(c)) |
|
|
/* Posix support is disabled in 16 bit only mode. */ | /* Posix support is disabled in 16 or 32 bit only mode. */ |
#if defined SUPPORT_PCRE16 && !defined SUPPORT_PCRE8 && !defined NOPOSIX | #if !defined SUPPORT_PCRE8 && !defined NOPOSIX |
#define NOPOSIX |
#define NOPOSIX |
#endif |
#endif |
|
|
Line 194 automatically cut out the UTF support if PCRE is built
|
Line 203 automatically cut out the UTF support if PCRE is built
|
#endif |
#endif |
#endif |
#endif |
|
|
/* To make the code a bit tidier for 8-bit and 16-bit support, we define macros | /* To make the code a bit tidier for 8/16/32-bit support, we define macros |
for all the pcre[16]_xxx functions (except pcre16_fullinfo, which is called |
for all the pcre[16]_xxx functions (except pcre16_fullinfo, which is called |
only from one place and is handled differently). I couldn't dream up any way of |
only from one place and is handled differently). I couldn't dream up any way of |
using a single macro to do this in a generic way, because of the many different |
using a single macro to do this in a generic way, because of the many different |
Line 216 argument, the casting might be incorrectly applied. */
|
Line 225 argument, the casting might be incorrectly applied. */
|
#define PCHARSV8(p, offset, len, f) \ |
#define PCHARSV8(p, offset, len, f) \ |
(void)pchars((pcre_uint8 *)(p) + offset, len, f) |
(void)pchars((pcre_uint8 *)(p) + offset, len, f) |
|
|
#define READ_CAPTURE_NAME8(p, cn8, cn16, re) \ | #define READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re) \ |
p = read_capture_name8(p, cn8, re) |
p = read_capture_name8(p, cn8, re) |
|
|
#define STRLEN8(p) ((int)strlen((char *)p)) |
#define STRLEN8(p) ((int)strlen((char *)p)) |
Line 286 argument, the casting might be incorrectly applied. */
|
Line 295 argument, the casting might be incorrectly applied. */
|
#define PCRE_JIT_STACK_FREE8(stack) \ |
#define PCRE_JIT_STACK_FREE8(stack) \ |
pcre_jit_stack_free(stack) |
pcre_jit_stack_free(stack) |
|
|
|
#define pcre8_maketables pcre_maketables |
|
|
#endif /* SUPPORT_PCRE8 */ |
#endif /* SUPPORT_PCRE8 */ |
|
|
/* -----------------------------------------------------------*/ |
/* -----------------------------------------------------------*/ |
Line 298 argument, the casting might be incorrectly applied. */
|
Line 309 argument, the casting might be incorrectly applied. */
|
#define PCHARSV16(p, offset, len, f) \ |
#define PCHARSV16(p, offset, len, f) \ |
(void)pchars16((PCRE_SPTR16)(p) + offset, len, f) |
(void)pchars16((PCRE_SPTR16)(p) + offset, len, f) |
|
|
#define READ_CAPTURE_NAME16(p, cn8, cn16, re) \ | #define READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re) \ |
p = read_capture_name16(p, cn16, re) |
p = read_capture_name16(p, cn16, re) |
|
|
#define STRLEN16(p) ((int)strlen16((PCRE_SPTR16)p)) |
#define STRLEN16(p) ((int)strlen16((PCRE_SPTR16)p)) |
Line 377 argument, the casting might be incorrectly applied. */
|
Line 388 argument, the casting might be incorrectly applied. */
|
|
|
#endif /* SUPPORT_PCRE16 */ |
#endif /* SUPPORT_PCRE16 */ |
|
|
|
/* -----------------------------------------------------------*/ |
|
|
/* ----- Both modes are supported; a runtime test is needed, except for | #ifdef SUPPORT_PCRE32 |
| |
| #define PCHARS32(lv, p, offset, len, f) \ |
| lv = pchars32((PCRE_SPTR32)(p) + offset, len, use_utf, f) |
| |
| #define PCHARSV32(p, offset, len, f) \ |
| (void)pchars32((PCRE_SPTR32)(p) + offset, len, use_utf, f) |
| |
| #define READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re) \ |
| p = read_capture_name32(p, cn32, re) |
| |
| #define STRLEN32(p) ((int)strlen32((PCRE_SPTR32)p)) |
| |
| #define SET_PCRE_CALLOUT32(callout) \ |
| pcre32_callout = (int (*)(pcre32_callout_block *))callout |
| |
| #define PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata) \ |
| pcre32_assign_jit_stack((pcre32_extra *)extra, \ |
| (pcre32_jit_callback)callback, userdata) |
| |
| #define PCRE_COMPILE32(re, pat, options, error, erroffset, tables) \ |
| re = (pcre *)pcre32_compile((PCRE_SPTR32)pat, options, error, erroffset, \ |
| tables) |
| |
| #define PCRE_COPY_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \ |
| namesptr, cbuffer, size) \ |
| rc = pcre32_copy_named_substring((pcre32 *)re, (PCRE_SPTR32)bptr, offsets, \ |
| count, (PCRE_SPTR32)namesptr, (PCRE_UCHAR32 *)cbuffer, size/2) |
| |
| #define PCRE_COPY_SUBSTRING32(rc, bptr, offsets, count, i, cbuffer, size) \ |
| rc = pcre32_copy_substring((PCRE_SPTR32)bptr, offsets, count, i, \ |
| (PCRE_UCHAR32 *)cbuffer, size/2) |
| |
| #define PCRE_DFA_EXEC32(count, re, extra, bptr, len, start_offset, options, \ |
| offsets, size_offsets, workspace, size_workspace) \ |
| count = pcre32_dfa_exec((pcre32 *)re, (pcre32_extra *)extra, \ |
| (PCRE_SPTR32)bptr, len, start_offset, options, offsets, size_offsets, \ |
| workspace, size_workspace) |
| |
| #define PCRE_EXEC32(count, re, extra, bptr, len, start_offset, options, \ |
| offsets, size_offsets) \ |
| count = pcre32_exec((pcre32 *)re, (pcre32_extra *)extra, (PCRE_SPTR32)bptr, \ |
| len, start_offset, options, offsets, size_offsets) |
| |
| #define PCRE_FREE_STUDY32(extra) \ |
| pcre32_free_study((pcre32_extra *)extra) |
| |
| #define PCRE_FREE_SUBSTRING32(substring) \ |
| pcre32_free_substring((PCRE_SPTR32)substring) |
| |
| #define PCRE_FREE_SUBSTRING_LIST32(listptr) \ |
| pcre32_free_substring_list((PCRE_SPTR32 *)listptr) |
| |
| #define PCRE_GET_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \ |
| getnamesptr, subsptr) \ |
| rc = pcre32_get_named_substring((pcre32 *)re, (PCRE_SPTR32)bptr, offsets, \ |
| count, (PCRE_SPTR32)getnamesptr, (PCRE_SPTR32 *)(void*)subsptr) |
| |
| #define PCRE_GET_STRINGNUMBER32(n, rc, ptr) \ |
| n = pcre32_get_stringnumber(re, (PCRE_SPTR32)ptr) |
| |
| #define PCRE_GET_SUBSTRING32(rc, bptr, offsets, count, i, subsptr) \ |
| rc = pcre32_get_substring((PCRE_SPTR32)bptr, offsets, count, i, \ |
| (PCRE_SPTR32 *)(void*)subsptr) |
| |
| #define PCRE_GET_SUBSTRING_LIST32(rc, bptr, offsets, count, listptr) \ |
| rc = pcre32_get_substring_list((PCRE_SPTR32)bptr, offsets, count, \ |
| (PCRE_SPTR32 **)(void*)listptr) |
| |
| #define PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables) \ |
| rc = pcre32_pattern_to_host_byte_order((pcre32 *)re, (pcre32_extra *)extra, \ |
| tables) |
| |
| #define PCRE_PRINTINT32(re, outfile, debug_lengths) \ |
| pcre32_printint(re, outfile, debug_lengths) |
| |
| #define PCRE_STUDY32(extra, re, options, error) \ |
| extra = (pcre_extra *)pcre32_study((pcre32 *)re, options, error) |
| |
| #define PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \ |
| (pcre_jit_stack *)pcre32_jit_stack_alloc(startsize, maxsize) |
| |
| #define PCRE_JIT_STACK_FREE32(stack) \ |
| pcre32_jit_stack_free((pcre32_jit_stack *)stack) |
| |
| #endif /* SUPPORT_PCRE32 */ |
| |
| |
| /* ----- More than one mode is supported; a runtime test is needed, except for |
pcre_config(), and the JIT stack functions, when it doesn't matter which |
pcre_config(), and the JIT stack functions, when it doesn't matter which |
version is called. ----- */ | available version is called. ----- */ |
|
|
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 | enum { |
| PCRE8_MODE, |
| PCRE16_MODE, |
| PCRE32_MODE |
| }; |
|
|
#define CHAR_SIZE (use_pcre16? 2:1) | #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + \ |
| defined (SUPPORT_PCRE32)) >= 2 |
|
|
|
#define CHAR_SIZE (1 << pcre_mode) |
|
|
|
/* There doesn't seem to be an easy way of writing these macros that can cope |
|
with the 3 pairs of bit sizes plus all three bit sizes. So just handle all the |
|
cases separately. */ |
|
|
|
/* ----- All three modes supported ----- */ |
|
|
|
#if defined(SUPPORT_PCRE8) && defined(SUPPORT_PCRE16) && defined(SUPPORT_PCRE32) |
|
|
#define PCHARS(lv, p, offset, len, f) \ |
#define PCHARS(lv, p, offset, len, f) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCHARS32(lv, p, offset, len, f); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCHARS16(lv, p, offset, len, f); \ |
PCHARS16(lv, p, offset, len, f); \ |
else \ |
else \ |
PCHARS8(lv, p, offset, len, f) |
PCHARS8(lv, p, offset, len, f) |
|
|
#define PCHARSV(p, offset, len, f) \ |
#define PCHARSV(p, offset, len, f) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCHARSV32(p, offset, len, f); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCHARSV16(p, offset, len, f); \ |
PCHARSV16(p, offset, len, f); \ |
else \ |
else \ |
PCHARSV8(p, offset, len, f) |
PCHARSV8(p, offset, len, f) |
|
|
#define READ_CAPTURE_NAME(p, cn8, cn16, re) \ | #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
READ_CAPTURE_NAME16(p, cn8, cn16, re); \ | READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
| READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re); \ |
else \ |
else \ |
READ_CAPTURE_NAME8(p, cn8, cn16, re) | READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re) |
|
|
#define SET_PCRE_CALLOUT(callout) \ |
#define SET_PCRE_CALLOUT(callout) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| SET_PCRE_CALLOUT32(callout); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
SET_PCRE_CALLOUT16(callout); \ |
SET_PCRE_CALLOUT16(callout); \ |
else \ |
else \ |
SET_PCRE_CALLOUT8(callout) |
SET_PCRE_CALLOUT8(callout) |
|
|
#define STRLEN(p) (use_pcre16? STRLEN16(p) : STRLEN8(p)) | #define STRLEN(p) (pcre_mode == PCRE32_MODE ? STRLEN32(p) : pcre_mode == PCRE16_MODE ? STRLEN16(p) : STRLEN8(p)) |
|
|
#define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \ |
#define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata); \ |
PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata); \ |
else \ |
else \ |
PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata) |
PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata) |
|
|
#define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \ |
#define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_COMPILE32(re, pat, options, error, erroffset, tables); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_COMPILE16(re, pat, options, error, erroffset, tables); \ |
PCRE_COMPILE16(re, pat, options, error, erroffset, tables); \ |
else \ |
else \ |
PCRE_COMPILE8(re, pat, options, error, erroffset, tables) |
PCRE_COMPILE8(re, pat, options, error, erroffset, tables) |
Line 428 version is called. ----- */
|
Line 555 version is called. ----- */
|
|
|
#define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \ |
#define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \ |
namesptr, cbuffer, size) \ |
namesptr, cbuffer, size) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_COPY_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \ |
| namesptr, cbuffer, size); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \ |
PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \ |
namesptr, cbuffer, size); \ |
namesptr, cbuffer, size); \ |
else \ |
else \ |
Line 436 version is called. ----- */
|
Line 566 version is called. ----- */
|
namesptr, cbuffer, size) |
namesptr, cbuffer, size) |
|
|
#define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \ |
#define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_COPY_SUBSTRING32(rc, bptr, offsets, count, i, cbuffer, size); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size); \ |
PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size); \ |
else \ |
else \ |
PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size) |
PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size) |
|
|
#define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \ |
#define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \ |
offsets, size_offsets, workspace, size_workspace) \ |
offsets, size_offsets, workspace, size_workspace) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_DFA_EXEC32(count, re, extra, bptr, len, start_offset, options, \ |
| offsets, size_offsets, workspace, size_workspace); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \ |
PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \ |
offsets, size_offsets, workspace, size_workspace); \ |
offsets, size_offsets, workspace, size_workspace); \ |
else \ |
else \ |
Line 452 version is called. ----- */
|
Line 587 version is called. ----- */
|
|
|
#define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \ |
#define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \ |
offsets, size_offsets) \ |
offsets, size_offsets) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_EXEC32(count, re, extra, bptr, len, start_offset, options, \ |
| offsets, size_offsets); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \ |
PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \ |
offsets, size_offsets); \ |
offsets, size_offsets); \ |
else \ |
else \ |
Line 460 version is called. ----- */
|
Line 598 version is called. ----- */
|
offsets, size_offsets) |
offsets, size_offsets) |
|
|
#define PCRE_FREE_STUDY(extra) \ |
#define PCRE_FREE_STUDY(extra) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_FREE_STUDY32(extra); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_FREE_STUDY16(extra); \ |
PCRE_FREE_STUDY16(extra); \ |
else \ |
else \ |
PCRE_FREE_STUDY8(extra) |
PCRE_FREE_STUDY8(extra) |
|
|
#define PCRE_FREE_SUBSTRING(substring) \ |
#define PCRE_FREE_SUBSTRING(substring) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_FREE_SUBSTRING32(substring); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_FREE_SUBSTRING16(substring); \ |
PCRE_FREE_SUBSTRING16(substring); \ |
else \ |
else \ |
PCRE_FREE_SUBSTRING8(substring) |
PCRE_FREE_SUBSTRING8(substring) |
|
|
#define PCRE_FREE_SUBSTRING_LIST(listptr) \ |
#define PCRE_FREE_SUBSTRING_LIST(listptr) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_FREE_SUBSTRING_LIST32(listptr); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_FREE_SUBSTRING_LIST16(listptr); \ |
PCRE_FREE_SUBSTRING_LIST16(listptr); \ |
else \ |
else \ |
PCRE_FREE_SUBSTRING_LIST8(listptr) |
PCRE_FREE_SUBSTRING_LIST8(listptr) |
|
|
#define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \ |
#define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \ |
getnamesptr, subsptr) \ |
getnamesptr, subsptr) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_GET_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \ |
| getnamesptr, subsptr); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \ |
PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \ |
getnamesptr, subsptr); \ |
getnamesptr, subsptr); \ |
else \ |
else \ |
Line 487 version is called. ----- */
|
Line 634 version is called. ----- */
|
getnamesptr, subsptr) |
getnamesptr, subsptr) |
|
|
#define PCRE_GET_STRINGNUMBER(n, rc, ptr) \ |
#define PCRE_GET_STRINGNUMBER(n, rc, ptr) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_GET_STRINGNUMBER32(n, rc, ptr); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_GET_STRINGNUMBER16(n, rc, ptr); \ |
PCRE_GET_STRINGNUMBER16(n, rc, ptr); \ |
else \ |
else \ |
PCRE_GET_STRINGNUMBER8(n, rc, ptr) |
PCRE_GET_STRINGNUMBER8(n, rc, ptr) |
|
|
#define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \ |
#define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_GET_SUBSTRING32(rc, bptr, use_offsets, count, i, subsptr); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_GET_SUBSTRING16(rc, bptr, use_offsets, count, i, subsptr); \ |
PCRE_GET_SUBSTRING16(rc, bptr, use_offsets, count, i, subsptr); \ |
else \ |
else \ |
PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr) |
PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr) |
|
|
#define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \ |
#define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_GET_SUBSTRING_LIST32(rc, bptr, offsets, count, listptr); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr); \ |
PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr); \ |
else \ |
else \ |
PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr) |
PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr) |
|
|
#define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \ |
#define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \ |
(use_pcre16 ? \ | (pcre_mode == PCRE32_MODE ? \ |
PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \ | PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \ |
:PCRE_JIT_STACK_ALLOC8(startsize, maxsize)) | : pcre_mode == PCRE16_MODE ? \ |
| PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \ |
| : PCRE_JIT_STACK_ALLOC8(startsize, maxsize)) |
|
|
#define PCRE_JIT_STACK_FREE(stack) \ |
#define PCRE_JIT_STACK_FREE(stack) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_JIT_STACK_FREE32(stack); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_JIT_STACK_FREE16(stack); \ |
PCRE_JIT_STACK_FREE16(stack); \ |
else \ |
else \ |
PCRE_JIT_STACK_FREE8(stack) |
PCRE_JIT_STACK_FREE8(stack) |
|
|
#define PCRE_MAKETABLES \ |
#define PCRE_MAKETABLES \ |
(use_pcre16? pcre16_maketables() : pcre_maketables()) | (pcre_mode == PCRE32_MODE ? pcre32_maketables() : pcre_mode == PCRE16_MODE ? pcre16_maketables() : pcre_maketables()) |
|
|
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \ |
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables); \ |
PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables); \ |
else \ |
else \ |
PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables) |
PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables) |
|
|
#define PCRE_PRINTINT(re, outfile, debug_lengths) \ |
#define PCRE_PRINTINT(re, outfile, debug_lengths) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_PRINTINT32(re, outfile, debug_lengths); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_PRINTINT16(re, outfile, debug_lengths); \ |
PCRE_PRINTINT16(re, outfile, debug_lengths); \ |
else \ |
else \ |
PCRE_PRINTINT8(re, outfile, debug_lengths) |
PCRE_PRINTINT8(re, outfile, debug_lengths) |
|
|
#define PCRE_STUDY(extra, re, options, error) \ |
#define PCRE_STUDY(extra, re, options, error) \ |
if (use_pcre16) \ | if (pcre_mode == PCRE32_MODE) \ |
| PCRE_STUDY32(extra, re, options, error); \ |
| else if (pcre_mode == PCRE16_MODE) \ |
PCRE_STUDY16(extra, re, options, error); \ |
PCRE_STUDY16(extra, re, options, error); \ |
else \ |
else \ |
PCRE_STUDY8(extra, re, options, error) |
PCRE_STUDY8(extra, re, options, error) |
|
|
|
|
|
/* ----- Two out of three modes are supported ----- */ |
|
|
|
#else |
|
|
|
/* We can use some macro trickery to make a single set of definitions work in |
|
the three different cases. */ |
|
|
|
/* ----- 32-bit and 16-bit but not 8-bit supported ----- */ |
|
|
|
#if defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE16) |
|
#define BITONE 32 |
|
#define BITTWO 16 |
|
|
|
/* ----- 32-bit and 8-bit but not 16-bit supported ----- */ |
|
|
|
#elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE8) |
|
#define BITONE 32 |
|
#define BITTWO 8 |
|
|
|
/* ----- 16-bit and 8-bit but not 32-bit supported ----- */ |
|
|
|
#else |
|
#define BITONE 16 |
|
#define BITTWO 8 |
|
#endif |
|
|
|
#define glue(a,b) a##b |
|
#define G(a,b) glue(a,b) |
|
|
|
|
|
/* ----- Common macros for two-mode cases ----- */ |
|
|
|
#define PCHARS(lv, p, offset, len, f) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCHARS,BITONE)(lv, p, offset, len, f); \ |
|
else \ |
|
G(PCHARS,BITTWO)(lv, p, offset, len, f) |
|
|
|
#define PCHARSV(p, offset, len, f) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCHARSV,BITONE)(p, offset, len, f); \ |
|
else \ |
|
G(PCHARSV,BITTWO)(p, offset, len, f) |
|
|
|
#define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(READ_CAPTURE_NAME,BITONE)(p, cn8, cn16, cn32, re); \ |
|
else \ |
|
G(READ_CAPTURE_NAME,BITTWO)(p, cn8, cn16, cn32, re) |
|
|
|
#define SET_PCRE_CALLOUT(callout) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(SET_PCRE_CALLOUT,BITONE)(callout); \ |
|
else \ |
|
G(SET_PCRE_CALLOUT,BITTWO)(callout) |
|
|
|
#define STRLEN(p) ((pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \ |
|
G(STRLEN,BITONE)(p) : G(STRLEN,BITTWO)(p)) |
|
|
|
#define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_ASSIGN_JIT_STACK,BITONE)(extra, callback, userdata); \ |
|
else \ |
|
G(PCRE_ASSIGN_JIT_STACK,BITTWO)(extra, callback, userdata) |
|
|
|
#define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_COMPILE,BITONE)(re, pat, options, error, erroffset, tables); \ |
|
else \ |
|
G(PCRE_COMPILE,BITTWO)(re, pat, options, error, erroffset, tables) |
|
|
|
#define PCRE_CONFIG G(G(pcre,BITONE),_config) |
|
|
|
#define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \ |
|
namesptr, cbuffer, size) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_COPY_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \ |
|
namesptr, cbuffer, size); \ |
|
else \ |
|
G(PCRE_COPY_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \ |
|
namesptr, cbuffer, size) |
|
|
|
#define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_COPY_SUBSTRING,BITONE)(rc, bptr, offsets, count, i, cbuffer, size); \ |
|
else \ |
|
G(PCRE_COPY_SUBSTRING,BITTWO)(rc, bptr, offsets, count, i, cbuffer, size) |
|
|
|
#define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \ |
|
offsets, size_offsets, workspace, size_workspace) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_DFA_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \ |
|
offsets, size_offsets, workspace, size_workspace); \ |
|
else \ |
|
G(PCRE_DFA_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \ |
|
offsets, size_offsets, workspace, size_workspace) |
|
|
|
#define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \ |
|
offsets, size_offsets) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \ |
|
offsets, size_offsets); \ |
|
else \ |
|
G(PCRE_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \ |
|
offsets, size_offsets) |
|
|
|
#define PCRE_FREE_STUDY(extra) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_FREE_STUDY,BITONE)(extra); \ |
|
else \ |
|
G(PCRE_FREE_STUDY,BITTWO)(extra) |
|
|
|
#define PCRE_FREE_SUBSTRING(substring) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_FREE_SUBSTRING,BITONE)(substring); \ |
|
else \ |
|
G(PCRE_FREE_SUBSTRING,BITTWO)(substring) |
|
|
|
#define PCRE_FREE_SUBSTRING_LIST(listptr) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_FREE_SUBSTRING_LIST,BITONE)(listptr); \ |
|
else \ |
|
G(PCRE_FREE_SUBSTRING_LIST,BITTWO)(listptr) |
|
|
|
#define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \ |
|
getnamesptr, subsptr) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_GET_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \ |
|
getnamesptr, subsptr); \ |
|
else \ |
|
G(PCRE_GET_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \ |
|
getnamesptr, subsptr) |
|
|
|
#define PCRE_GET_STRINGNUMBER(n, rc, ptr) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_GET_STRINGNUMBER,BITONE)(n, rc, ptr); \ |
|
else \ |
|
G(PCRE_GET_STRINGNUMBER,BITTWO)(n, rc, ptr) |
|
|
|
#define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_GET_SUBSTRING,BITONE)(rc, bptr, use_offsets, count, i, subsptr); \ |
|
else \ |
|
G(PCRE_GET_SUBSTRING,BITTWO)(rc, bptr, use_offsets, count, i, subsptr) |
|
|
|
#define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_GET_SUBSTRING_LIST,BITONE)(rc, bptr, offsets, count, listptr); \ |
|
else \ |
|
G(PCRE_GET_SUBSTRING_LIST,BITTWO)(rc, bptr, offsets, count, listptr) |
|
|
|
#define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \ |
|
(pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \ |
|
G(PCRE_JIT_STACK_ALLOC,BITONE)(startsize, maxsize) \ |
|
: G(PCRE_JIT_STACK_ALLOC,BITTWO)(startsize, maxsize) |
|
|
|
#define PCRE_JIT_STACK_FREE(stack) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_JIT_STACK_FREE,BITONE)(stack); \ |
|
else \ |
|
G(PCRE_JIT_STACK_FREE,BITTWO)(stack) |
|
|
|
#define PCRE_MAKETABLES \ |
|
(pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \ |
|
G(G(pcre,BITONE),_maketables)() : G(G(pcre,BITTWO),_maketables)() |
|
|
|
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITONE)(rc, re, extra, tables); \ |
|
else \ |
|
G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITTWO)(rc, re, extra, tables) |
|
|
|
#define PCRE_PRINTINT(re, outfile, debug_lengths) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_PRINTINT,BITONE)(re, outfile, debug_lengths); \ |
|
else \ |
|
G(PCRE_PRINTINT,BITTWO)(re, outfile, debug_lengths) |
|
|
|
#define PCRE_STUDY(extra, re, options, error) \ |
|
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \ |
|
G(PCRE_STUDY,BITONE)(extra, re, options, error); \ |
|
else \ |
|
G(PCRE_STUDY,BITTWO)(extra, re, options, error) |
|
|
|
#endif /* Two out of three modes */ |
|
|
|
/* ----- End of cases where more than one mode is supported ----- */ |
|
|
|
|
/* ----- Only 8-bit mode is supported ----- */ |
/* ----- Only 8-bit mode is supported ----- */ |
|
|
#elif defined SUPPORT_PCRE8 |
#elif defined SUPPORT_PCRE8 |
Line 568 version is called. ----- */
|
Line 921 version is called. ----- */
|
|
|
/* ----- Only 16-bit mode is supported ----- */ |
/* ----- Only 16-bit mode is supported ----- */ |
|
|
#else | #elif defined SUPPORT_PCRE16 |
#define CHAR_SIZE 2 |
#define CHAR_SIZE 2 |
#define PCHARS PCHARS16 |
#define PCHARS PCHARS16 |
#define PCHARSV PCHARSV16 |
#define PCHARSV PCHARSV16 |
Line 595 version is called. ----- */
|
Line 948 version is called. ----- */
|
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER16 |
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER16 |
#define PCRE_PRINTINT PCRE_PRINTINT16 |
#define PCRE_PRINTINT PCRE_PRINTINT16 |
#define PCRE_STUDY PCRE_STUDY16 |
#define PCRE_STUDY PCRE_STUDY16 |
|
|
|
/* ----- Only 32-bit mode is supported ----- */ |
|
|
|
#elif defined SUPPORT_PCRE32 |
|
#define CHAR_SIZE 4 |
|
#define PCHARS PCHARS32 |
|
#define PCHARSV PCHARSV32 |
|
#define READ_CAPTURE_NAME READ_CAPTURE_NAME32 |
|
#define SET_PCRE_CALLOUT SET_PCRE_CALLOUT32 |
|
#define STRLEN STRLEN32 |
|
#define PCRE_ASSIGN_JIT_STACK PCRE_ASSIGN_JIT_STACK32 |
|
#define PCRE_COMPILE PCRE_COMPILE32 |
|
#define PCRE_CONFIG pcre32_config |
|
#define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING32 |
|
#define PCRE_COPY_SUBSTRING PCRE_COPY_SUBSTRING32 |
|
#define PCRE_DFA_EXEC PCRE_DFA_EXEC32 |
|
#define PCRE_EXEC PCRE_EXEC32 |
|
#define PCRE_FREE_STUDY PCRE_FREE_STUDY32 |
|
#define PCRE_FREE_SUBSTRING PCRE_FREE_SUBSTRING32 |
|
#define PCRE_FREE_SUBSTRING_LIST PCRE_FREE_SUBSTRING_LIST32 |
|
#define PCRE_GET_NAMED_SUBSTRING PCRE_GET_NAMED_SUBSTRING32 |
|
#define PCRE_GET_STRINGNUMBER PCRE_GET_STRINGNUMBER32 |
|
#define PCRE_GET_SUBSTRING PCRE_GET_SUBSTRING32 |
|
#define PCRE_GET_SUBSTRING_LIST PCRE_GET_SUBSTRING_LIST32 |
|
#define PCRE_JIT_STACK_ALLOC PCRE_JIT_STACK_ALLOC32 |
|
#define PCRE_JIT_STACK_FREE PCRE_JIT_STACK_FREE32 |
|
#define PCRE_MAKETABLES pcre32_maketables() |
|
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER32 |
|
#define PCRE_PRINTINT PCRE_PRINTINT32 |
|
#define PCRE_STUDY PCRE_STUDY32 |
|
|
#endif |
#endif |
|
|
/* ----- End of mode-specific function call macros ----- */ |
/* ----- End of mode-specific function call macros ----- */ |
Line 640 static const unsigned char *last_callout_mark = NULL;
|
Line 1024 static const unsigned char *last_callout_mark = NULL;
|
|
|
static int buffer_size = 50000; |
static int buffer_size = 50000; |
static pcre_uint8 *buffer = NULL; |
static pcre_uint8 *buffer = NULL; |
static pcre_uint8 *dbuffer = NULL; |
|
static pcre_uint8 *pbuffer = NULL; |
static pcre_uint8 *pbuffer = NULL; |
|
|
/* Another buffer is needed translation to 16-bit character strings. It will | /* Just as a safety check, make sure that COMPILE_PCRE[16|32] are *not* set. */ |
obtained and extended as required. */ | |
|
|
#ifdef SUPPORT_PCRE16 |
|
static int buffer16_size = 0; |
|
static pcre_uint16 *buffer16 = NULL; |
|
|
|
#ifdef SUPPORT_PCRE8 |
|
|
|
/* We need the table of operator lengths that is used for 16-bit compiling, in |
|
order to swap bytes in a pattern for saving/reloading testing. Luckily, the |
|
data is defined as a macro. However, we must ensure that LINK_SIZE is adjusted |
|
appropriately for the 16-bit world. Just as a safety check, make sure that |
|
COMPILE_PCRE16 is *not* set. */ |
|
|
|
#ifdef COMPILE_PCRE16 |
#ifdef COMPILE_PCRE16 |
#error COMPILE_PCRE16 must not be set when compiling pcretest.c |
#error COMPILE_PCRE16 must not be set when compiling pcretest.c |
#endif |
#endif |
|
|
|
#ifdef COMPILE_PCRE32 |
|
#error COMPILE_PCRE32 must not be set when compiling pcretest.c |
|
#endif |
|
|
|
/* We need buffers for building 16/32-bit strings, and the tables of operator |
|
lengths that are used for 16/32-bit compiling, in order to swap bytes in a |
|
pattern for saving/reloading testing. Luckily, the data for these tables is |
|
defined as a macro. However, we must ensure that LINK_SIZE and IMM2_SIZE (which |
|
are used in the tables) are adjusted appropriately for the 16/32-bit world. |
|
LINK_SIZE is also used later in this program. */ |
|
|
|
#ifdef SUPPORT_PCRE16 |
|
#undef IMM2_SIZE |
|
#define IMM2_SIZE 1 |
|
|
#if LINK_SIZE == 2 |
#if LINK_SIZE == 2 |
#undef LINK_SIZE |
#undef LINK_SIZE |
#define LINK_SIZE 1 |
#define LINK_SIZE 1 |
Line 672 COMPILE_PCRE16 is *not* set. */
|
Line 1057 COMPILE_PCRE16 is *not* set. */
|
#error LINK_SIZE must be either 2, 3, or 4 |
#error LINK_SIZE must be either 2, 3, or 4 |
#endif |
#endif |
|
|
|
static int buffer16_size = 0; |
|
static pcre_uint16 *buffer16 = NULL; |
|
static const pcre_uint16 OP_lengths16[] = { OP_LENGTHS }; |
|
#endif /* SUPPORT_PCRE16 */ |
|
|
|
#ifdef SUPPORT_PCRE32 |
#undef IMM2_SIZE |
#undef IMM2_SIZE |
#define IMM2_SIZE 1 |
#define IMM2_SIZE 1 |
|
#undef LINK_SIZE |
|
#define LINK_SIZE 1 |
|
|
#endif /* SUPPORT_PCRE8 */ | static int buffer32_size = 0; |
| static pcre_uint32 *buffer32 = NULL; |
| static const pcre_uint32 OP_lengths32[] = { OP_LENGTHS }; |
| #endif /* SUPPORT_PCRE32 */ |
|
|
static const pcre_uint16 OP_lengths16[] = { OP_LENGTHS }; | /* If we have 8-bit support, default to it; if there is also 16-or 32-bit |
#endif /* SUPPORT_PCRE16 */ | support, it can be changed by an option. If there is no 8-bit support, there |
| must be 16-or 32-bit support, so default it to 1. */ |
|
|
/* If we have 8-bit support, default use_pcre16 to false; if there is also | #if defined SUPPORT_PCRE8 |
16-bit support, it can be changed by an option. If there is no 8-bit support, | static int pcre_mode = PCRE8_MODE; |
there must be 16-bit support, so default it to 1. */ | #elif defined SUPPORT_PCRE16 |
| static int pcre_mode = PCRE16_MODE; |
#ifdef SUPPORT_PCRE8 | #elif defined SUPPORT_PCRE32 |
static int use_pcre16 = 0; | static int pcre_mode = PCRE32_MODE; |
#else | |
static int use_pcre16 = 1; | |
#endif |
#endif |
|
|
/* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */ |
/* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */ |
Line 704 static int jit_study_bits[] =
|
Line 1099 static int jit_study_bits[] =
|
PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |
PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |
}; |
}; |
|
|
|
#define PCRE_STUDY_ALLJIT (PCRE_STUDY_JIT_COMPILE | \ |
|
PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE) |
|
|
/* Textual explanations for runtime error codes */ |
/* Textual explanations for runtime error codes */ |
|
|
static const char *errtexts[] = { |
static const char *errtexts[] = { |
Line 737 static const char *errtexts[] = {
|
Line 1135 static const char *errtexts[] = {
|
"JIT stack limit reached", |
"JIT stack limit reached", |
"pattern compiled in wrong mode: 8-bit/16-bit error", |
"pattern compiled in wrong mode: 8-bit/16-bit error", |
"pattern compiled with other endianness", |
"pattern compiled with other endianness", |
"invalid data in workspace for DFA restart" | "invalid data in workspace for DFA restart", |
| "bad JIT option", |
| "bad length" |
}; |
}; |
|
|
|
|
Line 922 graph, print, punct, and cntrl. Other classes are buil
|
Line 1322 graph, print, punct, and cntrl. Other classes are buil
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */ |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */ |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */ |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */ |
|
|
/* This is a set of tables that came orginally from a Windows user. It seems to | /* This is a set of tables that came originally from a Windows user. It seems to |
be at least an approximation of ISO 8859. In particular, there are characters |
be at least an approximation of ISO 8859. In particular, there are characters |
greater than 128 that are marked as spaces, letters, etc. */ |
greater than 128 that are marked as spaces, letters, etc. */ |
|
|
Line 1089 return sys_errlist[n];
|
Line 1489 return sys_errlist[n];
|
#endif /* HAVE_STRERROR */ |
#endif /* HAVE_STRERROR */ |
|
|
|
|
|
|
/************************************************* |
/************************************************* |
|
* Print newline configuration * |
|
*************************************************/ |
|
|
|
/* |
|
Arguments: |
|
rc the return code from PCRE_CONFIG_NEWLINE |
|
isc TRUE if called from "-C newline" |
|
Returns: nothing |
|
*/ |
|
|
|
static void |
|
print_newline_config(int rc, BOOL isc) |
|
{ |
|
const char *s = NULL; |
|
if (!isc) printf(" Newline sequence is "); |
|
switch(rc) |
|
{ |
|
case CHAR_CR: s = "CR"; break; |
|
case CHAR_LF: s = "LF"; break; |
|
case (CHAR_CR<<8 | CHAR_LF): s = "CRLF"; break; |
|
case -1: s = "ANY"; break; |
|
case -2: s = "ANYCRLF"; break; |
|
|
|
default: |
|
printf("a non-standard value: 0x%04x\n", rc); |
|
return; |
|
} |
|
|
|
printf("%s\n", s); |
|
} |
|
|
|
|
|
|
|
/************************************************* |
* JIT memory callback * |
* JIT memory callback * |
*************************************************/ |
*************************************************/ |
|
|
Line 1100 return (pcre_jit_stack *)arg;
|
Line 1535 return (pcre_jit_stack *)arg;
|
} |
} |
|
|
|
|
#if !defined NOUTF || defined SUPPORT_PCRE16 | #if !defined NOUTF || defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32 |
/************************************************* |
/************************************************* |
* Convert UTF-8 string to value * |
* Convert UTF-8 string to value * |
*************************************************/ |
*************************************************/ |
Line 1117 Returns: > 0 => the number of bytes consumed
|
Line 1552 Returns: > 0 => the number of bytes consumed
|
*/ |
*/ |
|
|
static int |
static int |
utf82ord(pcre_uint8 *utf8bytes, int *vptr) | utf82ord(pcre_uint8 *utf8bytes, pcre_uint32 *vptr) |
{ |
{ |
int c = *utf8bytes++; | pcre_uint32 c = *utf8bytes++; |
int d = c; | pcre_uint32 d = c; |
int i, j, s; |
int i, j, s; |
|
|
for (i = -1; i < 6; i++) /* i is number of additional bytes */ |
for (i = -1; i < 6; i++) /* i is number of additional bytes */ |
Line 1148 for (j = 0; j < i; j++)
|
Line 1583 for (j = 0; j < i; j++)
|
/* Check that encoding was the correct unique one */ |
/* Check that encoding was the correct unique one */ |
|
|
for (j = 0; j < utf8_table1_size; j++) |
for (j = 0; j < utf8_table1_size; j++) |
if (d <= utf8_table1[j]) break; | if (d <= (pcre_uint32)utf8_table1[j]) break; |
if (j != i) return -(i+1); |
if (j != i) return -(i+1); |
|
|
/* Valid value */ |
/* Valid value */ |
Line 1160 return i+1;
|
Line 1595 return i+1;
|
|
|
|
|
|
|
#if !defined NOUTF || defined SUPPORT_PCRE16 | #if defined SUPPORT_PCRE8 && !defined NOUTF |
/************************************************* |
/************************************************* |
* Convert character value to UTF-8 * |
* Convert character value to UTF-8 * |
*************************************************/ |
*************************************************/ |
Line 1176 Returns: number of characters placed in the buffer
|
Line 1611 Returns: number of characters placed in the buffer
|
*/ |
*/ |
|
|
static int |
static int |
ord2utf8(int cvalue, pcre_uint8 *utf8bytes) | ord2utf8(pcre_uint32 cvalue, pcre_uint8 *utf8bytes) |
{ |
{ |
register int i, j; |
register int i, j; |
|
if (cvalue > 0x7fffffffu) |
|
return -1; |
for (i = 0; i < utf8_table1_size; i++) |
for (i = 0; i < utf8_table1_size; i++) |
if (cvalue <= utf8_table1[i]) break; | if (cvalue <= (pcre_uint32)utf8_table1[i]) break; |
utf8bytes += i; |
utf8bytes += i; |
for (j = i; j > 0; j--) |
for (j = i; j > 0; j--) |
{ |
{ |
Line 1249 if (!utf && !data)
|
Line 1686 if (!utf && !data)
|
|
|
else |
else |
{ |
{ |
int c = 0; | pcre_uint32 c = 0; |
while (len > 0) |
while (len > 0) |
{ |
{ |
int chlen = utf82ord(p, &c); |
int chlen = utf82ord(p, &c); |
Line 1272 return pp - buffer16;
|
Line 1709 return pp - buffer16;
|
} |
} |
#endif |
#endif |
|
|
|
#ifdef SUPPORT_PCRE32 |
|
/************************************************* |
|
* Convert a string to 32-bit * |
|
*************************************************/ |
|
|
|
/* In non-UTF mode, the space needed for a 32-bit string is exactly four times the |
|
8-bit size. For a UTF-8 string, the size needed for UTF-32 is no more than four |
|
times, because up to 0xffff uses no more than 3 bytes in UTF-8 but possibly 4 |
|
in UTF-32. Higher values use 4 bytes in UTF-8 and up to 4 bytes in UTF-32. The |
|
result is always left in buffer32. |
|
|
|
Note that this function does not object to surrogate values. This is |
|
deliberate; it makes it possible to construct UTF-32 strings that are invalid, |
|
for the purpose of testing that they are correctly faulted. |
|
|
|
Patterns to be converted are either plain ASCII or UTF-8; data lines are always |
|
in UTF-8 so that values greater than 255 can be handled. |
|
|
|
Arguments: |
|
data TRUE if converting a data line; FALSE for a regex |
|
p points to a byte string |
|
utf true if UTF-8 (to be converted to UTF-32) |
|
len number of bytes in the string (excluding trailing zero) |
|
|
|
Returns: number of 32-bit data items used (excluding trailing zero) |
|
OR -1 if a UTF-8 string is malformed |
|
OR -2 if a value > 0x10ffff is encountered |
|
OR -3 if an ill-formed value is encountered (i.e. a surrogate) |
|
*/ |
|
|
|
static int |
|
to32(int data, pcre_uint8 *p, int utf, int len) |
|
{ |
|
pcre_uint32 *pp; |
|
|
|
if (buffer32_size < 4*len + 4) |
|
{ |
|
if (buffer32 != NULL) free(buffer32); |
|
buffer32_size = 4*len + 4; |
|
buffer32 = (pcre_uint32 *)malloc(buffer32_size); |
|
if (buffer32 == NULL) |
|
{ |
|
fprintf(stderr, "pcretest: malloc(%d) failed for buffer32\n", buffer32_size); |
|
exit(1); |
|
} |
|
} |
|
|
|
pp = buffer32; |
|
|
|
if (!utf && !data) |
|
{ |
|
while (len-- > 0) *pp++ = *p++; |
|
} |
|
|
|
else |
|
{ |
|
pcre_uint32 c = 0; |
|
while (len > 0) |
|
{ |
|
int chlen = utf82ord(p, &c); |
|
if (chlen <= 0) return -1; |
|
if (utf) |
|
{ |
|
if (c > 0x10ffff) return -2; |
|
if (!data && (c & 0xfffff800u) == 0xd800u) return -3; |
|
} |
|
|
|
p += chlen; |
|
len -= chlen; |
|
*pp++ = c; |
|
} |
|
} |
|
|
|
*pp = 0; |
|
return pp - buffer32; |
|
} |
|
|
|
/* Check that a 32-bit character string is valid UTF-32. |
|
|
|
Arguments: |
|
string points to the string |
|
length length of string, or -1 if the string is zero-terminated |
|
|
|
Returns: TRUE if the string is a valid UTF-32 string |
|
FALSE otherwise |
|
*/ |
|
|
|
#ifdef NEVER /* Not used */ |
|
#ifdef SUPPORT_UTF |
|
static BOOL |
|
valid_utf32(pcre_uint32 *string, int length) |
|
{ |
|
register pcre_uint32 *p; |
|
register pcre_uint32 c; |
|
|
|
for (p = string; length-- > 0; p++) |
|
{ |
|
c = *p; |
|
if (c > 0x10ffffu) return FALSE; /* Too big */ |
|
if ((c & 0xfffff800u) == 0xd800u) return FALSE; /* Surrogate */ |
|
} |
|
|
|
return TRUE; |
|
} |
|
#endif /* SUPPORT_UTF */ |
|
#endif /* NEVER */ |
|
#endif /* SUPPORT_PCRE32 */ |
|
|
|
|
/************************************************* |
/************************************************* |
* Read or extend an input line * |
* Read or extend an input line * |
*************************************************/ |
*************************************************/ |
Line 1347 for (;;)
|
Line 1892 for (;;)
|
{ |
{ |
int new_buffer_size = 2*buffer_size; |
int new_buffer_size = 2*buffer_size; |
pcre_uint8 *new_buffer = (pcre_uint8 *)malloc(new_buffer_size); |
pcre_uint8 *new_buffer = (pcre_uint8 *)malloc(new_buffer_size); |
pcre_uint8 *new_dbuffer = (pcre_uint8 *)malloc(new_buffer_size); |
|
pcre_uint8 *new_pbuffer = (pcre_uint8 *)malloc(new_buffer_size); |
pcre_uint8 *new_pbuffer = (pcre_uint8 *)malloc(new_buffer_size); |
|
|
if (new_buffer == NULL || new_dbuffer == NULL || new_pbuffer == NULL) | if (new_buffer == NULL || new_pbuffer == NULL) |
{ |
{ |
fprintf(stderr, "pcretest: malloc(%d) failed\n", new_buffer_size); |
fprintf(stderr, "pcretest: malloc(%d) failed\n", new_buffer_size); |
exit(1); |
exit(1); |
Line 1365 for (;;)
|
Line 1909 for (;;)
|
here = new_buffer + (here - buffer); |
here = new_buffer + (here - buffer); |
|
|
free(buffer); |
free(buffer); |
free(dbuffer); |
|
free(pbuffer); |
free(pbuffer); |
|
|
buffer = new_buffer; |
buffer = new_buffer; |
dbuffer = new_dbuffer; |
|
pbuffer = new_pbuffer; |
pbuffer = new_pbuffer; |
} |
} |
} |
} |
Line 1412 return(result);
|
Line 1954 return(result);
|
|
|
/* Print a single character either literally, or as a hex escape. */ |
/* Print a single character either literally, or as a hex escape. */ |
|
|
static int pchar(int c, FILE *f) | static int pchar(pcre_uint32 c, FILE *f) |
{ |
{ |
|
int n = 0; |
if (PRINTOK(c)) |
if (PRINTOK(c)) |
{ |
{ |
if (f != NULL) fprintf(f, "%c", c); |
if (f != NULL) fprintf(f, "%c", c); |
Line 1434 if (c < 0x100)
|
Line 1977 if (c < 0x100)
|
} |
} |
} |
} |
|
|
if (f != NULL) fprintf(f, "\\x{%02x}", c); | if (f != NULL) n = fprintf(f, "\\x{%02x}", c); |
return (c <= 0x000000ff)? 6 : | return n >= 0 ? n : 0; |
(c <= 0x00000fff)? 7 : | |
(c <= 0x0000ffff)? 8 : | |
(c <= 0x000fffff)? 9 : 10; | |
} |
} |
|
|
|
|
Line 1453 If handed a NULL file, just counts chars without print
|
Line 1993 If handed a NULL file, just counts chars without print
|
|
|
static int pchars(pcre_uint8 *p, int length, FILE *f) |
static int pchars(pcre_uint8 *p, int length, FILE *f) |
{ |
{ |
int c = 0; | pcre_uint32 c = 0; |
int yield = 0; |
int yield = 0; |
|
|
if (length < 0) |
if (length < 0) |
Line 1498 return len;
|
Line 2038 return len;
|
#endif /* SUPPORT_PCRE16 */ |
#endif /* SUPPORT_PCRE16 */ |
|
|
|
|
|
|
|
#ifdef SUPPORT_PCRE32 |
|
/************************************************* |
|
* Find length of 0-terminated 32-bit string * |
|
*************************************************/ |
|
|
|
static int strlen32(PCRE_SPTR32 p) |
|
{ |
|
int len = 0; |
|
while (*p++ != 0) len++; |
|
return len; |
|
} |
|
#endif /* SUPPORT_PCRE32 */ |
|
|
|
|
|
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
/************************************************* |
/************************************************* |
* Print 16-bit character string * |
* Print 16-bit character string * |
Line 1515 if (length < 0)
|
Line 2071 if (length < 0)
|
|
|
while (length-- > 0) |
while (length-- > 0) |
{ |
{ |
int c = *p++ & 0xffff; | pcre_uint32 c = *p++ & 0xffff; |
#if !defined NOUTF |
#if !defined NOUTF |
if (use_utf && c >= 0xD800 && c < 0xDC00 && length > 0) |
if (use_utf && c >= 0xD800 && c < 0xDC00 && length > 0) |
{ |
{ |
int d = *p & 0xffff; |
int d = *p & 0xffff; |
if (d >= 0xDC00 && d < 0xDFFF) | if (d >= 0xDC00 && d <= 0xDFFF) |
{ |
{ |
c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000; |
c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000; |
length--; |
length--; |
Line 1537 return yield;
|
Line 2093 return yield;
|
|
|
|
|
|
|
|
#ifdef SUPPORT_PCRE32 |
|
/************************************************* |
|
* Print 32-bit character string * |
|
*************************************************/ |
|
|
|
/* Must handle UTF-32 strings in utf mode. Yields number of characters printed. |
|
If handed a NULL file, just counts chars without printing. */ |
|
|
|
static int pchars32(PCRE_SPTR32 p, int length, BOOL utf, FILE *f) |
|
{ |
|
int yield = 0; |
|
|
|
(void)(utf); /* Avoid compiler warning */ |
|
|
|
if (length < 0) |
|
length = strlen32(p); |
|
|
|
while (length-- > 0) |
|
{ |
|
pcre_uint32 c = *p++; |
|
yield += pchar(c, f); |
|
} |
|
|
|
return yield; |
|
} |
|
#endif /* SUPPORT_PCRE32 */ |
|
|
|
|
|
|
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
/************************************************* |
/************************************************* |
* Read a capture name (8-bit) and check it * |
* Read a capture name (8-bit) and check it * |
Line 1590 return p;
|
Line 2175 return p;
|
|
|
|
|
|
|
|
#ifdef SUPPORT_PCRE32 |
/************************************************* |
/************************************************* |
|
* Read a capture name (32-bit) and check it * |
|
*************************************************/ |
|
|
|
/* Note that the text being read is 8-bit. */ |
|
|
|
static pcre_uint8 * |
|
read_capture_name32(pcre_uint8 *p, pcre_uint32 **pp, pcre *re) |
|
{ |
|
pcre_uint32 *npp = *pp; |
|
while (isalnum(*p)) *npp++ = *p++; |
|
*npp++ = 0; |
|
*npp = 0; |
|
if (pcre32_get_stringnumber((pcre32 *)re, (PCRE_SPTR32)(*pp)) < 0) |
|
{ |
|
fprintf(outfile, "no parentheses with name \""); |
|
PCHARSV(*pp, 0, -1, outfile); |
|
fprintf(outfile, "\"\n"); |
|
} |
|
*pp = npp; |
|
return p; |
|
} |
|
#endif /* SUPPORT_PCRE32 */ |
|
|
|
|
|
|
|
/************************************************* |
* Callout function * |
* Callout function * |
*************************************************/ |
*************************************************/ |
|
|
Line 1747 free(block);
|
Line 2359 free(block);
|
*************************************************/ |
*************************************************/ |
|
|
/* Get one piece of information from the pcre_fullinfo() function. When only |
/* Get one piece of information from the pcre_fullinfo() function. When only |
one of 8-bit or 16-bit is supported, use_pcre16 should always have the correct | one of 8-, 16- or 32-bit is supported, pcre_mode should always have the correct |
value, but the code is defensive. |
value, but the code is defensive. |
|
|
Arguments: |
Arguments: |
Line 1764 new_info(pcre *re, pcre_extra *study, int option, void
|
Line 2376 new_info(pcre *re, pcre_extra *study, int option, void
|
{ |
{ |
int rc; |
int rc; |
|
|
if (use_pcre16) | if (pcre_mode == PCRE32_MODE) |
| #ifdef SUPPORT_PCRE32 |
| rc = pcre32_fullinfo((pcre32 *)re, (pcre32_extra *)study, option, ptr); |
| #else |
| rc = PCRE_ERROR_BADMODE; |
| #endif |
| else if (pcre_mode == PCRE16_MODE) |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
rc = pcre16_fullinfo((pcre16 *)re, (pcre16_extra *)study, option, ptr); |
rc = pcre16_fullinfo((pcre16 *)re, (pcre16_extra *)study, option, ptr); |
#else |
#else |
Line 1777 else
|
Line 2395 else
|
rc = PCRE_ERROR_BADMODE; |
rc = PCRE_ERROR_BADMODE; |
#endif |
#endif |
|
|
if (rc < 0) | if (rc < 0 && rc != PCRE_ERROR_UNSET) |
{ |
{ |
fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc, |
fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc, |
use_pcre16? "16" : "", option); | pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "", option); |
if (rc == PCRE_ERROR_BADMODE) |
if (rc == PCRE_ERROR_BADMODE) |
fprintf(outfile, "Running in %s-bit mode but pattern was compiled in " | fprintf(outfile, "Running in %d-bit mode but pattern was compiled in " |
"%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16"); | "%d-bit mode\n", 8 * CHAR_SIZE, |
| 8 * (REAL_PCRE_FLAGS(re) & PCRE_MODE_MASK)); |
} |
} |
|
|
return rc; |
return rc; |
Line 1832 bytes in the pattern itself. This is to make it possib
|
Line 2451 bytes in the pattern itself. This is to make it possib
|
ability to reload byte-flipped patterns, e.g. those compiled on a different |
ability to reload byte-flipped patterns, e.g. those compiled on a different |
architecture. */ |
architecture. */ |
|
|
|
#if defined SUPPORT_PCRE8 || defined SUPPORT_PCRE16 |
static void |
static void |
regexflip(pcre *ere, pcre_extra *extra) | regexflip8_or_16(pcre *ere, pcre_extra *extra) |
{ |
{ |
REAL_PCRE *re = (REAL_PCRE *)ere; | real_pcre8_or_16 *re = (real_pcre8_or_16 *)ere; |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
int op; |
int op; |
pcre_uint16 *ptr = (pcre_uint16 *)re + re->name_table_offset; |
pcre_uint16 *ptr = (pcre_uint16 *)re + re->name_table_offset; |
Line 1851 BOOL utf16_char = FALSE;
|
Line 2471 BOOL utf16_char = FALSE;
|
re->magic_number = REVERSED_MAGIC_NUMBER; |
re->magic_number = REVERSED_MAGIC_NUMBER; |
re->size = swap_uint32(re->size); |
re->size = swap_uint32(re->size); |
re->options = swap_uint32(re->options); |
re->options = swap_uint32(re->options); |
re->flags = swap_uint16(re->flags); | re->flags = swap_uint32(re->flags); |
re->top_bracket = swap_uint16(re->top_bracket); | re->limit_match = swap_uint32(re->limit_match); |
re->top_backref = swap_uint16(re->top_backref); | re->limit_recursion = swap_uint32(re->limit_recursion); |
re->first_char = swap_uint16(re->first_char); |
re->first_char = swap_uint16(re->first_char); |
re->req_char = swap_uint16(re->req_char); |
re->req_char = swap_uint16(re->req_char); |
|
re->max_lookbehind = swap_uint16(re->max_lookbehind); |
|
re->top_bracket = swap_uint16(re->top_bracket); |
|
re->top_backref = swap_uint16(re->top_backref); |
re->name_table_offset = swap_uint16(re->name_table_offset); |
re->name_table_offset = swap_uint16(re->name_table_offset); |
re->name_entry_size = swap_uint16(re->name_entry_size); |
re->name_entry_size = swap_uint16(re->name_entry_size); |
re->name_count = swap_uint16(re->name_count); |
re->name_count = swap_uint16(re->name_count); |
|
re->ref_count = swap_uint16(re->ref_count); |
|
|
if (extra != NULL) |
if (extra != NULL) |
{ |
{ |
Line 1872 if (extra != NULL)
|
Line 2496 if (extra != NULL)
|
in the name table, if present, and then in the pattern itself. */ |
in the name table, if present, and then in the pattern itself. */ |
|
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
if (!use_pcre16) return; | if (pcre_mode != PCRE16_MODE) return; |
|
|
while(TRUE) |
while(TRUE) |
{ |
{ |
Line 2010 while(TRUE)
|
Line 2634 while(TRUE)
|
/* Control should never reach here in 16 bit mode. */ |
/* Control should never reach here in 16 bit mode. */ |
#endif /* SUPPORT_PCRE16 */ |
#endif /* SUPPORT_PCRE16 */ |
} |
} |
|
#endif /* SUPPORT_PCRE[8|16] */ |
|
|
|
|
|
|
|
#if defined SUPPORT_PCRE32 |
|
static void |
|
regexflip_32(pcre *ere, pcre_extra *extra) |
|
{ |
|
real_pcre32 *re = (real_pcre32 *)ere; |
|
int op; |
|
pcre_uint32 *ptr = (pcre_uint32 *)re + re->name_table_offset; |
|
int length = re->name_count * re->name_entry_size; |
|
|
|
/* Always flip the bytes in the main data block and study blocks. */ |
|
|
|
re->magic_number = REVERSED_MAGIC_NUMBER; |
|
re->size = swap_uint32(re->size); |
|
re->options = swap_uint32(re->options); |
|
re->flags = swap_uint32(re->flags); |
|
re->limit_match = swap_uint32(re->limit_match); |
|
re->limit_recursion = swap_uint32(re->limit_recursion); |
|
re->first_char = swap_uint32(re->first_char); |
|
re->req_char = swap_uint32(re->req_char); |
|
re->max_lookbehind = swap_uint16(re->max_lookbehind); |
|
re->top_bracket = swap_uint16(re->top_bracket); |
|
re->top_backref = swap_uint16(re->top_backref); |
|
re->name_table_offset = swap_uint16(re->name_table_offset); |
|
re->name_entry_size = swap_uint16(re->name_entry_size); |
|
re->name_count = swap_uint16(re->name_count); |
|
re->ref_count = swap_uint16(re->ref_count); |
|
|
|
if (extra != NULL) |
|
{ |
|
pcre_study_data *rsd = (pcre_study_data *)(extra->study_data); |
|
rsd->size = swap_uint32(rsd->size); |
|
rsd->flags = swap_uint32(rsd->flags); |
|
rsd->minlength = swap_uint32(rsd->minlength); |
|
} |
|
|
|
/* In 32-bit mode we must swap bytes in the name table, if present, and then in |
|
the pattern itself. */ |
|
|
|
while(TRUE) |
|
{ |
|
/* Swap previous characters. */ |
|
while (length-- > 0) |
|
{ |
|
*ptr = swap_uint32(*ptr); |
|
ptr++; |
|
} |
|
|
|
/* Get next opcode. */ |
|
|
|
length = 0; |
|
op = *ptr; |
|
*ptr++ = swap_uint32(op); |
|
|
|
switch (op) |
|
{ |
|
case OP_END: |
|
return; |
|
|
|
default: |
|
length = OP_lengths32[op] - 1; |
|
break; |
|
|
|
case OP_CLASS: |
|
case OP_NCLASS: |
|
/* Skip the character bit map. */ |
|
ptr += 32/sizeof(pcre_uint32); |
|
length = 0; |
|
break; |
|
|
|
case OP_XCLASS: |
|
/* LINK_SIZE can only be 1 in 32-bit mode. */ |
|
length = (int)((unsigned int)(ptr[0]) - (1 + LINK_SIZE + 1)); |
|
|
|
/* Reverse the size of the XCLASS instance. */ |
|
*ptr = swap_uint32(*ptr); |
|
ptr++; |
|
|
|
op = *ptr; |
|
*ptr = swap_uint32(op); |
|
ptr++; |
|
if ((op & XCL_MAP) != 0) |
|
{ |
|
/* Skip the character bit map. */ |
|
ptr += 32/sizeof(pcre_uint32); |
|
length -= 32/sizeof(pcre_uint32); |
|
} |
|
break; |
|
} |
|
} |
|
/* Control should never reach here in 32 bit mode. */ |
|
} |
|
|
|
#endif /* SUPPORT_PCRE32 */ |
|
|
|
|
|
|
|
static void |
|
regexflip(pcre *ere, pcre_extra *extra) |
|
{ |
|
#if defined SUPPORT_PCRE32 |
|
if (REAL_PCRE_FLAGS(ere) & PCRE_MODE32) |
|
regexflip_32(ere, extra); |
|
#endif |
|
#if defined SUPPORT_PCRE8 || defined SUPPORT_PCRE16 |
|
if (REAL_PCRE_FLAGS(ere) & (PCRE_MODE8 | PCRE_MODE16)) |
|
regexflip8_or_16(ere, extra); |
|
#endif |
|
} |
|
|
|
|
|
|
/************************************************* |
/************************************************* |
* Check match or recursion limit * |
* Check match or recursion limit * |
*************************************************/ |
*************************************************/ |
Line 2138 printf("\nOptions:\n");
|
Line 2874 printf("\nOptions:\n");
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
printf(" -16 use the 16-bit library\n"); |
printf(" -16 use the 16-bit library\n"); |
#endif |
#endif |
|
#ifdef SUPPORT_PCRE32 |
|
printf(" -32 use the 32-bit library\n"); |
|
#endif |
printf(" -b show compiled code\n"); |
printf(" -b show compiled code\n"); |
printf(" -C show PCRE compile-time options and exit\n"); |
printf(" -C show PCRE compile-time options and exit\n"); |
printf(" -C arg show a specific compile-time option\n"); |
printf(" -C arg show a specific compile-time option\n"); |
Line 2145 printf(" and exit with its value. The arg ca
|
Line 2884 printf(" and exit with its value. The arg ca
|
printf(" linksize internal link size [2, 3, 4]\n"); |
printf(" linksize internal link size [2, 3, 4]\n"); |
printf(" pcre8 8 bit library support enabled [0, 1]\n"); |
printf(" pcre8 8 bit library support enabled [0, 1]\n"); |
printf(" pcre16 16 bit library support enabled [0, 1]\n"); |
printf(" pcre16 16 bit library support enabled [0, 1]\n"); |
|
printf(" pcre32 32 bit library support enabled [0, 1]\n"); |
printf(" utf Unicode Transformation Format supported [0, 1]\n"); |
printf(" utf Unicode Transformation Format supported [0, 1]\n"); |
printf(" ucp Unicode Properties supported [0, 1]\n"); |
printf(" ucp Unicode Properties supported [0, 1]\n"); |
printf(" jit Just-in-time compiler supported [0, 1]\n"); |
printf(" jit Just-in-time compiler supported [0, 1]\n"); |
Line 2209 int all_use_dfa = 0;
|
Line 2949 int all_use_dfa = 0;
|
int verify_jit = 0; |
int verify_jit = 0; |
int yield = 0; |
int yield = 0; |
int stack_size; |
int stack_size; |
|
pcre_uint8 *dbuffer = NULL; |
|
size_t dbuffer_size = 1u << 14; |
|
|
#if !defined NOPOSIX |
#if !defined NOPOSIX |
int posix = 0; |
int posix = 0; |
Line 2222 pcre_jit_stack *jit_stack = NULL;
|
Line 2964 pcre_jit_stack *jit_stack = NULL;
|
/* These vectors store, end-to-end, a list of zero-terminated captured |
/* These vectors store, end-to-end, a list of zero-terminated captured |
substring names, each list itself being terminated by an empty name. Assume |
substring names, each list itself being terminated by an empty name. Assume |
that 1024 is plenty long enough for the few names we'll be testing. It is |
that 1024 is plenty long enough for the few names we'll be testing. It is |
easiest to keep separate 8-bit and 16-bit versions, using the 16-bit version | easiest to keep separate 8-, 16- and 32-bit versions, using the 32-bit version |
for the actual memory, to ensure alignment. */ |
for the actual memory, to ensure alignment. */ |
|
|
pcre_uint16 copynames[1024]; | pcre_uint32 copynames[1024]; |
pcre_uint16 getnames[1024]; | pcre_uint32 getnames[1024]; |
|
|
|
#ifdef SUPPORT_PCRE32 |
|
pcre_uint32 *cn32ptr; |
|
pcre_uint32 *gn32ptr; |
|
#endif |
|
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
|
pcre_uint16 *copynames16 = (pcre_uint16 *)copynames; |
|
pcre_uint16 *getnames16 = (pcre_uint16 *)getnames; |
pcre_uint16 *cn16ptr; |
pcre_uint16 *cn16ptr; |
pcre_uint16 *gn16ptr; |
pcre_uint16 *gn16ptr; |
#endif |
#endif |
Line 2241 pcre_uint8 *gn8ptr;
|
Line 2990 pcre_uint8 *gn8ptr;
|
#endif |
#endif |
|
|
/* Get buffers from malloc() so that valgrind will check their misuse when |
/* Get buffers from malloc() so that valgrind will check their misuse when |
debugging. They grow automatically when very long lines are read. The 16-bit | debugging. They grow automatically when very long lines are read. The 16- |
buffer (buffer16) is obtained only if needed. */ | and 32-bit buffers (buffer16, buffer32) are obtained only if needed. */ |
|
|
buffer = (pcre_uint8 *)malloc(buffer_size); |
buffer = (pcre_uint8 *)malloc(buffer_size); |
dbuffer = (pcre_uint8 *)malloc(buffer_size); |
|
pbuffer = (pcre_uint8 *)malloc(buffer_size); |
pbuffer = (pcre_uint8 *)malloc(buffer_size); |
|
|
/* The outfile variable is static so that new_malloc can use it. */ |
/* The outfile variable is static so that new_malloc can use it. */ |
Line 2264 _setmode( _fileno( stdout ), _O_BINARY );
|
Line 3012 _setmode( _fileno( stdout ), _O_BINARY );
|
/* Get the version number: both pcre_version() and pcre16_version() give the |
/* Get the version number: both pcre_version() and pcre16_version() give the |
same answer. We just need to ensure that we call one that is available. */ |
same answer. We just need to ensure that we call one that is available. */ |
|
|
#ifdef SUPPORT_PCRE8 | #if defined SUPPORT_PCRE8 |
version = pcre_version(); |
version = pcre_version(); |
#else | #elif defined SUPPORT_PCRE16 |
version = pcre16_version(); |
version = pcre16_version(); |
|
#elif defined SUPPORT_PCRE32 |
|
version = pcre32_version(); |
#endif |
#endif |
|
|
/* Scan options */ |
/* Scan options */ |
Line 2291 while (argc > 1 && argv[op][0] == '-')
|
Line 3041 while (argc > 1 && argv[op][0] == '-')
|
force_study_options = jit_study_bits[*arg - '1']; |
force_study_options = jit_study_bits[*arg - '1']; |
else goto BAD_ARG; |
else goto BAD_ARG; |
} |
} |
|
else if (strcmp(arg, "-8") == 0) |
|
{ |
|
#ifdef SUPPORT_PCRE8 |
|
pcre_mode = PCRE8_MODE; |
|
#else |
|
printf("** This version of PCRE was built without 8-bit support\n"); |
|
exit(1); |
|
#endif |
|
} |
else if (strcmp(arg, "-16") == 0) |
else if (strcmp(arg, "-16") == 0) |
{ |
{ |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
use_pcre16 = 1; | pcre_mode = PCRE16_MODE; |
#else |
#else |
printf("** This version of PCRE was built without 16-bit support\n"); |
printf("** This version of PCRE was built without 16-bit support\n"); |
exit(1); |
exit(1); |
#endif |
#endif |
} |
} |
|
else if (strcmp(arg, "-32") == 0) |
|
{ |
|
#ifdef SUPPORT_PCRE32 |
|
pcre_mode = PCRE32_MODE; |
|
#else |
|
printf("** This version of PCRE was built without 32-bit support\n"); |
|
exit(1); |
|
#endif |
|
} |
else if (strcmp(arg, "-q") == 0) quiet = 1; |
else if (strcmp(arg, "-q") == 0) quiet = 1; |
else if (strcmp(arg, "-b") == 0) debug = 1; |
else if (strcmp(arg, "-b") == 0) debug = 1; |
else if (strcmp(arg, "-i") == 0) showinfo = 1; |
else if (strcmp(arg, "-i") == 0) showinfo = 1; |
Line 2333 while (argc > 1 && argv[op][0] == '-')
|
Line 3101 while (argc > 1 && argv[op][0] == '-')
|
((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)), |
((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)), |
*endptr == 0)) |
*endptr == 0)) |
{ |
{ |
#if defined(_WIN32) || defined(WIN32) || defined(__minix) | #if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS) || defined(__VMS) |
printf("PCRE: -S not supported on this OS\n"); |
printf("PCRE: -S not supported on this OS\n"); |
exit(1); |
exit(1); |
#else |
#else |
Line 2366 while (argc > 1 && argv[op][0] == '-')
|
Line 3134 while (argc > 1 && argv[op][0] == '-')
|
(void)PCRE_CONFIG(PCRE_CONFIG_LINK_SIZE, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_LINK_SIZE, &rc); |
printf("%d\n", rc); |
printf("%d\n", rc); |
yield = rc; |
yield = rc; |
goto EXIT; | |
| #ifdef __VMS |
| vms_setsymbol("LINKSIZE",0,yield ); |
| #endif |
} |
} |
if (strcmp(argv[op + 1], "pcre8") == 0) | else if (strcmp(argv[op + 1], "pcre8") == 0) |
{ |
{ |
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
printf("1\n"); |
printf("1\n"); |
Line 2377 while (argc > 1 && argv[op][0] == '-')
|
Line 3148 while (argc > 1 && argv[op][0] == '-')
|
printf("0\n"); |
printf("0\n"); |
yield = 0; |
yield = 0; |
#endif |
#endif |
goto EXIT; | #ifdef __VMS |
| vms_setsymbol("PCRE8",0,yield ); |
| #endif |
} |
} |
if (strcmp(argv[op + 1], "pcre16") == 0) | else if (strcmp(argv[op + 1], "pcre16") == 0) |
{ |
{ |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
printf("1\n"); |
printf("1\n"); |
Line 2388 while (argc > 1 && argv[op][0] == '-')
|
Line 3161 while (argc > 1 && argv[op][0] == '-')
|
printf("0\n"); |
printf("0\n"); |
yield = 0; |
yield = 0; |
#endif |
#endif |
goto EXIT; | #ifdef __VMS |
| vms_setsymbol("PCRE16",0,yield ); |
| #endif |
} |
} |
if (strcmp(argv[op + 1], "utf") == 0) | else if (strcmp(argv[op + 1], "pcre32") == 0) |
{ |
{ |
|
#ifdef SUPPORT_PCRE32 |
|
printf("1\n"); |
|
yield = 1; |
|
#else |
|
printf("0\n"); |
|
yield = 0; |
|
#endif |
|
#ifdef __VMS |
|
vms_setsymbol("PCRE32",0,yield ); |
|
#endif |
|
} |
|
else if (strcmp(argv[op + 1], "utf") == 0) |
|
{ |
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
(void)pcre_config(PCRE_CONFIG_UTF8, &rc); | if (pcre_mode == PCRE8_MODE) |
| (void)pcre_config(PCRE_CONFIG_UTF8, &rc); |
| #endif |
| #ifdef SUPPORT_PCRE16 |
| if (pcre_mode == PCRE16_MODE) |
| (void)pcre16_config(PCRE_CONFIG_UTF16, &rc); |
| #endif |
| #ifdef SUPPORT_PCRE32 |
| if (pcre_mode == PCRE32_MODE) |
| (void)pcre32_config(PCRE_CONFIG_UTF32, &rc); |
| #endif |
printf("%d\n", rc); |
printf("%d\n", rc); |
yield = rc; |
yield = rc; |
#else | #ifdef __VMS |
(void)pcre16_config(PCRE_CONFIG_UTF16, &rc); | vms_setsymbol("UTF",0,yield ); |
printf("%d\n", rc); | |
yield = rc; | |
#endif |
#endif |
goto EXIT; |
|
} |
} |
if (strcmp(argv[op + 1], "ucp") == 0) | else if (strcmp(argv[op + 1], "ucp") == 0) |
{ |
{ |
(void)PCRE_CONFIG(PCRE_CONFIG_UNICODE_PROPERTIES, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_UNICODE_PROPERTIES, &rc); |
printf("%d\n", rc); |
printf("%d\n", rc); |
yield = rc; |
yield = rc; |
goto EXIT; |
|
} |
} |
if (strcmp(argv[op + 1], "jit") == 0) | else if (strcmp(argv[op + 1], "jit") == 0) |
{ |
{ |
(void)PCRE_CONFIG(PCRE_CONFIG_JIT, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_JIT, &rc); |
printf("%d\n", rc); |
printf("%d\n", rc); |
yield = rc; |
yield = rc; |
goto EXIT; |
|
} |
} |
if (strcmp(argv[op + 1], "newline") == 0) | else if (strcmp(argv[op + 1], "newline") == 0) |
{ |
{ |
(void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc); |
/* Note that these values are always the ASCII values, even | print_newline_config(rc, TRUE); |
in EBCDIC environments. CR is 13 and NL is 10. */ | |
printf("%s\n", (rc == 13)? "CR" : | |
(rc == 10)? "LF" : (rc == (13<<8 | 10))? "CRLF" : | |
(rc == -2)? "ANYCRLF" : | |
(rc == -1)? "ANY" : "???"); | |
goto EXIT; | |
} |
} |
printf("Unknown -C option: %s\n", argv[op + 1]); | else if (strcmp(argv[op + 1], "ebcdic") == 0) |
| { |
| #ifdef EBCDIC |
| printf("1\n"); |
| yield = 1; |
| #else |
| printf("0\n"); |
| #endif |
| } |
| else if (strcmp(argv[op + 1], "ebcdic-nl") == 0) |
| { |
| #ifdef EBCDIC |
| printf("0x%02x\n", CHAR_LF); |
| #else |
| printf("0\n"); |
| #endif |
| } |
| else |
| { |
| printf("Unknown -C option: %s\n", argv[op + 1]); |
| } |
goto EXIT; |
goto EXIT; |
} |
} |
|
|
|
/* No argument for -C: output all configuration information. */ |
|
|
printf("PCRE version %s\n", version); |
printf("PCRE version %s\n", version); |
printf("Compiled with\n"); |
printf("Compiled with\n"); |
|
|
|
#ifdef EBCDIC |
|
printf(" EBCDIC code support: LF is 0x%02x\n", CHAR_LF); |
|
#endif |
|
|
/* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both |
/* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both |
are set, either both UTFs are supported or both are not supported. */ |
are set, either both UTFs are supported or both are not supported. */ |
|
|
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 | #ifdef SUPPORT_PCRE8 |
printf(" 8-bit and 16-bit support\n"); | printf(" 8-bit support\n"); |
(void)pcre_config(PCRE_CONFIG_UTF8, &rc); |
(void)pcre_config(PCRE_CONFIG_UTF8, &rc); |
if (rc) | printf (" %sUTF-8 support\n", rc ? "" : "No "); |
printf(" UTF-8 and UTF-16 support\n"); | #endif |
else | #ifdef SUPPORT_PCRE16 |
printf(" No UTF-8 or UTF-16 support\n"); | printf(" 16-bit support\n"); |
#elif defined SUPPORT_PCRE8 | |
printf(" 8-bit support only\n"); | |
(void)pcre_config(PCRE_CONFIG_UTF8, &rc); | |
printf(" %sUTF-8 support\n", rc? "" : "No "); | |
#else | |
printf(" 16-bit support only\n"); | |
(void)pcre16_config(PCRE_CONFIG_UTF16, &rc); |
(void)pcre16_config(PCRE_CONFIG_UTF16, &rc); |
printf(" %sUTF-16 support\n", rc? "" : "No "); | printf (" %sUTF-16 support\n", rc ? "" : "No "); |
#endif |
#endif |
|
#ifdef SUPPORT_PCRE32 |
|
printf(" 32-bit support\n"); |
|
(void)pcre32_config(PCRE_CONFIG_UTF32, &rc); |
|
printf (" %sUTF-32 support\n", rc ? "" : "No "); |
|
#endif |
|
|
(void)PCRE_CONFIG(PCRE_CONFIG_UNICODE_PROPERTIES, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_UNICODE_PROPERTIES, &rc); |
printf(" %sUnicode properties support\n", rc? "" : "No "); |
printf(" %sUnicode properties support\n", rc? "" : "No "); |
Line 2467 are set, either both UTFs are supported or both are no
|
Line 3279 are set, either both UTFs are supported or both are no
|
else |
else |
printf(" No just-in-time compiler support\n"); |
printf(" No just-in-time compiler support\n"); |
(void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc); |
/* Note that these values are always the ASCII values, even | print_newline_config(rc, FALSE); |
in EBCDIC environments. CR is 13 and NL is 10. */ | |
printf(" Newline sequence is %s\n", (rc == 13)? "CR" : | |
(rc == 10)? "LF" : (rc == (13<<8 | 10))? "CRLF" : | |
(rc == -2)? "ANYCRLF" : | |
(rc == -1)? "ANY" : "???"); | |
(void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc); |
(void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc); |
printf(" \\R matches %s\n", rc? "CR, LF, or CRLF only" : |
printf(" \\R matches %s\n", rc? "CR, LF, or CRLF only" : |
"all Unicode newlines"); |
"all Unicode newlines"); |
Line 2564 pcre16_stack_malloc = stack_malloc;
|
Line 3371 pcre16_stack_malloc = stack_malloc;
|
pcre16_stack_free = stack_free; |
pcre16_stack_free = stack_free; |
#endif |
#endif |
|
|
|
#ifdef SUPPORT_PCRE32 |
|
pcre32_malloc = new_malloc; |
|
pcre32_free = new_free; |
|
pcre32_stack_malloc = stack_malloc; |
|
pcre32_stack_free = stack_free; |
|
#endif |
|
|
/* Heading line unless quiet, then prompt for first regex if stdin */ |
/* Heading line unless quiet, then prompt for first regex if stdin */ |
|
|
if (!quiet) fprintf(outfile, "PCRE version %s\n\n", version); |
if (!quiet) fprintf(outfile, "PCRE version %s\n\n", version); |
Line 2652 while (!done)
|
Line 3466 while (!done)
|
(sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7]; |
(sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7]; |
|
|
re = (pcre *)new_malloc(true_size); |
re = (pcre *)new_malloc(true_size); |
|
if (re == NULL) |
|
{ |
|
printf("** Failed to get %d bytes of memory for pcre object\n", |
|
(int)true_size); |
|
yield = 1; |
|
goto EXIT; |
|
} |
regex_gotten_store = first_gotten_store; |
regex_gotten_store = first_gotten_store; |
|
|
if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ; |
if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ; |
|
|
magic = ((REAL_PCRE *)re)->magic_number; | magic = REAL_PCRE_MAGIC(re); |
if (magic != MAGIC_NUMBER) |
if (magic != MAGIC_NUMBER) |
{ |
{ |
if (swap_uint32(magic) == MAGIC_NUMBER) |
if (swap_uint32(magic) == MAGIC_NUMBER) |
Line 2666 while (!done)
|
Line 3487 while (!done)
|
else |
else |
{ |
{ |
fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p); |
fprintf(outfile, "Data in %s is not a compiled PCRE regex\n", p); |
|
new_free(re); |
fclose(f); |
fclose(f); |
continue; |
continue; |
} |
} |
Line 2695 while (!done)
|
Line 3517 while (!done)
|
{ |
{ |
PCRE_FREE_STUDY(extra); |
PCRE_FREE_STUDY(extra); |
} |
} |
if (re != NULL) new_free(re); | new_free(re); |
fclose(f); |
fclose(f); |
continue; |
continue; |
} |
} |
Line 2711 while (!done)
|
Line 3533 while (!done)
|
PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL); |
PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL); |
if (rc == PCRE_ERROR_BADMODE) |
if (rc == PCRE_ERROR_BADMODE) |
{ |
{ |
|
pcre_uint32 flags_in_host_byte_order; |
|
if (REAL_PCRE_MAGIC(re) == MAGIC_NUMBER) |
|
flags_in_host_byte_order = REAL_PCRE_FLAGS(re); |
|
else |
|
flags_in_host_byte_order = swap_uint32(REAL_PCRE_FLAGS(re)); |
/* Simulate the result of the function call below. */ |
/* Simulate the result of the function call below. */ |
fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc, |
fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc, |
use_pcre16? "16" : "", PCRE_INFO_OPTIONS); | pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "", |
fprintf(outfile, "Running in %s-bit mode but pattern was compiled in " | PCRE_INFO_OPTIONS); |
"%s-bit mode\n", use_pcre16? "16":"8", use_pcre16? "8":"16"); | fprintf(outfile, "Running in %d-bit mode but pattern was compiled in " |
| "%d-bit mode\n", 8 * CHAR_SIZE, 8 * (flags_in_host_byte_order & PCRE_MODE_MASK)); |
| new_free(re); |
| fclose(f); |
continue; |
continue; |
} |
} |
} |
} |
|
|
/* Need to know if UTF-8 for printing data strings. */ |
/* Need to know if UTF-8 for printing data strings. */ |
|
|
if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0) continue; | if (new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options) < 0) |
| { |
| new_free(re); |
| fclose(f); |
| continue; |
| } |
use_utf = (get_options & PCRE_UTF8) != 0; |
use_utf = (get_options & PCRE_UTF8) != 0; |
|
|
fclose(f); |
fclose(f); |
Line 2781 while (!done)
|
Line 3616 while (!done)
|
/* Look for options after final delimiter */ |
/* Look for options after final delimiter */ |
|
|
options = 0; |
options = 0; |
study_options = 0; | study_options = force_study_options; |
log_store = showstore; /* default from command line */ |
log_store = showstore; /* default from command line */ |
|
|
while (*pp != 0) |
while (*pp != 0) |
Line 2818 while (!done)
|
Line 3653 while (!done)
|
#endif |
#endif |
|
|
case 'S': |
case 'S': |
if (do_study == 0) | do_study = 1; |
| for (;;) |
{ |
{ |
do_study = 1; | switch (*pp++) |
if (*pp == '+') | |
{ |
{ |
if (*(++pp) == '+') | case 'S': |
| do_study = 0; |
| no_force_study = 1; |
| break; |
| |
| case '!': |
| study_options |= PCRE_STUDY_EXTRA_NEEDED; |
| break; |
| |
| case '+': |
| if (*pp == '+') |
{ |
{ |
verify_jit = TRUE; |
verify_jit = TRUE; |
pp++; |
pp++; |
Line 2832 while (!done)
|
Line 3677 while (!done)
|
study_options |= jit_study_bits[*pp++ - '1']; |
study_options |= jit_study_bits[*pp++ - '1']; |
else |
else |
study_options |= jit_study_bits[6]; |
study_options |= jit_study_bits[6]; |
|
break; |
|
|
|
case '-': |
|
study_options &= ~PCRE_STUDY_ALLJIT; |
|
break; |
|
|
|
default: |
|
pp--; |
|
goto ENDLOOP; |
} |
} |
} |
} |
else | ENDLOOP: |
{ | |
do_study = 0; | |
no_force_study = 1; | |
} | |
break; |
break; |
|
|
case 'U': options |= PCRE_UNGREEDY; break; |
case 'U': options |= PCRE_UNGREEDY; break; |
Line 2847 while (!done)
|
Line 3697 while (!done)
|
case 'Y': options |= PCRE_NO_START_OPTIMISE; break; |
case 'Y': options |= PCRE_NO_START_OPTIMISE; break; |
case 'Z': debug_lengths = 0; break; |
case 'Z': debug_lengths = 0; break; |
case '8': options |= PCRE_UTF8; use_utf = 1; break; |
case '8': options |= PCRE_UTF8; use_utf = 1; break; |
|
case '9': options |= PCRE_NEVER_UTF; break; |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
case '?': options |= PCRE_NO_UTF8_CHECK; break; |
|
|
case 'T': |
case 'T': |
Line 2957 while (!done)
|
Line 3808 while (!done)
|
#endif /* !defined NOPOSIX */ |
#endif /* !defined NOPOSIX */ |
|
|
{ |
{ |
/* In 16-bit mode, convert the input. */ | /* In 16- or 32-bit mode, convert the input. */ |
|
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
if (use_pcre16) | if (pcre_mode == PCRE16_MODE) |
{ |
{ |
switch(to16(FALSE, p, options & PCRE_UTF8, (int)strlen((char *)p))) |
switch(to16(FALSE, p, options & PCRE_UTF8, (int)strlen((char *)p))) |
{ |
{ |
Line 2986 while (!done)
|
Line 3837 while (!done)
|
} |
} |
#endif |
#endif |
|
|
|
#ifdef SUPPORT_PCRE32 |
|
if (pcre_mode == PCRE32_MODE) |
|
{ |
|
switch(to32(FALSE, p, options & PCRE_UTF32, (int)strlen((char *)p))) |
|
{ |
|
case -1: |
|
fprintf(outfile, "**Failed: invalid UTF-8 string cannot be " |
|
"converted to UTF-32\n"); |
|
goto SKIP_DATA; |
|
|
|
case -2: |
|
fprintf(outfile, "**Failed: character value greater than 0x10ffff " |
|
"cannot be converted to UTF-32\n"); |
|
goto SKIP_DATA; |
|
|
|
case -3: |
|
fprintf(outfile, "**Failed: character value is ill-formed UTF-32\n"); |
|
goto SKIP_DATA; |
|
|
|
default: |
|
break; |
|
} |
|
p = (pcre_uint8 *)buffer32; |
|
} |
|
#endif |
|
|
/* Compile many times when timing */ |
/* Compile many times when timing */ |
|
|
if (timeit > 0) |
if (timeit > 0) |
Line 3043 while (!done)
|
Line 3920 while (!done)
|
/* Extract the size for possible writing before possibly flipping it, |
/* Extract the size for possible writing before possibly flipping it, |
and remember the store that was got. */ |
and remember the store that was got. */ |
|
|
true_size = ((REAL_PCRE *)re)->size; | true_size = REAL_PCRE_SIZE(re); |
regex_gotten_store = first_gotten_store; |
regex_gotten_store = first_gotten_store; |
|
|
/* Output code size information if requested */ |
/* Output code size information if requested */ |
|
|
if (log_store) |
if (log_store) |
|
{ |
|
int name_count, name_entry_size, real_pcre_size; |
|
|
|
new_info(re, NULL, PCRE_INFO_NAMECOUNT, &name_count); |
|
new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &name_entry_size); |
|
real_pcre_size = 0; |
|
#ifdef SUPPORT_PCRE8 |
|
if (REAL_PCRE_FLAGS(re) & PCRE_MODE8) |
|
real_pcre_size = sizeof(real_pcre); |
|
#endif |
|
#ifdef SUPPORT_PCRE16 |
|
if (REAL_PCRE_FLAGS(re) & PCRE_MODE16) |
|
real_pcre_size = sizeof(real_pcre16); |
|
#endif |
|
#ifdef SUPPORT_PCRE32 |
|
if (REAL_PCRE_FLAGS(re) & PCRE_MODE32) |
|
real_pcre_size = sizeof(real_pcre32); |
|
#endif |
fprintf(outfile, "Memory allocation (code space): %d\n", |
fprintf(outfile, "Memory allocation (code space): %d\n", |
(int)(first_gotten_store - | (int)(first_gotten_store - real_pcre_size - name_count * name_entry_size)); |
sizeof(REAL_PCRE) - | } |
((REAL_PCRE *)re)->name_count * ((REAL_PCRE *)re)->name_entry_size)); | |
|
|
/* If -s or /S was present, study the regex to generate additional info to |
/* If -s or /S was present, study the regex to generate additional info to |
help with the matching, unless the pattern has the SS option, which |
help with the matching, unless the pattern has the SS option, which |
Line 3068 while (!done)
|
Line 3962 while (!done)
|
clock_t start_time = clock(); |
clock_t start_time = clock(); |
for (i = 0; i < timeit; i++) |
for (i = 0; i < timeit; i++) |
{ |
{ |
PCRE_STUDY(extra, re, study_options | force_study_options, &error); | PCRE_STUDY(extra, re, study_options, &error); |
} |
} |
time_taken = clock() - start_time; |
time_taken = clock() - start_time; |
if (extra != NULL) |
if (extra != NULL) |
Line 3079 while (!done)
|
Line 3973 while (!done)
|
(((double)time_taken * 1000.0) / (double)timeit) / |
(((double)time_taken * 1000.0) / (double)timeit) / |
(double)CLOCKS_PER_SEC); |
(double)CLOCKS_PER_SEC); |
} |
} |
PCRE_STUDY(extra, re, study_options | force_study_options, &error); | PCRE_STUDY(extra, re, study_options, &error); |
if (error != NULL) |
if (error != NULL) |
fprintf(outfile, "Failed to study: %s\n", error); |
fprintf(outfile, "Failed to study: %s\n", error); |
else if (extra != NULL) |
else if (extra != NULL) |
Line 3123 while (!done)
|
Line 4017 while (!done)
|
if (do_showinfo) |
if (do_showinfo) |
{ |
{ |
unsigned long int all_options; |
unsigned long int all_options; |
int count, backrefmax, first_char, need_char, okpartial, jchanged, | pcre_uint32 first_char, need_char; |
| pcre_uint32 match_limit, recursion_limit; |
| int count, backrefmax, first_char_set, need_char_set, okpartial, jchanged, |
hascrorlf, maxlookbehind; |
hascrorlf, maxlookbehind; |
int nameentrysize, namecount; |
int nameentrysize, namecount; |
const pcre_uint8 *nametable; |
const pcre_uint8 *nametable; |
Line 3131 while (!done)
|
Line 4027 while (!done)
|
if (new_info(re, NULL, PCRE_INFO_SIZE, &size) + |
if (new_info(re, NULL, PCRE_INFO_SIZE, &size) + |
new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count) + |
new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count) + |
new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax) + |
new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax) + |
new_info(re, NULL, PCRE_INFO_FIRSTBYTE, &first_char) + | new_info(re, NULL, PCRE_INFO_FIRSTCHARACTER, &first_char) + |
new_info(re, NULL, PCRE_INFO_LASTLITERAL, &need_char) + | new_info(re, NULL, PCRE_INFO_FIRSTCHARACTERFLAGS, &first_char_set) + |
| new_info(re, NULL, PCRE_INFO_REQUIREDCHAR, &need_char) + |
| new_info(re, NULL, PCRE_INFO_REQUIREDCHARFLAGS, &need_char_set) + |
new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize) + |
new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize) + |
new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount) + |
new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount) + |
new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable) + |
new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable) + |
Line 3148 while (!done)
|
Line 4046 while (!done)
|
(int)size, (int)regex_gotten_store); |
(int)size, (int)regex_gotten_store); |
|
|
fprintf(outfile, "Capturing subpattern count = %d\n", count); |
fprintf(outfile, "Capturing subpattern count = %d\n", count); |
|
|
if (backrefmax > 0) |
if (backrefmax > 0) |
fprintf(outfile, "Max back reference = %d\n", backrefmax); |
fprintf(outfile, "Max back reference = %d\n", backrefmax); |
|
|
|
if (maxlookbehind > 0) |
|
fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind); |
|
|
|
if (new_info(re, NULL, PCRE_INFO_MATCHLIMIT, &match_limit) == 0) |
|
fprintf(outfile, "Match limit = %u\n", match_limit); |
|
|
|
if (new_info(re, NULL, PCRE_INFO_RECURSIONLIMIT, &recursion_limit) == 0) |
|
fprintf(outfile, "Recursion limit = %u\n", recursion_limit); |
|
|
if (namecount > 0) |
if (namecount > 0) |
{ |
{ |
fprintf(outfile, "Named capturing subpatterns:\n"); |
fprintf(outfile, "Named capturing subpatterns:\n"); |
while (namecount-- > 0) |
while (namecount-- > 0) |
{ |
{ |
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 | int imm2_size = pcre_mode == PCRE8_MODE ? 2 : 1; |
int imm2_size = use_pcre16 ? 1 : 2; | |
#else | |
int imm2_size = IMM2_SIZE; | |
#endif | |
int length = (int)STRLEN(nametable + imm2_size); |
int length = (int)STRLEN(nametable + imm2_size); |
fprintf(outfile, " "); |
fprintf(outfile, " "); |
PCHARSV(nametable, imm2_size, length, outfile); |
PCHARSV(nametable, imm2_size, length, outfile); |
while (length++ < nameentrysize - imm2_size) putc(' ', outfile); |
while (length++ < nameentrysize - imm2_size) putc(' ', outfile); |
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 | #ifdef SUPPORT_PCRE32 |
fprintf(outfile, "%3d\n", use_pcre16? | if (pcre_mode == PCRE32_MODE) |
(int)(((PCRE_SPTR16)nametable)[0]) | fprintf(outfile, "%3d\n", (int)(((PCRE_SPTR32)nametable)[0])); |
:((int)nametable[0] << 8) | (int)nametable[1]); | |
nametable += nameentrysize * (use_pcre16 ? 2 : 1); | |
#else | |
fprintf(outfile, "%3d\n", GET2(nametable, 0)); | |
#ifdef SUPPORT_PCRE8 | |
nametable += nameentrysize; | |
#else | |
nametable += nameentrysize * 2; | |
#endif |
#endif |
|
#ifdef SUPPORT_PCRE16 |
|
if (pcre_mode == PCRE16_MODE) |
|
fprintf(outfile, "%3d\n", (int)(((PCRE_SPTR16)nametable)[0])); |
#endif |
#endif |
|
#ifdef SUPPORT_PCRE8 |
|
if (pcre_mode == PCRE8_MODE) |
|
fprintf(outfile, "%3d\n", ((int)nametable[0] << 8) | (int)nametable[1]); |
|
#endif |
|
nametable += nameentrysize * CHAR_SIZE; |
} |
} |
} |
} |
|
|
if (!okpartial) fprintf(outfile, "Partial matching not supported\n"); |
if (!okpartial) fprintf(outfile, "Partial matching not supported\n"); |
if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n"); |
if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n"); |
|
|
all_options = ((REAL_PCRE *)re)->options; | all_options = REAL_PCRE_OPTIONS(re); |
if (do_flip) all_options = swap_uint32(all_options); |
if (do_flip) all_options = swap_uint32(all_options); |
|
|
if (get_options == 0) fprintf(outfile, "No options\n"); |
if (get_options == 0) fprintf(outfile, "No options\n"); |
else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", | else fprintf(outfile, "Options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "", |
((get_options & PCRE_ANCHORED) != 0)? " anchored" : "", |
((get_options & PCRE_CASELESS) != 0)? " caseless" : "", |
((get_options & PCRE_CASELESS) != 0)? " caseless" : "", |
((get_options & PCRE_EXTENDED) != 0)? " extended" : "", |
((get_options & PCRE_EXTENDED) != 0)? " extended" : "", |
Line 3205 while (!done)
|
Line 4109 while (!done)
|
((get_options & PCRE_UCP) != 0)? " ucp" : "", |
((get_options & PCRE_UCP) != 0)? " ucp" : "", |
((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf_check" : "", |
((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf_check" : "", |
((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "", |
((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "", |
((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : ""); | ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "", |
| ((get_options & PCRE_NEVER_UTF) != 0)? " never_utf" : ""); |
|
|
if (jchanged) fprintf(outfile, "Duplicate name status changes\n"); |
if (jchanged) fprintf(outfile, "Duplicate name status changes\n"); |
|
|
Line 3235 while (!done)
|
Line 4140 while (!done)
|
break; |
break; |
} |
} |
|
|
if (first_char == -1) | if (first_char_set == 2) |
{ |
{ |
fprintf(outfile, "First char at start or follows newline\n"); |
fprintf(outfile, "First char at start or follows newline\n"); |
} |
} |
else if (first_char < 0) | else if (first_char_set == 1) |
{ |
{ |
fprintf(outfile, "No first char\n"); |
|
} |
|
else |
|
{ |
|
const char *caseless = |
const char *caseless = |
((((REAL_PCRE *)re)->flags & PCRE_FCH_CASELESS) == 0)? | ((REAL_PCRE_FLAGS(re) & PCRE_FCH_CASELESS) == 0)? |
"" : " (caseless)"; |
"" : " (caseless)"; |
|
|
if (PRINTOK(first_char)) |
if (PRINTOK(first_char)) |
Line 3258 while (!done)
|
Line 4159 while (!done)
|
fprintf(outfile, "%s\n", caseless); |
fprintf(outfile, "%s\n", caseless); |
} |
} |
} |
} |
|
else |
|
{ |
|
fprintf(outfile, "No first char\n"); |
|
} |
|
|
if (need_char < 0) | if (need_char_set == 0) |
{ |
{ |
fprintf(outfile, "No need char\n"); |
fprintf(outfile, "No need char\n"); |
} |
} |
else |
else |
{ |
{ |
const char *caseless = |
const char *caseless = |
((((REAL_PCRE *)re)->flags & PCRE_RCH_CASELESS) == 0)? | ((REAL_PCRE_FLAGS(re) & PCRE_RCH_CASELESS) == 0)? |
"" : " (caseless)"; |
"" : " (caseless)"; |
|
|
if (PRINTOK(need_char)) |
if (PRINTOK(need_char)) |
Line 3279 while (!done)
|
Line 4184 while (!done)
|
} |
} |
} |
} |
|
|
if (maxlookbehind > 0) |
|
fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind); |
|
|
|
/* Don't output study size; at present it is in any case a fixed |
/* Don't output study size; at present it is in any case a fixed |
value, but it varies, depending on the computer architecture, and |
value, but it varies, depending on the computer architecture, and |
so messes up the test suite. (And with the /F option, it might be |
so messes up the test suite. (And with the /F option, it might be |
Line 3339 while (!done)
|
Line 4241 while (!done)
|
|
|
/* Show this only if the JIT was set by /S, not by -s. */ |
/* Show this only if the JIT was set by /S, not by -s. */ |
|
|
if ((study_options & PCRE_STUDY_JIT_COMPILE) != 0) | if ((study_options & PCRE_STUDY_ALLJIT) != 0 && |
| (force_study_options & PCRE_STUDY_ALLJIT) == 0) |
{ |
{ |
int jit; |
int jit; |
if (new_info(re, extra, PCRE_INFO_JIT, &jit) == 0) |
if (new_info(re, extra, PCRE_INFO_JIT, &jit) == 0) |
Line 3426 while (!done)
|
Line 4329 while (!done)
|
|
|
for (;;) |
for (;;) |
{ |
{ |
pcre_uint8 *q; | #ifdef SUPPORT_PCRE8 |
| pcre_uint8 *q8; |
| #endif |
| #ifdef SUPPORT_PCRE16 |
| pcre_uint16 *q16; |
| #endif |
| #ifdef SUPPORT_PCRE32 |
| pcre_uint32 *q32; |
| #endif |
pcre_uint8 *bptr; |
pcre_uint8 *bptr; |
int *use_offsets = offsets; |
int *use_offsets = offsets; |
int use_size_offsets = size_offsets; |
int use_size_offsets = size_offsets; |
int callout_data = 0; |
int callout_data = 0; |
int callout_data_set = 0; |
int callout_data_set = 0; |
int count, c; | int count; |
| pcre_uint32 c; |
int copystrings = 0; |
int copystrings = 0; |
int find_match_limit = default_find_match_limit; |
int find_match_limit = default_find_match_limit; |
int getstrings = 0; |
int getstrings = 0; |
Line 3446 while (!done)
|
Line 4358 while (!done)
|
*copynames = 0; |
*copynames = 0; |
*getnames = 0; |
*getnames = 0; |
|
|
|
#ifdef SUPPORT_PCRE32 |
|
cn32ptr = copynames; |
|
gn32ptr = getnames; |
|
#endif |
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
cn16ptr = copynames; | cn16ptr = copynames16; |
gn16ptr = getnames; | gn16ptr = getnames16; |
#endif |
#endif |
#ifdef SUPPORT_PCRE8 |
#ifdef SUPPORT_PCRE8 |
cn8ptr = copynames8; |
cn8ptr = copynames8; |
Line 3493 while (!done)
|
Line 4409 while (!done)
|
p = buffer; |
p = buffer; |
while (isspace(*p)) p++; |
while (isspace(*p)) p++; |
|
|
bptr = q = dbuffer; | #ifndef NOUTF |
| /* Check that the data is well-formed UTF-8 if we're in UTF mode. To create |
| invalid input to pcre_exec, you must use \x?? or \x{} sequences. */ |
| |
| if (use_utf) |
| { |
| pcre_uint8 *q; |
| pcre_uint32 cc; |
| int n = 1; |
| |
| for (q = p; n > 0 && *q; q += n) n = utf82ord(q, &cc); |
| if (n <= 0) |
| { |
| fprintf(outfile, "**Failed: invalid UTF-8 string cannot be used as input in UTF mode\n"); |
| goto NEXT_DATA; |
| } |
| } |
| #endif |
| |
| #ifdef SUPPORT_VALGRIND |
| /* Mark the dbuffer as addressable but undefined again. */ |
| |
| if (dbuffer != NULL) |
| { |
| VALGRIND_MAKE_MEM_UNDEFINED(dbuffer, dbuffer_size * CHAR_SIZE); |
| } |
| #endif |
| |
| /* Allocate a buffer to hold the data line; len+1 is an upper bound on |
| the number of pcre_uchar units that will be needed. */ |
| |
| while (dbuffer == NULL || (size_t)len >= dbuffer_size) |
| { |
| dbuffer_size *= 2; |
| dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE); |
| if (dbuffer == NULL) |
| { |
| fprintf(stderr, "pcretest: realloc(%d) failed\n", (int)dbuffer_size); |
| exit(1); |
| } |
| } |
| |
| #ifdef SUPPORT_PCRE8 |
| q8 = (pcre_uint8 *) dbuffer; |
| #endif |
| #ifdef SUPPORT_PCRE16 |
| q16 = (pcre_uint16 *) dbuffer; |
| #endif |
| #ifdef SUPPORT_PCRE32 |
| q32 = (pcre_uint32 *) dbuffer; |
| #endif |
| |
while ((c = *p++) != 0) |
while ((c = *p++) != 0) |
{ |
{ |
int i = 0; |
int i = 0; |
Line 3502 while (!done)
|
Line 4469 while (!done)
|
/* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes. |
/* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes. |
In non-UTF mode, allow the value of the byte to fall through to later, |
In non-UTF mode, allow the value of the byte to fall through to later, |
where values greater than 127 are turned into UTF-8 when running in |
where values greater than 127 are turned into UTF-8 when running in |
16-bit mode. */ | 16-bit or 32-bit mode. */ |
|
|
if (c != '\\') |
if (c != '\\') |
{ |
{ |
if (use_utf) | #ifndef NOUTF |
{ | if (use_utf && HASUTF8EXTRALEN(c)) { GETUTF8INC(c, p); } |
*q++ = c; | #endif |
continue; | |
} | |
} |
} |
|
|
/* Handle backslash escapes */ |
/* Handle backslash escapes */ |
Line 3563 while (!done)
|
Line 4528 while (!done)
|
allows UTF-8 characters to be constructed byte by byte, and also allows |
allows UTF-8 characters to be constructed byte by byte, and also allows |
invalid UTF-8 sequences to be made. Just copy the byte in UTF mode. |
invalid UTF-8 sequences to be made. Just copy the byte in UTF mode. |
Otherwise, pass it down to later code so that it can be turned into |
Otherwise, pass it down to later code so that it can be turned into |
UTF-8 when running in 16-bit mode. */ | UTF-8 when running in 16/32-bit mode. */ |
|
|
c = 0; |
c = 0; |
while (i++ < 2 && isxdigit(*p)) |
while (i++ < 2 && isxdigit(*p)) |
Line 3571 while (!done)
|
Line 4536 while (!done)
|
c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'a' - 10); |
c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'a' - 10); |
p++; |
p++; |
} |
} |
if (use_utf) | #if !defined NOUTF && defined SUPPORT_PCRE8 |
| if (use_utf && (pcre_mode == PCRE8_MODE)) |
{ |
{ |
*q++ = c; | *q8++ = c; |
continue; |
continue; |
} |
} |
|
#endif |
break; |
break; |
|
|
case 0: /* \ followed by EOF allows for an empty line */ |
case 0: /* \ followed by EOF allows for an empty line */ |
Line 3608 while (!done)
|
Line 4575 while (!done)
|
} |
} |
else if (isalnum(*p)) |
else if (isalnum(*p)) |
{ |
{ |
READ_CAPTURE_NAME(p, &cn8ptr, &cn16ptr, re); | READ_CAPTURE_NAME(p, &cn8ptr, &cn16ptr, &cn32ptr, re); |
} |
} |
else if (*p == '+') |
else if (*p == '+') |
{ |
{ |
Line 3671 while (!done)
|
Line 4638 while (!done)
|
} |
} |
else if (isalnum(*p)) |
else if (isalnum(*p)) |
{ |
{ |
READ_CAPTURE_NAME(p, &gn8ptr, &gn16ptr, re); | READ_CAPTURE_NAME(p, &gn8ptr, &gn16ptr, &gn32ptr, re); |
} |
} |
continue; |
continue; |
|
|
Line 3781 while (!done)
|
Line 4748 while (!done)
|
continue; |
continue; |
} |
} |
|
|
/* We now have a character value in c that may be greater than 255. In | /* We now have a character value in c that may be greater than 255. |
16-bit mode, we always convert characters to UTF-8 so that values greater | In 8-bit mode we convert to UTF-8 if we are in UTF mode. Values greater |
than 255 can be passed to non-UTF 16-bit strings. In 8-bit mode we | than 127 in UTF mode must have come from \x{...} or octal constructs |
convert to UTF-8 if we are in UTF mode. Values greater than 127 in UTF | because values from \x.. get this far only in non-UTF mode. */ |
mode must have come from \x{...} or octal constructs because values from | |
\x.. get this far only in non-UTF mode. */ | |
|
|
#if !defined NOUTF || defined SUPPORT_PCRE16 | #ifdef SUPPORT_PCRE8 |
if (use_pcre16 || use_utf) | if (pcre_mode == PCRE8_MODE) |
{ |
{ |
pcre_uint8 buff8[8]; | #ifndef NOUTF |
int ii, utn; | if (use_utf) |
utn = ord2utf8(c, buff8); | { |
for (ii = 0; ii < utn; ii++) *q++ = buff8[ii]; | if (c > 0x7fffffff) |
| { |
| fprintf(outfile, "** Character \\x{%x} is greater than 0x7fffffff " |
| "and so cannot be converted to UTF-8\n", c); |
| goto NEXT_DATA; |
| } |
| q8 += ord2utf8(c, q8); |
| } |
| else |
| #endif |
| { |
| if (c > 0xffu) |
| { |
| fprintf(outfile, "** Character \\x{%x} is greater than 255 " |
| "and UTF-8 mode is not enabled.\n", c); |
| fprintf(outfile, "** Truncation will probably give the wrong " |
| "result.\n"); |
| } |
| *q8++ = c; |
| } |
} |
} |
else |
|
#endif |
#endif |
|
#ifdef SUPPORT_PCRE16 |
|
if (pcre_mode == PCRE16_MODE) |
{ |
{ |
if (c > 255) | #ifndef NOUTF |
| if (use_utf) |
{ |
{ |
fprintf(outfile, "** Character \\x{%x} is greater than 255 " | if (c > 0x10ffffu) |
"and UTF-8 mode is not enabled.\n", c); | { |
fprintf(outfile, "** Truncation will probably give the wrong " | fprintf(outfile, "** Failed: character \\x{%x} is greater than " |
"result.\n"); | "0x10ffff and so cannot be converted to UTF-16\n", c); |
| goto NEXT_DATA; |
| } |
| else if (c >= 0x10000u) |
| { |
| c-= 0x10000u; |
| *q16++ = 0xD800 | (c >> 10); |
| *q16++ = 0xDC00 | (c & 0x3ff); |
| } |
| else |
| *q16++ = c; |
} |
} |
*q++ = c; | else |
| #endif |
| { |
| if (c > 0xffffu) |
| { |
| fprintf(outfile, "** Character \\x{%x} is greater than 0xffff " |
| "and UTF-16 mode is not enabled.\n", c); |
| fprintf(outfile, "** Truncation will probably give the wrong " |
| "result.\n"); |
| } |
| |
| *q16++ = c; |
| } |
} |
} |
|
#endif |
|
#ifdef SUPPORT_PCRE32 |
|
if (pcre_mode == PCRE32_MODE) |
|
{ |
|
*q32++ = c; |
|
} |
|
#endif |
|
|
} |
} |
|
|
/* Reached end of subject string */ |
/* Reached end of subject string */ |
|
|
*q = 0; | #ifdef SUPPORT_PCRE8 |
len = (int)(q - dbuffer); | if (pcre_mode == PCRE8_MODE) |
| { |
| *q8 = 0; |
| len = (int)(q8 - (pcre_uint8 *)dbuffer); |
| } |
| #endif |
| #ifdef SUPPORT_PCRE16 |
| if (pcre_mode == PCRE16_MODE) |
| { |
| *q16 = 0; |
| len = (int)(q16 - (pcre_uint16 *)dbuffer); |
| } |
| #endif |
| #ifdef SUPPORT_PCRE32 |
| if (pcre_mode == PCRE32_MODE) |
| { |
| *q32 = 0; |
| len = (int)(q32 - (pcre_uint32 *)dbuffer); |
| } |
| #endif |
|
|
/* Move the data to the end of the buffer so that a read over the end of | /* If we're compiling with explicit valgrind support, Mark the data from after |
the buffer will be seen by valgrind, even if it doesn't cause a crash. If | its end to the end of the buffer as unaddressable, so that a read over the end |
we are using the POSIX interface, we must include the terminating zero. */ | of the buffer will be seen by valgrind, even if it doesn't cause a crash. |
| If we're not building with valgrind support, at least move the data to the end |
| of the buffer so that it might at least cause a crash. |
| If we are using the POSIX interface, we must include the terminating zero. */ |
|
|
|
bptr = dbuffer; |
|
|
#if !defined NOPOSIX |
#if !defined NOPOSIX |
if (posix || do_posix) |
if (posix || do_posix) |
{ |
{ |
memmove(bptr + buffer_size - len - 1, bptr, len + 1); | #ifdef SUPPORT_VALGRIND |
bptr += buffer_size - len - 1; | VALGRIND_MAKE_MEM_NOACCESS(dbuffer + len + 1, dbuffer_size - (len + 1)); |
| #else |
| memmove(bptr + dbuffer_size - len - 1, bptr, len + 1); |
| bptr += dbuffer_size - len - 1; |
| #endif |
} |
} |
else |
else |
#endif |
#endif |
{ |
{ |
memmove(bptr + buffer_size - len, bptr, len); | #ifdef SUPPORT_VALGRIND |
bptr += buffer_size - len; | VALGRIND_MAKE_MEM_NOACCESS(dbuffer + len * CHAR_SIZE, (dbuffer_size - len) * CHAR_SIZE); |
| #else |
| bptr = memmove(bptr + (dbuffer_size - len) * CHAR_SIZE, bptr, len * CHAR_SIZE); |
| #endif |
} |
} |
|
|
if ((all_use_dfa || use_dfa) && find_match_limit) |
if ((all_use_dfa || use_dfa) && find_match_limit) |
Line 3860 while (!done)
|
Line 4907 while (!done)
|
(void)regerror(rc, &preg, (char *)buffer, buffer_size); |
(void)regerror(rc, &preg, (char *)buffer, buffer_size); |
fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer); |
fprintf(outfile, "No match: POSIX code %d: %s\n", rc, buffer); |
} |
} |
else if ((((const pcre *)preg.re_pcre)->options & PCRE_NO_AUTO_CAPTURE) | else if ((REAL_PCRE_OPTIONS(preg.re_pcre) & PCRE_NO_AUTO_CAPTURE) != 0) |
!= 0) | |
{ |
{ |
fprintf(outfile, "Matched with REG_NOSUB\n"); |
fprintf(outfile, "Matched with REG_NOSUB\n"); |
} |
} |
Line 3894 while (!done)
|
Line 4940 while (!done)
|
|
|
/* Handle matching via the native interface - repeats for /g and /G */ |
/* Handle matching via the native interface - repeats for /g and /G */ |
|
|
#ifdef SUPPORT_PCRE16 |
|
if (use_pcre16) |
|
{ |
|
len = to16(TRUE, bptr, (((REAL_PCRE *)re)->options) & PCRE_UTF8, len); |
|
switch(len) |
|
{ |
|
case -1: |
|
fprintf(outfile, "**Failed: invalid UTF-8 string cannot be " |
|
"converted to UTF-16\n"); |
|
goto NEXT_DATA; |
|
|
|
case -2: |
|
fprintf(outfile, "**Failed: character value greater than 0x10ffff " |
|
"cannot be converted to UTF-16\n"); |
|
goto NEXT_DATA; |
|
|
|
case -3: |
|
fprintf(outfile, "**Failed: character value greater than 0xffff " |
|
"cannot be converted to 16-bit in non-UTF mode\n"); |
|
goto NEXT_DATA; |
|
|
|
default: |
|
break; |
|
} |
|
bptr = (pcre_uint8 *)buffer16; |
|
} |
|
#endif |
|
|
|
/* Ensure that there is a JIT callback if we want to verify that JIT was |
/* 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. */ |
actually used. If jit_stack == NULL, no stack has yet been assigned. */ |
|
|
Line 3979 while (!done)
|
Line 4997 while (!done)
|
|
|
if (find_match_limit) |
if (find_match_limit) |
{ |
{ |
if (extra == NULL) | if (extra != NULL) { PCRE_FREE_STUDY(extra); } |
{ | extra = (pcre_extra *)malloc(sizeof(pcre_extra)); |
extra = (pcre_extra *)malloc(sizeof(pcre_extra)); | extra->flags = 0; |
extra->flags = 0; | |
} | |
else extra->flags &= ~PCRE_EXTRA_EXECUTABLE_JIT; | |
|
|
(void)check_match_limit(re, extra, bptr, len, start_offset, |
(void)check_match_limit(re, extra, bptr, len, start_offset, |
options|g_notempty, use_offsets, use_size_offsets, |
options|g_notempty, use_offsets, use_size_offsets, |
Line 4028 while (!done)
|
Line 5043 while (!done)
|
DFA_WS_DIMENSION); |
DFA_WS_DIMENSION); |
if (count == 0) |
if (count == 0) |
{ |
{ |
fprintf(outfile, "Matched, but too many subsidiary matches\n"); | fprintf(outfile, "Matched, but offsets vector is too small to show all matches\n"); |
count = use_size_offsets/2; |
count = use_size_offsets/2; |
} |
} |
} |
} |
Line 4041 while (!done)
|
Line 5056 while (!done)
|
if (count == 0) |
if (count == 0) |
{ |
{ |
fprintf(outfile, "Matched, but too many substrings\n"); |
fprintf(outfile, "Matched, but too many substrings\n"); |
count = use_size_offsets/3; | /* 2 is a special case; match can be returned */ |
| count = (use_size_offsets == 2)? 1 : use_size_offsets/3; |
} |
} |
} |
} |
|
|
Line 4055 while (!done)
|
Line 5071 while (!done)
|
#if !defined NODFA |
#if !defined NODFA |
if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2; else |
if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2; else |
#endif |
#endif |
maxcount = use_size_offsets/3; | /* 2 is a special case; match can be returned */ |
| maxcount = (use_size_offsets == 2)? 1 : use_size_offsets/3; |
|
|
/* This is a check against a lunatic return value. */ |
/* This is a check against a lunatic return value. */ |
|
|
Line 4146 while (!done)
|
Line 5163 while (!done)
|
int rc; |
int rc; |
char copybuffer[256]; |
char copybuffer[256]; |
|
|
if (use_pcre16) | #ifdef SUPPORT_PCRE32 |
| if (pcre_mode == PCRE32_MODE) |
{ |
{ |
|
if (*(pcre_uint32 *)cnptr == 0) break; |
|
} |
|
#endif |
|
#ifdef SUPPORT_PCRE16 |
|
if (pcre_mode == PCRE16_MODE) |
|
{ |
if (*(pcre_uint16 *)cnptr == 0) break; |
if (*(pcre_uint16 *)cnptr == 0) break; |
} |
} |
else | #endif |
| #ifdef SUPPORT_PCRE8 |
| if (pcre_mode == PCRE8_MODE) |
{ |
{ |
if (*(pcre_uint8 *)cnptr == 0) break; |
if (*(pcre_uint8 *)cnptr == 0) break; |
} |
} |
|
#endif |
|
|
PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count, |
PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count, |
cnptr, copybuffer, sizeof(copybuffer)); |
cnptr, copybuffer, sizeof(copybuffer)); |
Line 4201 while (!done)
|
Line 5228 while (!done)
|
int rc; |
int rc; |
const char *substring; |
const char *substring; |
|
|
if (use_pcre16) | #ifdef SUPPORT_PCRE32 |
| if (pcre_mode == PCRE32_MODE) |
{ |
{ |
|
if (*(pcre_uint32 *)gnptr == 0) break; |
|
} |
|
#endif |
|
#ifdef SUPPORT_PCRE16 |
|
if (pcre_mode == PCRE16_MODE) |
|
{ |
if (*(pcre_uint16 *)gnptr == 0) break; |
if (*(pcre_uint16 *)gnptr == 0) break; |
} |
} |
else | #endif |
| #ifdef SUPPORT_PCRE8 |
| if (pcre_mode == PCRE8_MODE) |
{ |
{ |
if (*(pcre_uint8 *)gnptr == 0) break; |
if (*(pcre_uint8 *)gnptr == 0) break; |
} |
} |
|
#endif |
|
|
PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count, |
PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count, |
gnptr, &substring); |
gnptr, &substring); |
Line 4253 while (!done)
|
Line 5290 while (!done)
|
} |
} |
} |
} |
|
|
/* There was a partial match */ | /* There was a partial match. If the bumpalong point is not the same as |
| the first inspected character, show the offset explicitly. */ |
|
|
else if (count == PCRE_ERROR_PARTIAL) |
else if (count == PCRE_ERROR_PARTIAL) |
{ |
{ |
if (markptr == NULL) fprintf(outfile, "Partial match"); | fprintf(outfile, "Partial match"); |
else | if (use_size_offsets > 2 && use_offsets[0] != use_offsets[2]) |
| fprintf(outfile, " at offset %d", use_offsets[2]); |
| if (markptr != NULL) |
{ |
{ |
fprintf(outfile, "Partial match, mark="); | fprintf(outfile, ", mark="); |
PCHARSV(markptr, 0, -1, outfile); |
PCHARSV(markptr, 0, -1, outfile); |
} |
} |
if (use_size_offsets > 1) |
if (use_size_offsets > 1) |
Line 4295 while (!done)
|
Line 5335 while (!done)
|
if (g_notempty != 0) |
if (g_notempty != 0) |
{ |
{ |
int onechar = 1; |
int onechar = 1; |
unsigned int obits = ((REAL_PCRE *)re)->options; | unsigned int obits = REAL_PCRE_OPTIONS(re); |
use_offsets[0] = start_offset; |
use_offsets[0] = start_offset; |
if ((obits & PCRE_NEWLINE_BITS) == 0) |
if ((obits & PCRE_NEWLINE_BITS) == 0) |
{ |
{ |
Line 4313 while (!done)
|
Line 5353 while (!done)
|
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_CRLF || |
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_CRLF || |
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF) |
(obits & PCRE_NEWLINE_BITS) == PCRE_NEWLINE_ANYCRLF) |
&& |
&& |
start_offset < len - 1 && | start_offset < len - 1 && ( |
#if defined SUPPORT_PCRE8 && defined SUPPORT_PCRE16 | #ifdef SUPPORT_PCRE8 |
(use_pcre16? | (pcre_mode == PCRE8_MODE && |
((PCRE_SPTR16)bptr)[start_offset] == '\r' | bptr[start_offset] == '\r' && |
&& ((PCRE_SPTR16)bptr)[start_offset + 1] == '\n' | bptr[start_offset + 1] == '\n') || |
: | |
bptr[start_offset] == '\r' | |
&& bptr[start_offset + 1] == '\n') | |
#elif defined SUPPORT_PCRE16 | |
((PCRE_SPTR16)bptr)[start_offset] == '\r' | |
&& ((PCRE_SPTR16)bptr)[start_offset + 1] == '\n' | |
#else | |
bptr[start_offset] == '\r' | |
&& bptr[start_offset + 1] == '\n' | |
#endif |
#endif |
) | #ifdef SUPPORT_PCRE16 |
| (pcre_mode == PCRE16_MODE && |
| ((PCRE_SPTR16)bptr)[start_offset] == '\r' && |
| ((PCRE_SPTR16)bptr)[start_offset + 1] == '\n') || |
| #endif |
| #ifdef SUPPORT_PCRE32 |
| (pcre_mode == PCRE32_MODE && |
| ((PCRE_SPTR32)bptr)[start_offset] == '\r' && |
| ((PCRE_SPTR32)bptr)[start_offset + 1] == '\n') || |
| #endif |
| 0)) |
onechar++; |
onechar++; |
else if (use_utf) |
else if (use_utf) |
{ |
{ |
Line 4363 while (!done)
|
Line 5404 while (!done)
|
|
|
case PCRE_ERROR_BADUTF8: |
case PCRE_ERROR_BADUTF8: |
case PCRE_ERROR_SHORTUTF8: |
case PCRE_ERROR_SHORTUTF8: |
fprintf(outfile, "Error %d (%s UTF-%s string)", count, | fprintf(outfile, "Error %d (%s UTF-%d string)", count, |
(count == PCRE_ERROR_BADUTF8)? "bad" : "short", |
(count == PCRE_ERROR_BADUTF8)? "bad" : "short", |
use_pcre16? "16" : "8"); | 8 * CHAR_SIZE); |
if (use_size_offsets >= 2) |
if (use_size_offsets >= 2) |
fprintf(outfile, " offset=%d reason=%d", use_offsets[0], |
fprintf(outfile, " offset=%d reason=%d", use_offsets[0], |
use_offsets[1]); |
use_offsets[1]); |
Line 4373 while (!done)
|
Line 5414 while (!done)
|
break; |
break; |
|
|
case PCRE_ERROR_BADUTF8_OFFSET: |
case PCRE_ERROR_BADUTF8_OFFSET: |
fprintf(outfile, "Error %d (bad UTF-%s offset)\n", count, | fprintf(outfile, "Error %d (bad UTF-%d offset)\n", count, |
use_pcre16? "16" : "8"); | 8 * CHAR_SIZE); |
break; |
break; |
|
|
default: |
default: |
Line 4463 free(offsets);
|
Line 5504 free(offsets);
|
|
|
#ifdef SUPPORT_PCRE16 |
#ifdef SUPPORT_PCRE16 |
if (buffer16 != NULL) free(buffer16); |
if (buffer16 != NULL) free(buffer16); |
|
#endif |
|
#ifdef SUPPORT_PCRE32 |
|
if (buffer32 != NULL) free(buffer32); |
|
#endif |
|
|
|
#if !defined NODFA |
|
if (dfa_workspace != NULL) |
|
free(dfa_workspace); |
|
#endif |
|
|
|
#if defined(__VMS) |
|
yield = SS$_NORMAL; /* Return values via DCL symbols */ |
#endif |
#endif |
|
|
return yield; |
return yield; |