/[pcre]/code/trunk/pcre_internal.h
ViewVC logotype

Diff of /code/trunk/pcre_internal.h

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

revision 1100 by chpe, Tue Oct 16 15:56:26 2012 UTC revision 1199 by chpe, Sat Nov 3 19:21:37 2012 UTC
# Line 53  depending on the PRIV macro. */ Line 53  depending on the PRIV macro. */
53  #endif  #endif
54    
55  /* PCRE is compiled as an 8 bit library if it is not requested otherwise. */  /* PCRE is compiled as an 8 bit library if it is not requested otherwise. */
56  #if !defined COMPILE_PCRE16 && ! defined COMPILE_PCRE32  
57    #if !defined COMPILE_PCRE16 && !defined COMPILE_PCRE32
58  #define COMPILE_PCRE8  #define COMPILE_PCRE8
59  #endif  #endif
60    
# Line 111  setjmp and stdarg are used is when NO_RE Line 112  setjmp and stdarg are used is when NO_RE
112  #include <stdlib.h>  #include <stdlib.h>
113  #include <string.h>  #include <string.h>
114    
115    /* Valgrind (memcheck) support */
116    
117    #ifdef SUPPORT_VALGRIND
118    #include <valgrind/memcheck.h>
119    #endif
120    
121  /* When compiling a DLL for Windows, the exported symbols have to be declared  /* When compiling a DLL for Windows, the exported symbols have to be declared
122  using some MS magic. I found some useful information on this web page:  using some MS magic. I found some useful information on this web page:
123  http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the  http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
# Line 214  stdint.h is available, include it; it ma Line 221  stdint.h is available, include it; it ma
221  have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set  have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set
222  by "configure". */  by "configure". */
223    
224  #if HAVE_STDINT_H  #if defined HAVE_STDINT_H
225  #include <stdint.h>  #include <stdint.h>
226  #elif HAVE_INTTYPES_H  #elif defined HAVE_INTTYPES_H
227  #include <inttypes.h>  #include <inttypes.h>
228  #endif  #endif
229    
# Line 272  typedef pcre_uint32 pcre_uchar; Line 279  typedef pcre_uint32 pcre_uchar;
279  #define MAX_255(c) ((c) <= 255u)  #define MAX_255(c) ((c) <= 255u)
280  #define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))  #define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
281    
 /* Assert that pcre_uchar32 is a 32-bit type */  
 typedef int __assert_pcre_uchar32_size[sizeof(pcre_uchar) == 4 ? 1 : -1];  
   
282  #else  #else
283  #error Unsupported compiling mode  #error Unsupported compiling mode
284  #endif /* COMPILE_PCRE[8|16|32] */  #endif /* COMPILE_PCRE[8|16|32] */
# Line 344  values. */ Line 348  values. */
348  #include "pcre.h"  #include "pcre.h"
349  #include "ucp.h"  #include "ucp.h"
350    
351    #ifdef COMPILE_PCRE32
352    /* Assert that the public PCRE_UCHAR32 is a 32-bit type */
353    typedef int __assert_pcre_uchar32_size[sizeof(PCRE_UCHAR32) == 4 ? 1 : -1];
354    #endif
355    
356  /* When compiling for use with the Virtual Pascal compiler, these functions  /* When compiling for use with the Virtual Pascal compiler, these functions
357  need to have their names changed. PCRE must be compiled with the -DVPCOMPAT  need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
358  option on the command line. */  option on the command line. */
# Line 522  capturing parenthesis numbers in back re Line 531  capturing parenthesis numbers in back re
531  #define PUT2(a,n,d)   \  #define PUT2(a,n,d)   \
532    a[n] = (d) >> 8; \    a[n] = (d) >> 8; \
533    a[(n)+1] = (d) & 255    a[(n)+1] = (d) & 255
534    
535    /* For reasons that I do not understand, the expression in this GET2 macro is
536    treated by gcc as a signed expression, even when a is declared as unsigned. It
537    seems that any kind of arithmetic results in a signed value. */
538    
539  #define GET2(a,n) \  #define GET2(a,n) \
540    (((a)[n] << 8) | (a)[(n)+1])    (unsigned int)(((a)[n] << 8) | (a)[(n)+1])
541    
542  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
543    
# Line 765  we know we are in UTF mode. */ Line 778  we know we are in UTF mode. */
778  we know we are in UTF mode. */  we know we are in UTF mode. */
779    
780  #define RAWUCHARINC(eptr) \  #define RAWUCHARINC(eptr) \
781    (*(eptr)++)    (*((eptr)++))
782    
783  /* Returns the next uchar, testing for UTF mode, and not advancing the  /* Returns the next uchar, testing for UTF mode, and not advancing the
784  pointer. */  pointer. */
# Line 777  pointer. */ Line 790  pointer. */
790  pointer. */  pointer. */
791    
792  #define RAWUCHARINCTEST(eptr) \  #define RAWUCHARINCTEST(eptr) \
793    (*(eptr)++)    (*((eptr)++))
794    
795  /* 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
796  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 884  we know we are in UTF mode. */ Line 897  we know we are in UTF mode. */
897  we know we are in UTF mode. */  we know we are in UTF mode. */
898    
899  #define RAWUCHARINC(eptr) \  #define RAWUCHARINC(eptr) \
900    (*(eptr)++)    (*((eptr)++))
901    
902  /* Returns the next uchar, testing for UTF mode, and not advancing the  /* Returns the next uchar, testing for UTF mode, and not advancing the
903  pointer. */  pointer. */
# Line 896  pointer. */ Line 909  pointer. */
909  pointer. */  pointer. */
910    
911  #define RAWUCHARINCTEST(eptr) \  #define RAWUCHARINCTEST(eptr) \
912    (*(eptr)++)    (*((eptr)++))
913    
914  /* 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
915  it is. This is called only in UTF-16 mode - we don't put a test within the  it is. This is called only in UTF-16 mode - we don't put a test within the
# Line 914  code. */ Line 927  code. */
927    
928  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
929    
930  /* These are unnecessary for the 32-bit library */  /* These are trivial for the 32-bit library, since all UTF-32 characters fit
931  #undef MAX_VALUE_FOR_SINGLE_CHAR  into one pcre_uchar unit. */
932  #undef HAS_EXTRALEN  #define MAX_VALUE_FOR_SINGLE_CHAR (0x10ffffu)
933  #undef GET_EXTRALEN  #define HAS_EXTRALEN(c) (0)
934  #undef NOT_FIRSTCHAR  #define GET_EXTRALEN(c) (0)
935    #define NOT_FIRSTCHAR(c) (0)
936    
937    #define UTF32_MASK (0x1fffffu)
938    
939  #define UTF32_MASK (0x1ffffful)  /* Base macro to pick up an UTF-32 character out of a uint32 */
940    
941    #define MASKHIGHBITS(c) ((c) & UTF32_MASK)
942    
943    /* Base macro to pick up an UTF-32 character, not advancing the pointer */
944    
945    #define GETUTF32(eptr) (MASKHIGHBITS(*(eptr)))
946    
947    /* Base macro to pick up an UTF-32 character, advancing the pointer */
948    
949    #define GETUTF32INC(eptr) (MASKHIGHBITS(*((eptr)++)))
950    
951  /* Get the next UTF-32 character, not advancing the pointer. This is called when  /* Get the next UTF-32 character, not advancing the pointer. This is called when
952  we know we are in UTF-32 mode. */  we know we are in UTF-32 mode. */
953    
954  #define GETCHAR(c, eptr) \  #define GETCHAR(c, eptr) \
955    c = (*eptr) & UTF32_MASK;    c = GETUTF32(eptr);
956    
957  /* Get the next UTF-32 character, testing for UTF-32 mode, and not advancing the  /* Get the next UTF-32 character, testing for UTF-32 mode, and not advancing the
958  pointer. */  pointer. */
959    
960  #define GETCHARTEST(c, eptr) \  #define GETCHARTEST(c, eptr) \
961    c = *eptr; \    c = (utf ? GETUTF32(eptr) : *(eptr));
   if (utf) c &= UTF32_MASK;  
962    
963  /* Get the next UTF-32 character, advancing the pointer. This is called when we  /* Get the next UTF-32 character, advancing the pointer. This is called when we
964  know we are in UTF-32 mode. */  know we are in UTF-32 mode. */
965    
966  #define GETCHARINC(c, eptr) \  #define GETCHARINC(c, eptr) \
967    c = (*eptr++) & UTF32_MASK;    c = GETUTF32INC(eptr);
968    
969  /* Get the next character, testing for UTF-32 mode, and advancing the pointer.  /* Get the next character, testing for UTF-32 mode, and advancing the pointer.
970  This is called when we don't know if we are in UTF-32 mode. */  This is called when we don't know if we are in UTF-32 mode. */
971    
972  #define GETCHARINCTEST(c, eptr) \  #define GETCHARINCTEST(c, eptr) \
973    c = *eptr++; \    c = (utf ? GETUTF32INC(eptr) : *((eptr)++));
   if (utf) c &= UTF32_MASK;  
974    
975  /* Get the next UTF-32 character, not advancing the pointer, not incrementing  /* Get the next UTF-32 character, not advancing the pointer, not incrementing
976  length (since all UTF-32 is of length 1). This is called when we know we are in  length (since all UTF-32 is of length 1). This is called when we know we are in
# Line 966  This is called when we do not know if we Line 990  This is called when we do not know if we
990  we know we are in UTF mode. */  we know we are in UTF mode. */
991    
992  #define RAWUCHAR(eptr) \  #define RAWUCHAR(eptr) \
993    (*(eptr) & UTF32_MASK)    (MASKHIGHBITS(*(eptr)))
994    
995  /* Returns the next uchar, advancing the pointer. This is called when  /* Returns the next uchar, advancing the pointer. This is called when
996  we know we are in UTF mode. */  we know we are in UTF mode. */
997    
998  #define RAWUCHARINC(eptr) \  #define RAWUCHARINC(eptr) \
999    (*(eptr)++ & UTF32_MASK)    (MASKHIGHBITS(*((eptr)++)))
1000    
1001  /* Returns the next uchar, testing for UTF mode, and not advancing the  /* Returns the next uchar, testing for UTF mode, and not advancing the
1002  pointer. */  pointer. */
1003    
1004  #define RAWUCHARTEST(eptr) \  #define RAWUCHARTEST(eptr) \
1005    (utf ? (*(eptr) & UTF32_MASK) : *(eptr))    (utf ? (MASKHIGHBITS(*(eptr))) : *(eptr))
1006    
1007  /* Returns the next uchar, testing for UTF mode, advancing the  /* Returns the next uchar, testing for UTF mode, advancing the
1008  pointer. */  pointer. */
1009    
1010  #define RAWUCHARINCTEST(eptr) \  #define RAWUCHARINCTEST(eptr) \
1011    (utf ? (*(eptr)++ & UTF32_MASK) : *(eptr)++)    (utf ? (MASKHIGHBITS(*((eptr)++))) : *((eptr)++))
1012    
1013  /* 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
1014  it is. This is called only in UTF-32 mode - we don't put a test within the  it is. This is called only in UTF-32 mode - we don't put a test within the
1015  macro because almost all calls are already within a block of UTF-32 only  macro because almost all calls are already within a block of UTF-32 only
1016  code. */  code.
1017    These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */
1018    
1019  #define BACKCHAR(eptr) do { } while (0)  #define BACKCHAR(eptr) do { } while (0)
1020    
# Line 1170  time, run time, or study time, respectiv Line 1195  time, run time, or study time, respectiv
1195     (PCRE_STUDY_JIT_COMPILE|PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE| \     (PCRE_STUDY_JIT_COMPILE|PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE| \
1196      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE|PCRE_STUDY_EXTRA_NEEDED)      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE|PCRE_STUDY_EXTRA_NEEDED)
1197    
1198    #define PUBLIC_JIT_EXEC_OPTIONS \
1199       (PCRE_NO_UTF8_CHECK|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|\
1200        PCRE_NOTEMPTY_ATSTART|PCRE_PARTIAL_SOFT|PCRE_PARTIAL_HARD)
1201    
1202  /* Magic number to provide a small check against being handed junk. */  /* Magic number to provide a small check against being handed junk. */
1203    
1204  #define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */  #define MAGIC_NUMBER  0x50435245UL   /* 'PCRE' */
# Line 1273  a positive value. */ Line 1302  a positive value. */
1302    
1303  /* The remaining definitions work in both environments. */  /* The remaining definitions work in both environments. */
1304    
1305    #define CHAR_NULL                   '\0'
1306  #define CHAR_HT                     '\t'  #define CHAR_HT                     '\t'
1307  #define CHAR_VT                     '\v'  #define CHAR_VT                     '\v'
1308  #define CHAR_FF                     '\f'  #define CHAR_FF                     '\f'
# Line 1542  only. */ Line 1572  only. */
1572  #define CHAR_ESC                    '\033'  #define CHAR_ESC                    '\033'
1573  #define CHAR_DEL                    '\177'  #define CHAR_DEL                    '\177'
1574    
1575    #define CHAR_NULL                   '\0'
1576  #define CHAR_SPACE                  '\040'  #define CHAR_SPACE                  '\040'
1577  #define CHAR_EXCLAMATION_MARK       '\041'  #define CHAR_EXCLAMATION_MARK       '\041'
1578  #define CHAR_QUOTATION_MARK         '\042'  #define CHAR_QUOTATION_MARK         '\042'
# Line 2391  typedef struct compile_data { Line 2422  typedef struct compile_data {
2422    int  names_found;                 /* Number of entries so far */    int  names_found;                 /* Number of entries so far */
2423    int  name_entry_size;             /* Size of each entry */    int  name_entry_size;             /* Size of each entry */
2424    int  workspace_size;              /* Size of workspace */    int  workspace_size;              /* Size of workspace */
2425    int  bracount;                    /* Count of capturing parens as we compile */    unsigned int  bracount;           /* Count of capturing parens as we compile */
2426    int  final_bracount;              /* Saved value after first pass */    int  final_bracount;              /* Saved value after first pass */
2427    int  max_lookbehind;              /* Maximum lookbehind (characters) */    int  max_lookbehind;              /* Maximum lookbehind (characters) */
2428    int  top_backref;                 /* Maximum back reference */    int  top_backref;                 /* Maximum back reference */
# Line 2421  call within the pattern; used by pcre_ex Line 2452  call within the pattern; used by pcre_ex
2452    
2453  typedef struct recursion_info {  typedef struct recursion_info {
2454    struct recursion_info *prevrec; /* Previous recursion record (or NULL) */    struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
2455    int group_num;                  /* Number of group that was called */    unsigned int group_num;         /* Number of group that was called */
2456    int *offset_save;               /* Pointer to start of saved offsets */    int *offset_save;               /* Pointer to start of saved offsets */
2457    int saved_max;                  /* Number of saved offsets */    int saved_max;                  /* Number of saved offsets */
2458    PCRE_PUCHAR subject_position;   /* Position at start of recursion */    PCRE_PUCHAR subject_position;   /* Position at start of recursion */
# Line 2679  extern int               PRIV(strcmp_uc_ Line 2710  extern int               PRIV(strcmp_uc_
2710  extern const pcre_uchar *PRIV(find_bracket)(const pcre_uchar *, BOOL, int);  extern const pcre_uchar *PRIV(find_bracket)(const pcre_uchar *, BOOL, int);
2711  extern BOOL              PRIV(is_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,  extern BOOL              PRIV(is_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
2712                             int *, BOOL);                             int *, BOOL);
2713  extern int               PRIV(ord2utf)(pcre_uint32, pcre_uchar *);  extern unsigned int      PRIV(ord2utf)(pcre_uint32, pcre_uchar *);
2714  extern int               PRIV(valid_utf)(PCRE_PUCHAR, int, int *);  extern int               PRIV(valid_utf)(PCRE_PUCHAR, int, int *);
2715  extern BOOL              PRIV(was_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,  extern BOOL              PRIV(was_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
2716                             int *, BOOL);                             int *, BOOL);
# Line 2688  extern BOOL              PRIV(xclass)(pc Line 2719  extern BOOL              PRIV(xclass)(pc
2719  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
2720  extern void              PRIV(jit_compile)(const REAL_PCRE *,  extern void              PRIV(jit_compile)(const REAL_PCRE *,
2721                             PUBL(extra) *, int);                             PUBL(extra) *, int);
2722  extern int               PRIV(jit_exec)(const REAL_PCRE *, const PUBL(extra) *,  extern int               PRIV(jit_exec)(const PUBL(extra) *,
2723                             const pcre_uchar *, int, int, int, int *, int);                             const pcre_uchar *, int, int, int, int *, int);
2724  extern void              PRIV(jit_free)(void *);  extern void              PRIV(jit_free)(void *);
2725  extern int               PRIV(jit_get_size)(void *);  extern int               PRIV(jit_get_size)(void *);
# Line 2709  extern const pcre_uint32 PRIV(ucd_casele Line 2740  extern const pcre_uint32 PRIV(ucd_casele
2740  extern const ucd_record  PRIV(ucd_records)[];  extern const ucd_record  PRIV(ucd_records)[];
2741  extern const pcre_uint8  PRIV(ucd_stage1)[];  extern const pcre_uint8  PRIV(ucd_stage1)[];
2742  extern const pcre_uint16 PRIV(ucd_stage2)[];  extern const pcre_uint16 PRIV(ucd_stage2)[];
2743  extern const int         PRIV(ucp_gentype)[];  extern const pcre_uint32 PRIV(ucp_gentype)[];
2744  extern const pcre_uint32 PRIV(ucp_gbtable)[];  extern const pcre_uint32 PRIV(ucp_gbtable)[];
2745  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
2746  extern const int         PRIV(ucp_typerange)[];  extern const int         PRIV(ucp_typerange)[];

Legend:
Removed from v.1100  
changed lines
  Added in v.1199

  ViewVC Help
Powered by ViewVC 1.1.5