/[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 1080 by chpe, Tue Oct 16 15:55:07 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
145  regex, is held in a separate file so that (a) it can be compiled in either  regex, is held in a separate file so that (a) it can be compiled in either
146  8-bit or 16-bit mode, and (b) it can be #included directly in pcre_compile.c  8-, 16- or 32-bit mode, and (b) it can be #included directly in pcre_compile.c
147  when that is compiled in debug mode. */  when that is compiled in debug mode. */
148    
149  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
# Line 211  automatically cut out the UTF support if Line 203  automatically cut out the UTF support if
203  #endif  #endif
204  #endif  #endif
205    
206  /* To make the code a bit tidier for 8-bit and 16-bit support, we define macros  /* To make the code a bit tidier for 8/16/32-bit support, we define macros
207  for all the pcre[16]_xxx functions (except pcre16_fullinfo, which is called  for all the pcre[16]_xxx functions (except pcre16_fullinfo, which is called
208  only from one place and is handled differently). I couldn't dream up any way of  only from one place and is handled differently). I couldn't dream up any way of
209  using a single macro to do this in a generic way, because of the many different  using a single macro to do this in a generic way, because of the many different
# Line 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 399  argument, the casting might be incorrect Line 393  argument, the casting might be incorrect
393  #ifdef SUPPORT_PCRE32  #ifdef SUPPORT_PCRE32
394    
395  #define PCHARS32(lv, p, offset, len, f) \  #define PCHARS32(lv, p, offset, len, f) \
396    lv = pchars32((PCRE_SPTR32)(p) + offset, len, f)    lv = pchars32((PCRE_SPTR32)(p) + offset, len, use_utf, f)
397    
398  #define PCHARSV32(p, offset, len, f) \  #define PCHARSV32(p, offset, len, f)                \
399    (void)pchars32((PCRE_SPTR32)(p) + offset, len, f)    (void)pchars32((PCRE_SPTR32)(p) + offset, len, use_utf, f)
400    
401  #define READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re) \  #define READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re) \
402    p = read_capture_name32(p, cn32, re)    p = read_capture_name32(p, cn32, re)
# Line 484  argument, the casting might be incorrect Line 478  argument, the casting might be incorrect
478  #endif /* SUPPORT_PCRE32 */  #endif /* SUPPORT_PCRE32 */
479    
480    
481  /* ----- Both modes are 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 494  enum { Line 488  enum {
488    PCRE32_MODE    PCRE32_MODE
489  };  };
490    
491  #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + defined (SUPPORT_PCRE32)) >= 2  #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + \
492         defined (SUPPORT_PCRE32)) >= 2
493    
494  #define CHAR_SIZE (1 << pcre_mode)  #define CHAR_SIZE (1 << pcre_mode)
495    
496    /* There doesn't seem to be an easy way of writing these macros that can cope
497    with the 3 pairs of bit sizes plus all three bit sizes. So just handle all the
498    cases separately. */
499    
500    /* ----- All three modes supported ----- */
501    
502    #if defined(SUPPORT_PCRE8) && defined(SUPPORT_PCRE16) && defined(SUPPORT_PCRE32)
503    
504  #define PCHARS(lv, p, offset, len, f) \  #define PCHARS(lv, p, offset, len, f) \
505    if (pcre_mode == PCRE32_MODE) \    if (pcre_mode == PCRE32_MODE) \
506      PCHARS32(lv, p, offset, len, f); \      PCHARS32(lv, p, offset, len, f); \
# Line 696  enum { Line 699  enum {
699    else \    else \
700      PCRE_STUDY8(extra, re, options, error)      PCRE_STUDY8(extra, re, options, error)
701    
702    
703    /* ----- Two out of three modes are supported ----- */
704    
705    #else
706    
707    /* We can use some macro trickery to make a single set of definitions work in
708    the three different cases. */
709    
710    /* ----- 32-bit and 16-bit but not 8-bit supported ----- */
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 ----- */
717    
718    #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE8)
719    #define BITONE 32
720    #define BITTWO 8
721    
722    /* ----- 16-bit and 8-bit but not 32-bit supported ----- */
723    
724    #else
725    #define BITONE 16
726    #define BITTWO 8
727    #endif
728    
729    #define glue(a,b) a##b
730    #define G(a,b) glue(a,b)
731    
732    
733    /* ----- Common macros for two-mode cases ----- */
734    
735    #define PCHARS(lv, p, offset, len, f) \
736      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
737        G(PCHARS,BITONE)(lv, p, offset, len, f); \
738      else \
739        G(PCHARS,BITTWO)(lv, p, offset, len, f)
740    
741    #define PCHARSV(p, offset, len, f) \
742      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
743        G(PCHARSV,BITONE)(p, offset, len, f); \
744      else \
745        G(PCHARSV,BITTWO)(p, offset, len, f)
746    
747    #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
748      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
749        G(READ_CAPTURE_NAME,BITONE)(p, cn8, cn16, cn32, re); \
750      else \
751        G(READ_CAPTURE_NAME,BITTWO)(p, cn8, cn16, cn32, re)
752    
753    #define SET_PCRE_CALLOUT(callout) \
754      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
755        G(SET_PCRE_CALLOUT,BITONE)(callout); \
756      else \
757        G(SET_PCRE_CALLOUT,BITTWO)(callout)
758    
759    #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) \
763      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
764        G(PCRE_ASSIGN_JIT_STACK,BITONE)(extra, callback, userdata); \
765      else \
766        G(PCRE_ASSIGN_JIT_STACK,BITTWO)(extra, callback, userdata)
767    
768    #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
769      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
770        G(PCRE_COMPILE,BITONE)(re, pat, options, error, erroffset, tables); \
771      else \
772        G(PCRE_COMPILE,BITTWO)(re, pat, options, error, erroffset, tables)
773    
774    #define PCRE_CONFIG G(G(pcre,BITONE),_config)
775    
776    #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
777        namesptr, cbuffer, size) \
778      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
779        G(PCRE_COPY_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \
780          namesptr, cbuffer, size); \
781      else \
782        G(PCRE_COPY_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \
783          namesptr, cbuffer, size)
784    
785    #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
786      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
787        G(PCRE_COPY_SUBSTRING,BITONE)(rc, bptr, offsets, count, i, cbuffer, size); \
788      else \
789        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, \
792        offsets, size_offsets, workspace, size_workspace) \
793      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
794        G(PCRE_DFA_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \
795          offsets, size_offsets, workspace, size_workspace); \
796      else \
797        G(PCRE_DFA_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \
798          offsets, size_offsets, workspace, size_workspace)
799    
800    #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
801        offsets, size_offsets) \
802      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
803        G(PCRE_EXEC,BITONE)(count, re, extra, bptr, len, start_offset, options, \
804          offsets, size_offsets); \
805      else \
806        G(PCRE_EXEC,BITTWO)(count, re, extra, bptr, len, start_offset, options, \
807          offsets, size_offsets)
808    
809    #define PCRE_FREE_STUDY(extra) \
810      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
811        G(PCRE_FREE_STUDY,BITONE)(extra); \
812      else \
813        G(PCRE_FREE_STUDY,BITTWO)(extra)
814    
815    #define PCRE_FREE_SUBSTRING(substring) \
816      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
817        G(PCRE_FREE_SUBSTRING,BITONE)(substring); \
818      else \
819        G(PCRE_FREE_SUBSTRING,BITTWO)(substring)
820    
821    #define PCRE_FREE_SUBSTRING_LIST(listptr) \
822      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
823        G(PCRE_FREE_SUBSTRING_LIST,BITONE)(listptr); \
824      else \
825        G(PCRE_FREE_SUBSTRING_LIST,BITTWO)(listptr)
826    
827    #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
828        getnamesptr, subsptr) \
829      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
830        G(PCRE_GET_NAMED_SUBSTRING,BITONE)(rc, re, bptr, offsets, count, \
831          getnamesptr, subsptr); \
832      else \
833        G(PCRE_GET_NAMED_SUBSTRING,BITTWO)(rc, re, bptr, offsets, count, \
834          getnamesptr, subsptr)
835    
836    #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
837      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
838        G(PCRE_GET_STRINGNUMBER,BITONE)(n, rc, ptr); \
839      else \
840        G(PCRE_GET_STRINGNUMBER,BITTWO)(n, rc, ptr)
841    
842    #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
843      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
844        G(PCRE_GET_SUBSTRING,BITONE)(rc, bptr, use_offsets, count, i, subsptr); \
845      else \
846        G(PCRE_GET_SUBSTRING,BITTWO)(rc, bptr, use_offsets, count, i, subsptr)
847    
848    #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
849      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
850        G(PCRE_GET_SUBSTRING_LIST,BITONE)(rc, bptr, offsets, count, listptr); \
851      else \
852        G(PCRE_GET_SUBSTRING_LIST,BITTWO)(rc, bptr, offsets, count, listptr)
853    
854    #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
855      (pcre_mode == G(G(PCRE,BITONE),_MODE)) ? \
856         G(PCRE_JIT_STACK_ALLOC,BITONE)(startsize, maxsize) \
857        : G(PCRE_JIT_STACK_ALLOC,BITTWO)(startsize, maxsize)
858    
859    #define PCRE_JIT_STACK_FREE(stack) \
860      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
861        G(PCRE_JIT_STACK_FREE,BITONE)(stack); \
862      else \
863        G(PCRE_JIT_STACK_FREE,BITTWO)(stack)
864    
865    #define PCRE_MAKETABLES \
866      (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) \
870      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
871        G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITONE)(rc, re, extra, tables); \
872      else \
873        G(PCRE_PATTERN_TO_HOST_BYTE_ORDER,BITTWO)(rc, re, extra, tables)
874    
875    #define PCRE_PRINTINT(re, outfile, debug_lengths) \
876      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
877        G(PCRE_PRINTINT,BITONE)(re, outfile, debug_lengths); \
878      else \
879        G(PCRE_PRINTINT,BITTWO)(re, outfile, debug_lengths)
880    
881    #define PCRE_STUDY(extra, re, options, error) \
882      if (pcre_mode == G(G(PCRE,BITONE),_MODE)) \
883        G(PCRE_STUDY,BITONE)(extra, re, options, error); \
884      else \
885        G(PCRE_STUDY,BITTWO)(extra, re, options, error)
886    
887    #endif  /* Two out of three modes */
888    
889    /* ----- End of cases where more than one mode is supported ----- */
890    
891    
892  /* ----- Only 8-bit mode is supported ----- */  /* ----- Only 8-bit mode is supported ----- */
893    
894  #elif defined SUPPORT_PCRE8  #elif defined SUPPORT_PCRE8
# Line 831  static const unsigned char *last_callout Line 1024  static const unsigned char *last_callout
1024    
1025  static int buffer_size = 50000;  static int buffer_size = 50000;
1026  static pcre_uint8 *buffer = NULL;  static pcre_uint8 *buffer = NULL;
 static pcre_uint8 *dbuffer = NULL;  
1027  static pcre_uint8 *pbuffer = NULL;  static pcre_uint8 *pbuffer = NULL;
1028    
1029  /* Another buffer is needed translation to 16-bit character strings. It will  /* Just as a safety check, make sure that COMPILE_PCRE[16|32] are *not* set. */
 obtained and extended as required. */  
   
 #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 853  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 863  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 942  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 1299  return sys_errlist[n]; Line 1494  return sys_errlist[n];
1494  *       Print newline configuration              *  *       Print newline configuration              *
1495  *************************************************/  *************************************************/
1496    
1497  /*  /*
1498  Arguments:  Arguments:
1499    rc         the return code from PCRE_CONFIG_NEWLINE    rc         the return code from PCRE_CONFIG_NEWLINE
1500    isc        TRUE if called from "-C newline"    isc        TRUE if called from "-C newline"
1501  Returns:     nothing  Returns:     nothing
1502  */  */
1503    
# Line 1318  switch(rc) Line 1513  switch(rc)
1513    case (CHAR_CR<<8 | CHAR_LF): s = "CRLF"; break;    case (CHAR_CR<<8 | CHAR_LF): s = "CRLF"; break;
1514    case -1: s = "ANY"; break;    case -1: s = "ANY"; break;
1515    case -2: s = "ANYCRLF"; break;    case -2: s = "ANYCRLF"; break;
1516    
1517    default:    default:
1518    printf("a non-standard value: 0x%04x\n", rc);    printf("a non-standard value: 0x%04x\n", rc);
1519    return;    return;
1520    }    }
1521    
1522  printf("%s\n", s);  printf("%s\n", s);
1523  }  }
# Line 1357  Returns:      >  0 => the number of byte Line 1552  Returns:      >  0 => the number of byte
1552  */  */
1553    
1554  static int  static int
1555  utf82ord(pcre_uint8 *utf8bytes, int *vptr)  utf82ord(pcre_uint8 *utf8bytes, pcre_uint32 *vptr)
1556  {  {
1557  int c = *utf8bytes++;  pcre_uint32 c = *utf8bytes++;
1558  int d = c;  pcre_uint32 d = c;
1559  int i, j, s;  int i, j, s;
1560    
1561  for (i = -1; i < 6; i++)               /* i is number of additional bytes */  for (i = -1; i < 6; i++)               /* i is number of additional bytes */
# Line 1388  for (j = 0; j < i; j++) Line 1583  for (j = 0; j < i; j++)
1583  /* Check that encoding was the correct unique one */  /* Check that encoding was the correct unique one */
1584    
1585  for (j = 0; j < utf8_table1_size; j++)  for (j = 0; j < utf8_table1_size; j++)
1586    if (d <= utf8_table1[j]) break;    if (d <= (pcre_uint32)utf8_table1[j]) break;
1587  if (j != i) return -(i+1);  if (j != i) return -(i+1);
1588    
1589  /* Valid value */  /* Valid value */
# Line 1400  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 1416  Returns:     number of characters placed Line 1611  Returns:     number of characters placed
1611  */  */
1612    
1613  static int  static int
1614  ord2utf8(int cvalue, pcre_uint8 *utf8bytes)  ord2utf8(pcre_uint32 cvalue, pcre_uint8 *utf8bytes)
1615  {  {
1616  register int i, j;  register int i, j;
1617    if (cvalue > 0x7fffffffu)
1618      return -1;
1619  for (i = 0; i < utf8_table1_size; i++)  for (i = 0; i < utf8_table1_size; i++)
1620    if (cvalue <= utf8_table1[i]) break;    if (cvalue <= (pcre_uint32)utf8_table1[i]) break;
1621  utf8bytes += i;  utf8bytes += i;
1622  for (j = i; j > 0; j--)  for (j = i; j > 0; j--)
1623   {   {
# Line 1489  if (!utf && !data) Line 1686  if (!utf && !data)
1686    
1687  else  else
1688    {    {
1689    int c = 0;    pcre_uint32 c = 0;
1690    while (len > 0)    while (len > 0)
1691      {      {
1692      int chlen = utf82ord(p, &c);      int chlen = utf82ord(p, &c);
# Line 1568  if (!utf && !data) Line 1765  if (!utf && !data)
1765    
1766  else  else
1767    {    {
1768    int c = 0;    pcre_uint32 c = 0;
1769    while (len > 0)    while (len > 0)
1770      {      {
1771      int chlen = utf82ord(p, &c);      int chlen = utf82ord(p, &c);
# Line 1588  else Line 1785  else
1785  *pp = 0;  *pp = 0;
1786  return pp - buffer32;  return pp - buffer32;
1787  }  }
1788  #endif  
1789    /* Check that a 32-bit character string is valid UTF-32.
1790    
1791    Arguments:
1792      string       points to the string
1793      length       length of string, or -1 if the string is zero-terminated
1794    
1795    Returns:       TRUE  if the string is a valid UTF-32 string
1796                   FALSE otherwise
1797    */
1798    
1799    #ifdef NEVER   /* Not used */
1800    #ifdef SUPPORT_UTF
1801    static BOOL
1802    valid_utf32(pcre_uint32 *string, int length)
1803    {
1804    register pcre_uint32 *p;
1805    register pcre_uint32 c;
1806    
1807    for (p = string; length-- > 0; p++)
1808      {
1809      c = *p;
1810      if (c > 0x10ffffu) return FALSE;                 /* Too big */
1811      if ((c & 0xfffff800u) == 0xd800u) return FALSE;  /* Surrogate */
1812      }
1813    
1814    return TRUE;
1815    }
1816    #endif /* SUPPORT_UTF */
1817    #endif /* NEVER */
1818    #endif /* SUPPORT_PCRE32 */
1819    
1820    
1821  /*************************************************  /*************************************************
1822  *        Read or extend an input line            *  *        Read or extend an input line            *
# Line 1664  for (;;) Line 1892  for (;;)
1892      {      {
1893      int new_buffer_size = 2*buffer_size;      int new_buffer_size = 2*buffer_size;
1894      pcre_uint8 *new_buffer = (pcre_uint8 *)malloc(new_buffer_size);      pcre_uint8 *new_buffer = (pcre_uint8 *)malloc(new_buffer_size);
     pcre_uint8 *new_dbuffer = (pcre_uint8 *)malloc(new_buffer_size);  
1895      pcre_uint8 *new_pbuffer = (pcre_uint8 *)malloc(new_buffer_size);      pcre_uint8 *new_pbuffer = (pcre_uint8 *)malloc(new_buffer_size);
1896    
1897      if (new_buffer == NULL || new_dbuffer == NULL || new_pbuffer == NULL)      if (new_buffer == NULL || new_pbuffer == NULL)
1898        {        {
1899        fprintf(stderr, "pcretest: malloc(%d) failed\n", new_buffer_size);        fprintf(stderr, "pcretest: malloc(%d) failed\n", new_buffer_size);
1900        exit(1);        exit(1);
# Line 1682  for (;;) Line 1909  for (;;)
1909      here = new_buffer + (here - buffer);      here = new_buffer + (here - buffer);
1910    
1911      free(buffer);      free(buffer);
     free(dbuffer);  
1912      free(pbuffer);      free(pbuffer);
1913    
1914      buffer = new_buffer;      buffer = new_buffer;
     dbuffer = new_dbuffer;  
1915      pbuffer = new_pbuffer;      pbuffer = new_pbuffer;
1916      }      }
1917    }    }
# Line 1731  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 = 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 1751  if (c < 0x100) Line 1977  if (c < 0x100)
1977      }      }
1978    }    }
1979    
1980  if (f != NULL) fprintf(f, "\\x{%02x}", c);  if (f != NULL) n = fprintf(f, "\\x{%02x}", c);
1981  return (c <= 0x000000ff)? 6 :  return n >= 0 ? n : 0;
        (c <= 0x00000fff)? 7 :  
        (c <= 0x0000ffff)? 8 :  
        (c <= 0x000fffff)? 9 : 10;  
1982  }  }
1983    
1984    
# Line 1770  If handed a NULL file, just counts chars Line 1993  If handed a NULL file, just counts chars
1993    
1994  static int pchars(pcre_uint8 *p, int length, FILE *f)  static int pchars(pcre_uint8 *p, int length, FILE *f)
1995  {  {
1996  int c = 0;  pcre_uint32 c = 0;
1997  int yield = 0;  int yield = 0;
1998    
1999  if (length < 0)  if (length < 0)
# Line 1853  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 1878  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    
2104  static int pchars32(PCRE_SPTR32 p, int length, 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    
# Line 2170  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 2246  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 2417  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 2443  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 2719  int all_use_dfa = 0; Line 2949  int all_use_dfa = 0;
2949  int verify_jit = 0;  int verify_jit = 0;
2950  int yield = 0;  int yield = 0;
2951  int stack_size;  int stack_size;
2952    pcre_uint8 *dbuffer = NULL;
2953    size_t dbuffer_size = 1u << 14;
2954    
2955  #if !defined NOPOSIX  #if !defined NOPOSIX
2956  int posix = 0;  int posix = 0;
# Line 2758  pcre_uint8 *gn8ptr; Line 2990  pcre_uint8 *gn8ptr;
2990  #endif  #endif
2991    
2992  /* Get buffers from malloc() so that valgrind will check their misuse when  /* Get buffers from malloc() so that valgrind will check their misuse when
2993  debugging. They grow automatically when very long lines are read. The 16-  debugging. They grow automatically when very long lines are read. The 16-
2994  and 32-bit buffers (buffer16, buffer32) are obtained only if needed. */  and 32-bit buffers (buffer16, buffer32) are obtained only if needed. */
2995    
2996  buffer = (pcre_uint8 *)malloc(buffer_size);  buffer = (pcre_uint8 *)malloc(buffer_size);
 dbuffer = (pcre_uint8 *)malloc(buffer_size);  
2997  pbuffer = (pcre_uint8 *)malloc(buffer_size);  pbuffer = (pcre_uint8 *)malloc(buffer_size);
2998    
2999  /* The outfile variable is static so that new_malloc can use it. */  /* The outfile variable is static so that new_malloc can use it. */
# Line 2810  while (argc > 1 && argv[op][0] == '-') Line 3041  while (argc > 1 && argv[op][0] == '-')
3041        force_study_options = jit_study_bits[*arg - '1'];        force_study_options = jit_study_bits[*arg - '1'];
3042      else goto BAD_ARG;      else goto BAD_ARG;
3043      }      }
3044      else if (strcmp(arg, "-8") == 0)
3045        {
3046    #ifdef SUPPORT_PCRE8
3047        pcre_mode = PCRE8_MODE;
3048    #else
3049        printf("** This version of PCRE was built without 8-bit support\n");
3050        exit(1);
3051    #endif
3052        }
3053    else if (strcmp(arg, "-16") == 0)    else if (strcmp(arg, "-16") == 0)
3054      {      {
3055  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
# Line 2861  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 2894  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 2904  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 2914  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 2924  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 2942  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 2959  while (argc > 1 && argv[op][0] == '-') Line 3213  while (argc > 1 && argv[op][0] == '-')
3213        else if (strcmp(argv[op + 1], "newline") == 0)        else if (strcmp(argv[op + 1], "newline") == 0)
3214          {          {
3215          (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);          (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
3216          print_newline_config(rc, TRUE);          print_newline_config(rc, TRUE);
3217          }          }
3218        else if (strcmp(argv[op + 1], "ebcdic") == 0)        else if (strcmp(argv[op + 1], "ebcdic") == 0)
3219          {          {
3220  #ifdef EBCDIC  #ifdef EBCDIC
3221          printf("1\n");          printf("1\n");
3222          yield = 1;          yield = 1;
3223  #else  #else
3224          printf("0\n");          printf("0\n");
3225  #endif  #endif
3226          }          }
3227        else if (strcmp(argv[op + 1], "ebcdic-nl") == 0)        else if (strcmp(argv[op + 1], "ebcdic-nl") == 0)
3228          {          {
3229  #ifdef EBCDIC  #ifdef EBCDIC
3230          printf("0x%02x\n", CHAR_LF);          printf("0x%02x\n", CHAR_LF);
3231  #else  #else
3232          printf("0\n");          printf("0\n");
3233  #endif  #endif
3234          }          }
3235        else        else
3236          {          {
3237          printf("Unknown -C option: %s\n", argv[op + 1]);          printf("Unknown -C option: %s\n", argv[op + 1]);
3238          }          }
3239        goto EXIT;        goto EXIT;
3240        }        }
3241    
3242      /* No argument for -C: output all configuration information. */      /* No argument for -C: output all configuration information. */
3243    
3244      printf("PCRE version %s\n", version);      printf("PCRE version %s\n", version);
3245      printf("Compiled with\n");      printf("Compiled with\n");
3246    
3247  #ifdef EBCDIC  #ifdef EBCDIC
3248      printf("  EBCDIC code support: LF is 0x%02x\n", CHAR_LF);      printf("  EBCDIC code support: LF is 0x%02x\n", CHAR_LF);
3249  #endif  #endif
3250    
3251  /* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both  /* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both
3252  are set, either both UTFs are supported or both are not supported. */  are set, either both UTFs are supported or both are not supported. */
# Line 3025  are set, either both UTFs are supported Line 3279  are set, either both UTFs are supported
3279      else      else
3280        printf("  No just-in-time compiler support\n");        printf("  No just-in-time compiler support\n");
3281      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
3282      print_newline_config(rc, FALSE);      print_newline_config(rc, FALSE);
3283      (void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc);
3284      printf("  \\R matches %s\n", rc? "CR, LF, or CRLF only" :      printf("  \\R matches %s\n", rc? "CR, LF, or CRLF only" :
3285                                       "all Unicode newlines");                                       "all Unicode newlines");
# Line 3279  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 3439  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 3672  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 3758  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 3766  while (!done) Line 4027  while (!done)
4027        if (new_info(re, NULL, PCRE_INFO_SIZE, &size) +        if (new_info(re, NULL, PCRE_INFO_SIZE, &size) +
4028            new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count) +            new_info(re, NULL, PCRE_INFO_CAPTURECOUNT, &count) +
4029            new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax) +            new_info(re, NULL, PCRE_INFO_BACKREFMAX, &backrefmax) +
4030            new_info(re, NULL, PCRE_INFO_FIRSTLITERAL, &first_char) +            new_info(re, NULL, PCRE_INFO_FIRSTCHARACTER, &first_char) +
4031            new_info(re, NULL, PCRE_INFO_FIRSTLITERALSET, &first_char_set) +            new_info(re, NULL, PCRE_INFO_FIRSTCHARACTERFLAGS, &first_char_set) +
4032            new_info(re, NULL, PCRE_INFO_LASTLITERAL2, &need_char) +            new_info(re, NULL, PCRE_INFO_REQUIREDCHAR, &need_char) +
4033            new_info(re, NULL, PCRE_INFO_LASTLITERAL2SET, &need_char_set) +            new_info(re, NULL, PCRE_INFO_REQUIREDCHARFLAGS, &need_char_set) +
4034            new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize) +            new_info(re, NULL, PCRE_INFO_NAMEENTRYSIZE, &nameentrysize) +
4035            new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount) +            new_info(re, NULL, PCRE_INFO_NAMECOUNT, &namecount) +
4036            new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable) +            new_info(re, NULL, PCRE_INFO_NAMETABLE, (void *)&nametable) +
# Line 3785  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 3821  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 3838  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 3912  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 4060  while (!done) Line 4329  while (!done)
4329    
4330    for (;;)    for (;;)
4331      {      {
4332      pcre_uint8 *q;  #ifdef SUPPORT_PCRE8
4333        pcre_uint8 *q8;
4334    #endif
4335    #ifdef SUPPORT_PCRE16
4336        pcre_uint16 *q16;
4337    #endif
4338    #ifdef SUPPORT_PCRE32
4339        pcre_uint32 *q32;
4340    #endif
4341      pcre_uint8 *bptr;      pcre_uint8 *bptr;
4342      int *use_offsets = offsets;      int *use_offsets = offsets;
4343      int use_size_offsets = size_offsets;      int use_size_offsets = size_offsets;
4344      int callout_data = 0;      int callout_data = 0;
4345      int callout_data_set = 0;      int callout_data_set = 0;
4346      int count, c;      int count;
4347        pcre_uint32 c;
4348      int copystrings = 0;      int copystrings = 0;
4349      int find_match_limit = default_find_match_limit;      int find_match_limit = default_find_match_limit;
4350      int getstrings = 0;      int getstrings = 0;
# Line 4131  while (!done) Line 4409  while (!done)
4409      p = buffer;      p = buffer;
4410      while (isspace(*p)) p++;      while (isspace(*p)) p++;
4411    
4412      bptr = q = dbuffer;  #ifndef NOUTF
4413        /* Check that the data is well-formed UTF-8 if we're in UTF mode. To create
4414           invalid input to pcre_exec, you must use \x?? or \x{} sequences. */
4415        if (use_utf)
4416          {
4417          pcre_uint8 *q;
4418          pcre_uint32 cc;
4419          int n = 1;
4420    
4421          for (q = p; n > 0 && *q; q += n) n = utf82ord(q, &cc);
4422          if (n <= 0)
4423            {
4424            fprintf(outfile, "**Failed: invalid UTF-8 string cannot be used as input in UTF mode\n");
4425            goto NEXT_DATA;
4426            }
4427          }
4428    #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
4439           the number of pcre_uchar units that will be needed. */
4440        if (dbuffer == NULL || (size_t)len >= dbuffer_size)
4441          {
4442          dbuffer_size *= 2;
4443          dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);
4444          if (dbuffer == NULL)
4445            {
4446            fprintf(stderr, "pcretest: malloc(%d) failed\n", (int)dbuffer_size);
4447            exit(1);
4448            }
4449          }
4450    
4451    #ifdef SUPPORT_PCRE8
4452        q8 = (pcre_uint8 *) dbuffer;
4453    #endif
4454    #ifdef SUPPORT_PCRE16
4455        q16 = (pcre_uint16 *) dbuffer;
4456    #endif
4457    #ifdef SUPPORT_PCRE32
4458        q32 = (pcre_uint32 *) dbuffer;
4459    #endif
4460    
4461      while ((c = *p++) != 0)      while ((c = *p++) != 0)
4462        {        {
4463        int i = 0;        int i = 0;
# Line 4140  while (!done) Line 4466  while (!done)
4466        /* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes.        /* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes.
4467        In non-UTF mode, allow the value of the byte to fall through to later,        In non-UTF mode, allow the value of the byte to fall through to later,
4468        where values greater than 127 are turned into UTF-8 when running in        where values greater than 127 are turned into UTF-8 when running in
4469        16-bit mode. */        16-bit or 32-bit mode. */
4470    
4471        if (c != '\\')        if (c != '\\')
4472          {          {
4473          if (use_utf)  #ifndef NOUTF
4474            {          if (use_utf && HASUTF8EXTRALEN(c)) { GETUTF8INC(c, p); }
4475            *q++ = c;  #endif
           continue;  
           }  
4476          }          }
4477    
4478        /* Handle backslash escapes */        /* Handle backslash escapes */
# Line 4209  while (!done) Line 4533  while (!done)
4533            c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'a' - 10);            c = c * 16 + tolower(*p) - ((isdigit(*p))? '0' : 'a' - 10);
4534            p++;            p++;
4535            }            }
4536          if (use_utf)  #if !defined NOUTF && defined SUPPORT_PCRE8
4537            if (use_utf && (pcre_mode == PCRE8_MODE))
4538            {            {
4539            *q++ = c;            *q8++ = c;
4540            continue;            continue;
4541            }            }
4542    #endif
4543          break;          break;
4544    
4545          case 0:   /* \ followed by EOF allows for an empty line */          case 0:   /* \ followed by EOF allows for an empty line */
# Line 4419  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 mode, we always convert characters to UTF-8 so that values greater        In 8-bit mode we convert to UTF-8 if we are in UTF mode. Values greater
4750        than 255 can be passed to non-UTF 16-bit strings. In 8-bit mode we        than 127 in UTF mode must have come from \x{...} or octal constructs
4751        convert to UTF-8 if we are in UTF mode. Values greater than 127 in UTF        because values from \x.. get this far only in non-UTF mode. */
       mode must have come from \x{...} or octal constructs because values from  
       \x.. get this far only in non-UTF mode. */  
4752    
4753  #if !defined NOUTF || defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32  #ifdef SUPPORT_PCRE8
4754        if (pcre_mode != PCRE8_MODE || use_utf)        if (pcre_mode == PCRE8_MODE)
4755          {          {
4756          pcre_uint8 buff8[8];  #ifndef NOUTF
4757          int ii, utn;          if (use_utf)
4758          utn = ord2utf8(c, buff8);            {
4759          for (ii = 0; ii < utn; ii++) *q++ = buff8[ii];            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);
4766              }
4767            else
4768    #endif
4769              {
4770              if (c > 0xffu)
4771                {
4772                fprintf(outfile, "** Character \\x{%x} is greater than 255 "
4773                  "and UTF-8 mode is not enabled.\n", c);
4774                fprintf(outfile, "** Truncation will probably give the wrong "
4775                  "result.\n");
4776                }
4777              *q8++ = c;
4778              }
4779          }          }
       else  
4780  #endif  #endif
4781    #ifdef SUPPORT_PCRE16
4782          if (pcre_mode == PCRE16_MODE)
4783          {          {
4784          if (c > 255)  #ifndef NOUTF
4785            if (use_utf)
4786            {            {
4787            fprintf(outfile, "** Character \\x{%x} is greater than 255 "            if (c > 0x10ffffu)
4788              "and UTF-8 mode is not enabled.\n", c);              {
4789            fprintf(outfile, "** Truncation will probably give the wrong "              fprintf(outfile, "** Failed: character \\x{%x} is greater than "
4790              "result.\n");                "0x10ffff and so cannot be converted to UTF-16\n", c);
4791                goto NEXT_DATA;
4792                }
4793              else if (c >= 0x10000u)
4794                {
4795                c-= 0x10000u;
4796                *q16++ = 0xD800 | (c >> 10);
4797                *q16++ = 0xDC00 | (c & 0x3ff);
4798                }
4799              else
4800                *q16++ = c;
4801              }
4802            else
4803    #endif
4804              {
4805              if (c > 0xffffu)
4806                {
4807                fprintf(outfile, "** Character \\x{%x} is greater than 0xffff "
4808                  "and UTF-16 mode is not enabled.\n", c);
4809                fprintf(outfile, "** Truncation will probably give the wrong "
4810                  "result.\n");
4811                }
4812    
4813              *q16++ = c;
4814            }            }
         *q++ = c;  
4815          }          }
4816    #endif
4817    #ifdef SUPPORT_PCRE32
4818          if (pcre_mode == PCRE32_MODE)
4819            {
4820            *q32++ = c;
4821            }
4822    #endif
4823    
4824        }        }
4825    
4826      /* Reached end of subject string */      /* Reached end of subject string */
4827    
4828      *q = 0;  #ifdef SUPPORT_PCRE8
4829      len = (int)(q - dbuffer);      if (pcre_mode == PCRE8_MODE)
4830        {
4831          *q8 = 0;
4832          len = (int)(q8 - (pcre_uint8 *)dbuffer);
4833        }
4834    #endif
4835    #ifdef SUPPORT_PCRE16
4836        if (pcre_mode == PCRE16_MODE)
4837        {
4838          *q16 = 0;
4839          len = (int)(q16 - (pcre_uint16 *)dbuffer);
4840        }
4841    #endif
4842    #ifdef SUPPORT_PCRE32
4843        if (pcre_mode == PCRE32_MODE)
4844        {
4845          *q32 = 0;
4846          len = (int)(q32 - (pcre_uint32 *)dbuffer);
4847        }
4848    #endif
4849    
4850      /* Move the data to the end of the buffer so that a read over the end of      /* If we're compiling with explicit valgrind support, Mark the data from after
4851      the buffer will be seen by valgrind, even if it doesn't cause a crash. If      its end to the end of the buffer as unaddressable, so that a read over the end
4852      we are using the POSIX interface, we must include the terminating zero. */      of the buffer will be seen by valgrind, even if it doesn't cause a crash.
4853        If we're not building with valgrind support, at least move the data to the end
4854        of the buffer so that it might at least cause a crash.
4855        If we are using the POSIX interface, we must include the terminating zero. */
4856    
4857        bptr = dbuffer;
4858    
4859  #if !defined NOPOSIX  #if !defined NOPOSIX
4860      if (posix || do_posix)      if (posix || do_posix)
4861        {        {
4862        memmove(bptr + buffer_size - len - 1, bptr, len + 1);  #ifdef SUPPORT_VALGRIND
4863        bptr += buffer_size - len - 1;        VALGRIND_MAKE_MEM_NOACCESS(dbuffer + len + 1, dbuffer_size - (len + 1));
4864    #else
4865          memmove(bptr + dbuffer_size - len - 1, bptr, len + 1);
4866          bptr += dbuffer_size - len - 1;
4867    #endif
4868        }        }
4869      else      else
4870  #endif  #endif
4871        {        {
4872        memmove(bptr + buffer_size - len, bptr, len);  #ifdef SUPPORT_VALGRIND
4873        bptr += buffer_size - len;        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);
4876    #endif
4877        }        }
4878    
4879      if ((all_use_dfa || use_dfa) && find_match_limit)      if ((all_use_dfa || use_dfa) && find_match_limit)
# Line 4531  while (!done) Line 4937  while (!done)
4937    
4938      /* Handle matching via the native interface - repeats for /g and /G */      /* Handle matching via the native interface - repeats for /g and /G */
4939    
 #ifdef SUPPORT_PCRE16  
     if (pcre_mode == PCRE16_MODE)  
       {  
       len = to16(TRUE, bptr, REAL_PCRE_OPTIONS(re) & PCRE_UTF8, len);  
       switch(len)  
         {  
         case -1:  
         fprintf(outfile, "**Failed: invalid UTF-8 string cannot be "  
           "converted to UTF-16\n");  
         goto NEXT_DATA;  
   
         case -2:  
         fprintf(outfile, "**Failed: character value greater than 0x10ffff "  
           "cannot be converted to UTF-16\n");  
         goto NEXT_DATA;  
   
         case -3:  
         fprintf(outfile, "**Failed: character value greater than 0xffff "  
           "cannot be converted to 16-bit in non-UTF mode\n");  
         goto NEXT_DATA;  
   
         default:  
         break;  
         }  
       bptr = (pcre_uint8 *)buffer16;  
       }  
 #endif  
   
 #ifdef SUPPORT_PCRE32  
     if (pcre_mode == PCRE32_MODE)  
       {  
       len = to32(TRUE, bptr, REAL_PCRE_OPTIONS(re) & PCRE_UTF32, len);  
       switch(len)  
         {  
         case -1:  
         fprintf(outfile, "**Failed: invalid UTF-8 string cannot be "  
           "converted to UTF-32\n");  
         goto NEXT_DATA;  
   
         case -2:  
         fprintf(outfile, "**Failed: character value greater than 0x10ffff "  
           "cannot be converted to UTF-32\n");  
         goto NEXT_DATA;  
   
         case -3:  
         fprintf(outfile, "**Failed: character value is ill-formed UTF-32\n");  
         goto NEXT_DATA;  
   
         default:  
         break;  
         }  
       bptr = (pcre_uint8 *)buffer32;  
       }  
 #endif  
   
4940      /* Ensure that there is a JIT callback if we want to verify that JIT was      /* Ensure that there is a JIT callback if we want to verify that JIT was
4941      actually used. If jit_stack == NULL, no stack has yet been assigned. */      actually used. If jit_stack == NULL, no stack has yet been assigned. */
4942    
# Line 4702  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 4716  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 4807  while (!done) Line 5160  while (!done)
5160            int rc;            int rc;
5161            char copybuffer[256];            char copybuffer[256];
5162    
5163    #ifdef SUPPORT_PCRE32
5164              if (pcre_mode == PCRE32_MODE)
5165                {
5166                if (*(pcre_uint32 *)cnptr == 0) break;
5167                }
5168    #endif
5169    #ifdef SUPPORT_PCRE16
5170            if (pcre_mode == PCRE16_MODE)            if (pcre_mode == PCRE16_MODE)
5171              {              {
5172              if (*(pcre_uint16 *)cnptr == 0) break;              if (*(pcre_uint16 *)cnptr == 0) break;
5173              }              }
5174            else  #endif
5175    #ifdef SUPPORT_PCRE8
5176              if (pcre_mode == PCRE8_MODE)
5177              {              {
5178              if (*(pcre_uint8 *)cnptr == 0) break;              if (*(pcre_uint8 *)cnptr == 0) break;
5179              }              }
5180    #endif
5181    
5182            PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count,            PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count,
5183              cnptr, copybuffer, sizeof(copybuffer));              cnptr, copybuffer, sizeof(copybuffer));
# Line 4862  while (!done) Line 5225  while (!done)
5225            int rc;            int rc;
5226            const char *substring;            const char *substring;
5227    
5228    #ifdef SUPPORT_PCRE32
5229              if (pcre_mode == PCRE32_MODE)
5230                {
5231                if (*(pcre_uint32 *)gnptr == 0) break;
5232                }
5233    #endif
5234    #ifdef SUPPORT_PCRE16
5235            if (pcre_mode == PCRE16_MODE)            if (pcre_mode == PCRE16_MODE)
5236              {              {
5237              if (*(pcre_uint16 *)gnptr == 0) break;              if (*(pcre_uint16 *)gnptr == 0) break;
5238              }              }
5239            else  #endif
5240    #ifdef SUPPORT_PCRE8
5241              if (pcre_mode == PCRE8_MODE)
5242              {              {
5243              if (*(pcre_uint8 *)gnptr == 0) break;              if (*(pcre_uint8 *)gnptr == 0) break;
5244              }              }
5245    #endif
5246    
5247            PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count,            PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, use_offsets, count,
5248              gnptr, &substring);              gnptr, &substring);
# Line 4914  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 5135  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.1080  
changed lines
  Added in v.1313

  ViewVC Help
Powered by ViewVC 1.1.5