develooper Front page | perl.perl5.porters | Postings from September 2000

[PATCH] Tie::StdHandle did not know about 3-arg open

Thread Next
From:
Gisle Aas
Date:
September 3, 2000 17:15
Subject:
[PATCH] Tie::StdHandle did not know about 3-arg open
Message ID:
20000904000422.26002.qmail@eik.g.aas.no
This patch relative to perl-5.7.0 fix Tie::StdHandle::OPEN to deal
with 3-arg open.

There are also some lines in this patch removing whitespace from the
end of some lines.  Too ugly when editing with cperl-mode in Emacs.

Regards,
Gisle


Index: lib/Tie/Handle.pm
===================================================================
RCS file: /local/perl/build/CVSROOT/perl/lib/Tie/Handle.pm,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 Handle.pm
--- lib/Tie/Handle.pm	2000/09/03 23:29:48	1.1.1.1
+++ lib/Tie/Handle.pm	2000/09/03 23:58:05
@@ -183,10 +183,10 @@ sub WRITE {
 sub CLOSE {
     my $pkg = ref $_[0];
     croak "$pkg doesn't define a CLOSE method";
-} 
+}
 
 package Tie::StdHandle; 
-our @ISA = 'Tie::Handle';       
+our @ISA = 'Tie::Handle';
 use Carp;
 
 sub TIEHANDLE 
@@ -196,7 +196,7 @@ sub TIEHANDLE 
  bless $fh,$class;
  $fh->OPEN(@_) if (@_);
  return $fh;
-}         
+}
 
 sub EOF     { eof($_[0]) }
 sub TELL    { tell($_[0]) }
@@ -206,9 +206,9 @@ sub CLOSE   { close($_[0]) }
 sub BINMODE { binmode($_[0]) }
 
 sub OPEN
-{         
+{
  $_[0]->CLOSE if defined($_[0]->FILENO);
- open($_[0],$_[1]);
+ @_ == 2 ? open($_[0], $_[1]) : open($_[0], $_[1], $_[2]);
 }
 
 sub READ     { read($_[0],$_[1],$_[2]) }
@@ -216,7 +216,7 @@ sub READLINE { my $fh = $_[0]; <$fh> }
 sub GETC     { getc($_[0]) }
 
 sub WRITE
-{        
+{
  my $fh = $_[0];
  print $fh substr($_[1],0,$_[2])
 }
Index: t/lib/tie-stdhandle.t
===================================================================
RCS file: /local/perl/build/CVSROOT/perl/t/lib/tie-stdhandle.t,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 tie-stdhandle.t
--- t/lib/tie-stdhandle.t	2000/09/03 23:29:51	1.1.1.1
+++ t/lib/tie-stdhandle.t	2000/09/03 23:58:42
@@ -10,16 +10,16 @@ tie *tst,Tie::StdHandle;
 
 $f = 'tst';
 
-print "1..13\n";   
+print "1..13\n";
 
 # my $file tests
 
-unlink("afile.new") if -f "afile";     
-print "$!\nnot " unless open($f,"+>afile");
+unlink("afile.new") if -f "afile";
+print "$!\nnot " unless open($f,"+>afile") && open($f, "+<", "afile");
 print "ok 1\n";
 print "$!\nnot " unless binmode($f);
 print "ok 2\n";
-print "not " unless -f "afile";     
+print "not " unless -f "afile";
 print "ok 3\n";
 print "not " unless print $f "SomeData\n";
 print "ok 4\n";
@@ -44,4 +44,4 @@ print "not " unless eof($f);
 print "ok 12\n";
 print "not " unless close($f);
 print "ok 13\n";
-unlink("afile");     
+unlink("afile");


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About