summaryrefslogtreecommitdiff
path: root/pcre_internal.h
diff options
context:
space:
mode:
authorchpe <chpe@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-11-01 19:23:35 +0000
committerchpe <chpe@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-11-01 19:23:35 +0000
commitc683f7e1c262a656f0afbd73e85a5eed66849365 (patch)
tree2574a56a372a04b132c01da1587d3ba422347954 /pcre_internal.h
parent2281bb807408e94631a98a9c2c56bbef64fcde59 (diff)
downloadpcre-c683f7e1c262a656f0afbd73e85a5eed66849365.tar.gz
Rewrite 32-bit GETCHAR* macros
Move the high-bit masking to a dedicated macro, and use that in the GETCHAR* and RAWUCHAR* macros. git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1198 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_internal.h')
-rw-r--r--pcre_internal.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/pcre_internal.h b/pcre_internal.h
index 06aa614..3adc612 100644
--- a/pcre_internal.h
+++ b/pcre_internal.h
@@ -934,31 +934,41 @@ into one pcre_uchar unit. */
#define UTF32_MASK (0x1fffffu)
+/* Base macro to pick up an UTF-32 character out of a uint32 */
+
+#define MASKHIGHBITS(c) ((c) & UTF32_MASK)
+
+/* Base macro to pick up an UTF-32 character, not advancing the pointer */
+
+#define GETUTF32(eptr) (MASKHIGHBITS(*(eptr)))
+
+/* Base macro to pick up an UTF-32 character, advancing the pointer */
+
+#define GETUTF32INC(eptr) (MASKHIGHBITS(*((eptr)++)))
+
/* Get the next UTF-32 character, not advancing the pointer. This is called when
we know we are in UTF-32 mode. */
#define GETCHAR(c, eptr) \
- c = (*eptr) & UTF32_MASK;
+ c = GETUTF32(eptr);
/* Get the next UTF-32 character, testing for UTF-32 mode, and not advancing the
pointer. */
#define GETCHARTEST(c, eptr) \
- c = *eptr; \
- if (utf) c &= UTF32_MASK;
+ c = (utf ? GETUTF32(eptr) : *(eptr));
/* Get the next UTF-32 character, advancing the pointer. This is called when we
know we are in UTF-32 mode. */
#define GETCHARINC(c, eptr) \
- c = (*eptr++) & UTF32_MASK;
+ c = GETUTF32INC(eptr);
/* Get the next character, testing for UTF-32 mode, and advancing the pointer.
This is called when we don't know if we are in UTF-32 mode. */
#define GETCHARINCTEST(c, eptr) \
- c = *eptr++; \
- if (utf) c &= UTF32_MASK;
+ c = (utf ? GETUTF32INC(eptr) : *((eptr)++));
/* Get the next UTF-32 character, not advancing the pointer, not incrementing
length (since all UTF-32 is of length 1). This is called when we know we are in
@@ -978,25 +988,25 @@ This is called when we do not know if we are in UTF-32 mode. */
we know we are in UTF mode. */
#define RAWUCHAR(eptr) \
- (*(eptr) & UTF32_MASK)
+ (MASKHIGHBITS(*(eptr)))
/* Returns the next uchar, advancing the pointer. This is called when
we know we are in UTF mode. */
#define RAWUCHARINC(eptr) \
- (*((eptr)++) & UTF32_MASK)
+ (MASKHIGHBITS(*((eptr)++)))
/* Returns the next uchar, testing for UTF mode, and not advancing the
pointer. */
#define RAWUCHARTEST(eptr) \
- (utf ? (*(eptr) & UTF32_MASK) : *(eptr))
+ (utf ? (MASKHIGHBITS(*(eptr))) : *(eptr))
/* Returns the next uchar, testing for UTF mode, advancing the
pointer. */
#define RAWUCHARINCTEST(eptr) \
- (utf ? (*((eptr)++) & UTF32_MASK) : *((eptr)++))
+ (utf ? (MASKHIGHBITS(*((eptr)++))) : *((eptr)++))
/* If the pointer is not at the start of a character, move it back until
it is. This is called only in UTF-32 mode - we don't put a test within the