summaryrefslogtreecommitdiff
path: root/ext/B
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2001-05-10 19:54:59 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-05-10 22:28:36 +0000
commitbec892532a745f0388849c19cf8d4d5b3cbbda35 (patch)
tree90199c6db03b31b73a2f927f2eae11346f5ba8dc /ext/B
parentfecea80608f57b51d05df84f3a72f304337280cb (diff)
downloadperl-bec892532a745f0388849c19cf8d4d5b3cbbda35.tar.gz
Extend tr/\0-\377/blah/c support
Message-ID: <20010510185459.A5995@penderel> p4raw-id: //depot/perl@10075
Diffstat (limited to 'ext/B')
-rw-r--r--ext/B/B.xs19
-rw-r--r--ext/B/B/Deparse.pm2
2 files changed, 15 insertions, 6 deletions
diff --git a/ext/B/B.xs b/ext/B/B.xs
index b19eb7c9ea..ea4f620862 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -756,13 +756,22 @@ PVOP_pv(o)
B::PVOP o
CODE:
/*
- * OP_TRANS uses op_pv to point to a table of 256 or 258 shorts
+ * OP_TRANS uses op_pv to point to a table of 256 or >=258 shorts
* whereas other PVOPs point to a null terminated string.
*/
- ST(0) = sv_2mortal(newSVpv(o->op_pv, (o->op_type == OP_TRANS) ?
- ((o->op_private & OPpTRANS_COMPLEMENT) &&
- !(o->op_private & OPpTRANS_DELETE) ? 258 : 256)
- * sizeof(short) : 0));
+ if (o->op_type == OP_TRANS &&
+ (o->op_private & OPpTRANS_COMPLEMENT) &&
+ !(o->op_private & OPpTRANS_DELETE))
+ {
+ short* tbl = (short*)o->op_pv;
+ short entries = 257 + tbl[256];
+ ST(0) = sv_2mortal(newSVpv(o->op_pv, entries * sizeof(short)));
+ }
+ else if (o->op_type == OP_TRANS) {
+ ST(0) = sv_2mortal(newSVpv(o->op_pv, 256 * sizeof(short)));
+ }
+ else
+ ST(0) = sv_2mortal(newSVpv(o->op_pv, 0));
#define LOOP_redoop(o) o->op_redoop
#define LOOP_nextop(o) o->op_nextop
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index f88b0fbd63..21fdd15114 100644
--- a/ext/B/B/Deparse.pm
+++ b/ext/B/B/Deparse.pm
@@ -3238,7 +3238,7 @@ sub collapse {
sub tr_decode_byte {
my($table, $flags) = @_;
my(@table) = unpack("s*", $table);
- splice @table, 0x100, 1; # Just flags presence of element 0x101
+ splice @table, 0x100, 1; # Number of subsequent elements
my($c, $tr, @from, @to, @delfrom, $delhyphen);
if ($table[ord "-"] != -1 and
$table[ord("-") - 1] == -1 || $table[ord("-") + 1] == -1)