Change 34298 by [EMAIL PROTECTED] on 2008/09/06 14:47:42

        Integrate:
        [ 34262]
        Integrate:
        [ 34068]
        Subject: [perl #51370] length($@)>0 for empty $@ if utf8 is in use 
        From: "Bram via RT" <[EMAIL PROTECTED]>
        Date: Wed, 11 Jun 2008 03:26:26 -0700
        Message-ID: <[EMAIL PROTECTED]>
        
        (The first patch)
        
        [ 34069]
        Rename the new macro clear_errsv() from last patch to CLEAR_ERRSV()

Affected files ...

... //depot/maint-5.8/perl/op.c#232 integrate
... //depot/maint-5.8/perl/perl.c#233 integrate
... //depot/maint-5.8/perl/perl.h#185 integrate
... //depot/maint-5.8/perl/pp_ctl.c#192 integrate
... //depot/maint-5.8/perl/t/op/eval.t#11 integrate

Differences ...

==== //depot/maint-5.8/perl/op.c#232 (text) ====
Index: perl/op.c
--- perl/op.c#231~33932~        2008-05-25 16:00:21.000000000 -0700
+++ perl/op.c   2008-09-06 07:47:42.000000000 -0700
@@ -2213,7 +2213,7 @@
     case 3:
        /* Something tried to die.  Abandon constant folding.  */
        /* Pretend the error never happened.  */
-       sv_setpvn(ERRSV,"",0);
+       CLEAR_ERRSV();
        o->op_next = old_next;
        break;
     default:

==== //depot/maint-5.8/perl/perl.c#233 (text) ====
Index: perl/perl.c
--- perl/perl.c#232~34279~      2008-09-05 12:03:34.000000000 -0700
+++ perl/perl.c 2008-09-06 07:47:42.000000000 -0700
@@ -2728,8 +2728,9 @@
            call_body((OP*)&myop, FALSE);
 #endif
            retval = PL_stack_sp - (PL_stack_base + oldmark);
-           if (!(flags & G_KEEPERR))
-               sv_setpvn(ERRSV,"",0);
+           if (!(flags & G_KEEPERR)) {
+               CLEAR_ERRSV();
+           }
            break;
        case 1:
            STATUS_ALL_FAILURE;
@@ -2862,8 +2863,9 @@
        call_body((OP*)&myop,TRUE);
 #endif
        retval = PL_stack_sp - (PL_stack_base + oldmark);
-       if (!(flags & G_KEEPERR))
-           sv_setpvn(ERRSV,"",0);
+       if (!(flags & G_KEEPERR)) {
+           CLEAR_ERRSV();
+       }
        break;
     case 1:
        STATUS_ALL_FAILURE;
@@ -3631,7 +3633,7 @@
     gv_SVadd(PL_errgv);
 #endif
     sv_grow(ERRSV, 240);       /* Preallocate - for immediate signals. */
-    sv_setpvn(ERRSV, "", 0);
+    CLEAR_ERRSV();
     PL_curstash = PL_defstash;
     CopSTASH_set(&PL_compiling, PL_defstash);
     PL_debstash = GvHV(gv_fetchpvs("DB::", GV_ADDMULTI, SVt_PVHV));

==== //depot/maint-5.8/perl/perl.h#185 (text) ====
Index: perl/perl.h
--- perl/perl.h#184~33926~      2008-05-25 14:12:26.000000000 -0700
+++ perl/perl.h 2008-09-06 07:47:42.000000000 -0700
@@ -5774,6 +5774,8 @@
 
 #endif /* Include guard */
 
+#define CLEAR_ERRSV() STMT_START { sv_setpvn(ERRSV,"",0); if 
(SvMAGICAL(ERRSV)) { mg_free(ERRSV); } SvPOK_only(ERRSV); } STMT_END
+
 /*
  * Local variables:
  * c-indentation-style: bsd

==== //depot/maint-5.8/perl/pp_ctl.c#192 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#191~34293~    2008-09-06 01:58:18.000000000 -0700
+++ perl/pp_ctl.c       2008-09-06 07:47:42.000000000 -0700
@@ -1949,8 +1949,9 @@
     PL_curpm = newpm;  /* ... and pop $1 et al */
 
     LEAVESUB(sv);
-    if (clear_errsv)
-       sv_setpvn(ERRSV,"",0);
+    if (clear_errsv) {
+       CLEAR_ERRSV();
+    }
     return pop_return();
 }
 
@@ -2841,7 +2842,7 @@
     if (saveop && (saveop->op_type != OP_REQUIRE) && (saveop->op_flags & 
OPf_SPECIAL))
        PL_in_eval |= EVAL_KEEPERR;
     else
-       sv_setpvn(ERRSV,"",0);
+       CLEAR_ERRSV();
     if (yyparse() || PL_error_count || !PL_eval_root) {
        SV **newsp;                     /* Used by POPBLOCK. */
        PERL_CONTEXT *cx;
@@ -3616,8 +3617,9 @@
     }
     else {
        LEAVE;
-       if (!(save_flags & OPf_SPECIAL))
-           sv_setpvn(ERRSV,"",0);
+       if (!(save_flags & OPf_SPECIAL)) {
+           CLEAR_ERRSV();
+       }
     }
 
     RETURNOP(retop);
@@ -3662,7 +3664,7 @@
     if (flags & G_KEEPERR)
        PL_in_eval |= EVAL_KEEPERR;
     else
-       sv_setpvn(ERRSV,"",0);
+       CLEAR_ERRSV();
     if (flags & G_FAKINGEVAL) {
        PL_eval_root = PL_op; /* Only needed so that goto works right. */
     }
@@ -3719,7 +3721,7 @@
     PL_curpm = newpm;  /* Don't pop $1 et al till now */
 
     LEAVE;
-    sv_setpvn(ERRSV,"",0);
+    CLEAR_ERRSV();
     RETURN;
 }
 

==== //depot/maint-5.8/perl/t/op/eval.t#11 (xtext) ====
Index: perl/t/op/eval.t
--- perl/t/op/eval.t#10~33177~  2008-02-01 13:32:02.000000000 -0800
+++ perl/t/op/eval.t    2008-09-06 07:47:42.000000000 -0700
@@ -5,7 +5,7 @@
     @INC = '../lib';
 }
 
-print "1..95\n";
+print "1..98\n";
 
 eval 'print "ok 1\n";';
 
@@ -485,4 +485,63 @@
 }
 
 
+# [perl #51370] eval { die "\x{a10d}" } followed by eval { 1 } did not reset
+# length $@ 
+$@ = "";
+eval { die "\x{a10d}"; };
+$_ = length $@;
+eval { 1 };
+
+print "not " if ($@ ne "");
+print "ok $test # length of \$@ after eval\n"; $test++;
+
+print "not " if (length $@ != 0);
+print "ok $test # length of \$@ after eval\n"; $test++;
+
+# Check if eval { 1 }; compeltly resets $@
+if (eval "use Devel::Peek; 1;") {
+  
+  open PROG, ">", "peek_eval_$$.t" or die "Can't create test file";
+  print PROG <<'END_EVAL_TEST';
+    use Devel::Peek;
+    $! = 0;
+    $@ = $!;
+    my $ok = 0;
+    open(SAVERR, ">&STDERR") or die "Can't dup STDERR: $!";
+    if (open(OUT,">peek_eval$$")) {
+      open(STDERR, ">&OUT") or die "Can't dup OUT: $!";
+      Dump($@);
+      print STDERR "******\n";
+      eval { die "\x{a10d}"; };
+      $_ = length $@;
+      eval { 1 };
+      Dump($@);
+      open(STDERR, ">&SAVERR") or die "Can't restore STDERR: $!";
+      close(OUT);
+      if (open(IN, "peek_eval$$")) {
+        local $/;
+        my $in = <IN>;
+        my ($first, $second) = split (/\*\*\*\*\*\*\n/, $in, 2);
+        $first =~ s/,pNOK//;
+        $ok = 1 if ($first eq $second);
+      }
+    }
+
+    print $ok;
+    END {
+      1 while unlink("peek_eval$$");
+    }
+END_EVAL_TEST
+   close PROG;
+
+   my $ok = runperl(progfile => "peek_eval_$$.t");
+   print "not " unless $ok;
+   print "ok $test # eval { 1 } completly resets [EMAIL PROTECTED]";
+
+   $test++;
+   1 while unlink("peek_eval_$$.t");
+}
+else {
+  print "ok $test # skipped - eval { 1 } completly resets \$@";
+}
 
End of Patch.

Reply via email to