diff options
author | Nicholas Clark <nick@ccl4.org> | 2001-11-04 10:41:24 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-11-04 15:15:42 +0000 |
commit | b26b1ab5d13700c72864b2f555b309a62eee6884 (patch) | |
tree | b1ee9c83ded7c16daa937193b5c7361d46810d1f /ext | |
parent | 6222ea982923143b82f6cc746e96854484c8537b (diff) | |
download | perl-b26b1ab5d13700c72864b2f555b309a62eee6884.tar.gz |
[REPATCH] Re: PerlIOBuf_dup
Message-ID: <20011104104123.U20123@plum.flirble.org>
p4raw-id: //depot/perl@12839
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Encode/Encode.xs | 9 | ||||
-rw-r--r-- | ext/PerlIO/t/encoding.t | 20 |
2 files changed, 24 insertions, 5 deletions
diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 299af4471f..e7d8c6f5c7 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -102,12 +102,15 @@ PerlIOEncode_pushed(PerlIO *f, const char *mode, SV *arg) e->enc = Nullsv; errno = EINVAL; Perl_warner(aTHX_ WARN_IO, "Cannot find encoding \"%"SVf"\"", arg); - return -1; + code = -1; + } + else + { + SvREFCNT_inc(e->enc); + PerlIOBase(f)->flags |= PERLIO_F_UTF8; } - SvREFCNT_inc(e->enc); FREETMPS; LEAVE; - PerlIOBase(f)->flags |= PERLIO_F_UTF8; return code; } diff --git a/ext/PerlIO/t/encoding.t b/ext/PerlIO/t/encoding.t index dc2b2ba864..590fc00266 100644 --- a/ext/PerlIO/t/encoding.t +++ b/ext/PerlIO/t/encoding.t @@ -9,10 +9,11 @@ BEGIN { } } -print "1..8\n"; +print "1..10\n"; my $grk = "grk$$"; my $utf = "utf$$"; +my $fail1 = "fail$$"; if (open(GRK, ">$grk")) { # alpha beta gamma in ISO 8859-7 @@ -57,6 +58,21 @@ if (open(GRK, "<$grk")) { close GRK; } +$SIG{__WARN__} = sub {$warn = $_[0]}; + +if (open(FAIL, ">:encoding(NoneSuch)", $fail1)) { + print "not ok 9 # Open should fail\n"; +} else { + print "ok 9\n"; +} +if (!defined $warn) { + print "not ok 10 # warning is undef\n"; +} elsif ($warn =~ /^Cannot find encoding "NoneSuch" at/) { + print "ok 10\n"; +} else { + print "not ok 10 # warning is '$warn'"; +} + END { - unlink($grk, $utf); + unlink($grk, $utf, $fail1); } |