diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-10-19 15:45:43 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-10-19 15:45:43 +0000 |
commit | ba51b0eb436f3b79734194e7640f4075cdb302a8 (patch) | |
tree | 3bb97de303cbed1e8ffbeddd3aaf370aa2cdce67 /pcretest.c | |
parent | f33b6401d64a3cd0dd27441eab2b8d1e8126192a (diff) | |
download | pcre-ba51b0eb436f3b79734194e7640f4075cdb302a8.tar.gz |
Fix bugs in pcretest when different combinations of 8-, 16-, and 32-bit
libraries were compiled. For example, test 2 segfaulted when only 16- and
32-bit libraries were compiled.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1142 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcretest.c')
-rw-r--r-- | pcretest.c | 66 |
1 files changed, 26 insertions, 40 deletions
@@ -36,15 +36,15 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -/* This program now supports the testing of both the 8-bit and 16-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 both modes are enabled, for example, pcre_compile.c is compiled twice -(the second time with COMPILE_PCRE16 defined). 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 or COMPILE_PCRE16. It does, -however, make use of SUPPORT_PCRE8 and SUPPORT_PCRE16 to ensure that it calls -only supported library functions. */ +/* 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" @@ -133,20 +133,6 @@ 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" - -#if defined SUPPORT_PCRE32 && !defined SUPPORT_PCRE8 && !defined SUPPORT_PCRE16 -/* Configure internal macros to 32 bit mode. */ -#define COMPILE_PCRE32 -#endif -#if defined SUPPORT_PCRE16 && !defined SUPPORT_PCRE8 && !defined SUPPORT_PCRE32 -/* Configure internal macros to 16 bit mode. */ -#define COMPILE_PCRE16 -#endif -#if defined SUPPORT_PCRE8 && !defined SUPPORT_PCRE16 && !defined SUPPORT_PCRE32 -/* Configure internal macros to 16 bit mode. */ -#define COMPILE_PCRE8 -#endif - #include "pcre_internal.h" /* The pcre_printint() function, which prints the internal form of a compiled @@ -1034,16 +1020,7 @@ static int buffer_size = 50000; static pcre_uint8 *buffer = NULL; static pcre_uint8 *pbuffer = NULL; -/* Another buffer is needed translation to 16/32-bit character strings. It will -obtained and extended as required. */ - -#if defined SUPPORT_PCRE8 && (defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32) - -/* We need the table of operator lengths that is used for 16/32-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/32-bit world. Just as a safety check, make sure that -COMPILE_PCRE[16|32] is *not* set. */ +/* 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 @@ -1053,6 +1030,17 @@ COMPILE_PCRE[16|32] is *not* set. */ #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 @@ -1063,19 +1051,17 @@ COMPILE_PCRE[16|32] is *not* set. */ #error LINK_SIZE must be either 2, 3, or 4 #endif -#undef IMM2_SIZE -#define IMM2_SIZE 1 - -#endif /* SUPPORT_PCRE8 && (SUPPORT_PCRE16 || SUPPORT_PCRE32) */ - - -#ifdef SUPPORT_PCRE16 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 }; |