This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8n_to_uvchr() Fix EBCDIC bug with overlongs
authorKarl Williamson <khw@cpan.org>
Thu, 29 Sep 2016 02:42:30 +0000 (20:42 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 30 Sep 2016 03:32:18 +0000 (21:32 -0600)
The comment removed in this commit was wrong, and so was the code it
described.  On EBCDIC platforms, there are malformations that need to be
converted from Unicode to native.  When I wrote that I wasn't thinking
about overlongs, which can evaluate to any code point.  The new tests in
d566bd20c27a46aecd668d2f739b9515f46ac74f caught this.

utf8.c

diff --git a/utf8.c b/utf8.c
index 7f8df9d..8fb4bdd 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1046,9 +1046,7 @@ Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
        }
 
        if (sv) {
-            outlier_ret = uv;   /* Note we don't bother to convert to native,
-                                   as all the outlier code points are the same
-                                   in both ASCII and EBCDIC */
+            outlier_ret = UNI_TO_NATIVE(uv);
            goto do_warn;
        }