diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-02-07 14:31:09 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-08-29 09:55:48 -0600 |
commit | bc3632a8dfddf6cbc7c8232fd9d4d20f6c35dbd6 (patch) | |
tree | 07375c205e7acc93cbe473db8bc3e475f0e681a0 /utfebcdic.h | |
parent | 59a449d552a392b1e9daa9122be82f385d8c1f04 (diff) | |
download | perl-bc3632a8dfddf6cbc7c8232fd9d4d20f6c35dbd6.tar.gz |
Use new clearer named #defines
This converts several areas of code to use the more clearly named macros
introduced in the previous commit
Diffstat (limited to 'utfebcdic.h')
-rw-r--r-- | utfebcdic.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/utfebcdic.h b/utfebcdic.h index 9f2bfa6d9f..ec342b5623 100644 --- a/utfebcdic.h +++ b/utfebcdic.h @@ -527,12 +527,17 @@ END_EXTERN_C #define NATIVE_UTF8_TO_I8(ch) (ch) PL_e2utf[(U8)(ch)] #define I8_TO_NATIVE_UTF8(ch) (ch) PL_utf2e[(U8)(ch)] -/* Transform in wide UV char space */ -#define NATIVE_TO_UNI(ch) (((ch) > 255) ? (ch) : NATIVE_TO_ASCII(ch)) -#define UNI_TO_NATIVE(ch) (((ch) > 255) ? (ch) : ASCII_TO_NATIVE(ch)) +/* Transforms in wide UV chars */ +#define NATIVE_TO_UNI(ch) (((ch) > 255) ? (ch) : NATIVE_TO_LATIN1(ch)) +#define UNI_TO_NATIVE(ch) (((ch) > 255) ? (ch) : LATIN1_TO_NATIVE(ch)) + /* Transform in invariant..byte space */ -#define NATIVE_TO_NEED(enc,ch) ((enc) ? UTF_TO_NATIVE(NATIVE_TO_ASCII(ch)) : (ch)) -#define ASCII_TO_NEED(enc,ch) ((enc) ? UTF_TO_NATIVE(ch) : ASCII_TO_NATIVE(ch)) +#define NATIVE_TO_NEED(enc,ch) ((enc) \ + ? I8_TO_NATIVE_UTF8(NATIVE_TO_LATIN1(ch)) \ + : (ch)) +#define ASCII_TO_NEED(enc,ch) ((enc) \ + ? I8_TO_NATIVE_UTF8(ch) \ + : LATIN1_TO_NATIVE(ch)) /* The following table is adapted from tr16, it shows I8 encoding of Unicode code points. @@ -565,11 +570,13 @@ END_EXTERN_C * Comments as to the meaning of each are given at their corresponding utf8.h * definitions */ -#define UTF8_IS_START(c) (NATIVE_TO_UTF(c) >= 0xC5 && NATIVE_TO_UTF(c) != 0xE0) -#define UTF8_IS_CONTINUATION(c) ((NATIVE_TO_UTF(c) & 0xE0) == 0xA0) -#define UTF8_IS_CONTINUED(c) (NATIVE_TO_UTF(c) >= 0xA0) -#define UTF8_IS_DOWNGRADEABLE_START(c) (NATIVE_TO_UTF(c) >= 0xC5 && NATIVE_TO_UTF(c) <= 0xC7) -#define UTF8_IS_ABOVE_LATIN1(c) (NATIVE_TO_I8(c) >= 0xC8) +#define UTF8_IS_START(c) (NATIVE_UTF8_TO_I8(c) >= 0xC5 \ + && NATIVE_UTF8_TO_I8(c) != 0xE0) +#define UTF8_IS_CONTINUATION(c) ((NATIVE_UTF8_TO_I8(c) & 0xE0) == 0xA0) +#define UTF8_IS_CONTINUED(c) (NATIVE_UTF8_TO_I8(c) >= 0xA0) +#define UTF8_IS_DOWNGRADEABLE_START(c) (NATIVE_UTF8_TO_I8(c) >= 0xC5 \ + && NATIVE_UTF8_TO_I8(c) <= 0xC7) +#define UTF8_IS_ABOVE_LATIN1(c) (NATIVE_UTF8_TO_I8(c) >= 0xC8) #define UTF_START_MARK(len) (((len) > 7) ? 0xFF : ((U8)(0xFE << (7-(len))))) #define UTF_START_MASK(len) (((len) >= 6) ? 0x01 : (0x1F >> ((len)-2))) |