diff options
author | Father Chrysostomos <sprout@cpan.org> | 2010-09-16 14:07:50 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-09-16 14:07:50 +0200 |
commit | 83c555564918110c20f99f55c77d9dfc27f217fb (patch) | |
tree | 31c5fd2e85ae42e4d1d88c89b6060a98f8dc018f | |
parent | 95961f2bb1706f8782e09e22425d5958169ef5cd (diff) | |
download | perl-83c555564918110c20f99f55c77d9dfc27f217fb.tar.gz |
Fix warn to respect utf8-encoded scalars [perl #45549]
-rw-r--r-- | t/op/warn.t | 26 | ||||
-rw-r--r-- | util.c | 4 |
2 files changed, 26 insertions, 4 deletions
diff --git a/t/op/warn.t b/t/op/warn.t index 571dfb011c..5f4e04e9a5 100644 --- a/t/op/warn.t +++ b/t/op/warn.t @@ -7,7 +7,7 @@ BEGIN { require './test.pl'; } -plan 18; +plan 20; my @warnings; my $wa = []; my $ea = []; @@ -107,4 +107,28 @@ $@ = $ea; warn; ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $ea; +fresh_perl_like( + ' + $a = "\xee\n"; + print STDERR $a; warn $a; + utf8::upgrade($a); + print STDERR $a; warn $a; + ', + qr/^\xee(?:\r?\n\xee){3}/, + {}, + 'warn emits logical characters, not internal bytes [perl #45549]' +); + +fresh_perl_like( + ' + $a = "\xee\n"; + print STDERR $a; warn $a; + utf8::upgrade($a); + print STDERR $a; warn $a; + ', + qr/^\xc3\xae(?:\r?\n\xc3\xae){3}/, + { switches => ['-CE'] }, + 'warn respects :utf8 layer' +); + 1; @@ -1399,10 +1399,8 @@ Perl_write_to_stderr(pTHX_ SV* msv) dSAVED_ERRNO; #endif PerlIO * const serr = Perl_error_log; - STRLEN msglen; - const char* message = SvPVx_const(msv, msglen); - PERL_WRITE_MSG_TO_CONSOLE(serr, message, msglen); + do_print(msv, serr); (void)PerlIO_flush(serr); #ifdef USE_SFIO RESTORE_ERRNO; |