/[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

revision 781 by zherczeg, Sat Dec 3 07:58:30 2011 UTC revision 782 by zherczeg, Sat Dec 3 23:58:37 2011 UTC
# Line 531  not used when UTF-8 is not supported, so Line 531  not used when UTF-8 is not supported, so
531  never be called in byte mode. To make sure they can never even appear when  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. */  UTF-8 support is omitted, we don't even define them. */
533    
534  #ifndef SUPPORT_UTF8  /* #define HAS_EXTRALEN(c) */
535    /* #define GET_EXTRALEN(c) */
536    #ifndef SUPPORT_UTF
537  #define GETCHAR(c, eptr) c = *eptr;  #define GETCHAR(c, eptr) c = *eptr;
538  #define GETCHARTEST(c, eptr) c = *eptr;  #define GETCHARTEST(c, eptr) c = *eptr;
539  #define GETCHARINC(c, eptr) c = *eptr++;  #define GETCHARINC(c, eptr) c = *eptr++;
# Line 539  UTF-8 support is omitted, we don't even Line 541  UTF-8 support is omitted, we don't even
541  #define GETCHARLEN(c, eptr, len) c = *eptr;  #define GETCHARLEN(c, eptr, len) c = *eptr;
542  /* #define GETCHARLENTEST(c, eptr, len) */  /* #define GETCHARLENTEST(c, eptr, len) */
543  /* #define BACKCHAR(eptr) */  /* #define BACKCHAR(eptr) */
544    /* #define FORWARDCHAR(eptr) */
545    /* #define INTERNALCHAR(condition, eptr, action) */
546    
547    #else   /* SUPPORT_UTF */
548    
549  #else   /* SUPPORT_UTF8 */  #ifdef COMPILE_PCRE8
550    
551  /* These macros were originally written in the form of loops that used data  /* These macros were originally written in the form of loops that used data
552  from the tables whose names start with PRIV(utf8_table). They were rewritten by  from the tables whose names start with PRIV(utf8_table). They were rewritten by
553  a user so as not to use loops, because in some environments this gives a  a user so as not to use loops, because in some environments this gives a
554  significant performance advantage, and it seems never to do any harm. */  significant performance advantage, and it seems never to do any harm. */
555    
556    /* Tests whether the code point needs extra characters to decode. */
557    
558    #define HAS_EXTRALEN(c) ((c) >= 0xc0)
559    
560    /* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
561    Otherwise it has an undefined behaviour. */
562    
563    #define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3f])
564    
565  /* Base macro to pick up the remaining bytes of a UTF-8 character, not  /* Base macro to pick up the remaining bytes of a UTF-8 character, not
566  advancing the pointer. */  advancing the pointer. */
567    
# Line 689  because almost all calls are already wit Line 704  because almost all calls are already wit
704    
705  #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--  #define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
706    
707  #endif  /* SUPPORT_UTF8 */  /* Same as above, just in the other direction. */
708    #define FORWARDCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr++
709    
710    /* Same as above, but it allows a fully customizable form. */
711    #define INTERNALCHAR(condition, eptr, action) \
712      while((condition) && ((eptr) & 0xc0) == 0x80) action
713    
714    #else /* COMPILE_PCRE8 */
715    
716    #ifdef COMPILE_PCRE16
717    
718    /* Tests whether the code point needs extra characters to decode. */
719    
720    #define HAS_EXTRALEN(c) (((c) & 0xfc00) == 0xd800)
721    
722    /* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
723    Otherwise it has an undefined behaviour. */
724    
725    #define GET_EXTRALEN(c) 1
726    
727    /* Base macro to pick up the low surrogate of a UTF-16 character, not
728    advancing the pointer. */
729    
730    #define GETUTF16(c, eptr) \
731       { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; }
732    
733    /* Get the next UTF-16 character, not advancing the pointer. This is called when
734    we know we are in UTF-16 mode. */
735    
736    #define GETCHAR(c, eptr) \
737      c = *eptr; \
738      if ((c & 0xfc00) == 0xd800) GETUTF16(c, eptr);
739    
740    /* Get the next UTF-16 character, testing for UTF-16 mode, and not advancing the
741    pointer. */
742    
743    #define GETCHARTEST(c, eptr) \
744      c = *eptr; \
745      if (utf && (c & 0xfc00) == 0xd800) GETUTF16(c, eptr);
746    
747    /* Base macro to pick up the low surrogate of a UTF-16 character, advancing
748    the pointer. */
749    
750    #define GETUTF16INC(c, eptr) \
751       { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; eptr++; }
752    
753    /* Get the next UTF-16 character, advancing the pointer. This is called when we
754    know we are in UTF-16 mode. */
755    
756    #define GETCHARINC(c, eptr) \
757      c = *eptr++; \
758      if ((c & 0xfc00) == 0xd800) GETUTF16INC(c, eptr);
759    
760    /* Get the next character, testing for UTF-16 mode, and advancing the pointer.
761    This is called when we don't know if we are in UTF-16 mode. */
762    
763    #define GETCHARINCTEST(c, eptr) \
764      c = *eptr++; \
765      if (utf && (c & 0xfc00) == 0xd800) GETUTF16INC(c, eptr);
766    
767    /* Base macro to pick up the low surrogate of a UTF-16 character, not
768    advancing the pointer, incrementing the length. */
769    
770    #define GETUTF16LEN(c, eptr, len) \
771       { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; len++; }
772    
773    /* Get the next UTF-16 character, not advancing the pointer, incrementing
774    length if there is a low surrogate. This is called when we know we are in
775    UTF-16 mode. */
776    
777    #define GETCHARLEN(c, eptr, len) \
778      c = *eptr; \
779      if ((c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
780    
781    /* Get the next UTF-816character, testing for UTF-16 mode, not advancing the
782    pointer, incrementing length if there is a low surrogate. This is called when
783    we do not know if we are in UTF-16 mode. */
784    
785    #define GETCHARLENTEST(c, eptr, len) \
786      c = *eptr; \
787      if (utf && (c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
788    
789    /* If the pointer is not at the start of a character, move it back until
790    it is. This is called only in UTF-16 mode - we don't put a test within the
791    macro because almost all calls are already within a block of UTF-16 only
792    code. */
793    
794    #define BACKCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr--
795    
796    /* Same as above, just in the other direction. */
797    #define FORWARDCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr++
798    
799    /* Same as above, but it allows a fully customizable form. */
800    #define INTERNALCHAR(condition, eptr, action) \
801      if ((condition) && ((eptr) & 0xfc00) == 0xdc00) action
802    
803    #endif
804    
805    #endif /* COMPILE_PCRE8 */
806    
807    #endif  /* SUPPORT_UTF */
808    
809    
810  /* 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 2043  of the exported public functions. They h Line 2158  of the exported public functions. They h
2158  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
2159  pcre_tables.c module. */  pcre_tables.c module. */
2160    
2161    #ifdef COMPILE_PCRE8
2162    
2163  extern const int            PRIV(utf8_table1)[];  extern const int            PRIV(utf8_table1)[];
2164    extern const int            PRIV(utf8_table1_size);
2165  extern const int            PRIV(utf8_table2)[];  extern const int            PRIV(utf8_table2)[];
2166  extern const int            PRIV(utf8_table3)[];  extern const int            PRIV(utf8_table3)[];
2167  extern const pcre_uint8     PRIV(utf8_table4)[];  extern const pcre_uint8     PRIV(utf8_table4)[];
2168    
2169  extern const int            PRIV(utf8_table1_size);  #endif /* COMPILE_PCRE8 */
2170    
2171  extern const char           PRIV(utt_names)[];  extern const char           PRIV(utt_names)[];
2172  extern const ucp_type_table PRIV(utt)[];  extern const ucp_type_table PRIV(utt)[];

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

  ViewVC Help
Powered by ViewVC 1.1.5