summaryrefslogtreecommitdiff
path: root/Porting
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-10-20 12:21:01 +0100
committerDavid Mitchell <davem@iabyn.com>2017-10-23 11:52:02 +0100
commita6d04d4a416678fd2fca673a2ae82d27327a17de (patch)
tree7ff353b7bd5556aed6a3bce734a6eaaf1147b857 /Porting
parent78d44f6b66556e32bff56e2900677530ad3e66a7 (diff)
downloadperl-a6d04d4a416678fd2fca673a2ae82d27327a17de.tar.gz
bench.pl: allow negative column indices
e.g. --norm=-2 will make the second-to-rightmost column the 100% one Also fix a slight bug in the existing positive (0..N-1) column selection code: it didn't match against more than one digit, so for example --norm=10 didn't work.
Diffstat (limited to 'Porting')
-rwxr-xr-xPorting/bench.pl31
1 files changed, 27 insertions, 4 deletions
diff --git a/Porting/bench.pl b/Porting/bench.pl
index fff0161488..cdce94d526 100755
--- a/Porting/bench.pl
+++ b/Porting/bench.pl
@@ -303,7 +303,21 @@ If only one field is selected, the output is in more compact form.
--norm=I<foo>
Specify which perl column in the output to treat as the 100% norm.
-It may be a column number (0..N-1) or a perl executable name or label.
+It may be:
+
+=over
+
+* a column number (0..N-1),
+
+* a negative column number (-1..-N) which counts from the right (so -1 is
+the right-most column),
+
+* or a perl executable name,
+
+* or a perl executable label.
+
+=back
+
It defaults to the leftmost column.
=item *
@@ -614,10 +628,19 @@ sub read_tests_file {
sub select_a_perl {
my ($perl, $perls, $who) = @_;
- $perls||=[];
- if ($perl =~ /^[0-9]$/) {
+ $perls ||= [];
+ my $n = @$perls;
+
+ if ($perl =~ /^-([0-9]+)$/) {
+ my $p = $1;
+ die "Error: $who value $perl outside range -1..-$n\n"
+ if $p < 1 || $p > $n;
+ return $n - $p;
+ }
+
+ if ($perl =~ /^[0-9]+$/) {
die "Error: $who value $perl outside range 0.." . $#$perls . "\n"
- unless $perl < @$perls;
+ unless $perl < $n;
return $perl;
}
else {