diff options
author | Karl Williamson <khw@khw-desktop.(none)> | 2010-07-24 10:46:45 -0600 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-07-26 09:29:18 +0200 |
commit | e95a9fc214b6cb4aa721db3682e902f327e354f2 (patch) | |
tree | 560ddb415f34916f0975509a1d62839f72964ab5 | |
parent | a9bec28731f6ff92754c2d5febd8958a20ef8e7e (diff) | |
download | perl-e95a9fc214b6cb4aa721db3682e902f327e354f2.tar.gz |
warnings.pl: Silence perl compiler warnings
warnings.pl was trying to read two beyond the end of an array.
-rw-r--r-- | warnings.pl | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/warnings.pl b/warnings.pl index ea6e14414d..e57ed1f513 100644 --- a/warnings.pl +++ b/warnings.pl @@ -168,13 +168,13 @@ sub mkRange { my @a = @_ ; my @out = @a ; - my $i ; - - for ($i = 1 ; $i < @a; ++ $i) { + for my $i (1 .. @a - 1) { $out[$i] = ".." - if $a[$i] == $a[$i - 1] + 1 && $a[$i] + 1 == $a[$i + 1] ; + if $a[$i] == $a[$i - 1] + 1 + && ($i >= @a - 1 || $a[$i] + 1 == $a[$i + 1] ); } + $out[-1] = $a[-1] if $out[-1] eq ".."; my $out = join(",",@out); |