From: Nicholas Clark Date: Sun, 2 Jun 2002 20:26:22 +0000 (+0100) Subject: [Encode PATCH] spurious warning X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb7af5ca4c2c314cbc4d8bf6a2c966e012f3faa5;p=p5sagit%2Fp5-mst-13.2.git [Encode PATCH] spurious warning Message-ID: <20020602192619.GA320@Bagpuss.unfortu.net> p4raw-id: //depot/perl@17009 --- diff --git a/ext/Encode/lib/Encode/Alias.pm b/ext/Encode/lib/Encode/Alias.pm index 876f971..9e9cca5 100644 --- a/ext/Encode/lib/Encode/Alias.pm +++ b/ext/Encode/lib/Encode/Alias.pm @@ -158,7 +158,7 @@ sub init_aliases define_alias( qr/^(.+)\@euro$/i => '"$1"' ); define_alias( qr/\b(?:iso[-_]?)?latin[-_]?(\d+)$/i - => '"iso-8859-$Encode::Alias::Latin2iso[$1]"' ); + => 'defined $Encode::Alias::Latin2iso[$1] ? "iso-8859-$Encode::Alias::Latin2iso[$1]" : undef' ); define_alias( qr/\bwin(latin[12]|cyrillic|baltic|greek|turkish| hebrew|arabic|baltic|vietnamese)$/ix => diff --git a/ext/PerlIO/t/encoding.t b/ext/PerlIO/t/encoding.t index b53eab5..986f21e 100644 --- a/ext/PerlIO/t/encoding.t +++ b/ext/PerlIO/t/encoding.t @@ -1,8 +1,10 @@ -#!./perl +#!./perl -w BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + no warnings; # Need global -w flag for later tests, but don't want this + # to warn here: push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS'; unless (find PerlIO::Layer 'perlio') { print "1..0 # Skip: not perlio\n"; @@ -10,11 +12,12 @@ BEGIN { } } -print "1..11\n"; +print "1..13\n"; my $grk = "grk$$"; my $utf = "utf$$"; my $fail1 = "fail$$"; +my $fail2 = "fail_$$"; my $russki = "koi8r$$"; if (open(GRK, ">$grk")) { @@ -68,7 +71,7 @@ if (open(GRK, "<$grk")) { close GRK; } -$SIG{__WARN__} = sub {$warn = $_[0]}; +$SIG{__WARN__} = sub {$warn .= $_[0]}; if (open(FAIL, ">:encoding(NoneSuch)", $fail1)) { print "not ok 9 # Open should fail\n"; @@ -90,7 +93,7 @@ if (open(RUSSKI, ">$russki")) { binmode(RUSSKI, ":raw"); my $buf1; read(RUSSKI, $buf1, 1); - eof(RUSSKI); + # eof(RUSSKI); binmode(RUSSKI, ":encoding(koi8-r)"); my $buf2; read(RUSSKI, $buf2, 1); @@ -109,6 +112,25 @@ if (open(RUSSKI, ">$russki")) { print "not ok 11 # open failed: $!\n"; } +undef $warn; + +# Check there is no Use of uninitialized value in concatenation (.) warning +# due to the way @latin2iso_num was used to make aliases. +if (open(FAIL, ">:encoding(latin42)", $fail2)) { + print "not ok 12 # Open should fail\n"; +} else { + print "ok 12\n"; +} +if (!defined $warn) { + print "not ok 13 # warning is undef\n"; +} elsif ($warn =~ /^Cannot find encoding "latin42" at.*line \d+\.$/) { + print "ok 13\n"; +} else { + print "not ok 13 # warning is: \n"; + $warn =~ s/^/# /mg; + print "$warn"; +} + END { unlink($grk, $utf, $fail1, $russki); }