Change 18515 by jhi@lyta on 2003/01/18 18:43:52

        Integrate:
        [ 18474]
        Integrate from perlio:
        [ 18470]
        Fix #16306 and #16880
        
        (#16306 Big Badda leak in Sockets)
        (#16880 Memory leak with IO::Socket in Perl v5.8.0)
        
        [ 18475]
        Integrate from perlio:
        [ 18471]
        Fix #18711 and add test for it (and indeed tell on write
        handles at all !
        
        (#18711 Serious bug of tell() in perl)
        
        [ 18507]
        Thread-protection for dup/fclose/dup2 scheme of stdio leak
        avoidance.
        
        [ 18508]
        Subject: Re: 18457 on cygwin/20030113
        From: Nick Ing-Simmons <[EMAIL PROTECTED]>
        Date: Fri, 17 Jan 2003 15:10:34 +0000
        Message-Id: <[EMAIL PROTECTED]>
        
        [ 18509]
        Upgrade to Digest::MD5 2.22.
        
        [ 18510]
        Typo fixes from [EMAIL PROTECTED] (from openbsd.bugs)
        
        [ 18511]
        Upgrade to Digest 1.01.
        
        [ 18512]
        EPOC perl address updates.
        
        [ 18513]
        Slight pod reformatting based on [perl #20284].
        
        [ 18514]
        Integrate from perlio:
        [ 18507]
        Thread-protection for dup/fclose/dup2 scheme of stdio leak
        avoidance.

Affected files ...

... //depot/maint-5.8/perl/README.epoc#3 integrate
... //depot/maint-5.8/perl/README.mint#3 integrate
... //depot/maint-5.8/perl/ext/Data/Dumper/Dumper.pm#2 integrate
... //depot/maint-5.8/perl/ext/Digest/MD5/Changes#3 integrate
... //depot/maint-5.8/perl/ext/Digest/MD5/MD5.pm#3 integrate
... //depot/maint-5.8/perl/ext/Digest/MD5/MD5.xs#2 integrate
... //depot/maint-5.8/perl/ext/Digest/MD5/README#2 integrate
... //depot/maint-5.8/perl/ext/Digest/MD5/t/files.t#3 integrate
... //depot/maint-5.8/perl/lib/Digest.pm#2 integrate
... //depot/maint-5.8/perl/perlio.c#5 integrate
... //depot/maint-5.8/perl/t/io/tell.t#3 integrate
... //depot/maint-5.8/perl/utils/libnetcfg.PL#2 integrate

Differences ...

==== //depot/maint-5.8/perl/README.epoc#3 (text) ====
Index: perl/README.epoc
--- perl/README.epoc#2~18080~   Sun Nov  3 21:23:04 2002
+++ perl/README.epoc    Sat Jan 18 10:43:52 2003
@@ -17,8 +17,8 @@
 
 This is a port of perl to the epocemx SDK by Eberhard Mattes, which
 itself uses the SDK by symbian. Essentially epocemx it is a POSIX
-look alike environment for the EPOC OS. For more informations look at: 
-http://www.windhager.de/~mattes/epocemx/
+look alike environment for the EPOC OS.  For more information look at: 
+http://epocemx.sourceforge.net/
 
 perl and epocemx runs on Epoc Release 5 machines: Psion 5mx, 5mx Pro,
 Psion Revo, Psion Netbook and on the Ericson M128. It may run on Epoc
@@ -31,13 +31,12 @@
 =head1 INSTALLING PERL ON EPOC
 
 You can download a ready-to-install version from
-http://www.science-computing.de/o.flebbe/perl/
+http://www.oflebbe.de/oflebbe/perl/
 
-You will need at least ~6MB free space in order to install and run
-perl.
+You will need at least ~6MB free space in order to install and run perl.
 
 Please install the emxusr.sis package from
-http://www.windhager.de/~mattes/epocemx/ first.
+http://epocemx.sourceforge.net/ first.
 
 Install perl.sis on the EPOC machine. If you do not know how to do
 that, consult your PsiWin documentation.
@@ -150,11 +149,11 @@
 
 =head1 AUTHOR
 
-Olaf Flebbe <[EMAIL PROTECTED]>
-http://www.science-computing.de/o.flebbe/perl/
+Olaf Flebbe <[EMAIL PROTECTED]>
+http://www.oflebbe.de/oflebbe/perl/
 
 =head1 LAST UPDATE
 
-2002-03-26
+2003-01-18
 
 =cut

==== //depot/maint-5.8/perl/README.mint#3 (text) ====
Index: perl/README.mint
--- perl/README.mint#2~18080~   Sun Nov  3 21:23:04 2002
+++ perl/README.mint    Sat Jan 18 10:43:52 2003
@@ -123,16 +123,16 @@
 
 This version (5.00402) of perl has passed most of the tests on my system:
 
-Failed Test  Status Wstat Total Fail  Failed  List of failed
-------------------------------------------------------------------------------
-io/pipe.t                    10    2  20.00%  7, 9
-io/tell.t                    13    1   7.69%  12
-lib/complex.t               762   13   1.71%  84-85, 248-251, 257, 272-273,
-                                              371, 380, 419-420
-lib/io_pipe.t                10    1  10.00%  9
-lib/io_tell.t                13    1   7.69%  12
-op/magic.t                   30    2   6.67%  29-30
-Failed 6/152 test scripts, 96.05% okay. 20/4359 subtests failed, 99.54% okay.
+ Failed Test  Status Wstat Total Fail  Failed  List of failed
+ ------------------------------------------------------------------------------
+ io/pipe.t                    10    2  20.00%  7, 9
+ io/tell.t                    13    1   7.69%  12
+ lib/complex.t               762   13   1.71%  84-85, 248-251, 257, 272-273,
+                                               371, 380, 419-420
+ lib/io_pipe.t                10    1  10.00%  9
+ lib/io_tell.t                13    1   7.69%  12
+ op/magic.t                   30    2   6.67%  29-30
+ Failed 6/152 test scripts, 96.05% okay. 20/4359 subtests failed, 99.54% okay.
 
 Pipes always cause problems with MiNT, it's actually a surprise that
 most of the tests did work.  I've got no idea why the "tell" test failed,

==== //depot/maint-5.8/perl/ext/Data/Dumper/Dumper.pm#2 (text) ====
Index: perl/ext/Data/Dumper/Dumper.pm
--- perl/ext/Data/Dumper/Dumper.pm#1~17645~     Fri Jul 19 12:29:57 2002
+++ perl/ext/Data/Dumper/Dumper.pm      Sat Jan 18 10:43:52 2003
@@ -803,7 +803,9 @@
 
 =over 4
 
-=item $Data::Dumper::Indent  I<or>  I<$OBJ>->Indent(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Indent  I<or>  I<$OBJ>->Indent(I<[NEWVAL]>)
 
 Controls the style of indentation.  It can be set to 0, 1, 2 or 3.  Style 0
 spews output without any newlines, indentation, or spaces between list
@@ -816,24 +818,32 @@
 with their index (but the comment is on its own line, so array output
 consumes twice the number of lines).  Style 2 is the default.
 
-=item $Data::Dumper::Purity  I<or>  I<$OBJ>->Purity(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Purity  I<or>  I<$OBJ>->Purity(I<[NEWVAL]>)
 
 Controls the degree to which the output can be C<eval>ed to recreate the
 supplied reference structures.  Setting it to 1 will output additional perl
 statements that will correctly recreate nested references.  The default is
 0.
 
-=item $Data::Dumper::Pad  I<or>  I<$OBJ>->Pad(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Pad  I<or>  I<$OBJ>->Pad(I<[NEWVAL]>)
 
 Specifies the string that will be prefixed to every line of the output.
 Empty string by default.
 
-=item $Data::Dumper::Varname  I<or>  I<$OBJ>->Varname(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Varname  I<or>  I<$OBJ>->Varname(I<[NEWVAL]>)
 
 Contains the prefix to use for tagging variable names in the output. The
 default is "VAR".
 
-=item $Data::Dumper::Useqq  I<or>  I<$OBJ>->Useqq(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Useqq  I<or>  I<$OBJ>->Useqq(I<[NEWVAL]>)
 
 When set, enables the use of double quotes for representing string values.
 Whitespace other than space will be represented as C<[\n\t\r]>, "unsafe"
@@ -842,14 +852,18 @@
 penalty, the default is 0.  C<Dump()> will run slower if this flag is set,
 since the fast XSUB implementation doesn't support it yet.
 
-=item $Data::Dumper::Terse  I<or>  I<$OBJ>->Terse(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Terse  I<or>  I<$OBJ>->Terse(I<[NEWVAL]>)
 
 When set, Data::Dumper will emit single, non-self-referential values as
 atoms/terms rather than statements.  This means that the C<$VAR>I<n> names
 will be avoided where possible, but be advised that such output may not
 always be parseable by C<eval>.
 
-=item $Data::Dumper::Freezer  I<or>  $I<OBJ>->Freezer(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Freezer  I<or>  $I<OBJ>->Freezer(I<[NEWVAL]>)
 
 Can be set to a method name, or to an empty string to disable the feature.
 Data::Dumper will invoke that method via the object before attempting to
@@ -860,7 +874,9 @@
 only perl data types after the method has been called.  Defaults to an empty
 string.
 
-=item $Data::Dumper::Toaster  I<or>  $I<OBJ>->Toaster(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Toaster  I<or>  $I<OBJ>->Toaster(I<[NEWVAL]>)
 
 Can be set to a method name, or to an empty string to disable the feature.
 Data::Dumper will emit a method call for any objects that are to be dumped
@@ -871,26 +887,34 @@
 sure the method can be called via the object, and that it returns a valid
 object.  Defaults to an empty string.
 
-=item $Data::Dumper::Deepcopy  I<or>  $I<OBJ>->Deepcopy(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Deepcopy  I<or>  $I<OBJ>->Deepcopy(I<[NEWVAL]>)
 
 Can be set to a boolean value to enable deep copies of structures.
 Cross-referencing will then only be done when absolutely essential
 (i.e., to break reference cycles).  Default is 0.
 
-=item $Data::Dumper::Quotekeys  I<or>  $I<OBJ>->Quotekeys(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Quotekeys  I<or>  $I<OBJ>->Quotekeys(I<[NEWVAL]>)
 
 Can be set to a boolean value to control whether hash keys are quoted.
 A false value will avoid quoting hash keys when it looks like a simple
 string.  Default is 1, which will always enclose hash keys in quotes.
 
-=item $Data::Dumper::Bless  I<or>  $I<OBJ>->Bless(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Bless  I<or>  $I<OBJ>->Bless(I<[NEWVAL]>)
 
 Can be set to a string that specifies an alternative to the C<bless>
 builtin operator used to create objects.  A function with the specified
 name should exist, and should accept the same arguments as the builtin.
 Default is C<bless>.
 
-=item $Data::Dumper::Maxdepth  I<or>  $I<OBJ>->Maxdepth(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Maxdepth  I<or>  $I<OBJ>->Maxdepth(I<[NEWVAL]>)
 
 Can be set to a positive integer that specifies the depth beyond which
 which we don't venture into a structure.  Has no effect when
@@ -898,7 +922,9 @@
 want to see more than enough).  Default is 0, which means there is 
 no maximum depth. 
 
-=item $Data::Dumper::Useperl  I<or>  $I<OBJ>->Useperl(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Useperl  I<or>  $I<OBJ>->Useperl(I<[NEWVAL]>)
 
 Can be set to a boolean value which controls whether the pure Perl
 implementation of C<Data::Dumper> is used. The C<Data::Dumper> module is
@@ -908,7 +934,9 @@
 default behavior, usually for testing purposes only. Default is 0, which
 means the XS implementation will be used if possible.
 
-=item $Data::Dumper::Sortkeys  I<or>  $I<OBJ>->Sortkeys(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Sortkeys  I<or>  $I<OBJ>->Sortkeys(I<[NEWVAL]>)
 
 Can be set to a boolean value to control whether hash keys are dumped in
 sorted order. A true value will cause the keys of all hashes to be
@@ -923,7 +951,9 @@
 certain keys from being dumped. Default is 0, which means that hash keys
 are not sorted.
 
-=item $Data::Dumper::Deparse  I<or>  $I<OBJ>->Deparse(I<[NEWVAL]>)
+=item *
+
+$Data::Dumper::Deparse  I<or>  $I<OBJ>->Deparse(I<[NEWVAL]>)
 
 Can be set to a boolean value to control whether code references are
 turned into perl source code. If set to a true value, C<B::Deparse>

==== //depot/maint-5.8/perl/ext/Digest/MD5/Changes#3 (text) ====
Index: perl/ext/Digest/MD5/Changes
--- perl/ext/Digest/MD5/Changes#2~18503~        Thu Jan 16 15:29:57 2003
+++ perl/ext/Digest/MD5/Changes Sat Jan 18 10:43:52 2003
@@ -1,3 +1,12 @@
+2002-03-04   Gisle Aas <[EMAIL PROTECTED]>
+
+   Release 2.22.
+
+   Added clone method.
+   Contributed by Holger Smolinski <[EMAIL PROTECTED]>
+
+
+
 2002-12-27   Gisle Aas <[EMAIL PROTECTED]>
 
    Release 2.21

==== //depot/maint-5.8/perl/ext/Digest/MD5/MD5.pm#3 (text) ====
Index: perl/ext/Digest/MD5/MD5.pm
--- perl/ext/Digest/MD5/MD5.pm#2~18503~ Thu Jan 16 15:29:57 2003
+++ perl/ext/Digest/MD5/MD5.pm  Sat Jan 18 10:43:52 2003
@@ -3,7 +3,7 @@
 use strict;
 use vars qw($VERSION @ISA @EXPORT_OK);
 
-$VERSION = '2.21';  # $Date: 2002/12/28 05:30:03 $
+$VERSION = '2.22';  # $Date: 2003/01/05 00:56:14 $
 
 require Exporter;
 *import = \&Exporter::import;
@@ -117,6 +117,14 @@
 state the object to the state of a newly created object.  No new
 object is created in this case.
 
+=item $md5->clone
+
+This is a copy constructor returning a clone of the $md5 object. It is
+useful when you do not want to destroy the digests state, but need an
+intermediate value of the digest, e.g. when calculating digests
+iteratively on a continuous data stream in order to obtain a copy which
+may be destroyed.
+
 =item $md5->reset
 
 This is just an alias for $md5->new.
@@ -142,7 +150,8 @@
 Note that the C<digest> operation is effectively a destructive,
 read-once operation. Once it has been performed, the C<Digest::MD5>
 object is automatically C<reset> and can be used to calculate another
-digest value.
+digest value.  Call $md5->clone->digest if you want to calculate the
+digest without reseting the digest state.
 
 =item $md5->hexdigest
 
@@ -253,7 +262,7 @@
 This library is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.
 
- Copyright 1998-2002 Gisle Aas.
+ Copyright 1998-2003 Gisle Aas.
  Copyright 1995-1996 Neil Winton.
  Copyright 1991-1992 RSA Data Security, Inc.
 

==== //depot/maint-5.8/perl/ext/Digest/MD5/MD5.xs#2 (text) ====
Index: perl/ext/Digest/MD5/MD5.xs
--- perl/ext/Digest/MD5/MD5.xs#1~17645~ Fri Jul 19 12:29:57 2002
+++ perl/ext/Digest/MD5/MD5.xs  Sat Jan 18 10:43:52 2003
@@ -1,4 +1,4 @@
-/* $Id: MD5.xs,v 1.34 2002/05/01 23:30:28 gisle Exp $ */
+/* $Id: MD5.xs,v 1.35 2003/01/05 00:54:17 gisle Exp $ */
 
 /* 
  * This library is free software; you can redistribute it and/or
@@ -559,6 +559,22 @@
            context = get_md5_ctx(xclass);
        }
         MD5Init(context);
+       XSRETURN(1);
+
+void
+clone(self)
+       SV* self
+    PREINIT:
+       MD5_CTX* cont = get_md5_ctx(self);
+       char *myname = sv_reftype(SvRV(self),TRUE);
+       MD5_CTX* context;
+    PPCODE:
+       STRLEN my_na;
+       New(55, context, 1, MD5_CTX);
+       ST(0) = sv_newmortal();
+       sv_setref_pv(ST(0), myname , (void*)context);
+       SvREADONLY_on(SvRV(ST(0)));
+       memcpy(context,cont,sizeof(MD5_CTX));
        XSRETURN(1);
 
 void

==== //depot/maint-5.8/perl/ext/Digest/MD5/README#2 (text) ====
Index: perl/ext/Digest/MD5/README
--- perl/ext/Digest/MD5/README#1~17645~ Fri Jul 19 12:29:57 2002
+++ perl/ext/Digest/MD5/README  Sat Jan 18 10:43:52 2003
@@ -6,7 +6,7 @@
 
 You will need perl version 5.004 or better to install this module.
 
-Copyright 1998-2002 Gisle Aas.
+Copyright 1998-2003 Gisle Aas.
 Copyright 1995-1996 Neil Winton.
 Copyright 1990-1992 RSA Data Security, Inc.
 

==== //depot/maint-5.8/perl/ext/Digest/MD5/t/files.t#3 (text) ====
Index: perl/ext/Digest/MD5/t/files.t
--- perl/ext/Digest/MD5/t/files.t#2~18503~      Thu Jan 16 15:29:57 2003
+++ perl/ext/Digest/MD5/t/files.t       Sat Jan 18 10:43:52 2003
@@ -20,27 +20,27 @@
 my $EXPECT;
 if (ord "A" == 193) { # EBCDIC
     $EXPECT = <<EOT;
-36158997c99f2e1396ee40ddc4634a40  Changes
-5a591a47e8c40fe4b78c744111511c45  README
-770a5ef28ab15e66355639f21152afb0  MD5.pm
-4850753428db9422e8e5f97b401d5a13  MD5.xs
+ed8efe2e2dbab62fcc9dea2df6682569  Changes
+0565ec21b15c0f23f4c51fb327c8926d  README
+0fcdd6d6e33b8772bd4b4832043035cd  MD5.pm
+d7fd24455b9160aa8706635d15e6177e  MD5.xs
 276da0aa4e9a08b7fe09430c9c5690aa  rfc1321.txt
 EOT
 } elsif ("\n" eq "\015") { # MacOS
     $EXPECT = <<EOT;
-e68b13fe9edf36fe13551bf410b7a745  Changes
-3519f3d02c7c91158f732f0f00064657  README
-4113db8afad83eb7c01f1bf2c53e66ee  MD5.pm
-1be293491bba726810f8e87671ee0328  MD5.xs
+2879619f967d5fc5a00ffe37b639f2ee  Changes
+6c950a0211a5a28f023bb482037698cd  README
+4e1043f0a7a266416d8408d6fa96f454  MD5.pm
+6bff95ff70ba43a6c81e255c6510a865  MD5.xs
 754b9db19f79dbc4992f7166eb0f37ce  rfc1321.txt
 EOT
 } else {
     # This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt'
     $EXPECT = <<EOT;
-e68b13fe9edf36fe13551bf410b7a745  Changes
-3519f3d02c7c91158f732f0f00064657  README
-4113db8afad83eb7c01f1bf2c53e66ee  MD5.pm
-1be293491bba726810f8e87671ee0328  MD5.xs
+2879619f967d5fc5a00ffe37b639f2ee  Changes
+6c950a0211a5a28f023bb482037698cd  README
+4e1043f0a7a266416d8408d6fa96f454  MD5.pm
+6bff95ff70ba43a6c81e255c6510a865  MD5.xs
 754b9db19f79dbc4992f7166eb0f37ce  rfc1321.txt
 EOT
 }

==== //depot/maint-5.8/perl/lib/Digest.pm#2 (text) ====
Index: perl/lib/Digest.pm
--- perl/lib/Digest.pm#1~17645~ Fri Jul 19 12:29:57 2002
+++ perl/lib/Digest.pm  Sat Jan 18 10:43:52 2003
@@ -3,7 +3,7 @@
 use strict;
 use vars qw($VERSION %MMAP $AUTOLOAD);
 
-$VERSION = "1.00";
+$VERSION = "1.01";
 
 %MMAP = (
   "SHA-1"      => "Digest::SHA1",
@@ -124,11 +124,16 @@
 algorithm names which contains letters which are not legal perl
 identifiers, e.g. "SHA-1".
 
-If new() is called as an instance method (i.e. $ctx->new) it will just
+If new() is called as a instance method (i.e. $ctx->new) it will just
 reset the state the object to the state of a newly created object.  No
 new object is created in this case, and the return value is the
 reference to the object (i.e. $ctx).
 
+=item $other_ctx = $ctx->clone
+
+The clone method creates a copy of the digest state object and returns
+a reference to the copy.
+
 =item $ctx->reset
 
 This is just an alias for $ctx->new.
@@ -151,7 +156,8 @@
 Note that the C<digest> operation is effectively a destructive,
 read-once operation. Once it has been performed, the $ctx object is
 automatically C<reset> and can be used to calculate another digest
-value.
+value.  Call $ctx->clone->digest if you want to calculate the digest
+without reseting the digest state.
 
 =item $ctx->hexdigest
 

==== //depot/maint-5.8/perl/perlio.c#5 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#4~18197~      Wed Nov 27 20:14:27 2002
+++ perl/perlio.c       Sat Jan 18 10:43:52 2003
@@ -2662,11 +2662,13 @@
      */
     if ((f = PerlIOBase_dup(aTHX_ f, o, param, flags))) {
        FILE *stdio = PerlIOSelf(o, PerlIOStdio)->stdio;
+       int fd = fileno(stdio);
+       char mode[8];
        if (flags & PERLIO_DUP_FD) {
-           int fd = PerlLIO_dup(fileno(stdio));
-           if (fd >= 0) {
-               char mode[8];
-               stdio = PerlSIO_fdopen(fd, PerlIO_modestr(o,mode));
+           int dfd = PerlLIO_dup(fileno(stdio));
+           if (dfd >= 0) {
+               stdio = PerlSIO_fdopen(dfd, PerlIO_modestr(o,mode));
+               goto set_this;
            }
            else {
                /* FIXME: To avoid messy error recovery if dup fails
@@ -2674,6 +2676,8 @@
                 */
            }
        }
+       stdio = PerlSIO_fdopen(fd, PerlIO_modestr(o,mode));
+    set_this:
        PerlIOSelf(f, PerlIOStdio)->stdio = stdio;
        PerlIOUnix_refcnt_inc(fileno(stdio));
     }
@@ -2692,11 +2696,29 @@
        errno = EBADF;
        return -1;
     }
-    if (PerlIOUnix_refcnt_dec(fileno(stdio)) > 0) {
-       /* Do not close it but do flush any buffers */
-       return PerlIO_flush(f);
-    }
-    return (
+    else {
+        int fd = fileno(stdio);
+       int dupfd = -1;
+       IV result;
+       if (PerlIOUnix_refcnt_dec(fd) > 0) {
+           /* File descriptor still in use */
+           if (fd < 3) {
+               /* For STD* handles don't close the stdio at all */
+               return PerlIO_flush(f);
+           }
+           else {
+               /* Tricky - must fclose(stdio) to free memory but not close(fd) */ 
+#ifdef USE_THREADS
+               /* Sarathy pointed out that another thread could reuse
+                  fd after fclose() but before we dup2() below
+                  so take out a MUTEX to shut them out 
+                */  
+               MUTEX_LOCK(&PerlIO_mutex);
+#endif
+               dupfd = PerlLIO_dup(fd);
+           }
+       }    
+        result = (
 #ifdef SOCKS5_VERSION_NAME
               (getsockopt
                (PerlIO_fileno(f), SOL_SOCKET, SO_TYPE, (void *) &optval,
@@ -2706,7 +2728,18 @@
               PerlSIO_fclose(stdio)
 #endif
        );
-
+       if (dupfd >= 0) {
+           /* We need to restore fd from the saved copy */
+           if (PerlLIO_dup2(dupfd,fd) != fd)
+             result = -1;
+#ifdef USE_THREADS
+           MUTEX_UNLOCK(&PerlIO_mutex);
+#endif
+           if (PerlLIO_close(dupfd) != 0)
+             result = -1; 
+       }
+       return result;
+    } 
 }
 
 
@@ -3403,6 +3436,11 @@
        PerlIO_get_base(f);
     if (!(PerlIOBase(f)->flags & PERLIO_F_CANWRITE))
        return 0;
+    if (PerlIOBase(f)->flags & PERLIO_F_RDBUF) {
+       if (PerlIO_flush(f) != 0) {
+           return 0;
+       }
+    }  
     while (count > 0) {
        SSize_t avail = b->bufsiz - (b->ptr - b->buf);
        if ((SSize_t) count < avail)
@@ -3461,6 +3499,19 @@
      * b->posn is file position where b->buf was read, or will be written
      */
     Off_t posn = b->posn;
+    if ((PerlIOBase(f)->flags & PERLIO_F_APPEND) && 
+        (PerlIOBase(f)->flags & PERLIO_F_WRBUF)) {
+#if 1
+       /* As O_APPEND files are normally shared in some sense it is better
+          to flush :
+        */     
+       PerlIO_flush(f);
+#else  
+        /* when file is NOT shared then this is sufficient */ 
+       PerlIO_seek(PerlIONext(f),0, SEEK_END);
+#endif
+       posn = b->posn = PerlIO_tell(PerlIONext(f));
+    }
     if (b->buf) {
        /*
         * If buffer is valid adjust position by amount in buffer

==== //depot/maint-5.8/perl/t/io/tell.t#3 (xtext) ====
Index: perl/t/io/tell.t
--- perl/t/io/tell.t#2~18503~   Thu Jan 16 15:29:57 2003
+++ perl/t/io/tell.t    Sat Jan 18 10:43:52 2003
@@ -103,7 +103,7 @@
 
 close($tst);
 open($tst,">$written")  || die "Cannot open $written:$!";
-binmode $TST if $Is_Dosish;
+binmode $tst if $Is_Dosish;
 
 if (tell($tst) == 0) { print "ok 24\n"; } else { print "not ok 24\n"; }
 
@@ -118,7 +118,7 @@
 close($tst);
 
 open($tst,"+>>$written")  || die "Cannot open $written:$!";
-binmode $TST if $Is_Dosish;
+binmode $tst if $Is_Dosish;
 
 if (0) 
 {

==== //depot/maint-5.8/perl/utils/libnetcfg.PL#2 (text) ====
Index: perl/utils/libnetcfg.PL
--- perl/utils/libnetcfg.PL#1~17645~    Fri Jul 19 12:29:57 2002
+++ perl/utils/libnetcfg.PL     Sat Jan 18 10:43:52 2003
@@ -77,9 +77,9 @@
 The default name of the old configuration file is by default
 "libnet.cfg", unless otherwise specified using the -i option,
 C<-i oldfile>, and it is searched first from the current directory,
-and the from your module path.
+and then from your module path.
 
-The default name of new configuration file is "libnet.cfg", and by
+The default name of the new configuration file is "libnet.cfg", and by
 default it is written to the current directory, unless otherwise
 specified using the -o option, C<-o newfile>.
 
@@ -91,7 +91,7 @@
 
 Graham Barr, the original Configure script of libnet.
 
-Jarkko Hietaniemi, conversion into libnet cfg for inclusion into Perl 5.8.
+Jarkko Hietaniemi, conversion into libnetcfg for inclusion into Perl 5.8.
 
 =cut
 
End of Patch.

Reply via email to