This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Remove an EBCDIC-only path
authorKarl Williamson <khw@cpan.org>
Thu, 11 Aug 2016 23:43:13 +0000 (17:43 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 17 Aug 2016 21:23:59 +0000 (15:23 -0600)
Rewriting this slightly allows an #ifdef EBCDIC to be removed.

I am copying from code written by pali@cpan.org and included in the
Encode distribution.

utf8.c

diff --git a/utf8.c b/utf8.c
index 7d72c55..0b7cbda 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -638,14 +638,10 @@ Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
     /* Here is not a continuation byte, nor an invariant.  The only thing left
      * is a start byte (possibly for an overlong) */
 
-#ifdef EBCDIC
-    uv = NATIVE_UTF8_TO_I8(uv);
-#endif
-
-    /* Remove the leading bits that indicate the number of bytes in the
-     * character's whole UTF-8 sequence, leaving just the bits that are part of
-     * the value */
-    uv &= UTF_START_MASK(expectlen);
+    /* Convert to I8 on EBCDIC (no-op on ASCII), then remove the leading bits
+     * that indicate the number of bytes in the character's whole UTF-8
+     * sequence, leaving just the bits that are part of the value.  */
+    uv = NATIVE_UTF8_TO_I8(uv) & UTF_START_MASK(expectlen);
 
     /* Now, loop through the remaining bytes in the character's sequence,
      * accumulating each into the working value as we go.  Be sure to not look