diff options
author | Hugo van der Sanden <hv@crypt.org> | 2002-11-04 15:16:34 +0000 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-11-04 15:16:34 +0000 |
commit | f4126beca049b2be5f2468b43c3ba2b4b0da6725 (patch) | |
tree | 40c2cf3998a973ca11ebbf31787fb22415ef48e6 | |
parent | 1d86a7f9aafa7b00ab187ace80f468664c66c924 (diff) | |
parent | bf02d38ec7892c236ea4b293274ea6a3c334a25d (diff) | |
download | perl-f4126beca049b2be5f2468b43c3ba2b4b0da6725.tar.gz |
integrate from perlio: changes #17709, #17795, #17796, #18032
p4raw-link: @17709 on //depot/perlio: e949e37c57a7b8894b837a34a436233508daf2e1
p4raw-id: //depot/perl@18086
-rw-r--r-- | Porting/apply | 3 | ||||
-rw-r--r-- | ext/PerlIO/t/encoding.t | 20 | ||||
-rw-r--r-- | ext/PerlIO/t/via.t | 9 | ||||
-rw-r--r-- | ext/PerlIO/via/via.xs | 4 | ||||
-rw-r--r-- | perlio.c | 5 | ||||
-rw-r--r-- | t/io/crlf.t | 14 |
6 files changed, 49 insertions, 6 deletions
diff --git a/Porting/apply b/Porting/apply index c313ee60e6..d3bdb0bd70 100644 --- a/Porting/apply +++ b/Porting/apply @@ -2,7 +2,7 @@ my $file = pop(@ARGV); my %meta; $ENV{'P4PORT'} = 'bactrian:1667'; -$ENV{'P4CLIENT'} = 'camel-linux'; +$ENV{'P4CLIENT'} = 'ni-s'; open(FILE,$file) || die "Cannot open $file:$!"; while (<FILE>) { @@ -69,3 +69,4 @@ sub System _exit(exec $cmd); } } + diff --git a/ext/PerlIO/t/encoding.t b/ext/PerlIO/t/encoding.t index ce07fea027..cf80af7160 100644 --- a/ext/PerlIO/t/encoding.t +++ b/ext/PerlIO/t/encoding.t @@ -12,13 +12,14 @@ BEGIN { } } -print "1..13\n"; +print "1..14\n"; my $grk = "grk$$"; my $utf = "utf$$"; my $fail1 = "fa$$"; my $fail2 = "fb$$"; my $russki = "koi8r$$"; +my $threebyte = "3byte$$"; if (open(GRK, ">$grk")) { binmode(GRK, ":bytes"); @@ -131,6 +132,21 @@ if (!defined $warn) { print "$warn"; } +# Create a string of chars that are 3 bytes in UTF-8 +my $str = "\x{1f80}" x 2048; + +# Write them to a file +open(F,'>:utf8',$threebyte) || die "Cannot open $threebyte:$!"; +print F $str; +close(F); + +# Read file back as UTF-8 +open(F,'<:encoding(utf-8)',$threebyte) || die "Cannot open $threebyte:$!"; +my $dstr = <F>; +close(F); +print "not " unless ($dstr eq $str); +print "ok 14\n"; + END { - unlink($grk, $utf, $fail1, $fail2, $russki); + unlink($grk, $utf, $fail1, $fail2, $russki, $threebyte); } diff --git a/ext/PerlIO/t/via.t b/ext/PerlIO/t/via.t index d40e85e365..124efbda68 100644 --- a/ext/PerlIO/t/via.t +++ b/ext/PerlIO/t/via.t @@ -14,7 +14,7 @@ BEGIN { my $tmp = "via$$"; -use Test::More tests => 16; +use Test::More tests => 18; my $fh; my $a = join("", map { chr } 0..255) x 10; @@ -58,7 +58,14 @@ is($a, $b, 'compare original data with filtered version'); close($fh); +{ +package Incomplete::Module; +} + $warnings = ''; + no warnings 'layer'; + ok( ! open($fh,">via(Incomplete::Module)", $tmp), 'open via Incomplete::Module will fail'); + is( $warnings, "", "don't warn about unknown package" ); $warnings = ''; no warnings 'layer'; diff --git a/ext/PerlIO/via/via.xs b/ext/PerlIO/via/via.xs index 2bcd35562d..d4546781e6 100644 --- a/ext/PerlIO/via/via.xs +++ b/ext/PerlIO/via/via.xs @@ -161,6 +161,9 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, else if (SvIV(result) != 0) return SvIV(result); } + else { + goto push_failed; + } if (PerlIOVia_fetchmethod(aTHX_ s, MYMethod(FILL)) == (CV *) - 1) PerlIOBase(f)->flags &= ~PERLIO_F_FASTGETS; @@ -172,6 +175,7 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, Perl_warner(aTHX_ packWARN(WARN_LAYER), "Cannot find package '%.*s'", (int) pkglen, pkg); +push_failed: #ifdef ENOSYS errno = ENOSYS; #else @@ -3839,13 +3839,16 @@ PerlIOCrlf_get_cnt(pTHX_ PerlIO *f) b->ptr++; /* say we have read it as far as * flush() is concerned */ b->buf++; /* Leave space in front of buffer */ + /* Note as we have moved buf up flush's + posn += ptr-buf + will naturally make posn point at CR + */ b->bufsiz--; /* Buffer is thus smaller */ code = PerlIO_fill(f); /* Fetch some more */ b->bufsiz++; /* Restore size for next time */ b->buf--; /* Point at space */ b->ptr = nl = b->buf; /* Which is what we hand * off */ - b->posn--; /* Buffer starts here */ *nl = 0xd; /* Fill in the CR */ if (code == 0) goto test; /* fill() call worked */ diff --git a/t/io/crlf.t b/t/io/crlf.t index 08ab4fe3b0..484596bd47 100644 --- a/t/io/crlf.t +++ b/t/io/crlf.t @@ -15,7 +15,7 @@ END { } if (find PerlIO::Layer 'perlio') { - plan(tests => 7); + plan(tests => 8); ok(open(FOO,">:crlf",$file)); ok(print FOO 'a'.((('a' x 14).qq{\n}) x 2000) || close(FOO)); ok(open(FOO,"<:crlf",$file)); @@ -30,6 +30,18 @@ if (find PerlIO::Layer 'perlio') { { local $/; $text = <FOO> } is(count_chars($text, "\015\012"), 2000); + { + my $fcontents = join "", map {"$_\r\n"} "a".."zzz"; + open my $fh, "<:crlf", \$fcontents; + local $/ = "xxx"; + local $_ = <$fh>; + my $pos = tell $fh; # pos must be behind "xxx", before "\nyyy\n" + seek $fh, $pos, 0; + $/ = "\n"; + $s = <$fh>.<$fh>; + ok($s eq "\nxxy\n"); + } + ok(close(FOO)); } else { |