This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utfebcdic.h: Use an internal macro to avoid repeating
authorKarl Williamson <khw@cpan.org>
Fri, 30 Oct 2015 16:01:09 +0000 (10:01 -0600)
committerKarl Williamson <khw@cpan.org>
Sun, 6 Dec 2015 05:06:49 +0000 (22:06 -0700)
This creates a macro that is used in portions of 2 other macros, thus
removing repetition.

utfebcdic.h

index c5a7859..ccb1fa1 100644 (file)
@@ -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