summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-03-13 12:20:03 +0000
committerDavid Mitchell <davem@iabyn.com>2018-03-20 07:59:26 +0000
commit4fc9437af9c4c388b6902d9bd9e4b25a4a56ab31 (patch)
treeefe7ca740d773b4870fa80435f28298471e2db5a /lib
parent5a92c67754c45dd4fc2ae77eee75f6fcaed2e2b1 (diff)
downloadperl-4fc9437af9c4c388b6902d9bd9e4b25a4a56ab31.tar.gz
Deparse.pm: tr/...//c was failing
Deparsing a tr/....//c (complement and an empty replacement list) was failing due to the 'delete RHS if LHS == RHS' action not triggering, due the LHS having already been complemented. At the same time, expand the set deparse tr/// tests;
Diffstat (limited to 'lib')
-rw-r--r--lib/B/Deparse.pm5
-rw-r--r--lib/B/Deparse.t33
2 files changed, 33 insertions, 5 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 5f3a591dad..d3ab507be2 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -5642,7 +5642,12 @@ sub tr_decode_byte {
}
}
@from = (@from, @delfrom);
+
if ($flags & OPpTRANS_COMPLEMENT) {
+ unless ($flags & OPpTRANS_DELETE) {
+ @to = () if ("@from" eq "@to");
+ }
+
my @newfrom = ();
my %from;
@from{@from} = (1) x @from;
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index ffdfc6c67e..983956d476 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -1438,11 +1438,34 @@ s/X//r;
use feature 'unicode_strings';
s/X//d;
####
-# all the flags (tr///)
-tr/X/Y/c;
-tr/X//d;
-tr/X//s;
-tr/X//r;
+# tr/// with all the flags: empty replacement
+tr/B-G//;
+tr/B-G//c;
+tr/B-G//d;
+tr/B-G//s;
+tr/B-G//cd;
+tr/B-G//ds;
+tr/B-G//cs;
+tr/B-G//cds;
+tr/B-G//r;
+####
+# tr/// with all the flags: short replacement
+tr/B-G/b/;
+tr/B-G/b/c;
+tr/B-G/b/d;
+tr/B-G/b/s;
+tr/B-G/b/cd;
+tr/B-G/b/ds;
+tr/B-G/b/cs;
+tr/B-G/b/cds;
+tr/B-G/b/r;
+####
+# tr/// with all the flags: equal length replacement
+tr/B-G/b-g/;
+tr/B-G/b-g/c;
+tr/B-G/b-g/s;
+tr/B-G/b-g/cs;
+tr/B-G/b-g/r;
####
# tr with extended table (/c)
tr/\000-\375/AB/c;