Change 18379 by jhi@lyta on 2002/12/31 15:33:11

        Integrate:
        [ 18371]
        Subject: [PATCH] Re: [perl #19330] Uneffective increment of $\
        From: Rafael Garcia-Suarez <[EMAIL PROTECTED]>
        Date: Fri, 27 Dec 2002 16:14:24 +0100
        Message-Id: <[EMAIL PROTECTED]>
        
        [ 18372]
        Subject: [PATCH lib/AutoSplit.pm] Holding filehandle open
        From: Michael G Schwern <[EMAIL PROTECTED]>
        Date: Sat, 21 Dec 2002 19:29:41 -0800
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 18373]
        Subject: [perl #19343] perlfunc.pod patch for stat() and lstat()
        From: Dave Paris (via RT) <[EMAIL PROTECTED]>
        Date: 22 Dec 2002 05:15:14 -0000
        Message-Id: <[EMAIL PROTECTED]>
        
        [ 18374]
        Remove duplicate entry
        
        [ 18378]
        integrate change#18377 from maint-5.6 branch
        
               change#17566 needs to be more defensive about win32_dup2()
               itself calling SetStdHandle() (at least MSVCRT does this)

Affected files ...

... //depot/maint-5.8/perl/MANIFEST#14 integrate
... //depot/maint-5.8/perl/lib/AutoSplit.pm#2 integrate
... //depot/maint-5.8/perl/mg.c#7 integrate
... //depot/maint-5.8/perl/pod/perlfunc.pod#6 integrate
... //depot/maint-5.8/perl/t/op/magic.t#7 integrate
... //depot/maint-5.8/perl/win32/win32.c#4 integrate

Differences ...

==== //depot/maint-5.8/perl/MANIFEST#14 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#13~18347~     Sun Dec 22 22:37:31 2002
+++ perl/MANIFEST       Tue Dec 31 07:33:11 2002
@@ -1347,7 +1347,6 @@
 lib/Net/Ping/t/200_ping_tcp.t  Ping Net::Ping
 lib/Net/Ping/t/250_ping_hires.t        Ping Net::Ping
 lib/Net/Ping/t/300_ping_stream.t       Ping Net::Ping
-lib/Net/Ping/t/300_ping_stream.t       Ping Net::Ping
 lib/Net/Ping/t/400_ping_syn.t  Ping Net::Ping
 lib/Net/Ping/t/410_syn_host.t  Ping Net::Ping
 lib/Net/Ping/t/450_service.t   Ping Net::Ping

==== //depot/maint-5.8/perl/lib/AutoSplit.pm#2 (text) ====
Index: perl/lib/AutoSplit.pm
--- perl/lib/AutoSplit.pm#1~17645~      Fri Jul 19 12:29:57 2002
+++ perl/lib/AutoSplit.pm       Tue Dec 31 07:33:11 2002
@@ -227,12 +227,12 @@
     # allow just a package name to be used
     $filename .= ".pm" unless ($filename =~ m/\.pm\z/);
 
-    open(IN, "<$filename") or die "AutoSplit: Can't open $filename: $!\n";
+    open(my $in, "<$filename") or die "AutoSplit: Can't open $filename: $!\n";
     my($pm_mod_time) = (stat($filename))[9];
     my($autoloader_seen) = 0;
     my($in_pod) = 0;
     my($def_package,$last_package,$this_package,$fnr);
-    while (<IN>) {
+    while (<$in>) {
        # Skip pod text.
        $fnr++;
        $in_pod = 1 if /^=\w/;
@@ -297,7 +297,8 @@
     my @cache = ();
     my $caching = 1;
     $last_package = '';
-    while (<IN>) {
+    my $out;
+    while (<$in>) {
        $fnr++;
        $in_pod = 1 if /^=\w/;
        $in_pod = 0 if /^=cut/;
@@ -308,8 +309,9 @@
        if (/^package\s+([\w:]+)\s*;/) {
            $this_package = $def_package = $1;
        }
+
        if (/^sub\s+([\w:]+)(\s*(?:\(.*?\))?(?:$attr_list)?)/) {
-           print OUT "# end of $last_package\::$subname\n1;\n"
+           print $out "# end of $last_package\::$subname\n1;\n"
                if $last_package;
            $subname = $1;
            my $proto = $2 || '';
@@ -329,18 +331,19 @@
            my($lpath) = catfile($modnamedir, "$lname.al");
            my($spath) = catfile($modnamedir, "$sname.al");
            my $path;
-           if (!$Is83 and open(OUT, ">$lpath")){
+
+           if (!$Is83 and open($out, ">$lpath")){
                $path=$lpath;
                print "  writing $lpath\n" if ($Verbose>=2);
            } else {
-               open(OUT, ">$spath") or die "Can't create $spath: $!\n";
+               open($out, ">$spath") or die "Can't create $spath: $!\n";
                $path=$spath;
                print "  writing $spath (with truncated name)\n"
                        if ($Verbose>=1);
            }
            push(@outfiles, $path);
            my $lineno = $fnr - @cache;
-           print OUT <<EOT;
+           print $out <<EOT;
 # NOTE: Derived from $filename.
 # Changes made here will be lost when autosplit is run again.
 # See AutoSplit.pm.
@@ -348,30 +351,30 @@
 
 #line $lineno "$filename (autosplit into $path)"
 EOT
-           print OUT @cache;
+           print $out @cache;
            @cache = ();
            $caching = 0;
        }
        if($caching) {
            push(@cache, $_) if @cache || /\S/;
        } else {
-           print OUT $_;
+           print $out $_;
        }
        if(/^\}/) {
            if($caching) {
-               print OUT @cache;
+               print $out @cache;
                @cache = ();
            }
-           print OUT "\n";
+           print $out "\n";
            $caching = 1;
        }
        $last_package = $this_package if defined $this_package;
     }
     if ($subname) {
-       print OUT @cache,"1;\n# end of $last_package\::$subname\n";
-       close(OUT);
+       print $out @cache,"1;\n# end of $last_package\::$subname\n";
+       close($out);
     }
-    close(IN);
+    close($in);
     
     if (!$keep){  # don't keep any obsolete *.al files in the directory
        my(%outfiles);
@@ -391,8 +394,8 @@
            $outdirs{File::Basename::dirname($_)}||=1;
        }
        for my $dir (keys %outdirs) {
-           opendir(OUTDIR,$dir);
-           foreach (sort readdir(OUTDIR)){
+           opendir(my $outdir,$dir);
+           foreach (sort readdir($outdir)){
                next unless /\.al\z/;
                my($file) = catfile($dir, $_);
                $file = lc $file if $Is83 or $Is_VMS;
@@ -402,25 +405,25 @@
                do { $deleted += ($thistime = unlink $file) } while ($thistime);
                carp "Unable to delete $file: $!" unless $deleted;
            }
-           closedir(OUTDIR);
+           closedir($outdir);
        }
     }
 
-    open(TS,">$al_idx_file") or
+    open(my $ts,">$al_idx_file") or
        carp "AutoSplit: unable to create timestamp file ($al_idx_file): $!";
-    print TS "# Index created by AutoSplit for $filename\n";
-    print TS "#    (file acts as timestamp)\n";
+    print $ts "# Index created by AutoSplit for $filename\n";
+    print $ts "#    (file acts as timestamp)\n";
     $last_package = '';
     for my $fqs (@subnames) {
        my($subname) = $fqs;
        $subname =~ s/.*:://;
-       print TS "package $package{$fqs};\n"
+       print $ts "package $package{$fqs};\n"
            unless $last_package eq $package{$fqs};
-       print TS "sub $subname $proto{$fqs};\n";
+       print $ts "sub $subname $proto{$fqs};\n";
        $last_package = $package{$fqs};
     }
-    print TS "1;\n";
-    close(TS);
+    print $ts "1;\n";
+    close($ts);
 
     _check_unique($filename, $Maxlen, 1, @outfiles);
 

==== //depot/maint-5.8/perl/mg.c#7 (text) ====
Index: perl/mg.c
--- perl/mg.c#6~18353~  Wed Dec 25 18:07:06 2002
+++ perl/mg.c   Tue Dec 31 07:33:11 2002
@@ -813,7 +813,7 @@
        break;
     case '\\':
        if (PL_ors_sv)
-           sv_setpv(sv,SvPVX(PL_ors_sv));
+           sv_copypv(sv, PL_ors_sv);
        break;
     case '#':
        sv_setpv(sv,PL_ofmt);

==== //depot/maint-5.8/perl/t/op/magic.t#7 (xtext) ====
Index: perl/t/op/magic.t
--- perl/t/op/magic.t#6~18234~  Mon Dec  2 14:30:41 2002
+++ perl/t/op/magic.t   Tue Dec 31 07:33:11 2002
@@ -36,7 +36,7 @@
     return 1;
 }
 
-print "1..48\n";
+print "1..50\n";
 
 $Is_MSWin32 = $^O eq 'MSWin32';
 $Is_NetWare = $^O eq 'NetWare';
@@ -324,3 +324,20 @@
 ok "@-" eq  "0 0 2 7";
 ok "@+" eq "10 1 6 10";
 
+# Tests for the magic get of $\
+{
+    my $ok = 0;
+    # [perl #19330]
+    {
+       local $\ = undef;
+       $\++; $\++;
+       $ok = $\ eq 2;
+    }
+    ok $ok;
+    $ok = 0;
+    {
+       local $\ = "a\0b";
+       $ok = "a$\b" eq "aa\0bb";
+    }
+    ok $ok;
+}

==== //depot/maint-5.8/perl/win32/win32.c#4 (text) ====
Index: perl/win32/win32.c
--- perl/win32/win32.c#3~18347~ Sun Dec 22 22:37:31 2002
+++ perl/win32/win32.c  Tue Dec 31 07:33:11 2002
@@ -2750,6 +2750,12 @@
     if ((oldfd = win32_dup(stdfd)) == -1)
         goto cleanup;
 
+    /* save the old std handle (this needs to happen before the
+     * dup2(), since that might call SetStdHandle() too) */
+    OP_REFCNT_LOCK;
+    lock_held = 1;
+    old_h = GetStdHandle(nhandle);
+
     /* make stdfd go to child end of pipe (implicitly closes stdfd) */
     /* stdfd will be inherited by the child */
     if (win32_dup2(p[child], stdfd) == -1)
@@ -2758,10 +2764,7 @@
     /* close the child end in parent */
     win32_close(p[child]);
 
-    /* save the old std handle, and set the std handle */
-    OP_REFCNT_LOCK;
-    lock_held = 1;
-    old_h = GetStdHandle(nhandle);
+    /* set the new std handle (in case dup2() above didn't) */
     SetStdHandle(nhandle, (HANDLE)_get_osfhandle(stdfd));
 
     /* start the child */
@@ -2770,16 +2773,17 @@
        if ((childpid = do_spawn_nowait((char*)command)) == -1)
            goto cleanup;
 
-       /* restore the old std handle */
+       /* revert stdfd to whatever it was before */
+       if (win32_dup2(oldfd, stdfd) == -1)
+           goto cleanup;
+
+       /* restore the old std handle (this needs to happen after the
+        * dup2(), since that might call SetStdHandle() too */
        if (lock_held) {
            SetStdHandle(nhandle, old_h);
            OP_REFCNT_UNLOCK;
            lock_held = 0;
        }
-
-       /* revert stdfd to whatever it was before */
-       if (win32_dup2(oldfd, stdfd) == -1)
-           goto cleanup;
 
        /* close saved handle */
        win32_close(oldfd);
End of Patch.

Reply via email to