From 7a4c00b4303a05a04564a03a88f4fa5c7a06a6e9 Mon Sep 17 00:00:00 2001 From: Perl 5 Porters Date: Wed, 25 Dec 1996 11:25:00 +1200 Subject: [inseparable changes from patch from perl5.003_15 to perl5.003_16] CORE PORTABILITY Subject: _13: patches for unicos/unicosmk Date: Fri, 20 Dec 1996 14:38:50 -0600 From: Dean Roehrich Files: Configure MANIFEST hints/unicos.sh hints/unicosmk.sh private-msgid: <199612202038.OAA22805@poplar.cray.com> LIBRARY AND EXTENSIONS Subject: Refresh IO to 1.14 From: Graham Barr Files: MANIFEST ext/IO/IO.xs ext/IO/README ext/IO/lib/IO/File.pm ext/IO/lib/IO/Handle.pm ext/IO/lib/IO/Pipe.pm ext/IO/lib/IO/Seekable.pm ext/IO/lib/IO/Select.pm ext/IO/lib/IO/Socket.pm t/lib/io_dup.t t/lib/io_pipe.t t/lib/io_sel.t t/lib/io_sock.t t/lib/io_tell.t t/lib/io_udp.t t/lib/io_xs.t OTHER CORE CHANGES Subject: Fix 'foreach(@ARGV) { while (<>) { push @p,$_ } }' From: Chip Salzenberg Files: cop.h pp_hot.c scope.c Subject: Eliminate warnings from C< undef $x; $x OP= "foo" > From: Chip Salzenberg Files: doop.c pp.c pp.h pp_hot.c Subject: Try again to improve method caching Date: Mon, 23 Dec 1996 20:13:56 -0500 (EST) From: Ilya Zakharevich Files: gv.c sv.c Msg-ID: <199612240113.UAA09487@monk.mps.ohio-state.edu> (applied based on p5p patch as commit 81c78688fe5c3927ad37ba29de14c86e38120317) Subject: Be more careful about 'o' magic memory management From: Chip Salzenberg Files: mg.c sv.c Subject: Fix bad pointer refs when localized object loses magic From: Chip Salzenberg Files: scope.c --- ext/IO/IO.xs | 4 ++ ext/IO/README | 4 ++ ext/IO/lib/IO/File.pm | 11 ++-- ext/IO/lib/IO/Handle.pm | 34 ++++++---- ext/IO/lib/IO/Pipe.pm | 21 +++--- ext/IO/lib/IO/Seekable.pm | 7 +- ext/IO/lib/IO/Select.pm | 163 +++++++++++++++++++++++++++++++++------------- ext/IO/lib/IO/Socket.pm | 132 ++++++++++++++++++------------------- 8 files changed, 225 insertions(+), 151 deletions(-) create mode 100644 ext/IO/README (limited to 'ext') diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs index 3cc3518e7e..a6eb075964 100644 --- a/ext/IO/IO.xs +++ b/ext/IO/IO.xs @@ -203,6 +203,7 @@ int untaint(handle) SV * handle CODE: +#ifdef IOf_UNTAINT IO * io; io = sv_2io(handle); if (io) { @@ -210,9 +211,12 @@ untaint(handle) RETVAL = 0; } else { +#endif RETVAL = -1; errno = EINVAL; +#ifdef IOf_UNTAINT } +#endif OUTPUT: RETVAL diff --git a/ext/IO/README b/ext/IO/README new file mode 100644 index 0000000000..e855afade4 --- /dev/null +++ b/ext/IO/README @@ -0,0 +1,4 @@ +This directory contains files from the IO distribution maintained by +Graham Barr . If you find that you have to modify +any files in this directory then please forward him a patch for only +the files in this directory. diff --git a/ext/IO/lib/IO/File.pm b/ext/IO/lib/IO/File.pm index 81d48b1c54..e44d77f1fe 100644 --- a/ext/IO/lib/IO/File.pm +++ b/ext/IO/lib/IO/File.pm @@ -1,3 +1,5 @@ +# + package IO::File; =head1 NAME @@ -91,14 +93,11 @@ L Derived from FileHandle.pm by Graham Barr EFE. -=head1 REVISION - -$Revision: 1.5 $ - =cut require 5.000; -use vars qw($VERSION @EXPORT @EXPORT_OK $AUTOLOAD); +use strict; +use vars qw($VERSION @EXPORT @EXPORT_OK $AUTOLOAD @ISA); use Carp; use Symbol; use SelectSaver; @@ -110,7 +109,7 @@ require DynaLoader; @ISA = qw(IO::Handle IO::Seekable Exporter DynaLoader); -$VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/); +$VERSION = "1.06"; @EXPORT = @IO::Seekable::EXPORT; diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm index 7b8c709c78..59741c1c11 100644 --- a/ext/IO/lib/IO/Handle.pm +++ b/ext/IO/lib/IO/Handle.pm @@ -180,12 +180,11 @@ class from C and inherit those methods. Derived from FileHandle.pm by Graham Barr EFE -Version 1.1201 specialized from 1.12 for inclusion in Perl distribution - =cut require 5.000; -use vars qw($RCS $VERSION @EXPORT_OK $AUTOLOAD); +use strict; +use vars qw($VERSION @EXPORT_OK $AUTOLOAD @ISA); use Carp; use Symbol; use SelectSaver; @@ -193,8 +192,7 @@ use SelectSaver; require Exporter; @ISA = qw(Exporter); -$VERSION = "1.1201"; -$RCS = sprintf("%s", q$Revision: 1.15 $ =~ /([\d\.]+)/); +$VERSION = "1.14"; @EXPORT_OK = qw( autoflush @@ -244,6 +242,7 @@ sub AUTOLOAD { $constname =~ s/.*:://; my $val = constant($constname); defined $val or croak "$constname is not a valid IO::Handle macro"; + no strict 'refs'; *$AUTOLOAD = sub { $val }; goto &$AUTOLOAD; } @@ -270,16 +269,23 @@ sub new_from_fd { bless $fh, $class; } -# -# That an IO::Handle is being destroyed does not necessarily mean -# that the associated filehandle should be closed. This is because -# *FOO{FILEHANDLE} may by a synonym for *BAR{FILEHANDLE}. -# -# If this IO::Handle really does have the final reference to the -# given FILEHANDLE, then Perl will close it for us automatically. -# - sub DESTROY { + my ($fh) = @_; + + # During global object destruction, this function may be called + # on FILEHANDLEs as well as on the GLOBs that contains them. + # Thus the following trickery. If only the CORE file operators + # could deal with FILEHANDLEs, it wouldn't be necessary... + + if ($fh =~ /=FILEHANDLE\(/) { + local *TMP = $fh; + close(TMP) + if defined fileno(TMP); + } + else { + close($fh) + if defined fileno($fh); + } } ################################################ diff --git a/ext/IO/lib/IO/Pipe.pm b/ext/IO/lib/IO/Pipe.pm index 9ec8b6498a..34cb0daad2 100644 --- a/ext/IO/lib/IO/Pipe.pm +++ b/ext/IO/lib/IO/Pipe.pm @@ -4,7 +4,7 @@ package IO::Pipe; =head1 NAME -IO::Pipe - supply object methods for pipes +IO::pipe - supply object methods for pipes =head1 SYNOPSIS @@ -89,11 +89,7 @@ L =head1 AUTHOR -Graham Barr EFE - -=head1 REVISION - -$Revision: 1.7 $ +Graham Barr =head1 COPYRIGHT @@ -104,12 +100,13 @@ as Perl itself. =cut require 5.000; +use strict; use vars qw($VERSION); use Carp; use Symbol; require IO::Handle; -$VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/); +$VERSION = "1.08"; sub new { my $type = shift; @@ -165,9 +162,10 @@ sub reader { my $pid = $me->_doit(0,@_) if(@_); + close(${*$me}[1]); bless $me, ref($fh); - *{*$me} = *{*$fh}; # Alias self to handle - bless $fh; # Really wan't un-bless here + *{*$me} = *{*$fh}; # Alias self to handle + bless $fh, 'IO::Pipe::DeadEnd'; # Really wan't un-bless here ${*$me}{'io_pipe_pid'} = $pid if defined $pid; @@ -181,9 +179,10 @@ sub writer { my $pid = $me->_doit(1,@_) if(@_); + close(${*$me}[0]); bless $me, ref($fh); - *{*$me} = *{*$fh}; # Alias self to handle - bless $fh; # Really wan't un-bless here + *{*$me} = *{*$fh}; # Alias self to handle + bless $fh, 'IO::Pipe::DeadEnd'; # Really wan't un-bless here ${*$me}{'io_pipe_pid'} = $pid if defined $pid; diff --git a/ext/IO/lib/IO/Seekable.pm b/ext/IO/lib/IO/Seekable.pm index 8e0f87ac18..e8a9530e80 100644 --- a/ext/IO/lib/IO/Seekable.pm +++ b/ext/IO/lib/IO/Seekable.pm @@ -42,14 +42,11 @@ L Derived from FileHandle.pm by Graham Barr Ebodg@tiuk.ti.comE -=head1 REVISION - -$Revision: 1.5 $ - =cut require 5.000; use Carp; +use strict; use vars qw($VERSION @EXPORT @ISA); use IO::Handle qw(SEEK_SET SEEK_CUR SEEK_END); require Exporter; @@ -57,7 +54,7 @@ require Exporter; @EXPORT = qw(SEEK_SET SEEK_CUR SEEK_END); @ISA = qw(Exporter); -$VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/); +$VERSION = "1.06"; sub clearerr { @_ == 1 or croak 'usage: $fh->clearerr()'; diff --git a/ext/IO/lib/IO/Select.pm b/ext/IO/lib/IO/Select.pm index 845d6b25a4..dea684a62e 100644 --- a/ext/IO/lib/IO/Select.pm +++ b/ext/IO/lib/IO/Select.pm @@ -1,4 +1,8 @@ # IO::Select.pm +# +# Copyright (c) 1995 Graham Barr. All rights reserved. This program is free +# software; you can redistribute it and/or modify it under the same terms +# as Perl itself. package IO::Select; @@ -47,17 +51,30 @@ will be returned when an event occurs. C keeps these values in a cache which is indexed by the C of the handle, so if more than one handle with the same C is specified then only the last one is cached. +Each handle can be an C object, an integer or an array +reference where the first element is a C or an integer. + =item remove ( HANDLES ) Remove all the given handles from the object. This method also works by the C of the handles. So the exact handles that were added need not be passed, just handles that have an equivalent C +=item exists ( HANDLE ) + +Returns a true value (actually the handle itself) if it is present. +Returns undef otherwise. + +=item handles + +Return an array of all registered handles. + =item can_read ( [ TIMEOUT ] ) -Return an array of handles that are ready for reading. C is the maximum -amount of time to wait before returning an empty list. If C is -not given then the call will block. +Return an array of handles that are ready for reading. C is +the maximum amount of time to wait before returning an empty list. If +C is not given and any handles are registered then the call +will block. =item can_write ( [ TIMEOUT ] ) @@ -65,8 +82,8 @@ Same as C except check for handles that can be written to. =item has_error ( [ TIMEOUT ] ) -Same as C except check for handles that have an error condition, for -example EOF. +Same as C except check for handles that have an error +condition, for example EOF. =item count () @@ -74,12 +91,20 @@ Returns the number of handles that the object will check for when one of the C methods is called or the object is passed to the C is a static method, that is you call it with the package name -like C. C, C and C are either C or -C objects. C is optional and has the same effect as -before. +C