summaryrefslogtreecommitdiff
path: root/utfebcdic.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-10-30 10:01:09 -0600
committerKarl Williamson <khw@cpan.org>2015-12-05 22:06:49 -0700
commite234db7ede8a67081f23cdec7790b8e7cfe746f1 (patch)
tree119d0cfa091bff8fd512f5c9f7613df2522bd954 /utfebcdic.h
parentc03c0950362cd6989da96074362b2d4456a8204d (diff)
downloadperl-e234db7ede8a67081f23cdec7790b8e7cfe746f1.tar.gz
utfebcdic.h: Use an internal macro to avoid repeating
This creates a macro that is used in portions of 2 other macros, thus removing repetition.
Diffstat (limited to 'utfebcdic.h')
-rw-r--r--utfebcdic.h27
1 files changed, 12 insertions, 15 deletions
diff --git a/utfebcdic.h b/utfebcdic.h
index c5a78599e7..ccb1fa19d8 100644
--- a/utfebcdic.h
+++ b/utfebcdic.h
@@ -183,14 +183,6 @@ zeros. Above 32 bits, these fill up, with each byte yielding 5 bits of
information, so that with 13 continuation bytes, we can handle 65 bits, just
above what a 64 bit word can hold */
-/* Input is a true Unicode (not-native) code point */
-#define OFFUNISKIP(uv) ( (uv) < 0xA0 ? 1 : \
- (uv) < 0x400 ? 2 : \
- (uv) < 0x4000 ? 3 : \
- (uv) < 0x40000 ? 4 : \
- (uv) < 0x400000 ? 5 : \
- (uv) < 0x4000000 ? 6 : \
- (uv) < 0x40000000 ? 7 : UTF8_MAXBYTES )
#define OFFUNI_IS_INVARIANT(c) (((UV)(c)) < 0xA0)
@@ -201,13 +193,18 @@ above what a 64 bit word can hold */
#define UVCHR_IS_INVARIANT(uv) cBOOL(FITS_IN_8_BITS(uv) \
&& (PL_charclass[(U8) (uv)] & (_CC_mask(_CC_ASCII) | _CC_mask(_CC_CNTRL))))
-#define UVCHR_SKIP(uv) (UVCHR_IS_INVARIANT(uv) ? 1 : \
- (uv) < 0x400 ? 2 : \
- (uv) < 0x4000 ? 3 : \
- (uv) < 0x40000 ? 4 : \
- (uv) < 0x400000 ? 5 : \
- (uv) < 0x4000000 ? 6 : \
- (uv) < 0x40000000 ? 7 : UTF8_MAXBYTES )
+/* Internal macro to be used only in the definitions of the next two */
+#define __BASE_UNI_SKIP(uv) ((uv) < 0x400 ? 2 : \
+ (uv) < 0x4000 ? 3 : \
+ (uv) < 0x40000 ? 4 : \
+ (uv) < 0x400000 ? 5 : \
+ (uv) < 0x4000000 ? 6 : \
+ (uv) < 0x40000000 ? 7 : UTF8_MAXBYTES )
+
+/* Input is a true Unicode (not-native) code point */
+#define OFFUNISKIP(uv) ( OFFUNI_IS_INVARIANT(uv) ? 1 : __BASE_UNI_SKIP(uv))
+
+#define UVCHR_SKIP(uv) ( UVCHR_IS_INVARIANT(uv) ? 1 : _BASE_UNI_SKIP(uv))
/* UTF-EBCDIC semantic macros - We used to transform back into I8 and then
* compare, but now only have to do a single lookup by using a bit in