pcre/pcretest.c

5774 lines
170 KiB
C
Raw Permalink Normal View History

2023-02-15 17:00:09 +03:00
/*************************************************
* PCRE testing program *
*************************************************/
/* This program was hacked up as a tester for PCRE. I really should have
written it more tidily in the first place. Will I ever learn? It has grown and
been extended and consequently is now rather, er, *very* untidy in places. The
addition of 16-bit support has made it even worse. :-(
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
/* This program now supports the testing of all of the 8-bit, 16-bit, and
32-bit PCRE libraries in a single program. This is different from the modules
such as pcre_compile.c in the library itself, which are compiled separately for
each mode. If two modes are enabled, for example, pcre_compile.c is compiled
twice. By contrast, pcretest.c is compiled only once. Therefore, it must not
make use of any of the macros from pcre_internal.h that depend on
COMPILE_PCRE8, COMPILE_PCRE16, or COMPILE_PCRE32. It does, however, make use of
SUPPORT_PCRE8, SUPPORT_PCRE16, and SUPPORT_PCRE32 to ensure that it calls only
supported library functions. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <locale.h>
#include <errno.h>
/* Both libreadline and libedit are optionally supported. The user-supplied
original patch uses readline/readline.h for libedit, but in at least one system
it is installed as editline/readline.h, so the configuration code now looks for
that first, falling back to readline/readline.h. */
#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#if defined(SUPPORT_LIBREADLINE)
#include <readline/readline.h>
#include <readline/history.h>
#else
#if defined(HAVE_EDITLINE_READLINE_H)
#include <editline/readline.h>
#else
#include <readline/readline.h>
#endif
#endif
#endif
/* A number of things vary for Windows builds. Originally, pcretest opened its
input and output without "b"; then I was told that "b" was needed in some
environments, so it was added for release 5.0 to both the input and output. (It
makes no difference on Unix-like systems.) Later I was told that it is wrong
for the input on Windows. I've now abstracted the modes into two macros that
are set here, to make it easier to fiddle with them, and removed "b" from the
input mode under Windows. */
#if defined(_WIN32) || defined(WIN32)
#include <io.h> /* For _setmode() */
#include <fcntl.h> /* For _O_BINARY */
#define INPUT_MODE "r"
#define OUTPUT_MODE "wb"
#ifndef isatty
#define isatty _isatty /* This is what Windows calls them, I'm told, */
#endif /* though in some environments they seem to */
/* be already defined, hence the #ifndefs. */
#ifndef fileno
#define fileno _fileno
#endif
/* A user sent this fix for Borland Builder 5 under Windows. */
#ifdef __BORLANDC__
#define _setmode(handle, mode) setmode(handle, mode)
#endif
/* Not Windows */
#else
#include <sys/time.h> /* These two includes are needed */
#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 OUTPUT_MODE "wb"
#endif
#endif
#ifdef __VMS
#include <ssdef.h>
void vms_setsymbol( char *, char *, int );
#endif
#define PRIV(name) name
/* We have to include pcre_internal.h because we need the internal info for
displaying the results of pcre_study() and we also need to know about the
internal macros, structures, and other internal data values; pcretest has
"inside information" compared to a program that strictly follows the PCRE API.
Although pcre_internal.h does itself include pcre.h, we explicitly include it
here before pcre_internal.h so that the PCRE_EXP_xxx macros get set
appropriately for an application, not for building PCRE. */
#include "pcre.h"
#include "pcre_internal.h"
/* 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
8-, 16- or 32-bit mode, and (b) it can be #included directly in pcre_compile.c
when that is compiled in debug mode. */
#ifdef SUPPORT_PCRE8
void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);
#endif
#ifdef SUPPORT_PCRE16
void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);
#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
to keep two copies, we include the source files here, changing the names of the
external symbols to prevent clashes. */
#define PCRE_INCLUDED
#include "pcre_tables.c"
#include "pcre_ucd.c"
/* 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
the same as in the printint.src file. We uses it here in cases when the locale
has not been explicitly changed, so as to get consistent output from systems
that differ in their output from isprint() even in the "C" locale. */
#ifdef EBCDIC
#define PRINTABLE(c) ((c) >= 64 && (c) < 255)
#else
#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
#endif
#define PRINTOK(c) (locale_set? (((c) < 256) && isprint(c)) : PRINTABLE(c))
/* Posix support is disabled in 16 or 32 bit only mode. */
#if !defined SUPPORT_PCRE8 && !defined NOPOSIX
#define NOPOSIX
#endif
/* It is possible to compile this test program without including support for
testing the POSIX interface, though this is not available via the standard
Makefile. */
#if !defined NOPOSIX
#include "pcreposix.h"
#endif
/* It is also possible, originally for the benefit of a version that was
imported into Exim, to build pcretest without support for UTF8 or UTF16 (define
NOUTF), without the interface to the DFA matcher (NODFA). In fact, we
automatically cut out the UTF support if PCRE is built without it. */
#ifndef SUPPORT_UTF
#ifndef NOUTF
#define NOUTF
#endif
#endif
/* 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
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
argument requirements. We know that at least one of SUPPORT_PCRE8 and
SUPPORT_PCRE16 must be set. First define macros for each individual mode; then
use these in the definitions of generic macros.
**** Special note about the PCHARSxxx macros: the address of the string to be
printed is always given as two arguments: a base address followed by an offset.
The base address is cast to the correct data size for 8 or 16 bit data; the
offset is in units of this size. If the string were given as base+offset in one
argument, the casting might be incorrectly applied. */
#ifdef SUPPORT_PCRE8
#define PCHARS8(lv, p, offset, len, f) \
lv = pchars((pcre_uint8 *)(p) + offset, len, f)
#define PCHARSV8(p, offset, len, f) \
(void)pchars((pcre_uint8 *)(p) + offset, len, f)
#define READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re) \
p = read_capture_name8(p, cn8, re)
#define STRLEN8(p) ((int)strlen((char *)p))
#define SET_PCRE_CALLOUT8(callout) \
pcre_callout = callout
#define SET_PCRE_STACK_GUARD8(stack_guard) \
pcre_stack_guard = stack_guard
#define PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata) \
pcre_assign_jit_stack(extra, callback, userdata)
#define PCRE_COMPILE8(re, pat, options, error, erroffset, tables) \
re = pcre_compile((char *)pat, options, error, erroffset, tables)
#define PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
namesptr, cbuffer, size) \
rc = pcre_copy_named_substring(re, (char *)bptr, offsets, count, \
(char *)namesptr, cbuffer, size)
#define PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size) \
rc = pcre_copy_substring((char *)bptr, offsets, count, i, cbuffer, size)
#define PCRE_DFA_EXEC8(count, re, extra, bptr, len, start_offset, options, \
offsets, size_offsets, workspace, size_workspace) \
count = pcre_dfa_exec(re, extra, (char *)bptr, len, start_offset, options, \
offsets, size_offsets, workspace, size_workspace)
#define PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \
offsets, size_offsets) \
count = pcre_exec(re, extra, (char *)bptr, len, start_offset, options, \
offsets, size_offsets)
#define PCRE_FREE_STUDY8(extra) \
pcre_free_study(extra)
#define PCRE_FREE_SUBSTRING8(substring) \
pcre_free_substring(substring)
#define PCRE_FREE_SUBSTRING_LIST8(listptr) \
pcre_free_substring_list(listptr)
#define PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
getnamesptr, subsptr) \
rc = pcre_get_named_substring(re, (char *)bptr, offsets, count, \
(char *)getnamesptr, subsptr)
#define PCRE_GET_STRINGNUMBER8(n, rc, ptr) \
n = pcre_get_stringnumber(re, (char *)ptr)
#define PCRE_GET_SUBSTRING8(rc, bptr, offsets, count, i, subsptr) \
rc = pcre_get_substring((char *)bptr, offsets, count, i, subsptr)
#define PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr) \
rc = pcre_get_substring_list((const char *)bptr, offsets, count, listptr)
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables) \
rc = pcre_pattern_to_host_byte_order(re, extra, tables)
#define PCRE_PRINTINT8(re, outfile, debug_lengths) \
pcre_printint(re, outfile, debug_lengths)
#define PCRE_STUDY8(extra, re, options, error) \
extra = pcre_study(re, options, error)
#define PCRE_JIT_STACK_ALLOC8(startsize, maxsize) \
pcre_jit_stack_alloc(startsize, maxsize)
#define PCRE_JIT_STACK_FREE8(stack) \
pcre_jit_stack_free(stack)
#define pcre8_maketables pcre_maketables
#endif /* SUPPORT_PCRE8 */
/* -----------------------------------------------------------*/
#ifdef SUPPORT_PCRE16
#define PCHARS16(lv, p, offset, len, f) \
lv = pchars16((PCRE_SPTR16)(p) + offset, len, f)
#define PCHARSV16(p, offset, len, f) \
(void)pchars16((PCRE_SPTR16)(p) + offset, len, f)
#define READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re) \
p = read_capture_name16(p, cn16, re)
#define STRLEN16(p) ((int)strlen16((PCRE_SPTR16)p))
#define SET_PCRE_CALLOUT16(callout) \
pcre16_callout = (int (*)(pcre16_callout_block *))callout
#define SET_PCRE_STACK_GUARD16(stack_guard) \
pcre16_stack_guard = (int (*)(void))stack_guard
#define PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata) \
pcre16_assign_jit_stack((pcre16_extra *)extra, \
(pcre16_jit_callback)callback, userdata)
#define PCRE_COMPILE16(re, pat, options, error, erroffset, tables) \
re = (pcre *)pcre16_compile((PCRE_SPTR16)pat, options, error, erroffset, \
tables)
#define PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
namesptr, cbuffer, size) \
rc = pcre16_copy_named_substring((pcre16 *)re, (PCRE_SPTR16)bptr, offsets, \
count, (PCRE_SPTR16)namesptr, (PCRE_UCHAR16 *)cbuffer, size/2)
#define PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size) \
rc = pcre16_copy_substring((PCRE_SPTR16)bptr, offsets, count, i, \
(PCRE_UCHAR16 *)cbuffer, size/2)
#define PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \
offsets, size_offsets, workspace, size_workspace) \
count = pcre16_dfa_exec((pcre16 *)re, (pcre16_extra *)extra, \
(PCRE_SPTR16)bptr, len, start_offset, options, offsets, size_offsets, \
workspace, size_workspace)
#define PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \
offsets, size_offsets) \
count = pcre16_exec((pcre16 *)re, (pcre16_extra *)extra, (PCRE_SPTR16)bptr, \
len, start_offset, options, offsets, size_offsets)
#define PCRE_FREE_STUDY16(extra) \
pcre16_free_study((pcre16_extra *)extra)
#define PCRE_FREE_SUBSTRING16(substring) \
pcre16_free_substring((PCRE_SPTR16)substring)
#define PCRE_FREE_SUBSTRING_LIST16(listptr) \
pcre16_free_substring_list((PCRE_SPTR16 *)listptr)
#define PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
getnamesptr, subsptr) \
rc = pcre16_get_named_substring((pcre16 *)re, (PCRE_SPTR16)bptr, offsets, \
count, (PCRE_SPTR16)getnamesptr, (PCRE_SPTR16 *)(void*)subsptr)
#define PCRE_GET_STRINGNUMBER16(n, rc, ptr) \
n = pcre16_get_stringnumber(re, (PCRE_SPTR16)ptr)
#define PCRE_GET_SUBSTRING16(rc, bptr, offsets, count, i, subsptr) \
rc = pcre16_get_substring((PCRE_SPTR16)bptr, offsets, count, i, \
(PCRE_SPTR16 *)(void*)subsptr)
#define PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr) \
rc = pcre16_get_substring_list((PCRE_SPTR16)bptr, offsets, count, \
(PCRE_SPTR16 **)(void*)listptr)
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables) \
rc = pcre16_pattern_to_host_byte_order((pcre16 *)re, (pcre16_extra *)extra, \
tables)
#define PCRE_PRINTINT16(re, outfile, debug_lengths) \
pcre16_printint(re, outfile, debug_lengths)
#define PCRE_STUDY16(extra, re, options, error) \
extra = (pcre_extra *)pcre16_study((pcre16 *)re, options, error)
#define PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
(pcre_jit_stack *)pcre16_jit_stack_alloc(startsize, maxsize)
#define PCRE_JIT_STACK_FREE16(stack) \
pcre16_jit_stack_free((pcre16_jit_stack *)stack)
#endif /* SUPPORT_PCRE16 */
/* -----------------------------------------------------------*/
#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 SET_PCRE_STACK_GUARD32(stack_guard) \
pcre32_stack_guard = (int (*)(void))stack_guard
#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/4)
#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/4)
#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
available version is called. ----- */
enum {
PCRE8_MODE,
PCRE16_MODE,
PCRE32_MODE
};
#if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + \
defined (SUPPORT_PCRE32)) >= 2
#define CHAR_SIZE (1U << 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) \
if (pcre_mode == PCRE32_MODE) \
PCHARS32(lv, p, offset, len, f); \
else if (pcre_mode == PCRE16_MODE) \
PCHARS16(lv, p, offset, len, f); \
else \
PCHARS8(lv, p, offset, len, f)
#define PCHARSV(p, offset, len, f) \
if (pcre_mode == PCRE32_MODE) \
PCHARSV32(p, offset, len, f); \
else if (pcre_mode == PCRE16_MODE) \
PCHARSV16(p, offset, len, f); \
else \
PCHARSV8(p, offset, len, f)
#define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
if (pcre_mode == PCRE32_MODE) \
READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re); \
else if (pcre_mode == PCRE16_MODE) \
READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re); \
else \
READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re)
#define SET_PCRE_CALLOUT(callout) \
if (pcre_mode == PCRE32_MODE) \
SET_PCRE_CALLOUT32(callout); \
else if (pcre_mode == PCRE16_MODE) \
SET_PCRE_CALLOUT16(callout); \
else \
SET_PCRE_CALLOUT8(callout)
#define SET_PCRE_STACK_GUARD(stack_guard) \
if (pcre_mode == PCRE32_MODE) \
SET_PCRE_STACK_GUARD32(stack_guard); \
else if (pcre_mode == PCRE16_MODE) \
SET_PCRE_STACK_GUARD16(stack_guard); \
else \
SET_PCRE_STACK_GUARD8(stack_guard)
#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) \
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); \
else \
PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata)
#define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
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); \
else \
PCRE_COMPILE8(re, pat, options, error, erroffset, tables)
#define PCRE_CONFIG pcre_config
#define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
namesptr, cbuffer, size) \
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, \
namesptr, cbuffer, size); \
else \
PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
namesptr, cbuffer, size)
#define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
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); \
else \
PCRE_COPY_SUBSTRING8(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 == 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, \
offsets, size_offsets, workspace, size_workspace); \
else \
PCRE_DFA_EXEC8(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 == 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, \
offsets, size_offsets); \
else \
PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \
offsets, size_offsets)
#define PCRE_FREE_STUDY(extra) \
if (pcre_mode == PCRE32_MODE) \
PCRE_FREE_STUDY32(extra); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_FREE_STUDY16(extra); \
else \
PCRE_FREE_STUDY8(extra)
#define PCRE_FREE_SUBSTRING(substring) \
if (pcre_mode == PCRE32_MODE) \
PCRE_FREE_SUBSTRING32(substring); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_FREE_SUBSTRING16(substring); \
else \
PCRE_FREE_SUBSTRING8(substring)
#define PCRE_FREE_SUBSTRING_LIST(listptr) \
if (pcre_mode == PCRE32_MODE) \
PCRE_FREE_SUBSTRING_LIST32(listptr); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_FREE_SUBSTRING_LIST16(listptr); \
else \
PCRE_FREE_SUBSTRING_LIST8(listptr)
#define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
getnamesptr, subsptr) \
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, \
getnamesptr, subsptr); \
else \
PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
getnamesptr, subsptr)
#define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
if (pcre_mode == PCRE32_MODE) \
PCRE_GET_STRINGNUMBER32(n, rc, ptr); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_GET_STRINGNUMBER16(n, rc, ptr); \
else \
PCRE_GET_STRINGNUMBER8(n, rc, ptr)
#define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
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); \
else \
PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr)
#define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
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); \
else \
PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)
#define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
(pcre_mode == PCRE32_MODE ? \
PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \
: pcre_mode == PCRE16_MODE ? \
PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
: PCRE_JIT_STACK_ALLOC8(startsize, maxsize))
#define PCRE_JIT_STACK_FREE(stack) \
if (pcre_mode == PCRE32_MODE) \
PCRE_JIT_STACK_FREE32(stack); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_JIT_STACK_FREE16(stack); \
else \
PCRE_JIT_STACK_FREE8(stack)
#define 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) \
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); \
else \
PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)
#define PCRE_PRINTINT(re, outfile, debug_lengths) \
if (pcre_mode == PCRE32_MODE) \
PCRE_PRINTINT32(re, outfile, debug_lengths); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_PRINTINT16(re, outfile, debug_lengths); \
else \
PCRE_PRINTINT8(re, outfile, debug_lengths)
#define PCRE_STUDY(extra, re, options, error) \
if (pcre_mode == PCRE32_MODE) \
PCRE_STUDY32(extra, re, options, error); \
else if (pcre_mode == PCRE16_MODE) \
PCRE_STUDY16(extra, re, options, error); \
else \
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 SET_PCRE_STACK_GUARD(stack_guard) \
if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
G(SET_PCRE_STACK_GUARD,BITONE)(stack_guard); \
else \
G(SET_PCRE_STACK_GUARD,BITTWO)(stack_guard)
#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 ----- */
#elif defined SUPPORT_PCRE8
#define CHAR_SIZE 1
#define PCHARS PCHARS8
#define PCHARSV PCHARSV8
#define READ_CAPTURE_NAME READ_CAPTURE_NAME8
#define SET_PCRE_CALLOUT SET_PCRE_CALLOUT8
#define SET_PCRE_STACK_GUARD SET_PCRE_STACK_GUARD8
#define STRLEN STRLEN8
#define PCRE_ASSIGN_JIT_STACK PCRE_ASSIGN_JIT_STACK8
#define PCRE_COMPILE PCRE_COMPILE8
#define PCRE_CONFIG pcre_config
#define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING8
#define PCRE_COPY_SUBSTRING PCRE_COPY_SUBSTRING8
#define PCRE_DFA_EXEC PCRE_DFA_EXEC8
#define PCRE_EXEC PCRE_EXEC8
#define PCRE_FREE_STUDY PCRE_FREE_STUDY8
#define PCRE_FREE_SUBSTRING PCRE_FREE_SUBSTRING8
#define PCRE_FREE_SUBSTRING_LIST PCRE_FREE_SUBSTRING_LIST8
#define PCRE_GET_NAMED_SUBSTRING PCRE_GET_NAMED_SUBSTRING8
#define PCRE_GET_STRINGNUMBER PCRE_GET_STRINGNUMBER8
#define PCRE_GET_SUBSTRING PCRE_GET_SUBSTRING8
#define PCRE_GET_SUBSTRING_LIST PCRE_GET_SUBSTRING_LIST8
#define PCRE_JIT_STACK_ALLOC PCRE_JIT_STACK_ALLOC8
#define PCRE_JIT_STACK_FREE PCRE_JIT_STACK_FREE8
#define PCRE_MAKETABLES pcre_maketables()
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER8
#define PCRE_PRINTINT PCRE_PRINTINT8
#define PCRE_STUDY PCRE_STUDY8
/* ----- Only 16-bit mode is supported ----- */
#elif defined SUPPORT_PCRE16
#define CHAR_SIZE 2
#define PCHARS PCHARS16
#define PCHARSV PCHARSV16
#define READ_CAPTURE_NAME READ_CAPTURE_NAME16
#define SET_PCRE_CALLOUT SET_PCRE_CALLOUT16
#define SET_PCRE_STACK_GUARD SET_PCRE_STACK_GUARD16
#define STRLEN STRLEN16
#define PCRE_ASSIGN_JIT_STACK PCRE_ASSIGN_JIT_STACK16
#define PCRE_COMPILE PCRE_COMPILE16
#define PCRE_CONFIG pcre16_config
#define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING16
#define PCRE_COPY_SUBSTRING PCRE_COPY_SUBSTRING16
#define PCRE_DFA_EXEC PCRE_DFA_EXEC16
#define PCRE_EXEC PCRE_EXEC16
#define PCRE_FREE_STUDY PCRE_FREE_STUDY16
#define PCRE_FREE_SUBSTRING PCRE_FREE_SUBSTRING16
#define PCRE_FREE_SUBSTRING_LIST PCRE_FREE_SUBSTRING_LIST16
#define PCRE_GET_NAMED_SUBSTRING PCRE_GET_NAMED_SUBSTRING16
#define PCRE_GET_STRINGNUMBER PCRE_GET_STRINGNUMBER16
#define PCRE_GET_SUBSTRING PCRE_GET_SUBSTRING16
#define PCRE_GET_SUBSTRING_LIST PCRE_GET_SUBSTRING_LIST16
#define PCRE_JIT_STACK_ALLOC PCRE_JIT_STACK_ALLOC16
#define PCRE_JIT_STACK_FREE PCRE_JIT_STACK_FREE16
#define PCRE_MAKETABLES pcre16_maketables()
#define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER16
#define PCRE_PRINTINT PCRE_PRINTINT16
#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 SET_PCRE_STACK_GUARD SET_PCRE_STACK_GUARD32
#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
/* ----- End of mode-specific function call macros ----- */
/* Other parameters */
#ifndef CLOCKS_PER_SEC
#ifdef CLK_TCK
#define CLOCKS_PER_SEC CLK_TCK
#else
#define CLOCKS_PER_SEC 100
#endif
#endif
#if !defined NODFA
#define DFA_WS_DIMENSION 1000
#endif
/* This is the default loop count for timing. */
#define LOOPREPEAT 500000
/* Static variables */
static FILE *outfile;
static int log_store = 0;
static int callout_count;
static int callout_extra;
static int callout_fail_count;
static int callout_fail_id;
static int debug_lengths;
static int first_callout;
static int jit_was_used;
static int locale_set = 0;
static int show_malloc;
static int stack_guard_return;
static int use_utf;
static const unsigned char *last_callout_mark = NULL;
/* The buffers grow automatically if very long input lines are encountered. */
static int buffer_size = 50000;
static pcre_uint8 *buffer = NULL;
static pcre_uint8 *pbuffer = NULL;
/* Just as a safety check, make sure that COMPILE_PCRE[16|32] are *not* set. */
#ifdef COMPILE_PCRE16
#error COMPILE_PCRE16 must not be set when compiling pcretest.c
#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
#undef LINK_SIZE
#define LINK_SIZE 1
#elif LINK_SIZE == 3 || LINK_SIZE == 4
#undef LINK_SIZE
#define LINK_SIZE 2
#else
#error LINK_SIZE must be either 2, 3, or 4
#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
#define IMM2_SIZE 1
#undef LINK_SIZE
#define LINK_SIZE 1
static int buffer32_size = 0;
static pcre_uint32 *buffer32 = NULL;
static const pcre_uint32 OP_lengths32[] = { OP_LENGTHS };
#endif /* SUPPORT_PCRE32 */
/* If we have 8-bit support, default to it; if there is also 16-or 32-bit
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 defined SUPPORT_PCRE8
static int pcre_mode = PCRE8_MODE;
#elif defined SUPPORT_PCRE16
static int pcre_mode = PCRE16_MODE;
#elif defined SUPPORT_PCRE32
static int pcre_mode = PCRE32_MODE;
#endif
/* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */