summaryrefslogtreecommitdiff
path: root/utfebcdic.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-08-26 15:38:39 -0600
committerKarl Williamson <khw@cpan.org>2015-09-04 10:49:22 -0600
commit8dcc0f39348a76159ea8f24adc9a2cfe2a41be9f (patch)
treee0bc99fdea9d8514b3d2b64122999298bc007247 /utfebcdic.h
parente9b19ab7df3480e8f710ca6faad519f6fccdb081 (diff)
downloadperl-8dcc0f39348a76159ea8f24adc9a2cfe2a41be9f.tar.gz
Fix potential flaw in 2 EBCDIC macros.
It occurred to me in code reading that it was possible for these macros to not give the correct result if passed a signed argument. An earlier version of this commit was buggy. Thanks to Yaroslav Kuzmin for spotting that.
Diffstat (limited to 'utfebcdic.h')
-rw-r--r--utfebcdic.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/utfebcdic.h b/utfebcdic.h
index 51e6e77f8d..c852946f44 100644
--- a/utfebcdic.h
+++ b/utfebcdic.h
@@ -142,8 +142,8 @@ END_EXTERN_C
#define I8_TO_NATIVE_UTF8(b) (__ASSERT_(FITS_IN_8_BITS(b)) PL_utf2e[(U8)(b)])
/* 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))
+#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))
/*
The following table is adapted from tr16, it shows I8 encoding of Unicode code points.