Integrate mainline
Nick Ing-Simmons [Sun, 15 Sep 2002 10:55:51 +0000 (10:55 +0000)]
p4raw-id: //depot/perlio@17905

Porting/apply
ext/PerlIO/t/via.t
ext/PerlIO/via/via.xs
perlio.c
t/io/crlf.t
t/op/utf8decode.t [changed mode: 0644->0755]

index c313ee6..d3bdb0b 100644 (file)
@@ -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);
   }
 }
+
index d40e85e..124efbd 100644 (file)
@@ -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';
index 2bcd355..d454678 100644 (file)
@@ -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
index 11f600f..ea36d80 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -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 */
index 08ab4fe..484596b 100644 (file)
@@ -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 {
old mode 100644 (file)
new mode 100755 (executable)