/[pcre]/code/trunk/pcretest.c
ViewVC logotype

Diff of /code/trunk/pcretest.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1122 by ph10, Wed Oct 17 17:31:19 2012 UTC revision 1313 by ph10, Wed Apr 24 12:07:09 2013 UTC
# Line 36  POSSIBILITY OF SUCH DAMAGE. Line 36  POSSIBILITY OF SUCH DAMAGE.
36  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
37  */  */
38    
39  /* 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
40  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
41  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
42  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
43  (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
44  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
45  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
46  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
47  only supported library functions. */  supported library functions. */
48    
49  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
50  #include "config.h"  #include "config.h"
# Line 121  input mode under Windows. */ Line 121  input mode under Windows. */
121  #endif  #endif
122  #endif  #endif
123    
124    #ifdef __VMS
125    #include <ssdef.h>
126    void vms_setsymbol( char *, char *, int );
127    #endif
128    
129    
130  #define PRIV(name) name  #define PRIV(name) name
131    
132  /* 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 133  here before pcre_internal.h so that the Line 139  here before pcre_internal.h so that the
139  appropriately for an application, not for building PCRE. */  appropriately for an application, not for building PCRE. */
140    
141  #include "pcre.h"  #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  
   
142  #include "pcre_internal.h"  #include "pcre_internal.h"
143    
144  /* The pcre_printint() function, which prints the internal form of a compiled  /* The pcre_printint() function, which prints the internal form of a compiled
# Line 303  argument, the casting might be incorrect Line 295  argument, the casting might be incorrect
295  #define PCRE_JIT_STACK_FREE8(stack) \  #define PCRE_JIT_STACK_FREE8(stack) \
296    pcre_jit_stack_free(stack)    pcre_jit_stack_free(stack)
297    
298    #define pcre8_maketables pcre_maketables
299    
300  #endif /* SUPPORT_PCRE8 */  #endif /* SUPPORT_PCRE8 */
301    
302  /* -----------------------------------------------------------*/  /* -----------------------------------------------------------*/
# Line 486  argument, the casting might be incorrect Line 480  argument, the casting might be incorrect
480    
481  /* ----- More than one mode is supported; a runtime test is needed, except for  /* ----- More than one mode is supported; a runtime test is needed, except for
482  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
483  version is called. ----- */  available version is called. ----- */
484    
485  enum {  enum {
486    PCRE8_MODE,    PCRE8_MODE,
# Line 706  cases separately. */ Line 700  cases separately. */
700      PCRE_STUDY8(extra, re, options, error)      PCRE_STUDY8(extra, re, options, error)
701    
702    
703  /* ----- 32-bit and 16-bit but not 8-bit supported ----- */  /* ----- Two out of three modes are supported ----- */
   
 #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE16)  
 #define PCHARS(lv, p, offset, len, f) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCHARS32(lv, p, offset, len, f); \  
   else \  
     PCHARS16(lv, p, offset, len, f)  
   
 #define PCHARSV(p, offset, len, f) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCHARSV32(p, offset, len, f); \  
   else \  
     PCHARSV16(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 \  
     READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re)  
   
 #define SET_PCRE_CALLOUT(callout) \  
   if (pcre_mode == PCRE32_MODE) \  
     SET_PCRE_CALLOUT32(callout); \  
   else \  
     SET_PCRE_CALLOUT16(callout)  
   
 #define STRLEN(p) (pcre_mode == PCRE32_MODE ? STRLEN32(p) : STRLEN16(p)  
   
 #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata); \  
   else \  
     PCRE_ASSIGN_JIT_STACK16(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 \  
     PCRE_COMPILE16(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 \  
     PCRE_COPY_NAMED_SUBSTRING16(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 \  
     PCRE_COPY_SUBSTRING16(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 \  
     PCRE_DFA_EXEC16(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 \  
     PCRE_EXEC16(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 \  
     PCRE_FREE_STUDY16(extra)  
   
 #define PCRE_FREE_SUBSTRING(substring) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_FREE_SUBSTRING32(substring); \  
   else \  
     PCRE_FREE_SUBSTRING16(substring)  
   
 #define PCRE_FREE_SUBSTRING_LIST(listptr) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_FREE_SUBSTRING_LIST32(listptr); \  
   else \  
     PCRE_FREE_SUBSTRING_LIST16(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 \  
     PCRE_GET_NAMED_SUBSTRING16(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 \  
     PCRE_GET_STRINGNUMBER16(n, rc, ptr)  
704    
705  #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \  #else
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_GET_SUBSTRING32(rc, bptr, use_offsets, count, i, subsptr); \  
   else \  
     PCRE_GET_SUBSTRING16(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 \  
     PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr)  
   
 #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \  
   (pcre_mode == PCRE32_MODE ? \  
      PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \  
     : PCRE_JIT_STACK_ALLOC16(startsize, maxsize)  
   
 #define PCRE_JIT_STACK_FREE(stack) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_JIT_STACK_FREE32(stack); \  
   else \  
     PCRE_JIT_STACK_FREE16(stack)  
   
 #define PCRE_MAKETABLES \  
   (pcre_mode == PCRE32_MODE ? pcre32_maketables() : pcre16_maketables())  
706    
707  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \  /* We can use some macro trickery to make a single set of definitions work in
708    if (pcre_mode == PCRE32_MODE) \  the three different cases. */
     PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables); \  
   else \  
     PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables)  
709    
710  #define PCRE_PRINTINT(re, outfile, debug_lengths) \  /* ----- 32-bit and 16-bit but not 8-bit supported ----- */
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_PRINTINT32(re, outfile, debug_lengths); \  
   else \  
     PCRE_PRINTINT16(re, outfile, debug_lengths)  
   
 #define PCRE_STUDY(extra, re, options, error) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_STUDY32(extra, re, options, error); \  
   else \  
     PCRE_STUDY16(extra, re, options, error)  
711    
712    #if defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE16)
713    #define BITONE 32
714    #define BITTWO 16
715    
716  /* ----- 32-bit and 8-bit but not 16-bit supported ----- */  /* ----- 32-bit and 8-bit but not 16-bit supported ----- */
717    
718  #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE8)  #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE8)
719    #define BITONE 32
720    #define BITTWO 8
721    
722  #define PCHARS(lv, p, offset, len, f) \  /* ----- 16-bit and 8-bit but not 32-bit supported ----- */
   if (pcre_mode == PCRE32_MODE) \  
     PCHARS32(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 \  
     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 \  
     READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re)  
   
 #define SET_PCRE_CALLOUT(callout) \  
   if (pcre_mode == PCRE32_MODE) \  
     SET_PCRE_CALLOUT32(callout); \  
   else \  
     SET_PCRE_CALLOUT8(callout)  
   
 #define STRLEN(p) (pcre_mode == PCRE32_MODE ? STRLEN32(p) : STRLEN8(p))  
   
 #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_ASSIGN_JIT_STACK32(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 \  
     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 \  
     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 \  
     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 \  
     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 \  
     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 \  
     PCRE_FREE_STUDY8(extra)  
   
 #define PCRE_FREE_SUBSTRING(substring) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_FREE_SUBSTRING32(substring); \  
   else \  
     PCRE_FREE_SUBSTRING8(substring)  
   
 #define PCRE_FREE_SUBSTRING_LIST(listptr) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_FREE_SUBSTRING_LIST32(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 \  
     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 \  
     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 \  
     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 \  
     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_JIT_STACK_ALLOC8(startsize, maxsize))  
   
 #define PCRE_JIT_STACK_FREE(stack) \  
   if (pcre_mode == PCRE32_MODE) \  
     PCRE_JIT_STACK_FREE32(stack); \  
   else \  
     PCRE_JIT_STACK_FREE8(stack)  
   
 #define PCRE_MAKETABLES \  
   (pcre_mode == PCRE32_MODE ? pcre32_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 \  
     PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)  
723    
724  #define PCRE_PRINTINT(re, outfile, debug_lengths) \  #else
725    if (pcre_mode == PCRE32_MODE) \  #define BITONE 16
726      PCRE_PRINTINT32(re, outfile, debug_lengths); \  #define BITTWO 8
727    else \  #endif
     PCRE_PRINTINT8(re, outfile, debug_lengths)  
728    
729  #define PCRE_STUDY(extra, re, options, error) \  #define glue(a,b) a##b
730    if (pcre_mode == PCRE32_MODE) \  #define G(a,b) glue(a,b)
     PCRE_STUDY32(extra, re, options, error); \  
   else \  
     PCRE_STUDY8(extra, re, options, error)  
731    
732    
733  /* ----- 16-bit and 8-bit but not 32-bit supported ----- */  /* ----- Common macros for two-mode cases ----- */
734    
 #else  
735  #define PCHARS(lv, p, offset, len, f) \  #define PCHARS(lv, p, offset, len, f) \
736    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
737      PCHARS16(lv, p, offset, len, f); \      G(PCHARS,BITONE)(lv, p, offset, len, f); \
738    else \    else \
739      PCHARS8(lv, p, offset, len, f)      G(PCHARS,BITTWO)(lv, p, offset, len, f)
740    
741  #define PCHARSV(p, offset, len, f) \  #define PCHARSV(p, offset, len, f) \
742    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
743      PCHARSV16(p, offset, len, f); \      G(PCHARSV,BITONE)(p, offset, len, f); \
744    else \    else \
745      PCHARSV8(p, offset, len, f)      G(PCHARSV,BITTWO)(p, offset, len, f)
746    
747  #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \  #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
748    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
749      READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re); \      G(READ_CAPTURE_NAME,BITONE)(p, cn8, cn16, cn32, re); \
750    else \    else \
751      READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re)      G(READ_CAPTURE_NAME,BITTWO)(p, cn8, cn16, cn32, re)
752    
753  #define SET_PCRE_CALLOUT(callout) \  #define SET_PCRE_CALLOUT(callout) \
754    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
755      SET_PCRE_CALLOUT16(callout); \      G(SET_PCRE_CALLOUT,BITONE)(callout); \
756    else \    else \
757      SET_PCRE_CALLOUT8(callout)      G(SET_PCRE_CALLOUT,BITTWO)(callout)
758    
759  #define STRLEN(p) (pcre_mode == PCRE16_MODE ? STRLEN16(p) : STRLEN8(p))  #define STRLEN(p) ((pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
760      G(STRLEN,BITONE)(p) : G(STRLEN,BITTWO)(p))
761    
762  #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \  #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
763    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
764      PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata); \      G(PCRE_ASSIGN_JIT_STACK,BITONE)(extra, callback, userdata); \
765    else \    else \
766      PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata)      G(PCRE_ASSIGN_JIT_STACK,BITTWO)(extra, callback, userdata)
767    
768  #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \  #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
769    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
770      PCRE_COMPILE16(re, pat, options, error, erroffset, tables); \      G(PCRE_COMPILE,BITONE)(re, pat, options, error, erroffset, tables); \
771    else \    else \
772      PCRE_COMPILE8(re, pat, options, error, erroffset, tables)      G(PCRE_COMPILE,BITTWO)(re, pat, options, error, erroffset, tables)
773    
774  #define PCRE_CONFIG pcre_config  #define PCRE_CONFIG G(G(pcre,BITONE),_config)
775    
776  #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \  #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
777      namesptr, cbuffer, size) \      namesptr, cbuffer, size) \
778    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
779      PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \      G(PCRE_COPY_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \
780        namesptr, cbuffer, size); \        namesptr, cbuffer, size); \
781    else \    else \
782      PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \      G(PCRE_COPY_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \
783        namesptr, cbuffer, size)        namesptr, cbuffer, size)
784    
785  #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \  #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
786    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
787      PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size); \      G(PCRE_COPY_SUBSTRING,BITONE)(rc, bptr, offsets, count, i, cbuffer, size); \
788    else \    else \
789      PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size)      G(PCRE_COPY_SUBSTRING,BITTWO)(rc, bptr, offsets, count, i, cbuffer, size)
790    
791  #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \  #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \
792      offsets, size_offsets, workspace, size_workspace) \      offsets, size_offsets, workspace, size_workspace) \
793    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
794      PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \      G(PCRE_DFA_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \
795        offsets, size_offsets, workspace, size_workspace); \        offsets, size_offsets, workspace, size_workspace); \
796    else \    else \
797      PCRE_DFA_EXEC8(count, re, extra, bptr, len, start_offset, options, \      G(PCRE_DFA_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \
798        offsets, size_offsets, workspace, size_workspace)        offsets, size_offsets, workspace, size_workspace)
799    
800  #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \  #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
801      offsets, size_offsets) \      offsets, size_offsets) \
802    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
803      PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \      G(PCRE_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \
804        offsets, size_offsets); \        offsets, size_offsets); \
805    else \    else \
806      PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \      G(PCRE_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \
807        offsets, size_offsets)        offsets, size_offsets)
808    
809  #define PCRE_FREE_STUDY(extra) \  #define PCRE_FREE_STUDY(extra) \
810    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
811      PCRE_FREE_STUDY16(extra); \      G(PCRE_FREE_STUDY,BITONE)(extra); \
812    else \    else \
813      PCRE_FREE_STUDY8(extra)      G(PCRE_FREE_STUDY,BITTWO)(extra)
814    
815  #define PCRE_FREE_SUBSTRING(substring) \  #define PCRE_FREE_SUBSTRING(substring) \
816    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
817      PCRE_FREE_SUBSTRING16(substring); \      G(PCRE_FREE_SUBSTRING,BITONE)(substring); \
818    else \    else \
819      PCRE_FREE_SUBSTRING8(substring)      G(PCRE_FREE_SUBSTRING,BITTWO)(substring)
820    
821  #define PCRE_FREE_SUBSTRING_LIST(listptr) \  #define PCRE_FREE_SUBSTRING_LIST(listptr) \
822    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
823      PCRE_FREE_SUBSTRING_LIST16(listptr); \      G(PCRE_FREE_SUBSTRING_LIST,BITONE)(listptr); \
824    else \    else \
825      PCRE_FREE_SUBSTRING_LIST8(listptr)      G(PCRE_FREE_SUBSTRING_LIST,BITTWO)(listptr)
826    
827  #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \  #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
828      getnamesptr, subsptr) \      getnamesptr, subsptr) \
829    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
830      PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \      G(PCRE_GET_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \
831        getnamesptr, subsptr); \        getnamesptr, subsptr); \
832    else \    else \
833      PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \      G(PCRE_GET_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \
834        getnamesptr, subsptr)        getnamesptr, subsptr)
835    
836  #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \  #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
837    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
838      PCRE_GET_STRINGNUMBER16(n, rc, ptr); \      G(PCRE_GET_STRINGNUMBER,BITONE)(n, rc, ptr); \
839    else \    else \
840      PCRE_GET_STRINGNUMBER8(n, rc, ptr)      G(PCRE_GET_STRINGNUMBER,BITTWO)(n, rc, ptr)
841    
842  #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \  #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
843    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
844      PCRE_GET_SUBSTRING16(rc, bptr, use_offsets, count, i, subsptr); \      G(PCRE_GET_SUBSTRING,BITONE)(rc, bptr, use_offsets, count, i, subsptr); \
845    else \    else \
846      PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr)      G(PCRE_GET_SUBSTRING,BITTWO)(rc, bptr, use_offsets, count, i, subsptr)
847    
848  #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \  #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
849    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
850      PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr); \      G(PCRE_GET_SUBSTRING_LIST,BITONE)(rc, bptr, offsets, count, listptr); \
851    else \    else \
852      PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)      G(PCRE_GET_SUBSTRING_LIST,BITTWO)(rc, bptr, offsets, count, listptr)
853    
854  #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \  #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
855    (pcre_mode == PCRE16_MODE ? \    (pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
856        PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \       G(PCRE_JIT_STACK_ALLOC,BITONE)(startsize, maxsize) \
857        : PCRE_JIT_STACK_ALLOC8(startsize, maxsize))      : G(PCRE_JIT_STACK_ALLOC,BITTWO)(startsize, maxsize)
858    
859  #define PCRE_JIT_STACK_FREE(stack) \  #define PCRE_JIT_STACK_FREE(stack) \
860    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
861      PCRE_JIT_STACK_FREE16(stack); \      G(PCRE_JIT_STACK_FREE,BITONE)(stack); \
862    else \    else \
863      PCRE_JIT_STACK_FREE8(stack)      G(PCRE_JIT_STACK_FREE,BITTWO)(stack)
864    
865  #define PCRE_MAKETABLES \  #define PCRE_MAKETABLES \
866    (pcre_mode == PCRE16_MODE ? pcre16_maketables() : pcre_maketables())    (pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
867        G(G(pcre,BITONE),_maketables)() : G(G(pcre,BITTWO),_maketables)()
868    
869  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
870    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
871      PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables); \      G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITONE)(rc, re, extra, tables); \
872    else \    else \
873      PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)      G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITTWO)(rc, re, extra, tables)
874    
875  #define PCRE_PRINTINT(re, outfile, debug_lengths) \  #define PCRE_PRINTINT(re, outfile, debug_lengths) \
876    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
877      PCRE_PRINTINT16(re, outfile, debug_lengths); \      G(PCRE_PRINTINT,BITONE)(re, outfile, debug_lengths); \
878    else \    else \
879      PCRE_PRINTINT8(re, outfile, debug_lengths)      G(PCRE_PRINTINT,BITTWO)(re, outfile, debug_lengths)
880    
881  #define PCRE_STUDY(extra, re, options, error) \  #define PCRE_STUDY(extra, re, options, error) \
882    if (pcre_mode == PCRE16_MODE) \    if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
883      PCRE_STUDY16(extra, re, options, error); \      G(PCRE_STUDY,BITONE)(extra, re, options, error); \
884    else \    else \
885      PCRE_STUDY8(extra, re, options, error)      G(PCRE_STUDY,BITTWO)(extra, re, options, error)
886    
887  #endif  #endif  /* Two out of three modes */
888    
889  /* ----- End of cases where more than one mode is supported ----- */  /* ----- End of cases where more than one mode is supported ----- */
890    
# Line 1310  static int buffer_size = 50000; Line 1026  static int buffer_size = 50000;
1026  static pcre_uint8 *buffer = NULL;  static pcre_uint8 *buffer = NULL;
1027  static pcre_uint8 *pbuffer = NULL;  static pcre_uint8 *pbuffer = NULL;
1028    
1029  /* Another buffer is needed translation to 16/32-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. */  
   
 #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. */  
1030    
1031  #ifdef COMPILE_PCRE16  #ifdef COMPILE_PCRE16
1032  #error COMPILE_PCRE16 must not be set when compiling pcretest.c  #error COMPILE_PCRE16 must not be set when compiling pcretest.c
# Line 1329  COMPILE_PCRE[16|32] is *not* set. */ Line 1036  COMPILE_PCRE[16|32] is *not* set. */
1036  #error COMPILE_PCRE32 must not be set when compiling pcretest.c  #error COMPILE_PCRE32 must not be set when compiling pcretest.c
1037  #endif  #endif
1038    
1039    /* We need buffers for building 16/32-bit strings, and the tables of operator
1040    lengths that are used for 16/32-bit compiling, in order to swap bytes in a
1041    pattern for saving/reloading testing. Luckily, the data for these tables is
1042    defined as a macro. However, we must ensure that LINK_SIZE and IMM2_SIZE (which
1043    are used in the tables) are adjusted appropriately for the 16/32-bit world.
1044    LINK_SIZE is also used later in this program. */
1045    
1046    #ifdef SUPPORT_PCRE16
1047    #undef IMM2_SIZE
1048    #define IMM2_SIZE 1
1049    
1050  #if LINK_SIZE == 2  #if LINK_SIZE == 2
1051  #undef LINK_SIZE  #undef LINK_SIZE
1052  #define LINK_SIZE 1  #define LINK_SIZE 1
# Line 1339  COMPILE_PCRE[16|32] is *not* set. */ Line 1057  COMPILE_PCRE[16|32] is *not* set. */
1057  #error LINK_SIZE must be either 2, 3, or 4  #error LINK_SIZE must be either 2, 3, or 4
1058  #endif  #endif
1059    
 #undef IMM2_SIZE  
 #define IMM2_SIZE 1  
   
 #endif /* SUPPORT_PCRE8 && (SUPPORT_PCRE16 || SUPPORT_PCRE32) */  
   
 #ifdef SUPPORT_PCRE16  
1060  static int buffer16_size = 0;  static int buffer16_size = 0;
1061  static pcre_uint16 *buffer16 = NULL;  static pcre_uint16 *buffer16 = NULL;
1062  static const pcre_uint16 OP_lengths16[] = { OP_LENGTHS };  static const pcre_uint16 OP_lengths16[] = { OP_LENGTHS };
1063  #endif  /* SUPPORT_PCRE16 */  #endif  /* SUPPORT_PCRE16 */
1064    
1065  #ifdef SUPPORT_PCRE32  #ifdef SUPPORT_PCRE32
1066    #undef IMM2_SIZE
1067    #define IMM2_SIZE 1
1068    #undef LINK_SIZE
1069    #define LINK_SIZE 1
1070    
1071  static int buffer32_size = 0;  static int buffer32_size = 0;
1072  static pcre_uint32 *buffer32 = NULL;  static pcre_uint32 *buffer32 = NULL;
1073  static const pcre_uint32 OP_lengths32[] = { OP_LENGTHS };  static const pcre_uint32 OP_lengths32[] = { OP_LENGTHS };
1074  #endif  /* SUPPORT_PCRE32 */  #endif  /* SUPPORT_PCRE32 */
1075    
1076  /* If we have 8-bit support, default to it; if there is also  /* If we have 8-bit support, default to it; if there is also 16-or 32-bit
1077  16-or 32-bit support, it can be changed by an option. If there is no 8-bit support,  support, it can be changed by an option. If there is no 8-bit support, there
1078  there must be 16-or 32-bit support, so default it to 1. */  must be 16-or 32-bit support, so default it to 1. */
1079    
1080  #if defined SUPPORT_PCRE8  #if defined SUPPORT_PCRE8
1081  static int pcre_mode = PCRE8_MODE;  static int pcre_mode = PCRE8_MODE;
# Line 1418  static const char *errtexts[] = { Line 1135  static const char *errtexts[] = {
1135    "JIT stack limit reached",    "JIT stack limit reached",
1136    "pattern compiled in wrong mode: 8-bit/16-bit error",    "pattern compiled in wrong mode: 8-bit/16-bit error",
1137    "pattern compiled with other endianness",    "pattern compiled with other endianness",
1138    "invalid data in workspace for DFA restart"    "invalid data in workspace for DFA restart",
1139      "bad JIT option",
1140      "bad length"
1141  };  };
1142    
1143    
# Line 1876  return i+1; Line 1595  return i+1;
1595    
1596    
1597    
1598  #if !defined NOUTF || defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32  #if defined SUPPORT_PCRE8 && !defined NOUTF
1599  /*************************************************  /*************************************************
1600  *       Convert character value to UTF-8         *  *       Convert character value to UTF-8         *
1601  *************************************************/  *************************************************/
# Line 2077  Returns:       TRUE  if the string is a Line 1796  Returns:       TRUE  if the string is a
1796                 FALSE otherwise                 FALSE otherwise
1797  */  */
1798    
1799    #ifdef NEVER   /* Not used */
1800  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1801  static BOOL  static BOOL
1802  valid_utf32(pcre_uint32 *string, int length)  valid_utf32(pcre_uint32 *string, int length)
# Line 2087  register pcre_uint32 c; Line 1807  register pcre_uint32 c;
1807  for (p = string; length-- > 0; p++)  for (p = string; length-- > 0; p++)
1808    {    {
1809    c = *p;    c = *p;
1810      if (c > 0x10ffffu) return FALSE;                 /* Too big */
1811    if (c > 0x10ffffu)    if ((c & 0xfffff800u) == 0xd800u) return FALSE;  /* Surrogate */
     return FALSE;  
   
   /* A surrogate */  
   if ((c & 0xfffff800u) == 0xd800u)  
     return FALSE;  
   
   /* Non-character */  
   if ((c & 0xfffeu) == 0xfffeu ||  
       c >= 0xfdd0u && c <= 0xfdefu)  
     return FALSE;  
1812    }    }
1813    
1814  return TRUE;  return TRUE;
1815  }  }
1816  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
1817    #endif /* NEVER */
1818    #endif /* SUPPORT_PCRE32 */
1819    
 #endif  
1820    
1821  /*************************************************  /*************************************************
1822  *        Read or extend an input line            *  *        Read or extend an input line            *
# Line 2245  return(result); Line 1956  return(result);
1956    
1957  static int pchar(pcre_uint32 c, FILE *f)  static int pchar(pcre_uint32 c, FILE *f)
1958  {  {
1959  int n;  int n = 0;
1960  if (PRINTOK(c))  if (PRINTOK(c))
1961    {    {
1962    if (f != NULL) fprintf(f, "%c", c);    if (f != NULL) fprintf(f, "%c", c);
# Line 2365  while (length-- > 0) Line 2076  while (length-- > 0)
2076    if (use_utf && c >= 0xD800 && c < 0xDC00 && length > 0)    if (use_utf && c >= 0xD800 && c < 0xDC00 && length > 0)
2077      {      {
2078      int d = *p & 0xffff;      int d = *p & 0xffff;
2079      if (d >= 0xDC00 && d < 0xDFFF)      if (d >= 0xDC00 && d <= 0xDFFF)
2080        {        {
2081        c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000;        c = ((c & 0x3ff) << 10) + (d & 0x3ff) + 0x10000;
2082        length--;        length--;
# Line 2390  return yield; Line 2101  return yield;
2101  /* Must handle UTF-32 strings in utf mode. Yields number of characters printed.  /* Must handle UTF-32 strings in utf mode. Yields number of characters printed.
2102  If handed a NULL file, just counts chars without printing. */  If handed a NULL file, just counts chars without printing. */
2103    
 #define UTF32_MASK (0x1fffffu)  
   
2104  static int pchars32(PCRE_SPTR32 p, int length, BOOL utf, FILE *f)  static int pchars32(PCRE_SPTR32 p, int length, BOOL utf, FILE *f)
2105  {  {
2106  int yield = 0;  int yield = 0;
2107    
2108    (void)(utf);  /* Avoid compiler warning */
2109    
2110  if (length < 0)  if (length < 0)
2111    length = strlen32(p);    length = strlen32(p);
2112    
2113  while (length-- > 0)  while (length-- > 0)
2114    {    {
2115    pcre_uint32 c = *p++;    pcre_uint32 c = *p++;
   if (utf) c &= UTF32_MASK;  
2116    yield += pchar(c, f);    yield += pchar(c, f);
2117    }    }
2118    
# Line 2685  else Line 2395  else
2395    rc = PCRE_ERROR_BADMODE;    rc = PCRE_ERROR_BADMODE;
2396  #endif  #endif
2397    
2398  if (rc < 0)  if (rc < 0 && rc != PCRE_ERROR_UNSET)
2399    {    {
2400    fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,    fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
2401      pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "", option);      pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "", option);
# Line 2761  BOOL utf16_char = FALSE; Line 2471  BOOL utf16_char = FALSE;
2471  re->magic_number = REVERSED_MAGIC_NUMBER;  re->magic_number = REVERSED_MAGIC_NUMBER;
2472  re->size = swap_uint32(re->size);  re->size = swap_uint32(re->size);
2473  re->options = swap_uint32(re->options);  re->options = swap_uint32(re->options);
2474  re->flags = swap_uint16(re->flags);  re->flags = swap_uint32(re->flags);
2475  re->top_bracket = swap_uint16(re->top_bracket);  re->limit_match = swap_uint32(re->limit_match);
2476  re->top_backref = swap_uint16(re->top_backref);  re->limit_recursion = swap_uint32(re->limit_recursion);
2477  re->first_char = swap_uint16(re->first_char);  re->first_char = swap_uint16(re->first_char);
2478  re->req_char = swap_uint16(re->req_char);  re->req_char = swap_uint16(re->req_char);
2479    re->max_lookbehind = swap_uint16(re->max_lookbehind);
2480    re->top_bracket = swap_uint16(re->top_bracket);
2481    re->top_backref = swap_uint16(re->top_backref);
2482  re->name_table_offset = swap_uint16(re->name_table_offset);  re->name_table_offset = swap_uint16(re->name_table_offset);
2483  re->name_entry_size = swap_uint16(re->name_entry_size);  re->name_entry_size = swap_uint16(re->name_entry_size);
2484  re->name_count = swap_uint16(re->name_count);  re->name_count = swap_uint16(re->name_count);
2485    re->ref_count = swap_uint16(re->ref_count);
2486    
2487  if (extra != NULL)  if (extra != NULL)
2488    {    {
# Line 2932  real_pcre32 *re = (real_pcre32 *)ere; Line 2646  real_pcre32 *re = (real_pcre32 *)ere;
2646  int op;  int op;
2647  pcre_uint32 *ptr = (pcre_uint32 *)re + re->name_table_offset;  pcre_uint32 *ptr = (pcre_uint32 *)re + re->name_table_offset;
2648  int length = re->name_count * re->name_entry_size;  int length = re->name_count * re->name_entry_size;
 #ifdef SUPPORT_UTF  
 BOOL utf = (re->options & PCRE_UTF32) != 0;  
 #endif /* SUPPORT_UTF */  
2649    
2650  /* Always flip the bytes in the main data block and study blocks. */  /* Always flip the bytes in the main data block and study blocks. */
2651    
2652  re->magic_number = REVERSED_MAGIC_NUMBER;  re->magic_number = REVERSED_MAGIC_NUMBER;
2653  re->size = swap_uint32(re->size);  re->size = swap_uint32(re->size);
2654  re->options = swap_uint32(re->options);  re->options = swap_uint32(re->options);
2655  re->flags = swap_uint16(re->flags);  re->flags = swap_uint32(re->flags);
2656  re->top_bracket = swap_uint16(re->top_bracket);  re->limit_match = swap_uint32(re->limit_match);
2657  re->top_backref = swap_uint16(re->top_backref);  re->limit_recursion = swap_uint32(re->limit_recursion);
2658  re->first_char = swap_uint32(re->first_char);  re->first_char = swap_uint32(re->first_char);
2659  re->req_char = swap_uint32(re->req_char);  re->req_char = swap_uint32(re->req_char);
2660    re->max_lookbehind = swap_uint16(re->max_lookbehind);
2661    re->top_bracket = swap_uint16(re->top_bracket);
2662    re->top_backref = swap_uint16(re->top_backref);
2663  re->name_table_offset = swap_uint16(re->name_table_offset);  re->name_table_offset = swap_uint16(re->name_table_offset);
2664  re->name_entry_size = swap_uint16(re->name_entry_size);  re->name_entry_size = swap_uint16(re->name_entry_size);
2665  re->name_count = swap_uint16(re->name_count);  re->name_count = swap_uint16(re->name_count);
2666    re->ref_count = swap_uint16(re->ref_count);
2667    
2668  if (extra != NULL)  if (extra != NULL)
2669    {    {
# Line 2958  if (extra != NULL) Line 2673  if (extra != NULL)
2673    rsd->minlength = swap_uint32(rsd->minlength);    rsd->minlength = swap_uint32(rsd->minlength);
2674    }    }
2675    
2676  /* In 32-bit mode we must swap bytes  /* In 32-bit mode we must swap bytes in the name table, if present, and then in
2677  in the name table, if present, and then in the pattern itself. */  the pattern itself. */
2678    
2679  while(TRUE)  while(TRUE)
2680    {    {
# Line 3233  int done = 0; Line 2948  int done = 0;
2948  int all_use_dfa = 0;  int all_use_dfa = 0;
2949  int verify_jit = 0;  int verify_jit = 0;
2950  int yield = 0;  int yield = 0;
 #ifdef SUPPORT_PCRE32  
 int mask_utf32 = 0;  
 #endif  
2951  int stack_size;  int stack_size;
2952  pcre_uint8 *dbuffer = NULL;  pcre_uint8 *dbuffer = NULL;
2953  size_t dbuffer_size = 1u << 14;  size_t dbuffer_size = 1u << 14;
# Line 3347  while (argc > 1 && argv[op][0] == '-') Line 3059  while (argc > 1 && argv[op][0] == '-')
3059      exit(1);      exit(1);
3060  #endif  #endif
3061      }      }
3062    else if (strcmp(arg, "-32") == 0 || strcmp(arg, "-32+") == 0)    else if (strcmp(arg, "-32") == 0)
3063      {      {
3064  #ifdef SUPPORT_PCRE32  #ifdef SUPPORT_PCRE32
3065      pcre_mode = PCRE32_MODE;      pcre_mode = PCRE32_MODE;
     mask_utf32 = (strcmp(arg, "-32+") == 0);  
3066  #else  #else
3067      printf("** This version of PCRE was built without 32-bit support\n");      printf("** This version of PCRE was built without 32-bit support\n");
3068      exit(1);      exit(1);
# Line 3390  while (argc > 1 && argv[op][0] == '-') Line 3101  while (argc > 1 && argv[op][0] == '-')
3101        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),        ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),
3102          *endptr == 0))          *endptr == 0))
3103      {      {
3104  #if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS)  #if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS) || defined(__VMS)
3105      printf("PCRE: -S not supported on this OS\n");      printf("PCRE: -S not supported on this OS\n");
3106      exit(1);      exit(1);
3107  #else  #else
# Line 3423  while (argc > 1 && argv[op][0] == '-') Line 3134  while (argc > 1 && argv[op][0] == '-')
3134          (void)PCRE_CONFIG(PCRE_CONFIG_LINK_SIZE, &rc);          (void)PCRE_CONFIG(PCRE_CONFIG_LINK_SIZE, &rc);
3135          printf("%d\n", rc);          printf("%d\n", rc);
3136          yield = rc;          yield = rc;
3137    
3138    #ifdef __VMS
3139            vms_setsymbol("LINKSIZE",0,yield );
3140    #endif
3141          }          }
3142        else if (strcmp(argv[op + 1], "pcre8") == 0)        else if (strcmp(argv[op + 1], "pcre8") == 0)
3143          {          {
# Line 3433  while (argc > 1 && argv[op][0] == '-') Line 3148  while (argc > 1 && argv[op][0] == '-')
3148          printf("0\n");          printf("0\n");
3149          yield = 0;          yield = 0;
3150  #endif  #endif
3151    #ifdef __VMS
3152            vms_setsymbol("PCRE8",0,yield );
3153    #endif
3154          }          }
3155        else if (strcmp(argv[op + 1], "pcre16") == 0)        else if (strcmp(argv[op + 1], "pcre16") == 0)
3156          {          {
# Line 3443  while (argc > 1 && argv[op][0] == '-') Line 3161  while (argc > 1 && argv[op][0] == '-')
3161          printf("0\n");          printf("0\n");
3162          yield = 0;          yield = 0;
3163  #endif  #endif
3164    #ifdef __VMS
3165            vms_setsymbol("PCRE16",0,yield );
3166    #endif
3167          }          }
3168        else if (strcmp(argv[op + 1], "pcre32") == 0)        else if (strcmp(argv[op + 1], "pcre32") == 0)
3169          {          {
# Line 3453  while (argc > 1 && argv[op][0] == '-') Line 3174  while (argc > 1 && argv[op][0] == '-')
3174          printf("0\n");          printf("0\n");
3175          yield = 0;          yield = 0;
3176  #endif  #endif
3177          goto EXIT;  #ifdef __VMS
3178            vms_setsymbol("PCRE32",0,yield );
3179    #endif
3180          }          }
3181        if (strcmp(argv[op + 1], "utf") == 0)        else if (strcmp(argv[op + 1], "utf") == 0)
3182          {          {
3183  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
3184          if (pcre_mode == PCRE8_MODE)          if (pcre_mode == PCRE8_MODE)
# Line 3471  while (argc > 1 && argv[op][0] == '-') Line 3194  while (argc > 1 && argv[op][0] == '-')
3194  #endif  #endif
3195          printf("%d\n", rc);          printf("%d\n", rc);
3196          yield = rc;          yield = rc;
3197          goto EXIT;  #ifdef __VMS
3198            vms_setsymbol("UTF",0,yield );
3199    #endif
3200          }          }
3201        else if (strcmp(argv[op + 1], "ucp") == 0)        else if (strcmp(argv[op + 1], "ucp") == 0)
3202          {          {
# Line 3808  while (!done) Line 3533  while (!done)
3533        PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);        PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);
3534        if (rc == PCRE_ERROR_BADMODE)        if (rc == PCRE_ERROR_BADMODE)
3535          {          {
3536            pcre_uint32 flags_in_host_byte_order;
3537            if (REAL_PCRE_MAGIC(re) == MAGIC_NUMBER)
3538              flags_in_host_byte_order = REAL_PCRE_FLAGS(re);
3539            else
3540              flags_in_host_byte_order = swap_uint32(REAL_PCRE_FLAGS(re));
3541          /* Simulate the result of the function call below. */          /* Simulate the result of the function call below. */
3542          fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,          fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
3543            pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "",            pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "",
3544            PCRE_INFO_OPTIONS);            PCRE_INFO_OPTIONS);
3545          fprintf(outfile, "Running in %d-bit mode but pattern was compiled in "          fprintf(outfile, "Running in %d-bit mode but pattern was compiled in "
3546            "%d-bit mode\n", 8 * CHAR_SIZE,            "%d-bit mode\n", 8 * CHAR_SIZE, 8 * (flags_in_host_byte_order & PCRE_MODE_MASK));
           8 * (REAL_PCRE_FLAGS(re) & PCRE_MODE_MASK));  
3547          new_free(re);          new_free(re);
3548          fclose(f);          fclose(f);
3549          continue;          continue;
# Line 3968  while (!done) Line 3697  while (!done)
3697        case 'Y': options |= PCRE_NO_START_OPTIMISE; break;        case 'Y': options |= PCRE_NO_START_OPTIMISE; break;
3698        case 'Z': debug_lengths = 0; break;        case 'Z': debug_lengths = 0; break;
3699        case '8': options |= PCRE_UTF8; use_utf = 1; break;        case '8': options |= PCRE_UTF8; use_utf = 1; break;
3700          case '9': options |= PCRE_NEVER_UTF; break;
3701        case '?': options |= PCRE_NO_UTF8_CHECK; break;        case '?': options |= PCRE_NO_UTF8_CHECK; break;
3702    
3703        case 'T':        case 'T':
# Line 4201  while (!done) Line 3931  while (!done)
3931    
3932        new_info(re, NULL, PCRE_INFO_NAMECOUNT, &name_count);        new_info(re, NULL, PCRE_INFO_NAMECOUNT, &name_count);
3933        new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &name_entry_size);        new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &name_entry_size);
3934          real_pcre_size = 0;
3935  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
3936        if (REAL_PCRE_FLAGS(re) & PCRE_MODE8)        if (REAL_PCRE_FLAGS(re) & PCRE_MODE8)
3937          real_pcre_size = sizeof(real_pcre);          real_pcre_size = sizeof(real_pcre);
# Line 4287  while (!done) Line 4018  while (!done)
4018        {        {
4019        unsigned long int all_options;        unsigned long int all_options;
4020        pcre_uint32 first_char, need_char;        pcre_uint32 first_char, need_char;
4021          pcre_uint32 match_limit, recursion_limit;
4022        int count, backrefmax, first_char_set, need_char_set, okpartial, jchanged,        int count, backrefmax, first_char_set, need_char_set, okpartial, jchanged,
4023          hascrorlf, maxlookbehind;          hascrorlf, maxlookbehind;
4024        int nameentrysize, namecount;        int nameentrysize, namecount;
# Line 4314  while (!done) Line 4046  while (!done)
4046          (int)size, (int)regex_gotten_store);          (int)size, (int)regex_gotten_store);
4047    
4048        fprintf(outfile, "Capturing subpattern count = %d\n", count);        fprintf(outfile, "Capturing subpattern count = %d\n", count);
4049    
4050        if (backrefmax > 0)        if (backrefmax > 0)
4051          fprintf(outfile, "Max back reference = %d\n", backrefmax);          fprintf(outfile, "Max back reference = %d\n", backrefmax);
4052    
4053          if (maxlookbehind > 0)
4054            fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);
4055    
4056          if (new_info(re, NULL, PCRE_INFO_MATCHLIMIT, &match_limit) == 0)
4057            fprintf(outfile, "Match limit = %u\n", match_limit);
4058    
4059          if (new_info(re, NULL, PCRE_INFO_RECURSIONLIMIT, &recursion_limit) == 0)
4060            fprintf(outfile, "Recursion limit = %u\n", recursion_limit);
4061    
4062        if (namecount > 0)        if (namecount > 0)
4063          {          {
4064          fprintf(outfile, "Named capturing subpatterns:\n");          fprintf(outfile, "Named capturing subpatterns:\n");
# Line 4350  while (!done) Line 4092  while (!done)
4092        if (do_flip) all_options = swap_uint32(all_options);        if (do_flip) all_options = swap_uint32(all_options);
4093    
4094        if (get_options == 0) fprintf(outfile, "No options\n");        if (get_options == 0) fprintf(outfile, "No options\n");
4095          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",
4096            ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",            ((get_options & PCRE_ANCHORED) != 0)? " anchored" : "",
4097            ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",            ((get_options & PCRE_CASELESS) != 0)? " caseless" : "",
4098            ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",            ((get_options & PCRE_EXTENDED) != 0)? " extended" : "",
# Line 4367  while (!done) Line 4109  while (!done)
4109            ((get_options & PCRE_UCP) != 0)? " ucp" : "",            ((get_options & PCRE_UCP) != 0)? " ucp" : "",
4110            ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf_check" : "",            ((get_options & PCRE_NO_UTF8_CHECK) != 0)? " no_utf_check" : "",
4111            ((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "",            ((get_options & PCRE_NO_START_OPTIMIZE) != 0)? " no_start_optimize" : "",
4112            ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "");            ((get_options & PCRE_DUPNAMES) != 0)? " dupnames" : "",
4113              ((get_options & PCRE_NEVER_UTF) != 0)? " never_utf" : "");
4114    
4115        if (jchanged) fprintf(outfile, "Duplicate name status changes\n");        if (jchanged) fprintf(outfile, "Duplicate name status changes\n");
4116    
# Line 4441  while (!done) Line 4184  while (!done)
4184            }            }
4185          }          }
4186    
       if (maxlookbehind > 0)  
         fprintf(outfile, "Max lookbehind = %d\n", maxlookbehind);  
   
4187        /* 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
4188        value, but it varies, depending on the computer architecture, and        value, but it varies, depending on the computer architecture, and
4189        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 4687  while (!done) Line 4427  while (!done)
4427        }        }
4428  #endif  #endif
4429    
4430    #ifdef SUPPORT_VALGRIND
4431        /* Mark the dbuffer as addressable but undefined again. */
4432        if (dbuffer != NULL)
4433          {
4434          VALGRIND_MAKE_MEM_UNDEFINED(dbuffer, dbuffer_size * CHAR_SIZE);
4435          }
4436    #endif
4437    
4438      /* Allocate a buffer to hold the data line. len+1 is an upper bound on      /* Allocate a buffer to hold the data line. len+1 is an upper bound on
4439         the number of pcre_uchar units that will be needed. */         the number of pcre_uchar units that will be needed. */
4440      if (dbuffer == NULL || (size_t)len >= dbuffer_size)      if (dbuffer == NULL || (size_t)len >= dbuffer_size)
# Line 4695  while (!done) Line 4443  while (!done)
4443        dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);        dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);
4444        if (dbuffer == NULL)        if (dbuffer == NULL)
4445          {          {
4446          fprintf(stderr, "pcretest: malloc(%d) failed\n", dbuffer_size);          fprintf(stderr, "pcretest: malloc(%d) failed\n", (int)dbuffer_size);
4447          exit(1);          exit(1);
4448          }          }
4449        }        }
# Line 4997  while (!done) Line 4745  while (!done)
4745          continue;          continue;
4746          }          }
4747    
4748        /* 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.
4749        16-bit or 32-bit mode, we always convert characters to UTF-8 so that        In 8-bit mode we convert to UTF-8 if we are in UTF mode. Values greater
4750        values greater than 255 can be passed to non-UTF 16- or 32-bit strings.        than 127 in UTF mode must have come from \x{...} or octal constructs
       In 8-bit       mode we convert to UTF-8 if we are in UTF mode. Values greater  
       than 127       in UTF mode must have come from \x{...} or octal constructs  
4751        because values from \x.. get this far only in non-UTF mode. */        because values from \x.. get this far only in non-UTF mode. */
4752    
4753  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
# Line 5010  while (!done) Line 4756  while (!done)
4756  #ifndef NOUTF  #ifndef NOUTF
4757          if (use_utf)          if (use_utf)
4758            {            {
4759              if (c > 0x7fffffff)
4760                {
4761                fprintf(outfile, "** Character \\x{%x} is greater than 0x7fffffff "
4762                  "and so cannot be converted to UTF-8\n", c);
4763                goto NEXT_DATA;
4764                }
4765            q8 += ord2utf8(c, q8);            q8 += ord2utf8(c, q8);
4766            }            }
4767          else          else
# Line 5022  while (!done) Line 4774  while (!done)
4774              fprintf(outfile, "** Truncation will probably give the wrong "              fprintf(outfile, "** Truncation will probably give the wrong "
4775                "result.\n");                "result.\n");
4776              }              }
   
4777            *q8++ = c;            *q8++ = c;
4778            }            }
4779          }          }
# Line 5035  while (!done) Line 4786  while (!done)
4786            {            {
4787            if (c > 0x10ffffu)            if (c > 0x10ffffu)
4788              {              {
4789              fprintf(outfile, "**Failed: character value greater than 0x10ffff "              fprintf(outfile, "** Failed: character \\x{%x} is greater than "
4790                "cannot be converted to UTF-16\n");                "0x10ffff and so cannot be converted to UTF-16\n", c);
4791              goto NEXT_DATA;              goto NEXT_DATA;
4792              }              }
4793            else if (c >= 0x10000u)            else if (c >= 0x10000u)
# Line 5053  while (!done) Line 4804  while (!done)
4804            {            {
4805            if (c > 0xffffu)            if (c > 0xffffu)
4806              {              {
4807              fprintf(outfile, "** Character value is greater than 0xffff "              fprintf(outfile, "** Character \\x{%x} is greater than 0xffff "
4808                "and UTF-16 mode is not enabled.\n");                "and UTF-16 mode is not enabled.\n", c);
4809              fprintf(outfile, "** Truncation will probably give the wrong "              fprintf(outfile, "** Truncation will probably give the wrong "
4810                "result.\n");                "result.\n");
4811              }              }
# Line 5096  while (!done) Line 4847  while (!done)
4847      }      }
4848  #endif  #endif
4849    
4850  #if defined SUPPORT_UTF && defined SUPPORT_PCRE32      /* If we're compiling with explicit valgrind support, Mark the data from after
4851      /* If we're requsted to test UTF-32 masking of high bits, change the data      its end to the end of the buffer as unaddressable, so that a read over the end
4852      string to have high bits set, unless the string is invalid UTF-32.      of the buffer will be seen by valgrind, even if it doesn't cause a crash.
4853      Since the JIT doesn't support this yet, only do it when not JITing. */      If we're not building with valgrind support, at least move the data to the end
4854      if (use_utf && mask_utf32 && (study_options & PCRE_STUDY_ALLJIT) == 0 &&      of the buffer so that it might at least cause a crash.
4855          valid_utf32((pcre_uint32 *)dbuffer, len))      If we are using the POSIX interface, we must include the terminating zero. */
       {  
       for (q32 = (pcre_uint32 *)dbuffer; *q32; q32++)  
         *q32 |= ~(pcre_uint32)UTF32_MASK;  
   
       /* Need to pass NO_UTF32_CHECK so the high bits are allowed */  
       options |= PCRE_NO_UTF32_CHECK;  
       }  
 #endif  
   
     /* Move the data to the end of the buffer so that a read over the end of  
     the buffer will be seen by valgrind, even if it doesn't cause a crash. If  
     we are using the POSIX interface, we must include the terminating zero. */  
4856    
4857      bptr = dbuffer;      bptr = dbuffer;
4858    
4859  #if !defined NOPOSIX  #if !defined NOPOSIX
4860      if (posix || do_posix)      if (posix || do_posix)
4861        {        {
4862    #ifdef SUPPORT_VALGRIND
4863          VALGRIND_MAKE_MEM_NOACCESS(dbuffer + len + 1, dbuffer_size - (len + 1));
4864    #else
4865        memmove(bptr + dbuffer_size - len - 1, bptr, len + 1);        memmove(bptr + dbuffer_size - len - 1, bptr, len + 1);
4866        bptr += dbuffer_size - len - 1;        bptr += dbuffer_size - len - 1;
4867    #endif
4868        }        }
4869      else      else
4870  #endif  #endif
4871        {        {
4872    #ifdef SUPPORT_VALGRIND
4873          VALGRIND_MAKE_MEM_NOACCESS(dbuffer + len * CHAR_SIZE, (dbuffer_size - len) * CHAR_SIZE);
4874    #else
4875        bptr = memmove(bptr + (dbuffer_size - len) * CHAR_SIZE, bptr, len * CHAR_SIZE);        bptr = memmove(bptr + (dbuffer_size - len) * CHAR_SIZE, bptr, len * CHAR_SIZE);
4876    #endif
4877        }        }
4878    
4879      if ((all_use_dfa || use_dfa) && find_match_limit)      if ((all_use_dfa || use_dfa) && find_match_limit)
# Line 5306  while (!done) Line 5053  while (!done)
5053          if (count == 0)          if (count == 0)
5054            {            {
5055            fprintf(outfile, "Matched, but too many substrings\n");            fprintf(outfile, "Matched, but too many substrings\n");
5056            count = use_size_offsets/3;            /* 2 is a special case; match can be returned */
5057              count = (use_size_offsets == 2)? 1 : use_size_offsets/3;
5058            }            }
5059          }          }
5060    
# Line 5320  while (!done) Line 5068  while (!done)
5068  #if !defined NODFA  #if !defined NODFA
5069          if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2; else          if (all_use_dfa || use_dfa) maxcount = use_size_offsets/2; else
5070  #endif  #endif
5071            maxcount = use_size_offsets/3;            /* 2 is a special case; match can be returned */
5072              maxcount = (use_size_offsets == 2)? 1 : use_size_offsets/3;
5073    
5074          /* This is a check against a lunatic return value. */          /* This is a check against a lunatic return value. */
5075    
# Line 5538  while (!done) Line 5287  while (!done)
5287            }            }
5288          }          }
5289    
5290        /* There was a partial match */        /* There was a partial match. If the bumpalong point is not the same as
5291          the first inspected character, show the offset explicitly. */
5292    
5293        else if (count == PCRE_ERROR_PARTIAL)        else if (count == PCRE_ERROR_PARTIAL)
5294          {          {
5295          if (markptr == NULL) fprintf(outfile, "Partial match");          fprintf(outfile, "Partial match");
5296          else          if (use_size_offsets > 2 && use_offsets[0] != use_offsets[2])
5297              fprintf(outfile, " at offset %d", use_offsets[2]);
5298            if (markptr != NULL)
5299            {            {
5300            fprintf(outfile, "Partial match, mark=");            fprintf(outfile, ", mark=");
5301            PCHARSV(markptr, 0, -1, outfile);            PCHARSV(markptr, 0, -1, outfile);
5302            }            }
5303          if (use_size_offsets > 1)          if (use_size_offsets > 1)
# Line 5759  if (dfa_workspace != NULL) Line 5511  if (dfa_workspace != NULL)
5511    free(dfa_workspace);    free(dfa_workspace);
5512  #endif  #endif
5513    
5514    #if defined(__VMS)
5515      yield = SS$_NORMAL;  /* Return values via DCL symbols */
5516    #endif
5517    
5518  return yield;  return yield;
5519  }  }
5520    

Legend:
Removed from v.1122  
changed lines
  Added in v.1313

  ViewVC Help
Powered by ViewVC 1.1.5