/[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 345 by ph10, Mon Apr 28 15:10:02 2008 UTC revision 389 by ph10, Sun Mar 15 18:24:05 2009 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-2008 University of Cambridge             Copyright (c) 1997-2009 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 132  PCRE_EXP_DATA_DEFN only if they are not Line 132  PCRE_EXP_DATA_DEFN only if they are not
132  #  endif  #  endif
133  #endif  #endif
134    
135    /* When compiling with the MSVC compiler, it is sometimes necessary to include
136    a "calling convention" before exported function names. (This is secondhand
137    information; I know nothing about MSVC myself). For example, something like
138    
139      void __cdecl function(....)
140    
141    might be needed. In order so make this easy, all the exported functions have
142    PCRE_CALL_CONVENTION just before their names. It is rarely needed; if not
143    set, we ensure here that it has no effect. */
144    
145    #ifndef PCRE_CALL_CONVENTION
146    #define PCRE_CALL_CONVENTION
147    #endif
148    
149  /* We need to have types that specify unsigned 16-bit and 32-bit integers. We  /* We need to have types that specify unsigned 16-bit and 32-bit integers. We
150  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
151  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
# Line 140  preprocessor time in standard C environm Line 154  preprocessor time in standard C environm
154    
155  #if USHRT_MAX == 65535  #if USHRT_MAX == 65535
156    typedef unsigned short pcre_uint16;    typedef unsigned short pcre_uint16;
157      typedef short pcre_int16;
158  #elif UINT_MAX == 65535  #elif UINT_MAX == 65535
159    typedef unsigned int pcre_uint16;    typedef unsigned int pcre_uint16;
160      typedef int pcre_int16;
161  #else  #else
162    #error Cannot determine a type for 16-bit unsigned integers    #error Cannot determine a type for 16-bit unsigned integers
163  #endif  #endif
164    
165  #if UINT_MAX == 4294967295  #if UINT_MAX == 4294967295
166    typedef unsigned int pcre_uint32;    typedef unsigned int pcre_uint32;
167      typedef int pcre_int32;
168  #elif ULONG_MAX == 4294967295  #elif ULONG_MAX == 4294967295
169    typedef unsigned long int pcre_uint32;    typedef unsigned long int pcre_uint32;
170      typedef long int pcre_int32;
171  #else  #else
172    #error Cannot determine a type for 32-bit unsigned integers    #error Cannot determine a type for 32-bit unsigned integers
173  #endif  #endif
# Line 363  never be called in byte mode. To make su Line 381  never be called in byte mode. To make su
381  support is omitted, we don't even define it. */  support is omitted, we don't even define it. */
382    
383  #ifndef SUPPORT_UTF8  #ifndef SUPPORT_UTF8
 #define NEXTCHAR(p) p++;  
384  #define GETCHAR(c, eptr) c = *eptr;  #define GETCHAR(c, eptr) c = *eptr;
385  #define GETCHARTEST(c, eptr) c = *eptr;  #define GETCHARTEST(c, eptr) c = *eptr;
386  #define GETCHARINC(c, eptr) c = *eptr++;  #define GETCHARINC(c, eptr) c = *eptr++;
# Line 373  support is omitted, we don't even define Line 390  support is omitted, we don't even define
390    
391  #else   /* SUPPORT_UTF8 */  #else   /* SUPPORT_UTF8 */
392    
 /* Advance a character pointer one byte in non-UTF-8 mode and by one character  
 in UTF-8 mode. */  
   
 #define NEXTCHAR(p) \  
   p++; \  
   if (utf8) { while((*p & 0xc0) == 0x80) p++; }  
   
393  /* 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
394  we know we are in UTF-8 mode. */  we know we are in UTF-8 mode. */
395    
# Line 468  if there are extra bytes. This is called Line 478  if there are extra bytes. This is called
478      len += gcaa; \      len += gcaa; \
479      }      }
480    
481    /* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
482    pointer, incrementing length if there are extra bytes. This is called when we
483    know we are in UTF-8 mode. */
484    
485    #define GETCHARLENTEST(c, eptr, len) \
486      c = *eptr; \
487      if (utf8 && c >= 0xc0) \
488        { \
489        int gcii; \
490        int gcaa = _pcre_utf8_table4[c & 0x3f];  /* Number of additional bytes */ \
491        int gcss = 6*gcaa; \
492        c = (c & _pcre_utf8_table3[gcaa]) << gcss; \
493        for (gcii = 1; gcii <= gcaa; gcii++) \
494          { \
495          gcss -= 6; \
496          c |= (eptr[gcii] & 0x3f) << gcss; \
497          } \
498        len += gcaa; \
499        }
500    
501  /* 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
502  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
503  because almost all calls are already within a block of UTF-8 only code. */  because almost all calls are already within a block of UTF-8 only code. */
# Line 510  time, run time, or study time, respectiv Line 540  time, run time, or study time, respectiv
540  #define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \  #define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \
541                             PCRE_NEWLINE_ANYCRLF)                             PCRE_NEWLINE_ANYCRLF)
542    
543  #define PUBLIC_OPTIONS \  #define PUBLIC_COMPILE_OPTIONS \
544    (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \    (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
545     PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \     PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
546     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| \
# Line 519  time, run time, or study time, respectiv Line 549  time, run time, or study time, respectiv
549    
550  #define PUBLIC_EXEC_OPTIONS \  #define PUBLIC_EXEC_OPTIONS \
551    (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \    (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
552     PCRE_PARTIAL|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)     PCRE_PARTIAL|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
553       PCRE_NO_START_OPTIMIZE)
554    
555  #define PUBLIC_DFA_EXEC_OPTIONS \  #define PUBLIC_DFA_EXEC_OPTIONS \
556    (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \    (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NO_UTF8_CHECK| \
557     PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART|PCRE_NEWLINE_BITS| \     PCRE_PARTIAL|PCRE_DFA_SHORTEST|PCRE_DFA_RESTART|PCRE_NEWLINE_BITS| \
558     PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)     PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE|PCRE_NO_START_OPTIMIZE)
559    
560  #define PUBLIC_STUDY_OPTIONS 0   /* None defined */  #define PUBLIC_STUDY_OPTIONS 0   /* None defined */
561    
# Line 549  variable-length repeat, or a anything ot Line 580  variable-length repeat, or a anything ot
580  #define REQ_CASELESS 0x0100    /* indicates caselessness */  #define REQ_CASELESS 0x0100    /* indicates caselessness */
581  #define REQ_VARY     0x0200    /* reqbyte followed non-literal item */  #define REQ_VARY     0x0200    /* reqbyte followed non-literal item */
582    
583  /* Miscellaneous definitions */  /* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in
584    environments where these macros are defined elsewhere. Unfortunately, there
585    is no way to do the same for the typedef. */
586    
587  typedef int BOOL;  typedef int BOOL;
588    
589    #ifndef FALSE
590  #define FALSE   0  #define FALSE   0
591  #define TRUE    1  #define TRUE    1
592    #endif
593    
594  /* Escape items that are just an encoding of a particular data value. */  /* Escape items that are just an encoding of a particular data value. */
595    
# Line 1126  extern BOOL         _pcre_is_newline(con Line 1161  extern BOOL         _pcre_is_newline(con
1161  extern int          _pcre_ord2utf8(int, uschar *);  extern int          _pcre_ord2utf8(int, uschar *);
1162  extern real_pcre   *_pcre_try_flipped(const real_pcre *, real_pcre *,  extern real_pcre   *_pcre_try_flipped(const real_pcre *, real_pcre *,
1163                        const pcre_study_data *, pcre_study_data *);                        const pcre_study_data *, pcre_study_data *);
 extern int          _pcre_ucp_findprop(const unsigned int, int *, int *);  
 extern unsigned int _pcre_ucp_othercase(const unsigned int);  
1164  extern int          _pcre_valid_utf8(const uschar *, int);  extern int          _pcre_valid_utf8(const uschar *, int);
1165  extern BOOL         _pcre_was_newline(const uschar *, int, const uschar *,  extern BOOL         _pcre_was_newline(const uschar *, int, const uschar *,
1166                        int *, BOOL);                        int *, BOOL);
1167  extern BOOL         _pcre_xclass(int, const uschar *);  extern BOOL         _pcre_xclass(int, const uschar *);
1168    
1169    
1170    /* Unicode character database (UCD) */
1171    
1172    typedef struct {
1173      uschar script;
1174      uschar chartype;
1175      pcre_int32 other_case;
1176    } ucd_record;
1177    
1178    extern const ucd_record  _pcre_ucd_records[];
1179    extern const uschar      _pcre_ucd_stage1[];
1180    extern const pcre_uint16 _pcre_ucd_stage2[];
1181    extern const int         _pcre_ucp_gentype[];
1182    
1183    
1184    /* UCD access macros */
1185    
1186    #define UCD_BLOCK_SIZE 128
1187    #define GET_UCD(ch) (_pcre_ucd_records + \
1188            _pcre_ucd_stage2[_pcre_ucd_stage1[(ch) / UCD_BLOCK_SIZE] * \
1189            UCD_BLOCK_SIZE + ch % UCD_BLOCK_SIZE])
1190    
1191    #define UCD_CHARTYPE(ch)  GET_UCD(ch)->chartype
1192    #define UCD_SCRIPT(ch)    GET_UCD(ch)->script
1193    #define UCD_CATEGORY(ch)  _pcre_ucp_gentype[UCD_CHARTYPE(ch)]
1194    #define UCD_OTHERCASE(ch) (ch + GET_UCD(ch)->other_case)
1195    
1196  #endif  #endif
1197    
1198  /* End of pcre_internal.h */  /* End of pcre_internal.h */

Legend:
Removed from v.345  
changed lines
  Added in v.389

  ViewVC Help
Powered by ViewVC 1.1.5