utf8.c: EBCDIC fix
authorKarl Williamson <khw@cpan.org>
Wed, 9 Aug 2017 20:42:32 +0000 (14:42 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 9 Aug 2017 20:48:37 +0000 (14:48 -0600)
Commit d819dc506b9fbd0d9bb316e42ca5bbefdd5f1d77 did not fully work.  I
switched the wrong thing that should have been in native vs
Unicode/Latin1, and forgot to update the test file.

Hopefully this is correct.

ext/XS-APItest/t/utf8_warn_base.pl
utf8.c

index 0f781c4..91de8a8 100644 (file)
@@ -1087,7 +1087,10 @@ foreach my $test (@tests) {
                         $correct_bytes_for_overlong
                                             = display_bytes_no_quotes($bytes);
                     }
-                    my $prefix = ($allowed_uv > 0x10FFFF) ? "0x" : "U+";
+                    my $prefix = (   $allowed_uv > 0x10FFFF
+                                  || ! isASCII && $allowed_uv < 256)
+                                 ? "0x"
+                                 : "U+";
                     push @expected_malformation_warnings,
                             qr/\QMalformed UTF-8 character: $wrong_bytes\E
                                \Q (overlong; instead use\E
diff --git a/utf8.c b/utf8.c
index c24baeb..d6ff21a 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1875,8 +1875,8 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
                         }
                         else {
                             U8 tmpbuf[UTF8_MAXBYTES+1];
-                            const U8 * const e = uvchr_to_utf8_flags(tmpbuf,
-                                                                     uv, 0);
+                            const U8 * const e = uvoffuni_to_utf8_flags(tmpbuf,
+                                                                        uv, 0);
                             /* Don't use U+ for non-Unicode code points, which
                              * includes those in the Latin1 range */
                             const char * preface = (    uv > PERL_UNICODE_MAX
@@ -1895,7 +1895,7 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
                                 preface,
                                 ((uv < 256) ? 2 : 4), /* Field width of 2 for
                                                          small code points */
-                                uv);
+                                UNI_TO_NATIVE(uv));
                         }
                     }
                 }