/[pcre]/code/branches/pcre16/pcre_internal.h
ViewVC logotype

Diff of /code/branches/pcre16/pcre_internal.h

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

code/trunk/pcre_internal.h revision 483 by ph10, Mon Jan 4 16:19:17 2010 UTC code/branches/pcre16/pcre_internal.h revision 781 by zherczeg, Sat Dec 3 07:58:30 2011 UTC
# Line 7  Line 7 
7  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
8    
9                         Written by Philip Hazel                         Written by Philip Hazel
10             Copyright (c) 1997-2010 University of Cambridge             Copyright (c) 1997-2011 University of Cambridge
11    
12  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
13  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 40  POSSIBILITY OF SUCH DAMAGE. Line 40  POSSIBILITY OF SUCH DAMAGE.
40    
41  /* This header contains definitions that are shared between the different  /* This header contains definitions that are shared between the different
42  modules, but which are not relevant to the exported API. This includes some  modules, but which are not relevant to the exported API. This includes some
43  functions whose names all begin with "_pcre_". */  functions whose names all begin with "_pcre_" or "_pcre16_" depending on
44    the PRIV macro. */
45    
46  #ifndef PCRE_INTERNAL_H  #ifndef PCRE_INTERNAL_H
47  #define PCRE_INTERNAL_H  #define PCRE_INTERNAL_H
# Line 51  functions whose names all begin with "_p Line 52  functions whose names all begin with "_p
52  #define PCRE_DEBUG  #define PCRE_DEBUG
53  #endif  #endif
54    
55  /* We do not support both EBCDIC and UTF-8 at the same time. The "configure"  /* PCRE is compiled as an 8 bit library if it is not requested otherwise. */
56    #ifndef COMPILE_PCRE16
57    #define COMPILE_PCRE8
58    #endif
59    
60    /* We do not support both EBCDIC and UTF-8/16 at the same time. The "configure"
61  script prevents both being selected, but not everybody uses "configure". */  script prevents both being selected, but not everybody uses "configure". */
62    
63  #if defined EBCDIC && defined SUPPORT_UTF8  #if defined EBCDIC && (defined SUPPORT_UTF8 || defined SUPPORT_UTF16)
64  #error The use of both EBCDIC and SUPPORT_UTF8 is not supported.  #error The use of both EBCDIC and SUPPORT_UTF8/16 is not supported.
65  #endif  #endif
66    
67  /* If SUPPORT_UCP is defined, SUPPORT_UTF8 must also be defined. The  /* If SUPPORT_UCP is defined, SUPPORT_UTF8 must also be defined. The
# Line 65  script prevents both being selected, but Line 71  script prevents both being selected, but
71  #define SUPPORT_UTF8 1  #define SUPPORT_UTF8 1
72  #endif  #endif
73    
74    /* If SUPPORT_UCP is defined, SUPPORT_UTF16 must also be defined. The
75    "configure" script ensures this, but not everybody uses "configure". */
76    
77    #if defined SUPPORT_UCP && defined COMPILE_PCRE16 && !defined SUPPORT_UTF16
78    #define SUPPORT_UTF16 1
79    #endif
80    
81    /* This macro is defined if either UTF-8 or UTF-16 support or both are
82    enabled. */
83    
84    #if defined SUPPORT_UTF8 || defined SUPPORT_UTF16
85    /* Unicode Transformation Format is enabled. */
86    #define SUPPORT_UTF 1
87    #endif
88    
89  /* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef  /* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
90  inline, and there are *still* stupid compilers about that don't like indented  inline, and there are *still* stupid compilers about that don't like indented
91  pre-processor statements, or at least there were when I first wrote this. After  pre-processor statements, or at least there were when I first wrote this. After
# Line 158  set, we ensure here that it has no effec Line 179  set, we ensure here that it has no effec
179  #define PCRE_CALL_CONVENTION  #define PCRE_CALL_CONVENTION
180  #endif  #endif
181    
182  /* We need to have types that specify unsigned 16-bit and 32-bit integers. We  /* We need to have types that specify unsigned 8, 16 and 32-bit integers. We
183  cannot determine these outside the compilation (e.g. by running a program as  cannot determine these outside the compilation (e.g. by running a program as
184  part of "configure") because PCRE is often cross-compiled for use on other  part of "configure") because PCRE is often cross-compiled for use on other
185  systems. Instead we make use of the maximum sizes that are available at  systems. Instead we make use of the maximum sizes that are available at
186  preprocessor time in standard C environments. */  preprocessor time in standard C environments. */
187    
188    typedef unsigned char pcre_uint8;
189    
190  #if USHRT_MAX == 65535  #if USHRT_MAX == 65535
191    typedef unsigned short pcre_uint16;    typedef unsigned short pcre_uint16;
192    typedef short pcre_int16;    typedef short pcre_int16;
# Line 184  preprocessor time in standard C environm Line 207  preprocessor time in standard C environm
207    #error Cannot determine a type for 32-bit unsigned integers    #error Cannot determine a type for 32-bit unsigned integers
208  #endif  #endif
209    
210  /* When checking for integer overflow in pcre_compile(), we need to handle  /* When checking for integer overflow in pcre_compile(), we need to handle
211  large integers. If a 64-bit integer type is available, we can use that.  large integers. If a 64-bit integer type is available, we can use that.
212  Otherwise we have to cast to double, which of course requires floating point  Otherwise we have to cast to double, which of course requires floating point
213  arithmetic. Handle this by defining a macro for the appropriate type. If  arithmetic. Handle this by defining a macro for the appropriate type. If
214  stdint.h is available, include it; it may define INT64_MAX. The macro int64_t  stdint.h is available, include it; it may define INT64_MAX. Systems that do not
215  may be set by "configure". */  have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set
216    by "configure". */
217    
218  #if HAVE_STDINT_H  #if HAVE_STDINT_H
219  #include <stdint.h>  #include <stdint.h>
220    #elif HAVE_INTTYPES_H
221    #include <inttypes.h>
222  #endif  #endif
223    
224  #if defined INT64_MAX || defined int64_t  #if defined INT64_MAX || defined int64_t
# Line 203  may be set by "configure". */ Line 229  may be set by "configure". */
229    
230  /* All character handling must be done as unsigned characters. Otherwise there  /* All character handling must be done as unsigned characters. Otherwise there
231  are problems with top-bit-set characters and functions such as isspace().  are problems with top-bit-set characters and functions such as isspace().
232  However, we leave the interface to the outside world as char *, because that  However, we leave the interface to the outside world as char * or short *,
233  should make things easier for callers. We define a short type for unsigned char  because that should make things easier for callers. This character type is
234  to save lots of typing. I tried "uchar", but it causes problems on Digital  called pcre_uchar.
235  Unix, where it is defined in sys/types, so use "uschar" instead. */  
236    The IN_UCHARS macro multiply its argument with the byte size of the current
237    pcre_uchar type. Useful for memcpy and such operations, whose require the
238    byte size of their input/output buffers.
239    
240    The MAX_255 macro checks whether its pcre_uchar input is less than 256.
241    
242    The TABLE_GET macro is designed for accessing elements of tables whose contain
243    exactly 256 items. When the character is able to contain more than 256
244    items, some check is needed before accessing these tables.
245    */
246    
247    #ifdef COMPILE_PCRE8
248    
249    typedef unsigned char pcre_uchar;
250    #define IN_UCHARS(x) (x)
251    #define MAX_255(c) 1
252    #define TABLE_GET(c, table, default) ((table)[c])
253    
254    #else
255    
256    #ifdef COMPILE_PCRE16
257    #if USHRT_MAX != 65535
258    /* This is a warning message. Change PCRE_SCHAR16 to a 16 bit data type in
259    pcre.h(.in) and disable (comment out) this message. */
260    #error Warning: PCRE_SCHAR16 is not a 16 bit data type.
261    #endif
262    
263    typedef pcre_uint16 pcre_uchar;
264    #define IN_UCHARS(x) ((x) << 1)
265    #define MAX_255(c) ((c) <= 255u)
266    #define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
267    
268    #else
269    #error Unsupported compiling mode
270    #endif /* COMPILE_PCRE16 */
271    
272  typedef unsigned char uschar;  #endif /* COMPILE_PCRE8 */
273    
274  /* This is an unsigned int value that no character can ever have. UTF-8  /* This is an unsigned int value that no character can ever have. UTF-8
275  characters only go up to 0x7fffffff (though Unicode doesn't go beyond  characters only go up to 0x7fffffff (though Unicode doesn't go beyond
# Line 231  start/end of string field names are. */ Line 292  start/end of string field names are. */
292  #define IS_NEWLINE(p) \  #define IS_NEWLINE(p) \
293    ((NLBLOCK->nltype != NLTYPE_FIXED)? \    ((NLBLOCK->nltype != NLTYPE_FIXED)? \
294      ((p) < NLBLOCK->PSEND && \      ((p) < NLBLOCK->PSEND && \
295       _pcre_is_newline((p), NLBLOCK->nltype, NLBLOCK->PSEND, &(NLBLOCK->nllen),\       PRIV(is_newline)((p), NLBLOCK->nltype, NLBLOCK->PSEND, \
296         utf8)) \         &(NLBLOCK->nllen), utf)) \
297      : \      : \
298      ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \      ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
299       (p)[0] == NLBLOCK->nl[0] && \       (p)[0] == NLBLOCK->nl[0] && \
# Line 245  start/end of string field names are. */ Line 306  start/end of string field names are. */
306  #define WAS_NEWLINE(p) \  #define WAS_NEWLINE(p) \
307    ((NLBLOCK->nltype != NLTYPE_FIXED)? \    ((NLBLOCK->nltype != NLTYPE_FIXED)? \
308      ((p) > NLBLOCK->PSSTART && \      ((p) > NLBLOCK->PSSTART && \
309       _pcre_was_newline((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \       PRIV(was_newline)((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
310         &(NLBLOCK->nllen), utf8)) \         &(NLBLOCK->nllen), utf)) \
311      : \      : \
312      ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \      ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
313       (p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \       (p)[-NLBLOCK->nllen] == NLBLOCK->nl[0] && \
# Line 264  used for the external interface and appe Line 325  used for the external interface and appe
325  must begin with PCRE_. */  must begin with PCRE_. */
326    
327  #ifdef CUSTOM_SUBJECT_PTR  #ifdef CUSTOM_SUBJECT_PTR
328  #define PCRE_SPTR CUSTOM_SUBJECT_PTR  #define PCRE_PUCHAR CUSTOM_SUBJECT_PTR
 #define USPTR CUSTOM_SUBJECT_PTR  
329  #else  #else
330  #define PCRE_SPTR const char *  #define PCRE_PUCHAR const pcre_uchar *
 #define USPTR const unsigned char *  
331  #endif  #endif
332    
   
   
333  /* Include the public PCRE header and the definitions of UCP character property  /* Include the public PCRE header and the definitions of UCP character property
334  values. */  values. */
335    
# Line 340  The macros are controlled by the value o Line 397  The macros are controlled by the value o
397  the config.h file, but can be overridden by using -D on the command line. This  the config.h file, but can be overridden by using -D on the command line. This
398  is automated on Unix systems via the "configure" command. */  is automated on Unix systems via the "configure" command. */
399    
400    #ifdef COMPILE_PCRE8
401    
402  #if LINK_SIZE == 2  #if LINK_SIZE == 2
403    
404  #define PUT(a,n,d)   \  #define PUT(a,n,d)   \
# Line 376  is automated on Unix systems via the "co Line 435  is automated on Unix systems via the "co
435  #define GET(a,n) \  #define GET(a,n) \
436    (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])    (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
437    
438  #define MAX_PATTERN_SIZE (1 << 30)   /* Keep it positive */  /* Keep it positive */
439    #define MAX_PATTERN_SIZE (1 << 30)
440    
441    #else
442    #error LINK_SIZE must be either 2, 3, or 4
443    #endif
444    
445    #else /* COMPILE_PCRE8 */
446    
447    #ifdef COMPILE_PCRE16
448    
449    #if LINK_SIZE == 2
450    
451    #undef LINK_SIZE
452    #define LINK_SIZE 1
453    
454    #define PUT(a,n,d)   \
455      (a[n] = (d))
456    
457    #define GET(a,n) \
458      (a[n])
459    
460    #define MAX_PATTERN_SIZE (1 << 16)
461    
462    #elif LINK_SIZE == 3 || LINK_SIZE == 4
463    
464    #undef LINK_SIZE
465    #define LINK_SIZE 2
466    
467    #define PUT(a,n,d)   \
468      (a[n] = (d) >> 16), \
469      (a[(n)+1] = (d) & 65536)
470    
471    #define GET(a,n) \
472      (((a)[n] << 16) | (a)[(n)+1])
473    
474    /* Keep it positive */
475    #define MAX_PATTERN_SIZE (1 << 30)
476    
477  #else  #else
478  #error LINK_SIZE must be either 2, 3, or 4  #error LINK_SIZE must be either 2, 3, or 4
479  #endif  #endif
480    
481    #else
482    #error Unsupported compiling mode
483    #endif /* COMPILE_PCRE16 */
484    
485    #endif /* COMPILE_PCRE8 */
486    
487  /* Convenience macro defined in terms of the others */  /* Convenience macro defined in terms of the others */
488    
# Line 393  is automated on Unix systems via the "co Line 493  is automated on Unix systems via the "co
493  offsets changes. There are used for repeat counts and for other things such as  offsets changes. There are used for repeat counts and for other things such as
494  capturing parenthesis numbers in back references. */  capturing parenthesis numbers in back references. */
495    
496    #ifdef COMPILE_PCRE8
497    
498    #define IMM2_SIZE 2
499    
500  #define PUT2(a,n,d)   \  #define PUT2(a,n,d)   \
501    a[n] = (d) >> 8; \    a[n] = (d) >> 8; \
502    a[(n)+1] = (d) & 255    a[(n)+1] = (d) & 255
# Line 400  capturing parenthesis numbers in back re Line 504  capturing parenthesis numbers in back re
504  #define GET2(a,n) \  #define GET2(a,n) \
505    (((a)[n] << 8) | (a)[(n)+1])    (((a)[n] << 8) | (a)[(n)+1])
506    
507  #define PUT2INC(a,n,d)  PUT2(a,n,d), a += 2  #else /* COMPILE_PCRE8 */
508    
509    #ifdef COMPILE_PCRE16
510    
511    #define IMM2_SIZE 1
512    
513    #define PUT2(a,n,d)   \
514       a[n] = d
515    
516    #define GET2(a,n) \
517       a[n]
518    
519    #else
520    #error Unsupported compiling mode
521    #endif /* COMPILE_PCRE16 */
522    
523    #endif /* COMPILE_PCRE8 */
524    
525    #define PUT2INC(a,n,d)  PUT2(a,n,d), a += IMM2_SIZE
526    
527  /* When UTF-8 encoding is being used, a character is no longer just a single  /* When UTF-8 encoding is being used, a character is no longer just a single
528  byte. The macros for character handling generate simple sequences when used in  byte. The macros for character handling generate simple sequences when used in
529  byte-mode, and more complicated ones for UTF-8 characters. BACKCHAR should  byte-mode, and more complicated ones for UTF-8 characters. GETCHARLENTEST is
530  never be called in byte mode. To make sure it can never even appear when UTF-8  not used when UTF-8 is not supported, so it is not defined, and BACKCHAR should
531  support is omitted, we don't even define it. */  never be called in byte mode. To make sure they can never even appear when
532    UTF-8 support is omitted, we don't even define them. */
533    
534  #ifndef SUPPORT_UTF8  #ifndef SUPPORT_UTF8
535  #define GETCHAR(c, eptr) c = *eptr;  #define GETCHAR(c, eptr) c = *eptr;
# Line 415  support is omitted, we don't even define Line 537  support is omitted, we don't even define
537  #define GETCHARINC(c, eptr) c = *eptr++;  #define GETCHARINC(c, eptr) c = *eptr++;
538  #define GETCHARINCTEST(c, eptr) c = *eptr++;  #define GETCHARINCTEST(c, eptr) c = *eptr++;
539  #define GETCHARLEN(c, eptr, len) c = *eptr;  #define GETCHARLEN(c, eptr, len) c = *eptr;
540    /* #define GETCHARLENTEST(c, eptr, len) */
541  /* #define BACKCHAR(eptr) */  /* #define BACKCHAR(eptr) */
542    
543  #else   /* SUPPORT_UTF8 */  #else   /* SUPPORT_UTF8 */
544    
545    /* These macros were originally written in the form of loops that used data
546    from the tables whose names start with PRIV(utf8_table). They were rewritten by
547    a user so as not to use loops, because in some environments this gives a
548    significant performance advantage, and it seems never to do any harm. */
549    
550    /* Base macro to pick up the remaining bytes of a UTF-8 character, not
551    advancing the pointer. */
552    
553    #define GETUTF8(c, eptr) \
554        { \
555        if ((c & 0x20) == 0) \
556          c = ((c & 0x1f) << 6) | (eptr[1] & 0x3f); \
557        else if ((c & 0x10) == 0) \
558          c = ((c & 0x0f) << 12) | ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
559        else if ((c & 0x08) == 0) \
560          c = ((c & 0x07) << 18) | ((eptr[1] & 0x3f) << 12) | \
561          ((eptr[2] & 0x3f) << 6) | (eptr[3] & 0x3f); \
562        else if ((c & 0x04) == 0) \
563          c = ((c & 0x03) << 24) | ((eptr[1] & 0x3f) << 18) | \
564              ((eptr[2] & 0x3f) << 12) | ((eptr[3] & 0x3f) << 6) | \
565              (eptr[4] & 0x3f); \
566        else \
567          c = ((c & 0x01) << 30) | ((eptr[1] & 0x3f) << 24) | \
568              ((eptr[2] & 0x3f) << 18) | ((eptr[3] & 0x3f) << 12) | \
569              ((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
570        }
571    
572  /* Get the next UTF-8 character, not advancing the pointer. This is called when  /* Get the next UTF-8 character, not advancing the pointer. This is called when
573  we know we are in UTF-8 mode. */  we know we are in UTF-8 mode. */
574    
575  #define GETCHAR(c, eptr) \  #define GETCHAR(c, eptr) \
576    c = *eptr; \    c = *eptr; \
577    if (c >= 0xc0) \    if (c >= 0xc0) GETUTF8(c, eptr);
     { \  
     int gcii; \  
     int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \  
     int gcss = 6*gcaa; \  
     c = (c & _pcre_utf8_table3[gcaa]) << gcss; \  
     for (gcii = 1; gcii <= gcaa; gcii++) \  
       { \  
       gcss -= 6; \  
       c |= (eptr[gcii] & 0x3f) << gcss; \  
       } \  
     }  
578    
579  /* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the  /* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
580  pointer. */  pointer. */
581    
582  #define GETCHARTEST(c, eptr) \  #define GETCHARTEST(c, eptr) \
583    c = *eptr; \    c = *eptr; \
584    if (utf8 && c >= 0xc0) \    if (utf && c >= 0xc0) GETUTF8(c, eptr);
585    
586    /* Base macro to pick up the remaining bytes of a UTF-8 character, advancing
587    the pointer. */
588    
589    #define GETUTF8INC(c, eptr) \
590      { \      { \
591      int gcii; \      if ((c & 0x20) == 0) \
592      int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \        c = ((c & 0x1f) << 6) | (*eptr++ & 0x3f); \
593      int gcss = 6*gcaa; \      else if ((c & 0x10) == 0) \
594      c = (c & _pcre_utf8_table3[gcaa]) << gcss; \        { \
595      for (gcii = 1; gcii <= gcaa; gcii++) \        c = ((c & 0x0f) << 12) | ((*eptr & 0x3f) << 6) | (eptr[1] & 0x3f); \
596          eptr += 2; \
597          } \
598        else if ((c & 0x08) == 0) \
599          { \
600          c = ((c & 0x07) << 18) | ((*eptr & 0x3f) << 12) | \
601              ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
602          eptr += 3; \
603          } \
604        else if ((c & 0x04) == 0) \
605          { \
606          c = ((c & 0x03) << 24) | ((*eptr & 0x3f) << 18) | \
607              ((eptr[1] & 0x3f) << 12) | ((eptr[2] & 0x3f) << 6) | \
608              (eptr[3] & 0x3f); \
609          eptr += 4; \
610          } \
611        else \
612        { \        { \
613        gcss -= 6; \        c = ((c & 0x01) << 30) | ((*eptr & 0x3f) << 24) | \
614        c |= (eptr[gcii] & 0x3f) << gcss; \            ((eptr[1] & 0x3f) << 18) | ((eptr[2] & 0x3f) << 12) | \
615              ((eptr[3] & 0x3f) << 6) | (eptr[4] & 0x3f); \
616          eptr += 5; \
617        } \        } \
618      }      }
619    
# Line 460  know we are in UTF-8 mode. */ Line 622  know we are in UTF-8 mode. */
622    
623  #define GETCHARINC(c, eptr) \  #define GETCHARINC(c, eptr) \
624    c = *eptr++; \    c = *eptr++; \
625    if (c >= 0xc0) \    if (c >= 0xc0) GETUTF8INC(c, eptr);
     { \  
     int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \  
     int gcss = 6*gcaa; \  
     c = (c & _pcre_utf8_table3[gcaa]) << gcss; \  
     while (gcaa-- > 0) \  
       { \  
       gcss -= 6; \  
       c |= (*eptr++ & 0x3f) << gcss; \  
       } \  
     }  
626    
627  /* Get the next character, testing for UTF-8 mode, and advancing the pointer */  /* Get the next character, testing for UTF-8 mode, and advancing the pointer.
628    This is called when we don't know if we are in UTF-8 mode. */
629    
630  #define GETCHARINCTEST(c, eptr) \  #define GETCHARINCTEST(c, eptr) \
631    c = *eptr++; \    c = *eptr++; \
632    if (utf8 && c >= 0xc0) \    if (utf && c >= 0xc0) GETUTF8INC(c, eptr);
633    
634    /* Base macro to pick up the remaining bytes of a UTF-8 character, not
635    advancing the pointer, incrementing the length. */
636    
637    #define GETUTF8LEN(c, eptr, len) \
638      { \      { \
639      int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \      if ((c & 0x20) == 0) \
640      int gcss = 6*gcaa; \        { \
641      c = (c & _pcre_utf8_table3[gcaa]) << gcss; \        c = ((c & 0x1f) << 6) | (eptr[1] & 0x3f); \
642      while (gcaa-- > 0) \        len++; \
643          } \
644        else if ((c & 0x10)  == 0) \
645          { \
646          c = ((c & 0x0f) << 12) | ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
647          len += 2; \
648          } \
649        else if ((c & 0x08)  == 0) \
650          {\
651          c = ((c & 0x07) << 18) | ((eptr[1] & 0x3f) << 12) | \
652              ((eptr[2] & 0x3f) << 6) | (eptr[3] & 0x3f); \
653          len += 3; \
654          } \
655        else if ((c & 0x04)  == 0) \
656        { \        { \
657        gcss -= 6; \        c = ((c & 0x03) << 24) | ((eptr[1] & 0x3f) << 18) | \
658        c |= (*eptr++ & 0x3f) << gcss; \            ((eptr[2] & 0x3f) << 12) | ((eptr[3] & 0x3f) << 6) | \
659              (eptr[4] & 0x3f); \
660          len += 4; \
661          } \
662        else \
663          {\
664          c = ((c & 0x01) << 30) | ((eptr[1] & 0x3f) << 24) | \
665              ((eptr[2] & 0x3f) << 18) | ((eptr[3] & 0x3f) << 12) | \
666              ((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
667          len += 5; \
668        } \        } \
669      }      }
670    
# Line 493  if there are extra bytes. This is called Line 673  if there are extra bytes. This is called
673    
674  #define GETCHARLEN(c, eptr, len) \  #define GETCHARLEN(c, eptr, len) \
675    c = *eptr; \    c = *eptr; \
676    if (c >= 0xc0) \    if (c >= 0xc0) GETUTF8LEN(c, eptr, len);
     { \  
     int gcii; \  
     int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \  
     int gcss = 6*gcaa; \  
     c = (c & _pcre_utf8_table3[gcaa]) << gcss; \  
     for (gcii = 1; gcii <= gcaa; gcii++) \  
       { \  
       gcss -= 6; \  
       c |= (eptr[gcii] & 0x3f) << gcss; \  
       } \  
     len += gcaa; \  
     }  
677    
678  /* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the  /* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
679  pointer, incrementing length if there are extra bytes. This is called when we  pointer, incrementing length if there are extra bytes. This is called when we
680  know we are in UTF-8 mode. */  do not know if we are in UTF-8 mode. */
681    
682  #define GETCHARLENTEST(c, eptr, len) \  #define GETCHARLENTEST(c, eptr, len) \
683    c = *eptr; \    c = *eptr; \
684    if (utf8 && c >= 0xc0) \    if (utf && c >= 0xc0) GETUTF8LEN(c, eptr, len);
     { \  
     int gcii; \  
     int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \  
     int gcss = 6*gcaa; \  
     c = (c & _pcre_utf8_table3[gcaa]) << gcss; \  
     for (gcii = 1; gcii <= gcaa; gcii++) \  
       { \  
       gcss -= 6; \  
       c |= (eptr[gcii] & 0x3f) << gcss; \  
       } \  
     len += gcaa; \  
     }  
685    
686  /* If the pointer is not at the start of a character, move it back until  /* If the pointer is not at the start of a character, move it back until
687  it is. This is called only in UTF-8 mode - we don't put a test within the macro  it is. This is called only in UTF-8 mode - we don't put a test within the macro
# Line 533  because almost all calls are already wit Line 689  because almost all calls are already wit
689    
690  #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--  #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
691    
692  #endif  #endif  /* SUPPORT_UTF8 */
693    
694    
695  /* In case there is no definition of offsetof() provided - though any proper  /* In case there is no definition of offsetof() provided - though any proper
# Line 544  Standard C system should have one. */ Line 700  Standard C system should have one. */
700  #endif  #endif
701    
702    
 /* These are the public options that can change during matching. */  
   
 #define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)  
   
703  /* Private flags containing information about the compiled regex. They used to  /* Private flags containing information about the compiled regex. They used to
704  live at the top end of the options word, but that got almost full, so now they  live at the top end of the options word, but that got almost full, so now they
705  are in a 16-bit flags word. From release 8.00, PCRE_NOPARTIAL is unused, as  are in a 16-bit flags word. From release 8.00, PCRE_NOPARTIAL is unused, as
# Line 555  the restrictions on partial matching hav Line 707  the restrictions on partial matching hav
707  compatibility. */  compatibility. */
708    
709  #define PCRE_NOPARTIAL     0x0001  /* can't use partial with this regex */  #define PCRE_NOPARTIAL     0x0001  /* can't use partial with this regex */
710  #define PCRE_FIRSTSET      0x0002  /* first_byte is set */  #define PCRE_FIRSTSET      0x0002  /* first_char is set */
711  #define PCRE_REQCHSET      0x0004  /* req_byte is set */  #define PCRE_REQCHSET      0x0004  /* req_byte is set */
712  #define PCRE_STARTLINE     0x0008  /* start after \n for multiline */  #define PCRE_STARTLINE     0x0008  /* start after \n for multiline */
713  #define PCRE_JCHANGED      0x0010  /* j option used in regex */  #define PCRE_JCHANGED      0x0010  /* j option used in regex */
714  #define PCRE_HASCRORLF     0x0020  /* explicit \r or \n in pattern */  #define PCRE_HASCRORLF     0x0020  /* explicit \r or \n in pattern */
715    #define PCRE_HASTHEN       0x0040  /* pattern contains (*THEN) */
716    #define PCRE_FCH_CASELESS  0x0080  /* caseless first char */
717    #define PCRE_RCH_CASELESS  0x0100  /* caseless requested char */
718    
719  /* Options for the "extra" block produced by pcre_study(). */  /* Flags for the "extra" block produced by pcre_study(). */
720    
721  #define PCRE_STUDY_MAPPED   0x01     /* a map of starting chars exists */  #define PCRE_STUDY_MAPPED  0x0001  /* a map of starting chars exists */
722  #define PCRE_STUDY_MINLEN   0x02     /* a minimum length field exists */  #define PCRE_STUDY_MINLEN  0x0002  /* a minimum length field exists */
723    
724  /* Masks for identifying the public options that are permitted at compile  /* Masks for identifying the public options that are permitted at compile
725  time, run time, or study time, respectively. */  time, run time, or study time, respectively. */
# Line 577  time, run time, or study time, respectiv Line 732  time, run time, or study time, respectiv
732     PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \     PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
733     PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \     PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
734     PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \     PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
735     PCRE_JAVASCRIPT_COMPAT)     PCRE_JAVASCRIPT_COMPAT|PCRE_UCP|PCRE_NO_START_OPTIMIZE)
736    
737  #define PUBLIC_EXEC_OPTIONS \  #define PUBLIC_EXEC_OPTIONS \
738    (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \    (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
# Line 590  time, run time, or study time, respectiv Line 745  time, run time, or study time, respectiv
745     PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \     PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
746     PCRE_NO_START_OPTIMIZE)     PCRE_NO_START_OPTIMIZE)
747    
748  #define PUBLIC_STUDY_OPTIONS 0   /* None defined */  #define PUBLIC_STUDY_OPTIONS \
749       PCRE_STUDY_JIT_COMPILE
750    
751  /* Magic number to provide a small check against being handed junk. Also used  /* Magic number to provide a small check against being handed junk. Also used
752  to detect whether a pattern was compiled on a host of different endianness. */  to detect whether a pattern was compiled on a host of different endianness. */
# Line 607  req_byte match. */ Line 763  req_byte match. */
763    
764  #define REQ_BYTE_MAX 1000  #define REQ_BYTE_MAX 1000
765    
 /* Flags added to firstbyte or reqbyte; a "non-literal" item is either a  
 variable-length repeat, or a anything other than literal characters. */  
   
 #define REQ_CASELESS 0x0100    /* indicates caselessness */  
 #define REQ_VARY     0x0200    /* reqbyte followed non-literal item */  
   
766  /* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in  /* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in
767  environments where these macros are defined elsewhere. Unfortunately, there  environments where these macros are defined elsewhere. Unfortunately, there
768  is no way to do the same for the typedef. */  is no way to do the same for the typedef. */
# Line 872  so that PCRE works on both ASCII and EBC Line 1022  so that PCRE works on both ASCII and EBC
1022  #define STRING_COMMIT0              "COMMIT\0"  #define STRING_COMMIT0              "COMMIT\0"
1023  #define STRING_F0                   "F\0"  #define STRING_F0                   "F\0"
1024  #define STRING_FAIL0                "FAIL\0"  #define STRING_FAIL0                "FAIL\0"
1025    #define STRING_MARK0                "MARK\0"
1026  #define STRING_PRUNE0               "PRUNE\0"  #define STRING_PRUNE0               "PRUNE\0"
1027  #define STRING_SKIP0                "SKIP\0"  #define STRING_SKIP0                "SKIP\0"
1028  #define STRING_THEN                 "THEN"  #define STRING_THEN                 "THEN"
# Line 893  so that PCRE works on both ASCII and EBC Line 1044  so that PCRE works on both ASCII and EBC
1044    
1045  #define STRING_DEFINE               "DEFINE"  #define STRING_DEFINE               "DEFINE"
1046    
1047  #define STRING_CR_RIGHTPAR          "CR)"  #define STRING_CR_RIGHTPAR             "CR)"
1048  #define STRING_LF_RIGHTPAR          "LF)"  #define STRING_LF_RIGHTPAR             "LF)"
1049  #define STRING_CRLF_RIGHTPAR        "CRLF)"  #define STRING_CRLF_RIGHTPAR           "CRLF)"
1050  #define STRING_ANY_RIGHTPAR         "ANY)"  #define STRING_ANY_RIGHTPAR            "ANY)"
1051  #define STRING_ANYCRLF_RIGHTPAR     "ANYCRLF)"  #define STRING_ANYCRLF_RIGHTPAR        "ANYCRLF)"
1052  #define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"  #define STRING_BSR_ANYCRLF_RIGHTPAR    "BSR_ANYCRLF)"
1053  #define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"  #define STRING_BSR_UNICODE_RIGHTPAR    "BSR_UNICODE)"
1054  #define STRING_UTF8_RIGHTPAR        "UTF8)"  #define STRING_UTF8_RIGHTPAR           "UTF8)"
1055    #define STRING_UCP_RIGHTPAR            "UCP)"
1056    #define STRING_NO_START_OPT_RIGHTPAR   "NO_START_OPT)"
1057    
1058  #else  /* SUPPORT_UTF8 */  #else  /* SUPPORT_UTF8 */
1059    
# Line 1124  only. */ Line 1277  only. */
1277  #define STRING_COMMIT0              STR_C STR_O STR_M STR_M STR_I STR_T "\0"  #define STRING_COMMIT0              STR_C STR_O STR_M STR_M STR_I STR_T "\0"
1278  #define STRING_F0                   STR_F "\0"  #define STRING_F0                   STR_F "\0"
1279  #define STRING_FAIL0                STR_F STR_A STR_I STR_L "\0"  #define STRING_FAIL0                STR_F STR_A STR_I STR_L "\0"
1280    #define STRING_MARK0                STR_M STR_A STR_R STR_K "\0"
1281  #define STRING_PRUNE0               STR_P STR_R STR_U STR_N STR_E "\0"  #define STRING_PRUNE0               STR_P STR_R STR_U STR_N STR_E "\0"
1282  #define STRING_SKIP0                STR_S STR_K STR_I STR_P "\0"  #define STRING_SKIP0                STR_S STR_K STR_I STR_P "\0"
1283  #define STRING_THEN                 STR_T STR_H STR_E STR_N  #define STRING_THEN                 STR_T STR_H STR_E STR_N
# Line 1145  only. */ Line 1299  only. */
1299    
1300  #define STRING_DEFINE               STR_D STR_E STR_F STR_I STR_N STR_E  #define STRING_DEFINE               STR_D STR_E STR_F STR_I STR_N STR_E
1301    
1302  #define STRING_CR_RIGHTPAR          STR_C STR_R STR_RIGHT_PARENTHESIS  #define STRING_CR_RIGHTPAR             STR_C STR_R STR_RIGHT_PARENTHESIS
1303  #define STRING_LF_RIGHTPAR          STR_L STR_F STR_RIGHT_PARENTHESIS  #define STRING_LF_RIGHTPAR             STR_L STR_F STR_RIGHT_PARENTHESIS
1304  #define STRING_CRLF_RIGHTPAR        STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS  #define STRING_CRLF_RIGHTPAR           STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
1305  #define STRING_ANY_RIGHTPAR         STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS  #define STRING_ANY_RIGHTPAR            STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS
1306  #define STRING_ANYCRLF_RIGHTPAR     STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS  #define STRING_ANYCRLF_RIGHTPAR        STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
1307  #define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS  #define STRING_BSR_ANYCRLF_RIGHTPAR    STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
1308  #define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS  #define STRING_BSR_UNICODE_RIGHTPAR    STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
1309  #define STRING_UTF8_RIGHTPAR        STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS  #define STRING_UTF8_RIGHTPAR           STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
1310    #define STRING_UCP_RIGHTPAR            STR_U STR_C STR_P STR_RIGHT_PARENTHESIS
1311    #define STRING_NO_START_OPT_RIGHTPAR   STR_N STR_O STR_UNDERSCORE STR_S STR_T STR_A STR_R STR_T STR_UNDERSCORE STR_O STR_P STR_T STR_RIGHT_PARENTHESIS
1312    
1313  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF8 */
1314    
# Line 1185  only. */ Line 1341  only. */
1341    
1342  #define PT_ANY        0    /* Any property - matches all chars */  #define PT_ANY        0    /* Any property - matches all chars */
1343  #define PT_LAMP       1    /* L& - the union of Lu, Ll, Lt */  #define PT_LAMP       1    /* L& - the union of Lu, Ll, Lt */
1344  #define PT_GC         2    /* General characteristic (e.g. L) */  #define PT_GC         2    /* Specified general characteristic (e.g. L) */
1345  #define PT_PC         3    /* Particular characteristic (e.g. Lu) */  #define PT_PC         3    /* Specified particular characteristic (e.g. Lu) */
1346  #define PT_SC         4    /* Script (e.g. Han) */  #define PT_SC         4    /* Script (e.g. Han) */
1347    #define PT_ALNUM      5    /* Alphanumeric - the union of L and N */
1348    #define PT_SPACE      6    /* Perl space - Z plus 9,10,12,13 */
1349    #define PT_PXSPACE    7    /* POSIX space - Z plus 9,10,11,12,13 */
1350    #define PT_WORD       8    /* Word - L plus N plus underscore */
1351    
1352  /* Flag bits and data types for the extended class (OP_XCLASS) for classes that  /* Flag bits and data types for the extended class (OP_XCLASS) for classes that
1353  contain UTF-8 characters with values greater than 255. */  contain characters with values greater than 255. */
1354    
1355  #define XCL_NOT    0x01    /* Flag: this is a negative class */  #define XCL_NOT    0x01    /* Flag: this is a negative class */
1356  #define XCL_MAP    0x02    /* Flag: a 32-byte map is present */  #define XCL_MAP    0x02    /* Flag: a 32-byte map is present */
# Line 1204  contain UTF-8 characters with values gre Line 1364  contain UTF-8 characters with values gre
1364  /* These are escaped items that aren't just an encoding of a particular data  /* These are escaped items that aren't just an encoding of a particular data
1365  value such as \n. They must have non-zero values, as check_escape() returns  value such as \n. They must have non-zero values, as check_escape() returns
1366  their negation. Also, they must appear in the same order as in the opcode  their negation. Also, they must appear in the same order as in the opcode
1367  definitions below, up to ESC_z. There's a dummy for OP_ANY because it  definitions below, up to ESC_z. There's a dummy for OP_ALLANY because it
1368  corresponds to "." rather than an escape sequence, and another for OP_ALLANY  corresponds to "." in DOTALL mode rather than an escape sequence. It is also
1369  (which is used for [^] in JavaScript compatibility mode).  used for [^] in JavaScript compatibility mode, and for \C in non-utf mode. In
1370    non-DOTALL mode, "." behaves like \N.
1371    
1372    The special values ESC_DU, ESC_du, etc. are used instead of ESC_D, ESC_d, etc.
1373    when PCRE_UCP is set, when replacement of \d etc by \p sequences is required.
1374    They must be contiguous, and remain in order so that the replacements can be
1375    looked up from a table.
1376    
1377  The final escape must be ESC_REF as subsequent values are used for  The final escape must be ESC_REF as subsequent values are used for
1378  backreferences (\1, \2, \3, etc). There are two tests in the code for an escape  backreferences (\1, \2, \3, etc). There are two tests in the code for an escape
# Line 1216  put in between that don't consume a char Line 1382  put in between that don't consume a char
1382  */  */
1383    
1384  enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,  enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
1385         ESC_W, ESC_w, ESC_dum1, ESC_dum2, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,         ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
1386         ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_g, ESC_k,         ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,
1387           ESC_E, ESC_Q, ESC_g, ESC_k,
1388           ESC_DU, ESC_du, ESC_SU, ESC_su, ESC_WU, ESC_wu,
1389         ESC_REF };         ESC_REF };
1390    
   
1391  /* Opcode table: Starting from 1 (i.e. after OP_END), the values up to  /* Opcode table: Starting from 1 (i.e. after OP_END), the values up to
1392  OP_EOD must correspond in order to the list of escapes immediately above.  OP_EOD must correspond in order to the list of escapes immediately above.
1393    
# Line 1244  enum { Line 1411  enum {
1411    OP_WHITESPACE,         /*  9 \s */    OP_WHITESPACE,         /*  9 \s */
1412    OP_NOT_WORDCHAR,       /* 10 \W */    OP_NOT_WORDCHAR,       /* 10 \W */
1413    OP_WORDCHAR,           /* 11 \w */    OP_WORDCHAR,           /* 11 \w */
1414    OP_ANY,            /* 12 Match any character (subject to DOTALL) */  
1415    OP_ALLANY,         /* 13 Match any character (not subject to DOTALL) */    OP_ANY,            /* 12 Match any character except newline */
1416      OP_ALLANY,         /* 13 Match any character */
1417    OP_ANYBYTE,        /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */    OP_ANYBYTE,        /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
1418    OP_NOTPROP,        /* 15 \P (not Unicode property) */    OP_NOTPROP,        /* 15 \P (not Unicode property) */
1419    OP_PROP,           /* 16 \p (Unicode property) */    OP_PROP,           /* 16 \p (Unicode property) */
# Line 1258  enum { Line 1426  enum {
1426    OP_EODN,           /* 23 End of data or \n at end of data: \Z. */    OP_EODN,           /* 23 End of data or \n at end of data: \Z. */
1427    OP_EOD,            /* 24 End of data: \z */    OP_EOD,            /* 24 End of data: \z */
1428    
1429    OP_OPT,            /* 25 Set runtime options */    OP_CIRC,           /* 25 Start of line - not multiline */
1430    OP_CIRC,           /* 26 Start of line - varies with multiline switch */    OP_CIRCM,          /* 26 Start of line - multiline */
1431    OP_DOLL,           /* 27 End of line - varies with multiline switch */    OP_DOLL,           /* 27 End of line - not multiline */
1432    OP_CHAR,           /* 28 Match one character, casefully */    OP_DOLLM,          /* 28 End of line - multiline */
1433    OP_CHARNC,         /* 29 Match one character, caselessly */    OP_CHAR,           /* 29 Match one character, casefully */
1434    OP_NOT,            /* 30 Match one character, not the following one */    OP_CHARI,          /* 30 Match one character, caselessly */
1435      OP_NOT,            /* 31 Match one character, not the given one, casefully */
1436    OP_STAR,           /* 31 The maximizing and minimizing versions of */    OP_NOTI,           /* 32 Match one character, not the given one, caselessly */
1437    OP_MINSTAR,        /* 32 these six opcodes must come in pairs, with */  
1438    OP_PLUS,           /* 33 the minimizing one second. */    /* The following sets of 13 opcodes must always be kept in step because
1439    OP_MINPLUS,        /* 34 This first set applies to single characters.*/    the offset from the first one is used to generate the others. */
1440    OP_QUERY,          /* 35 */  
1441    OP_MINQUERY,       /* 36 */    /**** Single characters, caseful, must precede the caseless ones ****/
1442    
1443    OP_UPTO,           /* 37 From 0 to n matches */    OP_STAR,           /* 33 The maximizing and minimizing versions of */
1444    OP_MINUPTO,        /* 38 */    OP_MINSTAR,        /* 34 these six opcodes must come in pairs, with */
1445    OP_EXACT,          /* 39 Exactly n matches */    OP_PLUS,           /* 35 the minimizing one second. */
1446      OP_MINPLUS,        /* 36 */
1447    OP_POSSTAR,        /* 40 Possessified star */    OP_QUERY,          /* 37 */
1448    OP_POSPLUS,        /* 41 Possessified plus */    OP_MINQUERY,       /* 38 */
1449    OP_POSQUERY,       /* 42 Posesssified query */  
1450    OP_POSUPTO,        /* 43 Possessified upto */    OP_UPTO,           /* 39 From 0 to n matches of one character, caseful*/
1451      OP_MINUPTO,        /* 40 */
1452    OP_NOTSTAR,        /* 44 The maximizing and minimizing versions of */    OP_EXACT,          /* 41 Exactly n matches */
1453    OP_NOTMINSTAR,     /* 45 these six opcodes must come in pairs, with */  
1454    OP_NOTPLUS,        /* 46 the minimizing one second. They must be in */    OP_POSSTAR,        /* 42 Possessified star, caseful */
1455    OP_NOTMINPLUS,     /* 47 exactly the same order as those above. */    OP_POSPLUS,        /* 43 Possessified plus, caseful */
1456    OP_NOTQUERY,       /* 48 This set applies to "not" single characters. */    OP_POSQUERY,       /* 44 Posesssified query, caseful */
1457    OP_NOTMINQUERY,    /* 49 */    OP_POSUPTO,        /* 45 Possessified upto, caseful */
1458    
1459    OP_NOTUPTO,        /* 50 From 0 to n matches */    /**** Single characters, caseless, must follow the caseful ones */
1460    OP_NOTMINUPTO,     /* 51 */  
1461    OP_NOTEXACT,       /* 52 Exactly n matches */    OP_STARI,          /* 46 */
1462      OP_MINSTARI,       /* 47 */
1463    OP_NOTPOSSTAR,     /* 53 Possessified versions */    OP_PLUSI,          /* 48 */
1464    OP_NOTPOSPLUS,     /* 54 */    OP_MINPLUSI,       /* 49 */
1465    OP_NOTPOSQUERY,    /* 55 */    OP_QUERYI,         /* 50 */
1466    OP_NOTPOSUPTO,     /* 56 */    OP_MINQUERYI,      /* 51 */
1467    
1468    OP_TYPESTAR,       /* 57 The maximizing and minimizing versions of */    OP_UPTOI,          /* 52 From 0 to n matches of one character, caseless */
1469    OP_TYPEMINSTAR,    /* 58 these six opcodes must come in pairs, with */    OP_MINUPTOI,       /* 53 */
1470    OP_TYPEPLUS,       /* 59 the minimizing one second. These codes must */    OP_EXACTI,         /* 54 */
1471    OP_TYPEMINPLUS,    /* 60 be in exactly the same order as those above. */  
1472    OP_TYPEQUERY,      /* 61 This set applies to character types such as \d */    OP_POSSTARI,       /* 55 Possessified star, caseless */
1473    OP_TYPEMINQUERY,   /* 62 */    OP_POSPLUSI,       /* 56 Possessified plus, caseless */
1474      OP_POSQUERYI,      /* 57 Posesssified query, caseless */
1475    OP_TYPEUPTO,       /* 63 From 0 to n matches */    OP_POSUPTOI,       /* 58 Possessified upto, caseless */
1476    OP_TYPEMINUPTO,    /* 64 */  
1477    OP_TYPEEXACT,      /* 65 Exactly n matches */    /**** The negated ones must follow the non-negated ones, and match them ****/
1478      /**** Negated single character, caseful; must precede the caseless ones ****/
1479    OP_TYPEPOSSTAR,    /* 66 Possessified versions */  
1480    OP_TYPEPOSPLUS,    /* 67 */    OP_NOTSTAR,        /* 59 The maximizing and minimizing versions of */
1481    OP_TYPEPOSQUERY,   /* 68 */    OP_NOTMINSTAR,     /* 60 these six opcodes must come in pairs, with */
1482    OP_TYPEPOSUPTO,    /* 69 */    OP_NOTPLUS,        /* 61 the minimizing one second. They must be in */
1483      OP_NOTMINPLUS,     /* 62 exactly the same order as those above. */
1484    OP_CRSTAR,         /* 70 The maximizing and minimizing versions of */    OP_NOTQUERY,       /* 63 */
1485    OP_CRMINSTAR,      /* 71 all these opcodes must come in pairs, with */    OP_NOTMINQUERY,    /* 64 */
1486    OP_CRPLUS,         /* 72 the minimizing one second. These codes must */  
1487    OP_CRMINPLUS,      /* 73 be in exactly the same order as those above. */    OP_NOTUPTO,        /* 65 From 0 to n matches, caseful */
1488    OP_CRQUERY,        /* 74 These are for character classes and back refs */    OP_NOTMINUPTO,     /* 66 */
1489    OP_CRMINQUERY,     /* 75 */    OP_NOTEXACT,       /* 67 Exactly n matches */
1490    OP_CRRANGE,        /* 76 These are different to the three sets above. */  
1491    OP_CRMINRANGE,     /* 77 */    OP_NOTPOSSTAR,     /* 68 Possessified versions, caseful */
1492      OP_NOTPOSPLUS,     /* 69 */
1493    OP_CLASS,          /* 78 Match a character class, chars < 256 only */    OP_NOTPOSQUERY,    /* 70 */
1494    OP_NCLASS,         /* 79 Same, but the bitmap was created from a negative    OP_NOTPOSUPTO,     /* 71 */
1495                             class - the difference is relevant only when a UTF-8  
1496                             character > 255 is encountered. */    /**** Negated single character, caseless; must follow the caseful ones ****/
1497    
1498    OP_XCLASS,         /* 80 Extended class for handling UTF-8 chars within the    OP_NOTSTARI,       /* 72 */
1499                             class. This does both positive and negative. */    OP_NOTMINSTARI,    /* 73 */
1500      OP_NOTPLUSI,       /* 74 */
1501    OP_REF,            /* 81 Match a back reference */    OP_NOTMINPLUSI,    /* 75 */
1502    OP_RECURSE,        /* 82 Match a numbered subpattern (possibly recursive) */    OP_NOTQUERYI,      /* 76 */
1503    OP_CALLOUT,        /* 83 Call out to external function if provided */    OP_NOTMINQUERYI,   /* 77 */
1504    
1505    OP_ALT,            /* 84 Start of alternation */    OP_NOTUPTOI,       /* 78 From 0 to n matches, caseless */
1506    OP_KET,            /* 85 End of group that doesn't have an unbounded repeat */    OP_NOTMINUPTOI,    /* 79 */
1507    OP_KETRMAX,        /* 86 These two must remain together and in this */    OP_NOTEXACTI,      /* 80 Exactly n matches */
1508    OP_KETRMIN,        /* 87 order. They are for groups the repeat for ever. */  
1509      OP_NOTPOSSTARI,    /* 81 Possessified versions, caseless */
1510    /* The assertions must come before BRA, CBRA, ONCE, and COND.*/    OP_NOTPOSPLUSI,    /* 82 */
1511      OP_NOTPOSQUERYI,   /* 83 */
1512    OP_ASSERT,         /* 88 Positive lookahead */    OP_NOTPOSUPTOI,    /* 84 */
1513    OP_ASSERT_NOT,     /* 89 Negative lookahead */  
1514    OP_ASSERTBACK,     /* 90 Positive lookbehind */    /**** Character types ****/
1515    OP_ASSERTBACK_NOT, /* 91 Negative lookbehind */  
1516    OP_REVERSE,        /* 92 Move pointer back - used in lookbehind assertions */    OP_TYPESTAR,       /* 85 The maximizing and minimizing versions of */
1517      OP_TYPEMINSTAR,    /* 86 these six opcodes must come in pairs, with */
1518    /* ONCE, BRA, CBRA, and COND must come after the assertions, with ONCE first,    OP_TYPEPLUS,       /* 87 the minimizing one second. These codes must */
1519    as there's a test for >= ONCE for a subpattern that isn't an assertion. */    OP_TYPEMINPLUS,    /* 88 be in exactly the same order as those above. */
1520      OP_TYPEQUERY,      /* 89 */
1521    OP_ONCE,           /* 93 Atomic group */    OP_TYPEMINQUERY,   /* 90 */
1522    OP_BRA,            /* 94 Start of non-capturing bracket */  
1523    OP_CBRA,           /* 95 Start of capturing bracket */    OP_TYPEUPTO,       /* 91 From 0 to n matches */
1524    OP_COND,           /* 96 Conditional group */    OP_TYPEMINUPTO,    /* 92 */
1525      OP_TYPEEXACT,      /* 93 Exactly n matches */
1526    
1527      OP_TYPEPOSSTAR,    /* 94 Possessified versions */
1528      OP_TYPEPOSPLUS,    /* 95 */
1529      OP_TYPEPOSQUERY,   /* 96 */
1530      OP_TYPEPOSUPTO,    /* 97 */
1531    
1532      /* These are used for character classes and back references; only the
1533      first six are the same as the sets above. */
1534    
1535      OP_CRSTAR,         /* 98 The maximizing and minimizing versions of */
1536      OP_CRMINSTAR,      /* 99 all these opcodes must come in pairs, with */
1537      OP_CRPLUS,         /* 100 the minimizing one second. These codes must */
1538      OP_CRMINPLUS,      /* 101 be in exactly the same order as those above. */
1539      OP_CRQUERY,        /* 102 */
1540      OP_CRMINQUERY,     /* 103 */
1541    
1542      OP_CRRANGE,        /* 104 These are different to the three sets above. */
1543      OP_CRMINRANGE,     /* 105 */
1544    
1545      /* End of quantifier opcodes */
1546    
1547      OP_CLASS,          /* 106 Match a character class, chars < 256 only */
1548      OP_NCLASS,         /* 107 Same, but the bitmap was created from a negative
1549                                  class - the difference is relevant only when a
1550                                  character > 255 is encountered. */
1551      OP_XCLASS,         /* 108 Extended class for handling > 255 chars within the
1552                                  class. This does both positive and negative. */
1553      OP_REF,            /* 109 Match a back reference, casefully */
1554      OP_REFI,           /* 110 Match a back reference, caselessly */
1555      OP_RECURSE,        /* 111 Match a numbered subpattern (possibly recursive) */
1556      OP_CALLOUT,        /* 112 Call out to external function if provided */
1557    
1558      OP_ALT,            /* 113 Start of alternation */
1559      OP_KET,            /* 114 End of group that doesn't have an unbounded repeat */
1560      OP_KETRMAX,        /* 115 These two must remain together and in this */
1561      OP_KETRMIN,        /* 116 order. They are for groups the repeat for ever. */
1562      OP_KETRPOS,        /* 117 Possessive unlimited repeat. */
1563    
1564      /* The assertions must come before BRA, CBRA, ONCE, and COND, and the four
1565      asserts must remain in order. */
1566    
1567      OP_REVERSE,        /* 118 Move pointer back - used in lookbehind assertions */
1568      OP_ASSERT,         /* 119 Positive lookahead */
1569      OP_ASSERT_NOT,     /* 120 Negative lookahead */
1570      OP_ASSERTBACK,     /* 121 Positive lookbehind */
1571      OP_ASSERTBACK_NOT, /* 122 Negative lookbehind */
1572    
1573      /* ONCE, ONCE_NC, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come immediately
1574      after the assertions, with ONCE first, as there's a test for >= ONCE for a
1575      subpattern that isn't an assertion. The POS versions must immediately follow
1576      the non-POS versions in each case. */
1577    
1578      OP_ONCE,           /* 123 Atomic group, contains captures */
1579      OP_ONCE_NC,        /* 124 Atomic group containing no captures */
1580      OP_BRA,            /* 125 Start of non-capturing bracket */
1581      OP_BRAPOS,         /* 126 Ditto, with unlimited, possessive repeat */
1582      OP_CBRA,           /* 127 Start of capturing bracket */
1583      OP_CBRAPOS,        /* 128 Ditto, with unlimited, possessive repeat */
1584      OP_COND,           /* 129 Conditional group */
1585    
1586    /* These three must follow the previous three, in the same order. There's a    /* These five must follow the previous five, in the same order. There's a
1587    check for >= SBRA to distinguish the two sets. */    check for >= SBRA to distinguish the two sets. */
1588    
1589    OP_SBRA,           /* 97 Start of non-capturing bracket, check empty  */    OP_SBRA,           /* 130 Start of non-capturing bracket, check empty  */
1590    OP_SCBRA,          /* 98 Start of capturing bracket, check empty */    OP_SBRAPOS,        /* 131 Ditto, with unlimited, possessive repeat */
1591    OP_SCOND,          /* 99 Conditional group, check empty */    OP_SCBRA,          /* 132 Start of capturing bracket, check empty */
1592      OP_SCBRAPOS,       /* 133 Ditto, with unlimited, possessive repeat */
1593      OP_SCOND,          /* 134 Conditional group, check empty */
1594    
1595    /* The next two pairs must (respectively) be kept together. */    /* The next two pairs must (respectively) be kept together. */
1596    
1597    OP_CREF,           /* 100 Used to hold a capture number as condition */    OP_CREF,           /* 135 Used to hold a capture number as condition */
1598    OP_NCREF,          /* 101 Same, but generaged by a name reference*/    OP_NCREF,          /* 136 Same, but generated by a name reference*/
1599    OP_RREF,           /* 102 Used to hold a recursion number as condition */    OP_RREF,           /* 137 Used to hold a recursion number as condition */
1600    OP_NRREF,          /* 103 Same, but generaged by a name reference*/    OP_NRREF,          /* 138 Same, but generated by a name reference*/
1601    OP_DEF,            /* 104 The DEFINE condition */    OP_DEF,            /* 139 The DEFINE condition */
1602    
1603    OP_BRAZERO,        /* 105 These two must remain together and in this */    OP_BRAZERO,        /* 140 These two must remain together and in this */
1604    OP_BRAMINZERO,     /* 106 order. */    OP_BRAMINZERO,     /* 141 order. */
1605      OP_BRAPOSZERO,     /* 142 */
1606    
1607    /* These are backtracking control verbs */    /* These are backtracking control verbs */
1608    
1609    OP_PRUNE,          /* 107 */    OP_MARK,           /* 143 always has an argument */
1610    OP_SKIP,           /* 108 */    OP_PRUNE,          /* 144 */
1611    OP_THEN,           /* 109 */    OP_PRUNE_ARG,      /* 145 same, but with argument */
1612    OP_COMMIT,         /* 110 */    OP_SKIP,           /* 146 */
1613      OP_SKIP_ARG,       /* 147 same, but with argument */
1614      OP_THEN,           /* 148 */
1615      OP_THEN_ARG,       /* 149 same, but with argument */
1616      OP_COMMIT,         /* 150 */
1617    
1618    /* These are forced failure and success verbs */    /* These are forced failure and success verbs */
1619    
1620    OP_FAIL,           /* 111 */    OP_FAIL,           /* 151 */
1621    OP_ACCEPT,         /* 112 */    OP_ACCEPT,         /* 152 */
1622    OP_CLOSE,          /* 113 Used before OP_ACCEPT to close open captures */    OP_ASSERT_ACCEPT,  /* 153 Used inside assertions */
1623      OP_CLOSE,          /* 154 Used before OP_ACCEPT to close open captures */
1624    
1625    /* This is used to skip a subpattern with a {0} quantifier */    /* This is used to skip a subpattern with a {0} quantifier */
1626    
1627    OP_SKIPZERO        /* 114 */    OP_SKIPZERO,       /* 155 */
1628    
1629      /* This is not an opcode, but is used to check that tables indexed by opcode
1630      are the correct length, in order to catch updating errors - there have been
1631      some in the past. */
1632    
1633      OP_TABLE_LENGTH
1634  };  };
1635    
1636  /* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro  /* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro
1637  definitions that follow must also be updated to match. There are also tables  definitions that follow must also be updated to match. There are also tables
1638  called "coptable" cna "poptable" in pcre_dfa_exec.c that must be updated. */  called "coptable" and "poptable" in pcre_dfa_exec.c that must be updated. */
1639    
1640    
1641  /* This macro defines textual names for all the opcodes. These are used only  /* This macro defines textual names for all the opcodes. These are used only
1642  for debugging. The macro is referenced only in pcre_printint.c. */  for debugging, and some of them are only partial names. The macro is referenced
1643    only in pcre_printint.c, which fills out the full names in many cases (and in
1644    some cases doesn't actually use these names at all). */
1645    
1646  #define OP_NAME_LIST \  #define OP_NAME_LIST \
1647    "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d",         \    "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d",         \
1648    "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte",         \    "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte",         \
1649    "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v",           \    "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v",           \
1650    "extuni",  "\\Z", "\\z",                                        \    "extuni",  "\\Z", "\\z",                                        \
1651    "Opt", "^", "$", "char", "charnc", "not",                       \    "^", "^", "$", "$", "char", "chari", "not", "noti",             \
1652    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \    "*", "*?", "+", "+?", "?", "??",                                \
1653      "{", "{", "{",                                                  \
1654    "*+","++", "?+", "{",                                           \    "*+","++", "?+", "{",                                           \
1655    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \    "*", "*?", "+", "+?", "?", "??",                                \
1656      "{", "{", "{",                                                  \
1657      "*+","++", "?+", "{",                                           \
1658      "*", "*?", "+", "+?", "?", "??",                                \
1659      "{", "{", "{",                                                  \
1660      "*+","++", "?+", "{",                                           \
1661      "*", "*?", "+", "+?", "?", "??",                                \
1662      "{", "{", "{",                                                  \
1663    "*+","++", "?+", "{",                                           \    "*+","++", "?+", "{",                                           \
1664    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \    "*", "*?", "+", "+?", "?", "??", "{", "{", "{",                 \
1665    "*+","++", "?+", "{",                                           \    "*+","++", "?+", "{",                                           \
1666    "*", "*?", "+", "+?", "?", "??", "{", "{",                      \    "*", "*?", "+", "+?", "?", "??", "{", "{",                      \
1667    "class", "nclass", "xclass", "Ref", "Recurse", "Callout",       \    "class", "nclass", "xclass", "Ref", "Refi",                     \
1668    "Alt", "Ket", "KetRmax", "KetRmin", "Assert", "Assert not",     \    "Recurse", "Callout",                                           \
1669    "AssertB", "AssertB not", "Reverse",                            \    "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos",                  \
1670    "Once", "Bra", "CBra", "Cond", "SBra", "SCBra", "SCond",        \    "Reverse", "Assert", "Assert not", "AssertB", "AssertB not",    \
1671      "Once", "Once_NC",                                              \
1672      "Bra", "BraPos", "CBra", "CBraPos",                             \
1673      "Cond",                                                         \
1674      "SBra", "SBraPos", "SCBra", "SCBraPos",                         \
1675      "SCond",                                                        \
1676    "Cond ref", "Cond nref", "Cond rec", "Cond nrec", "Cond def",   \    "Cond ref", "Cond nref", "Cond rec", "Cond nrec", "Cond def",   \
1677    "Brazero", "Braminzero",                                        \    "Brazero", "Braminzero", "Braposzero",                          \
1678    "*PRUNE", "*SKIP", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT",      \    "*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP",                  \
1679      "*THEN", "*THEN", "*COMMIT", "*FAIL",                           \
1680      "*ACCEPT", "*ASSERT_ACCEPT",                                    \
1681    "Close", "Skip zero"    "Close", "Skip zero"
1682    
1683    
# Line 1436  in UTF-8 mode. The code that uses this t Line 1695  in UTF-8 mode. The code that uses this t
1695    1, 1, 1, 1, 1,                 /* \A, \G, \K, \B, \b                     */ \    1, 1, 1, 1, 1,                 /* \A, \G, \K, \B, \b                     */ \
1696    1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */ \    1, 1, 1, 1, 1, 1,              /* \D, \d, \S, \s, \W, \w                 */ \
1697    1, 1, 1,                       /* Any, AllAny, Anybyte                   */ \    1, 1, 1,                       /* Any, AllAny, Anybyte                   */ \
1698    3, 3, 1,                       /* NOTPROP, PROP, EXTUNI                  */ \    3, 3,                          /* \P, \p                                 */ \
1699    1, 1, 1, 1, 1,                 /* \R, \H, \h, \V, \v                     */ \    1, 1, 1, 1, 1,                 /* \R, \H, \h, \V, \v                     */ \
1700    1, 1, 2, 1, 1,                 /* \Z, \z, Opt, ^, $                      */ \    1,                             /* \X                                     */ \
1701      1, 1, 1, 1, 1, 1,              /* \Z, \z, ^, ^M, $, $M                   */ \
1702    2,                             /* Char  - the minimum length             */ \    2,                             /* Char  - the minimum length             */ \
1703    2,                             /* Charnc  - the minimum length           */ \    2,                             /* Chari  - the minimum length            */ \
1704    2,                             /* not                                    */ \    2,                             /* not                                    */ \
1705    /* Positive single-char repeats                            ** These are  */ \    2,                             /* noti                                   */ \
1706    2, 2, 2, 2, 2, 2,              /* *, *?, +, +?, ?, ??      ** minima in  */ \    /* Positive single-char repeats                             ** These are */ \
1707    4, 4, 4,                       /* upto, minupto, exact     ** UTF-8 mode */ \    2, 2, 2, 2, 2, 2,              /* *, *?, +, +?, ?, ??       ** minima in */ \
1708    2, 2, 2, 4,                    /* *+, ++, ?+, upto+                      */ \    2+IMM2_SIZE, 2+IMM2_SIZE,      /* upto, minupto             ** mode      */ \
1709      2+IMM2_SIZE,                   /* exact                                  */ \
1710      2, 2, 2, 2+IMM2_SIZE,          /* *+, ++, ?+, upto+                      */ \
1711      2, 2, 2, 2, 2, 2,              /* *I, *?I, +I, +?I, ?I, ??I ** UTF-8     */ \
1712      2+IMM2_SIZE, 2+IMM2_SIZE,      /* upto I, minupto I                      */ \
1713      2+IMM2_SIZE,                   /* exact I                                */ \
1714      2, 2, 2, 2+IMM2_SIZE,          /* *+I, ++I, ?+I, upto+I                  */ \
1715    /* Negative single-char repeats - only for chars < 256                   */ \    /* Negative single-char repeats - only for chars < 256                   */ \
1716    2, 2, 2, 2, 2, 2,              /* NOT *, *?, +, +?, ?, ??                */ \    2, 2, 2, 2, 2, 2,              /* NOT *, *?, +, +?, ?, ??                */ \
1717    4, 4, 4,                       /* NOT upto, minupto, exact               */ \    2+IMM2_SIZE, 2+IMM2_SIZE,      /* NOT upto, minupto                      */ \
1718    2, 2, 2, 4,                    /* Possessive *, +, ?, upto               */ \    2+IMM2_SIZE,                   /* NOT exact                              */ \
1719      2, 2, 2, 2+IMM2_SIZE,          /* Possessive NOT *, +, ?, upto           */ \
1720      2, 2, 2, 2, 2, 2,              /* NOT *I, *?I, +I, +?I, ?I, ??I          */ \
1721      2+IMM2_SIZE, 2+IMM2_SIZE,      /* NOT upto I, minupto I                  */ \
1722      2+IMM2_SIZE,                   /* NOT exact I                            */ \
1723      2, 2, 2, 2+IMM2_SIZE,          /* Possessive NOT *I, +I, ?I, upto I      */ \
1724    /* Positive type repeats                                                 */ \    /* Positive type repeats                                                 */ \
1725    2, 2, 2, 2, 2, 2,              /* Type *, *?, +, +?, ?, ??               */ \    2, 2, 2, 2, 2, 2,              /* Type *, *?, +, +?, ?, ??               */ \
1726    4, 4, 4,                       /* Type upto, minupto, exact              */ \    2+IMM2_SIZE, 2+IMM2_SIZE,      /* Type upto, minupto                     */ \
1727    2, 2, 2, 4,                    /* Possessive *+, ++, ?+, upto+           */ \    2+IMM2_SIZE,                   /* Type exact                             */ \
1728      2, 2, 2, 2+IMM2_SIZE,          /* Possessive *+, ++, ?+, upto+           */ \
1729    /* Character class & ref repeats                                         */ \    /* Character class & ref repeats                                         */ \
1730    1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */ \    1, 1, 1, 1, 1, 1,              /* *, *?, +, +?, ?, ??                    */ \
1731    5, 5,                          /* CRRANGE, CRMINRANGE                    */ \    1+2*IMM2_SIZE, 1+2*IMM2_SIZE,  /* CRRANGE, CRMINRANGE                    */ \
1732   33,                             /* CLASS                                  */ \    1+(32/sizeof(pcre_uchar)),     /* CLASS                                  */ \
1733   33,                             /* NCLASS                                 */ \    1+(32/sizeof(pcre_uchar)),     /* NCLASS                                 */ \
1734    0,                             /* XCLASS - variable length               */ \    0,                             /* XCLASS - variable length               */ \
1735    3,                             /* REF                                    */ \    1+IMM2_SIZE,                   /* REF                                    */ \
1736      1+IMM2_SIZE,                   /* REFI                                   */ \
1737    1+LINK_SIZE,                   /* RECURSE                                */ \    1+LINK_SIZE,                   /* RECURSE                                */ \
1738    2+2*LINK_SIZE,                 /* CALLOUT                                */ \    2+2*LINK_SIZE,                 /* CALLOUT                                */ \
1739    1+LINK_SIZE,                   /* Alt                                    */ \    1+LINK_SIZE,                   /* Alt                                    */ \
1740    1+LINK_SIZE,                   /* Ket                                    */ \    1+LINK_SIZE,                   /* Ket                                    */ \
1741    1+LINK_SIZE,                   /* KetRmax                                */ \    1+LINK_SIZE,                   /* KetRmax                                */ \
1742    1+LINK_SIZE,                   /* KetRmin                                */ \    1+LINK_SIZE,                   /* KetRmin                                */ \
1743      1+LINK_SIZE,                   /* KetRpos                                */ \
1744      1+LINK_SIZE,                   /* Reverse                                */ \
1745    1+LINK_SIZE,                   /* Assert                                 */ \    1+LINK_SIZE,                   /* Assert                                 */ \
1746    1+LINK_SIZE,                   /* Assert not                             */ \    1+LINK_SIZE,                   /* Assert not                             */ \
1747    1+LINK_SIZE,                   /* Assert behind                          */ \    1+LINK_SIZE,                   /* Assert behind                          */ \
1748    1+LINK_SIZE,                   /* Assert behind not                      */ \    1+LINK_SIZE,                   /* Assert behind not                      */ \
   1+LINK_SIZE,                   /* Reverse                                */ \  
1749    1+LINK_SIZE,                   /* ONCE                                   */ \    1+LINK_SIZE,                   /* ONCE                                   */ \
1750      1+LINK_SIZE,                   /* ONCE_NC                                */ \
1751    1+LINK_SIZE,                   /* BRA                                    */ \    1+LINK_SIZE,                   /* BRA                                    */ \
1752    3+LINK_SIZE,                   /* CBRA                                   */ \    1+LINK_SIZE,                   /* BRAPOS                                 */ \
1753      1+LINK_SIZE+IMM2_SIZE,         /* CBRA                                   */ \
1754      1+LINK_SIZE+IMM2_SIZE,         /* CBRAPOS                                */ \
1755    1+LINK_SIZE,                   /* COND                                   */ \    1+LINK_SIZE,                   /* COND                                   */ \
1756    1+LINK_SIZE,                   /* SBRA                                   */ \    1+LINK_SIZE,                   /* SBRA                                   */ \
1757    3+LINK_SIZE,                   /* SCBRA                                  */ \    1+LINK_SIZE,                   /* SBRAPOS                                */ \
1758      1+LINK_SIZE+IMM2_SIZE,         /* SCBRA                                  */ \
1759      1+LINK_SIZE+IMM2_SIZE,         /* SCBRAPOS                               */ \
1760    1+LINK_SIZE,                   /* SCOND                                  */ \    1+LINK_SIZE,                   /* SCOND                                  */ \
1761    3, 3,                          /* CREF, NCREF                            */ \    1+IMM2_SIZE, 1+IMM2_SIZE,      /* CREF, NCREF                            */ \
1762    3, 3,                          /* RREF, NRREF                            */ \    1+IMM2_SIZE, 1+IMM2_SIZE,      /* RREF, NRREF                            */ \
1763    1,                             /* DEF                                    */ \    1,                             /* DEF                                    */ \
1764    1, 1,                          /* BRAZERO, BRAMINZERO                    */ \    1, 1, 1,                       /* BRAZERO, BRAMINZERO, BRAPOSZERO        */ \
1765    1, 1, 1, 1,                    /* PRUNE, SKIP, THEN, COMMIT,             */ \    3, 1, 3,                       /* MARK, PRUNE, PRUNE_ARG                 */ \
1766    1, 1, 3, 1                     /* FAIL, ACCEPT, CLOSE, SKIPZERO          */    1, 3,                          /* SKIP, SKIP_ARG                         */ \
1767      1, 3,                          /* THEN, THEN_ARG                         */ \
1768      1, 1, 1, 1,                    /* COMMIT, FAIL, ACCEPT, ASSERT_ACCEPT    */ \
1769      1+IMM2_SIZE, 1                 /* CLOSE, SKIPZERO                        */
1770    
1771  /* A magic value for OP_RREF and OP_NRREF to indicate the "any recursion"  /* A magic value for OP_RREF and OP_NRREF to indicate the "any recursion"
1772  condition. */  condition. */
1773    
1774  #define RREF_ANY  0xffff  #define RREF_ANY  0xffff
1775    
1776  /* Error code numbers. They are given names so that they can more easily be  /* Compile time error code numbers. They are given names so that they can more
1777  tracked. */  easily be tracked. When a new number is added, the table called eint in
1778    pcreposix.c must be updated. */
1779    
1780  enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,  enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,
1781         ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,         ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,
# Line 1501  enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4, Line 1783  enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,
1783         ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,         ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
1784         ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,         ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
1785         ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,         ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
1786         ERR60, ERR61, ERR62, ERR63, ERR64, ERR65 };         ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69,
1787           ERR70, ERR71, ERRCOUNT };
1788    
1789  /* The real format of the start of the pcre block; the index of names and the  /* The real format of the start of the pcre block; the index of names and the
1790  code vector run on as long as necessary after the end. We store an explicit  code vector run on as long as necessary after the end. We store an explicit
# Line 1528  typedef struct real_pcre { Line 1811  typedef struct real_pcre {
1811    pcre_uint16 dummy1;             /* For future use */    pcre_uint16 dummy1;             /* For future use */
1812    pcre_uint16 top_bracket;    pcre_uint16 top_bracket;
1813    pcre_uint16 top_backref;    pcre_uint16 top_backref;
1814    pcre_uint16 first_byte;    pcre_uint16 first_char;         /* Starting character */
1815    pcre_uint16 req_byte;    pcre_uint16 req_char;           /* This character must be seen */
1816    pcre_uint16 name_table_offset;  /* Offset to name table that follows */    pcre_uint16 name_table_offset;  /* Offset to name table that follows */
1817    pcre_uint16 name_entry_size;    /* Size of any name items */    pcre_uint16 name_entry_size;    /* Size of any name items */
1818    pcre_uint16 name_count;         /* Number of name items */    pcre_uint16 name_count;         /* Number of name items */
1819    pcre_uint16 ref_count;          /* Reference count */    pcre_uint16 ref_count;          /* Reference count */
1820    
1821    const unsigned char *tables;    /* Pointer to tables or NULL for std */    const pcre_uint8 *tables;       /* Pointer to tables or NULL for std */
1822    const unsigned char *nullpad;   /* NULL padding */    const pcre_uint8 *nullpad;      /* NULL padding */
1823  } real_pcre;  } real_pcre;
1824    
1825  /* The format of the block used to store data from pcre_study(). The same  /* The format of the block used to store data from pcre_study(). The same
# Line 1545  remark (see NOTE above) about extending Line 1828  remark (see NOTE above) about extending
1828  typedef struct pcre_study_data {  typedef struct pcre_study_data {
1829    pcre_uint32 size;               /* Total that was malloced */    pcre_uint32 size;               /* Total that was malloced */
1830    pcre_uint32 flags;              /* Private flags */    pcre_uint32 flags;              /* Private flags */
1831    uschar start_bits[32];          /* Starting char bits */    pcre_uint8 start_bits[32];      /* Starting char bits */
1832    pcre_uint32 minlength;          /* Minimum subject length */    pcre_uint32 minlength;          /* Minimum subject length */
1833  } pcre_study_data;  } pcre_study_data;
1834    
1835  /* Structure for building a chain of open capturing subpatterns during  /* Structure for building a chain of open capturing subpatterns during
1836  compiling, so that instructions to close them can be compiled when (*ACCEPT) is  compiling, so that instructions to close them can be compiled when (*ACCEPT) is
1837  encountered. */  encountered. This is also used to identify subpatterns that contain recursive
1838    back references to themselves, so that they can be made atomic. */
1839    
1840  typedef struct open_capitem {  typedef struct open_capitem {
1841    struct open_capitem *next;    /* Chain link */    struct open_capitem *next;    /* Chain link */
1842    pcre_uint16 number;           /* Capture number */    pcre_uint16 number;           /* Capture number */
1843      pcre_uint16 flag;             /* Set TRUE if recursive back ref */
1844  } open_capitem;  } open_capitem;
1845    
1846  /* Structure for passing "static" information around between the functions  /* Structure for passing "static" information around between the functions
1847  doing the compiling, so that they are thread-safe. */  doing the compiling, so that they are thread-safe. */
1848    
1849  typedef struct compile_data {  typedef struct compile_data {
1850    const uschar *lcc;            /* Points to lower casing table */    const pcre_uint8 *lcc;            /* Points to lower casing table */
1851    const uschar *fcc;            /* Points to case-flipping table */    const pcre_uint8 *fcc;            /* Points to case-flipping table */
1852    const uschar *cbits;          /* Points to character type table */    const pcre_uint8 *cbits;          /* Points to character type table */
1853    const uschar *ctypes;         /* Points to table of type maps */    const pcre_uint8 *ctypes;         /* Points to table of type maps */
1854    const uschar *start_workspace;/* The start of working space */    const pcre_uchar *start_workspace;/* The start of working space */
1855    const uschar *start_code;     /* The start of the compiled code */    const pcre_uchar *start_code;     /* The start of the compiled code */
1856    const uschar *start_pattern;  /* The start of the pattern */    const pcre_uchar *start_pattern;  /* The start of the pattern */
1857    const uschar *end_pattern;    /* The end of the pattern */    const pcre_uchar *end_pattern;    /* The end of the pattern */
1858    open_capitem *open_caps;      /* Chain of open capture items */    open_capitem *open_caps;          /* Chain of open capture items */
1859    uschar *hwm;                  /* High watermark of workspace */    pcre_uchar *hwm;                  /* High watermark of workspace */
1860    uschar *name_table;           /* The name/number table */    pcre_uchar *name_table;           /* The name/number table */
1861    int  names_found;             /* Number of entries so far */    int  names_found;                 /* Number of entries so far */
1862    int  name_entry_size;         /* Size of each entry */    int  name_entry_size;             /* Size of each entry */
1863    int  bracount;                /* Count of capturing parens as we compile */    int  bracount;                    /* Count of capturing parens as we compile */
1864    int  final_bracount;          /* Saved value after first pass */    int  final_bracount;              /* Saved value after first pass */
1865    int  top_backref;             /* Maximum back reference */    int  top_backref;                 /* Maximum back reference */
1866    unsigned int backref_map;     /* Bitmap of low back refs */    unsigned int backref_map;         /* Bitmap of low back refs */
1867    int  external_options;        /* External (initial) options */    int  assert_depth;                /* Depth of nested assertions */
1868    int  external_flags;          /* External flag bits to be set */    int  external_options;            /* External (initial) options */
1869    int  req_varyopt;             /* "After variable item" flag for reqbyte */    int  external_flags;              /* External flag bits to be set */
1870    BOOL had_accept;              /* (*ACCEPT) encountered */    int  req_varyopt;                 /* "After variable item" flag for reqbyte */
1871    BOOL check_lookbehind;        /* Lookbehinds need later checking */    BOOL had_accept;                  /* (*ACCEPT) encountered */
1872    int  nltype;                  /* Newline type */    BOOL check_lookbehind;            /* Lookbehinds need later checking */
1873    int  nllen;                   /* Newline string length */    int  nltype;                      /* Newline type */
1874    uschar nl[4];                 /* Newline string when fixed length */    int  nllen;                       /* Newline string length */
1875      pcre_uchar nl[4];                 /* Newline string when fixed length */
1876  } compile_data;  } compile_data;
1877    
1878  /* Structure for maintaining a chain of pointers to the currently incomplete  /* Structure for maintaining a chain of pointers to the currently incomplete
1879  branches, for testing for left recursion. */  branches, for testing for left recursion while compiling. */
1880    
1881  typedef struct branch_chain {  typedef struct branch_chain {
1882    struct branch_chain *outer;    struct branch_chain *outer;
1883    uschar *current_branch;    pcre_uchar *current_branch;
1884  } branch_chain;  } branch_chain;
1885    
1886  /* Structure for items in a linked list that represents an explicit recursive  /* Structure for items in a linked list that represents an explicit recursive
1887  call within the pattern. */  call within the pattern; used by pcre_exec(). */
1888    
1889  typedef struct recursion_info {  typedef struct recursion_info {
1890    struct recursion_info *prevrec; /* Previous recursion record (or NULL) */    struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
1891    int group_num;                /* Number of group that was called */    int group_num;                  /* Number of group that was called */
1892    const uschar *after_call;     /* "Return value": points after the call in the expr */    int *offset_save;               /* Pointer to start of saved offsets */
1893    USPTR save_start;             /* Old value of mstart */    int saved_max;                  /* Number of saved offsets */
1894    int *offset_save;             /* Pointer to start of saved offsets */    PCRE_PUCHAR subject_position;   /* Position at start of recursion */
   int saved_max;                /* Number of saved offsets */  
   int save_offset_top;          /* Current value of offset_top */  
1895  } recursion_info;  } recursion_info;
1896    
1897    /* A similar structure for pcre_dfa_exec(). */
1898    
1899    typedef struct dfa_recursion_info {
1900      struct dfa_recursion_info *prevrec;
1901      int group_num;
1902      PCRE_PUCHAR subject_position;
1903    } dfa_recursion_info;
1904    
1905  /* Structure for building a chain of data for holding the values of the subject  /* Structure for building a chain of data for holding the values of the subject
1906  pointer at the start of each subpattern, so as to detect when an empty string  pointer at the start of each subpattern, so as to detect when an empty string
1907  has been matched by a subpattern - to break infinite loops. */  has been matched by a subpattern - to break infinite loops; used by
1908    pcre_exec(). */
1909    
1910  typedef struct eptrblock {  typedef struct eptrblock {
1911    struct eptrblock *epb_prev;    struct eptrblock *epb_prev;
1912    USPTR epb_saved_eptr;    PCRE_PUCHAR epb_saved_eptr;
1913  } eptrblock;  } eptrblock;
1914    
1915    
# Line 1627  typedef struct match_data { Line 1920  typedef struct match_data {
1920    unsigned long int match_call_count;      /* As it says */    unsigned long int match_call_count;      /* As it says */
1921    unsigned long int match_limit;           /* As it says */    unsigned long int match_limit;           /* As it says */
1922    unsigned long int match_limit_recursion; /* As it says */    unsigned long int match_limit_recursion; /* As it says */
1923    int   *offset_vector;         /* Offset vector */    int   *offset_vector;           /* Offset vector */
1924    int    offset_end;            /* One past the end */    int    offset_end;              /* One past the end */
1925    int    offset_max;            /* The maximum usable for return data */    int    offset_max;              /* The maximum usable for return data */
1926    int    nltype;                /* Newline type */    int    nltype;                  /* Newline type */
1927    int    nllen;                 /* Newline string length */    int    nllen;                   /* Newline string length */
1928    int    name_count;            /* Number of names in name table */    int    name_count;              /* Number of names in name table */
1929    int    name_entry_size;       /* Size of entry in names table */    int    name_entry_size;         /* Size of entry in names table */
1930    uschar *name_table;           /* Table of names */    pcre_uchar *name_table;         /* Table of names */
1931    uschar nl[4];                 /* Newline string when fixed */    pcre_uchar nl[4];               /* Newline string when fixed */
1932    const uschar *lcc;            /* Points to lower casing table */    const  pcre_uint8 *lcc;         /* Points to lower casing table */
1933    const uschar *ctypes;         /* Points to table of type maps */    const  pcre_uint8 *ctypes;      /* Points to table of type maps */
1934    BOOL   offset_overflow;       /* Set if too many extractions */    BOOL   offset_overflow;         /* Set if too many extractions */
1935    BOOL   notbol;                /* NOTBOL flag */    BOOL   notbol;                  /* NOTBOL flag */
1936    BOOL   noteol;                /* NOTEOL flag */    BOOL   noteol;                  /* NOTEOL flag */
1937    BOOL   utf8;                  /* UTF8 flag */    BOOL   utf;                     /* UTF-8 / UTF-16 flag */
1938    BOOL   jscript_compat;        /* JAVASCRIPT_COMPAT flag */    BOOL   jscript_compat;          /* JAVASCRIPT_COMPAT flag */
1939    BOOL   endonly;               /* Dollar not before final \n */    BOOL   use_ucp;                 /* PCRE_UCP flag */
1940    BOOL   notempty;              /* Empty string match not wanted */    BOOL   endonly;                 /* Dollar not before final \n */
1941    BOOL   notempty_atstart;      /* Empty string match at start not wanted */    BOOL   notempty;                /* Empty string match not wanted */
1942    BOOL   hitend;                /* Hit the end of the subject at some point */    BOOL   notempty_atstart;        /* Empty string match at start not wanted */
1943    BOOL   bsr_anycrlf;           /* \R is just any CRLF, not full Unicode */    BOOL   hitend;                  /* Hit the end of the subject at some point */
1944    const uschar *start_code;     /* For use when recursing */    BOOL   bsr_anycrlf;             /* \R is just any CRLF, not full Unicode */
1945    USPTR  start_subject;         /* Start of the subject string */    BOOL   hasthen;                 /* Pattern contains (*THEN) */
1946    USPTR  end_subject;           /* End of the subject string */    const  pcre_uchar *start_code;  /* For use when recursing */
1947    USPTR  start_match_ptr;       /* Start of matched string */    PCRE_PUCHAR start_subject;      /* Start of the subject string */
1948    USPTR  end_match_ptr;         /* Subject position at end match */    PCRE_PUCHAR end_subject;        /* End of the subject string */
1949    USPTR  start_used_ptr;        /* Earliest consulted character */    PCRE_PUCHAR start_match_ptr;    /* Start of matched string */
1950    int    partial;               /* PARTIAL options */    PCRE_PUCHAR end_match_ptr;      /* Subject position at end match */
1951    int    end_offset_top;        /* Highwater mark at end of match */    PCRE_PUCHAR start_used_ptr;     /* Earliest consulted character */
1952    int    capture_last;          /* Most recent capture number */    int    partial;                 /* PARTIAL options */
1953    int    start_offset;          /* The start offset value */    int    end_offset_top;          /* Highwater mark at end of match */
1954    eptrblock *eptrchain;         /* Chain of eptrblocks for tail recursions */    int    capture_last;            /* Most recent capture number */
1955    int    eptrn;                 /* Next free eptrblock */    int    start_offset;            /* The start offset value */
1956    recursion_info *recursive;    /* Linked list of recursion data */    int    match_function_type;     /* Set for certain special calls of MATCH() */
1957    void  *callout_data;          /* To pass back to callouts */    eptrblock *eptrchain;           /* Chain of eptrblocks for tail recursions */
1958      int    eptrn;                   /* Next free eptrblock */
1959      recursion_info *recursive;      /* Linked list of recursion data */
1960      void  *callout_data;            /* To pass back to callouts */
1961      const  pcre_uchar *mark;        /* Mark pointer to pass back */
1962      const  pcre_uchar *once_target; /* Where to back up to for atomic groups */
1963  } match_data;  } match_data;
1964    
1965  /* A similar structure is used for the same purpose by the DFA matching  /* A similar structure is used for the same purpose by the DFA matching
1966  functions. */  functions. */
1967    
1968  typedef struct dfa_match_data {  typedef struct dfa_match_data {
1969    const uschar *start_code;     /* Start of the compiled pattern */    const pcre_uchar *start_code;     /* Start of the compiled pattern */
1970    const uschar *start_subject;  /* Start of the subject string */    const pcre_uchar *start_subject ; /* Start of the subject string */
1971    const uschar *end_subject;    /* End of subject string */    const pcre_uchar *end_subject;    /* End of subject string */
1972    const uschar *start_used_ptr; /* Earliest consulted character */    const pcre_uchar *start_used_ptr; /* Earliest consulted character */
1973    const uschar *tables;         /* Character tables */    const pcre_uint8 *tables;         /* Character tables */
1974    int   start_offset;           /* The start offset value */    int   start_offset;               /* The start offset value */
1975    int   moptions;               /* Match options */    int   moptions;                   /* Match options */
1976    int   poptions;               /* Pattern options */    int   poptions;                   /* Pattern options */
1977    int    nltype;                /* Newline type */    int   nltype;                     /* Newline type */
1978    int    nllen;                 /* Newline string length */    int   nllen;                      /* Newline string length */
1979    uschar nl[4];                 /* Newline string when fixed */    pcre_uchar nl[4];                 /* Newline string when fixed */
1980    void  *callout_data;          /* To pass back to callouts */    void *callout_data;               /* To pass back to callouts */
1981      dfa_recursion_info *recursive;    /* Linked list of recursion data */
1982  } dfa_match_data;  } dfa_match_data;
1983    
1984  /* Bit definitions for entries in the pcre_ctypes table. */  /* Bit definitions for entries in the pcre_ctypes table. */
# Line 1715  total length. */ Line 2014  total length. */
2014  #define ctypes_offset (cbits_offset + cbit_length)  #define ctypes_offset (cbits_offset + cbit_length)
2015  #define tables_length (ctypes_offset + 256)  #define tables_length (ctypes_offset + 256)
2016    
2017    /* Internal function prefix */
2018    
2019    #ifdef COMPILE_PCRE8
2020    #define PRIV(name) _pcre_##name
2021    #else
2022    #ifdef COMPILE_PCRE16
2023    #define PRIV(name) _pcre16_##name
2024    #else
2025    #error Unsupported compiling mode
2026    #endif /* COMPILE_PCRE16 */
2027    #endif /* COMPILE_PCRE8 */
2028    
2029  /* Layout of the UCP type table that translates property names into types and  /* Layout of the UCP type table that translates property names into types and
2030  codes. Each entry used to point directly to a name, but to reduce the number of  codes. Each entry used to point directly to a name, but to reduce the number of
2031  relocations in shared libraries, it now has an offset into a single string  relocations in shared libraries, it now has an offset into a single string
# Line 1732  of the exported public functions. They h Line 2043  of the exported public functions. They h
2043  but are not part of the PCRE public API. The data for these tables is in the  but are not part of the PCRE public API. The data for these tables is in the
2044  pcre_tables.c module. */  pcre_tables.c module. */
2045    
2046  extern const int    _pcre_utf8_table1[];  extern const int            PRIV(utf8_table1)[];
2047  extern const int    _pcre_utf8_table2[];  extern const int            PRIV(utf8_table2)[];
2048  extern const int    _pcre_utf8_table3[];  extern const int            PRIV(utf8_table3)[];
2049  extern const uschar _pcre_utf8_table4[];  extern const pcre_uint8     PRIV(utf8_table4)[];
2050    
2051  extern const int    _pcre_utf8_table1_size;  extern const int            PRIV(utf8_table1_size);
2052    
2053  extern const char   _pcre_utt_names[];  extern const char           PRIV(utt_names)[];
2054  extern const ucp_type_table _pcre_utt[];  extern const ucp_type_table PRIV(utt)[];
2055  extern const int _pcre_utt_size;  extern const int            PRIV(utt_size);
2056    
2057  extern const uschar _pcre_default_tables[];  extern const pcre_uint8     PRIV(default_tables)[];
2058    
2059  extern const uschar _pcre_OP_lengths[];  extern const pcre_uint8     PRIV(OP_lengths)[];
2060    
2061    
2062  /* Internal shared functions. These are functions that are used by more than  /* Internal shared functions. These are functions that are used by more than
2063  one of the exported public functions. They have to be "external" in the C  one of the exported public functions. They have to be "external" in the C
2064  sense, but are not part of the PCRE public API. */  sense, but are not part of the PCRE public API. */
2065    
2066  extern const uschar *_pcre_find_bracket(const uschar *, BOOL, int);  /* String comparison functions. */
2067  extern BOOL          _pcre_is_newline(USPTR, int, USPTR, int *, BOOL);  #ifdef COMPILE_PCRE8
2068  extern int           _pcre_ord2utf8(int, uschar *);  
2069  extern real_pcre    *_pcre_try_flipped(const real_pcre *, real_pcre *,  #define STRCMP_UC_UC(str1, str2) \
2070                         const pcre_study_data *, pcre_study_data *);    strcmp((char *)(str1), (char *)(str2))
2071  extern int           _pcre_valid_utf8(USPTR, int);  #define STRCMP_UC_C8(str1, str2) \
2072  extern BOOL          _pcre_was_newline(USPTR, int, USPTR, int *, BOOL);    strcmp((char *)(str1), (str2))
2073  extern BOOL          _pcre_xclass(int, const uschar *);  #define STRNCMP_UC_UC(str1, str2, num) \
2074      strncmp((char *)(str1), (char *)(str2), (num))
2075    #define STRNCMP_UC_C8(str1, str2, num) \
2076      strncmp((char *)(str1), (str2), (num))
2077    #define STRLEN_UC(str) strlen((const char *)str)
2078    
2079    #else
2080    
2081    extern int               PRIV(strcmp_uc_uc)(const pcre_uchar *,
2082                               const pcre_uchar *);
2083    extern int               PRIV(strcmp_uc_c8)(const pcre_uchar *,
2084                               const char *);
2085    extern int               PRIV(strncmp_uc_uc)(const pcre_uchar *,
2086                               const pcre_uchar *, unsigned int num);
2087    extern int               PRIV(strncmp_uc_c8)(const pcre_uchar *,
2088                               const char *, unsigned int num);
2089    extern unsigned int      PRIV(strlen_uc)(const pcre_uchar *str);
2090    
2091    #define STRCMP_UC_UC(str1, str2) \
2092      PRIV(strcmp_uc_uc)((str1), (str2))
2093    #define STRCMP_UC_C8(str1, str2) \
2094      PRIV(strcmp_uc_c8)((str1), (str2))
2095    #define STRNCMP_UC_UC(str1, str2, num) \
2096      PRIV(strncmp_uc_uc)((str1), (str2), (num))
2097    #define STRNCMP_UC_C8(str1, str2, num) \
2098      PRIV(strncmp_uc_c8)((str1), (str2), (num))
2099    #define STRLEN_UC(str) PRIV(strlen_uc)(str)
2100    
2101    #endif /* COMPILE_PCRE8 */
2102    
2103    extern const pcre_uchar *PRIV(find_bracket)(const pcre_uchar *, BOOL, int);
2104    extern BOOL              PRIV(is_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
2105                               int *, BOOL);
2106    extern int               PRIV(ord2utf)(pcre_uint32, pcre_uchar *);
2107    extern real_pcre        *PRIV(try_flipped)(const real_pcre *, real_pcre *,
2108                               const pcre_study_data *, pcre_study_data *);
2109    extern int               PRIV(valid_utf)(PCRE_PUCHAR, int, int *);
2110    extern BOOL              PRIV(was_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
2111                               int *, BOOL);
2112    extern BOOL              PRIV(xclass)(int, const pcre_uchar *);
2113    
2114    #ifdef SUPPORT_JIT
2115    extern void              PRIV(jit_compile)(const real_pcre *, pcre_extra *);
2116    extern int               PRIV(jit_exec)(const real_pcre *, void *,
2117                               const pcre_uchar *, int, int, int, int, int *, int);
2118    extern void              PRIV(jit_free)(void *);
2119    #endif
2120    
2121  /* Unicode character database (UCD) */  /* Unicode character database (UCD) */
2122    
2123  typedef struct {  typedef struct {
2124    uschar script;    pcre_uint8 script;
2125    uschar chartype;    pcre_uint8 chartype;
2126    pcre_int32 other_case;    pcre_int32 other_case;
2127  } ucd_record;  } ucd_record;
2128    
2129  extern const ucd_record  _pcre_ucd_records[];  extern const ucd_record  PRIV(ucd_records)[];
2130  extern const uschar      _pcre_ucd_stage1[];  extern const pcre_uint8  PRIV(ucd_stage1)[];
2131  extern const pcre_uint16 _pcre_ucd_stage2[];  extern const pcre_uint16 PRIV(ucd_stage2)[];
2132  extern const int         _pcre_ucp_gentype[];  extern const int         PRIV(ucp_gentype)[];
2133    #ifdef SUPPORT_JIT
2134    extern const int         PRIV(ucp_typerange)[];
2135    #endif
2136    
2137  /* UCD access macros */  /* UCD access macros */
2138    
2139  #define UCD_BLOCK_SIZE 128  #define UCD_BLOCK_SIZE 128
2140  #define GET_UCD(ch) (_pcre_ucd_records + \  #define GET_UCD(ch) (PRIV(ucd_records) + \
2141          _pcre_ucd_stage2[_pcre_ucd_stage1[(ch) / UCD_BLOCK_SIZE] * \          PRIV(ucd_stage2)[PRIV(ucd_stage1)[(ch) / UCD_BLOCK_SIZE] * \
2142          UCD_BLOCK_SIZE + ch % UCD_BLOCK_SIZE])          UCD_BLOCK_SIZE + (ch) % UCD_BLOCK_SIZE])
2143    
2144  #define UCD_CHARTYPE(ch)  GET_UCD(ch)->chartype  #define UCD_CHARTYPE(ch)  GET_UCD(ch)->chartype
2145  #define UCD_SCRIPT(ch)    GET_UCD(ch)->script  #define UCD_SCRIPT(ch)    GET_UCD(ch)->script
2146  #define UCD_CATEGORY(ch)  _pcre_ucp_gentype[UCD_CHARTYPE(ch)]  #define UCD_CATEGORY(ch)  PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
2147  #define UCD_OTHERCASE(ch) (ch + GET_UCD(ch)->other_case)  #define UCD_OTHERCASE(ch) (ch + GET_UCD(ch)->other_case)
2148    
2149  #endif  #endif

Legend:
Removed from v.483  
changed lines
  Added in v.781

  ViewVC Help
Powered by ViewVC 1.1.5