From: Stephen McCamant <smcc@mit.edu>
Date: Thu, 31 Oct 2002 01:35:29 +0000 (-0500)
Subject: Re: [PATCH] [perl #18175] B::Concise,-exec doesn't handle // operator well
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=62e36f8a468863e09ecdb7f4dfc6bb112b1a327e;p=p5sagit%2Fp5-mst-13.2.git

Re: [PATCH] [perl #18175] B::Concise,-exec doesn't handle // operator well
Message-ID: <15808.53041.181907.308803@syllepsis.MIT.EDU>

plus a test case in ext/B/t/concise.t
plus a (less intrusive, but less future-proof) fix for a
similar problem in B::walkoptree_exec().

p4raw-id: //depot/perl@18114
---

diff --git a/ext/B/B.pm b/ext/B/B.pm
index 564b675..c1bd852 100644
--- a/ext/B/B.pm
+++ b/ext/B/B.pm
@@ -176,7 +176,7 @@ sub walkoptree_exec {
 	$op->$method($level);
 	$ppname = $op->name;
 	if ($ppname =~
-	    /^(or|and|mapwhile|grepwhile|entertry|range|cond_expr)$/)
+	    /^(d?or(assign)?|and(assign)?|mapwhile|grepwhile|entertry|range|cond_expr)$/)
 	{
 	    print $prefix, uc($1), " => {\n";
 	    walkoptree_exec($op->other, $method, $level + 1);
diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm
index 161bf6b..1166088 100644
--- a/ext/B/B/Concise.pm
+++ b/ext/B/B/Concise.pm
@@ -1,5 +1,5 @@
 package B::Concise;
-# Copyright (C) 2000, 2001 Stephen McCamant. All rights reserved.
+# Copyright (C) 2000-2002 Stephen McCamant. All rights reserved.
 # This program is free software; you can redistribute and/or modify it
 # under the same terms as Perl itself.
 
@@ -234,8 +234,7 @@ sub walk_exec {
 	    last if $opsseen{$$op}++;
 	    push @$targ, $op;
 	    my $name = $op->name;
-	    if ($name
-		=~ /^(or|and|(map|grep)while|entertry|range|cond_expr)$/) {
+	    if (class($op) eq "LOGOP") {
 		my $ar = [];
 		push @$targ, $ar;
 		push @todo, [$op->other, $ar];
diff --git a/ext/B/t/concise.t b/ext/B/t/concise.t
index a567a73..86a645c 100644
--- a/ext/B/t/concise.t
+++ b/ext/B/t/concise.t
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 4;
+plan tests => 5;
 
 require_ok("B::Concise");
 
@@ -24,3 +24,13 @@ is($op_base, 1, "Smallest OP sequence number");
 is($op_base_p1, 2, "Second-smallest OP sequence number");
 
 is($cop_base, 1, "Smallest COP sequence number");
+
+# test that with -exec B::Concise navigates past logops (bug #18175)
+
+$out = runperl(
+    switches => ["-MO=Concise,-exec"],
+    prog => q{$a//=$b && print q/foo/},
+    stderr => 1,
+);
+
+like($out, qr/"foo"/, "-exec option with //=");