Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Porting/deparse-skips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,11 @@ uni/variables.t
../ext/XS-APItest/t/call_checker.t
../ext/XS-APItest/t/cleanup.t
../ext/XS-APItest/t/fetch_pad_names.t
../ext/XS-APItest/t/regex_global_pos.t # string literals under 'use utf8'
# are deparsed wrongly
../ext/XS-APItest/t/synthetic_scope.t
../ext/XS-APItest/t/valid_identifier.t # string literals under 'use utf8'
# are deparsed wrongly
../lib/Config.t # Config_heavy.pl fns getting output
../lib/charnames.t
../lib/dumpvar.t
Expand Down
4 changes: 2 additions & 2 deletions lib/B/Deparse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# This is based on the module of the same name by Malcolm Beattie,
# but essentially none of his code remains.

package B::Deparse 1.83;
package B::Deparse 1.84;
use strict;
use Carp;
use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
Expand Down Expand Up @@ -3485,7 +3485,7 @@ sub pp_substr_left {

my $val = 'substr(' . $self->deparse($op->first->sibling, $cx)
. ', 0, ' . $self->deparse($op->first->sibling->sibling->sibling, $cx)
. ( (($op->private & 7) == 3) ? '' : ", '')" );
. ( (($op->private & 7) == 3) ? ')' : ", '')" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could even pull the common tail out:

Suggested change
. ( (($op->private & 7) == 3) ? ')' : ", '')" );
. ( (($op->private & 7) == 3) ? '' : ", ''" )
. ')';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make the change as absolutely minimal as possible, which is why I didn't factor out the common ')'.


if ($lex) {
my $targ = $op->targ;
Expand Down
8 changes: 8 additions & 0 deletions lib/B/Deparse.t
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,14 @@ print sort(foo('bar'));
substr(my $a, 0, 0) = (foo(), bar());
$a++;
####
# 3-arg substr (non-chop)
my $str = 'ABCD';
my $bbb = substr($str, 1, 1);
####
# 3-arg substr (chop)
my $str = 'ABCD';
my $aaa = substr($str, 0, 1);
####
# 4-arg substr (non-chop)
my $str = 'ABCD';
my $bbb = substr($str, 1, 1, '');
Expand Down
Loading