summaryrefslogtreecommitdiff
path: root/utfebcdic.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-10-29 20:32:08 -0600
committerKarl Williamson <khw@cpan.org>2015-11-09 10:53:32 -0700
commit111e8ed9ecc83b21b1472dfeafdb1e1918ddd493 (patch)
treeb252b765b50bdc33ec2ad0d4df3fdf90a78d840e /utfebcdic.h
parent6937f88504ae9c43ca157cfe296151540cdf5d36 (diff)
downloadperl-111e8ed9ecc83b21b1472dfeafdb1e1918ddd493.tar.gz
utf8.h, utfebcdic.h: Use mnemonic constant
The magic number 13 is used in various places on ASCII platforms, and 7 correspondingly on EBCDIC. This moves the #defines for what these represent to early in their files, and uses the symbolic name thereafter.
Diffstat (limited to 'utfebcdic.h')
-rw-r--r--utfebcdic.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/utfebcdic.h b/utfebcdic.h
index 5912b3a142..1e4dc7c26a 100644
--- a/utfebcdic.h
+++ b/utfebcdic.h
@@ -145,6 +145,13 @@ END_EXTERN_C
#define NATIVE_TO_UNI(ch) (FITS_IN_8_BITS(ch) ? NATIVE_TO_LATIN1(ch) : (ch))
#define UNI_TO_NATIVE(ch) (FITS_IN_8_BITS(ch) ? LATIN1_TO_NATIVE(ch) : (ch))
+/* How wide can a single UTF-8 encoded character become in bytes. */
+/* NOTE: Strictly speaking Perl's UTF-8 should not be called UTF-8 since UTF-8
+ * is an encoding of Unicode, and Unicode's upper limit, 0x10FFFF, can be
+ * expressed with 5 bytes. However, Perl thinks of UTF-8 as a way to encode
+ * non-negative integers in a binary format, even those above Unicode. */
+#define UTF8_MAXBYTES 7
+
/*
The following table is adapted from tr16, it shows I8 encoding of Unicode code points.
@@ -164,12 +171,13 @@ END_EXTERN_C
*/
/* 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 : 7 )
+#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)
@@ -185,7 +193,7 @@ END_EXTERN_C
(uv) < 0x4000 ? 3 : \
(uv) < 0x40000 ? 4 : \
(uv) < 0x400000 ? 5 : \
- (uv) < 0x4000000 ? 6 : 7 )
+ (uv) < 0x4000000 ? 6 : UTF8_MAXBYTES )
/* 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
@@ -221,13 +229,6 @@ END_EXTERN_C
#define UTF_CONTINUATION_MASK ((U8)0x1f)
#define UTF_ACCUMULATION_SHIFT 5
-/* How wide can a single UTF-8 encoded character become in bytes. */
-/* NOTE: Strictly speaking Perl's UTF-8 should not be called UTF-8 since UTF-8
- * is an encoding of Unicode, and Unicode's upper limit, 0x10FFFF, can be
- * expressed with 5 bytes. However, Perl thinks of UTF-8 as a way to encode
- * non-negative integers in a binary format, even those above Unicode */
-#define UTF8_MAXBYTES 7
-
/* The maximum number of UTF-8 bytes a single Unicode character can
* uppercase/lowercase/fold into. Unicode guarantees that the maximum
* expansion is 3 characters. On EBCDIC platforms, the highest Unicode