/[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 1197 by chpe, Thu Nov 1 19:23:27 2012 UTC revision 1199 by chpe, Sat Nov 3 19:21:37 2012 UTC
# Line 279  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 351  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 934  into one pcre_uchar unit. */ Line 936  into one pcre_uchar unit. */
936    
937  #define UTF32_MASK (0x1fffffu)  #define UTF32_MASK (0x1fffffu)
938    
939    /* 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 978  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

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

  ViewVC Help
Powered by ViewVC 1.1.5