The following commit has been merged in the master branch:
commit 503c1e8a4689fe3c329a2ff1dd7f3c2db0d60d3f
Author: Guillem Jover <[email protected]>
Date:   Tue Jan 1 03:00:54 2013 +0100

    perl: Use the .. operator instead of C-style for loops
    
    Fixes ControlStructures::ProhibitCStyleForLoops.
    
    Warned-by: perlcritic

diff --git a/dselect/mkcurkeys.pl b/dselect/mkcurkeys.pl
index d2f5783..882fa1f 100755
--- a/dselect/mkcurkeys.pl
+++ b/dselect/mkcurkeys.pl
@@ -38,9 +38,11 @@ while (<$override_fh>) {
 }
 close($override_fh);
 
-for (my $i = 1, my $let = 'A'; $i <= 26; $i++, $let++) {
+my $let = 'A';
+for my $i (1 .. 26) {
     $name{$i}= "^$let";
     $base{$i}= '';
+    $let++;
 }
 
 our ($k, $v);
@@ -78,7 +80,7 @@ END
 
 my ($comma);
 
-for (my $i = 33; $i <= 126; $i++) {
+for my $i (33 .. 126) {
     $k= $i;
     $v = pack('C', $i);
     if ($v eq ',') { $comma=$k; next; }
@@ -100,7 +102,7 @@ for $k (sort {
     p();
 }
 
-for (my $i = 1; $i < 64; $i++) {
+for my $i (1 .. 63) {
     $k= "KEY_F($i)"; $v= "F$i";
     p();
 }
diff --git a/scripts/Dpkg/Shlibs/Symbol.pm b/scripts/Dpkg/Shlibs/Symbol.pm
index ae53e43..ea767cf 100644
--- a/scripts/Dpkg/Shlibs/Symbol.pm
+++ b/scripts/Dpkg/Shlibs/Symbol.pm
@@ -265,7 +265,7 @@ sub equals {
     if ($opts{tags}) {
        return 0 if scalar(@{$self->{tagorder}}) != 
scalar(@{$other->{tagorder}});
 
-       for (my $i = 0; $i < scalar(@{$self->{tagorder}}); $i++) {
+       for my $i (0 .. scalar(@{$self->{tagorder}}) - 1) {
            my $tag = $self->{tagorder}->[$i];
            return 0 if $tag ne $other->{tagorder}->[$i];
            if (defined $self->{tags}{$tag} && defined $other->{tags}{$tag}) {
diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm 
b/scripts/Dpkg/Shlibs/SymbolFile.pm
index 6328f4b..9a4fac0 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -60,7 +60,7 @@ my %blacklist = (
     _SDA_BASE_ => 1,                   # powerpc
 );
 
-for (my $i = 14; $i <= 31; $i++) {
+for my $i (14 .. 31) {
     # Many powerpc specific symbols
     $blacklist{"_restfpr_$i"} = 1;
     $blacklist{"_restfpr_$i\_x"} = 1;
diff --git a/scripts/Dpkg/Source/Functions.pm b/scripts/Dpkg/Source/Functions.pm
index d830b0b..dcb23af 100644
--- a/scripts/Dpkg/Source/Functions.pm
+++ b/scripts/Dpkg/Source/Functions.pm
@@ -44,7 +44,7 @@ sub erasedir {
 
 sub fixperms {
     my ($dir) = @_;
-    my ($mode, $modes_set, $i, $j);
+    my ($mode, $modes_set);
     # Unfortunately tar insists on applying our umask _to the original
     # permissions_ rather than mostly-ignoring the original
     # permissions.  We fix it up with chmod -R (which saves us some
@@ -52,11 +52,11 @@ sub fixperms {
     # of a palaver.  (Numeric doesn't work because we need [ugo]+X
     # and [ugo]=<stuff> doesn't work because that unsets sgid on dirs.)
     $mode = 0777 & ~umask;
-    for ($i = 0; $i < 9; $i += 3) {
+    for my $i (0 .. 2) {
         $modes_set .= ',' if $i;
-        $modes_set .= qw(u g o)[$i/3];
-        for ($j = 0; $j < 3; $j++) {
-            $modes_set .= $mode & (0400 >> ($i+$j)) ? '+' : '-';
+        $modes_set .= qw(u g o)[$i];
+        for my $j (0 .. 2) {
+            $modes_set .= $mode & (0400 >> ($i * 3 + $j)) ? '+' : '-';
             $modes_set .= qw(r w X)[$j];
         }
     }
diff --git a/scripts/t/190_Dpkg_Shlibs_Cppfilt.t 
b/scripts/t/190_Dpkg_Shlibs_Cppfilt.t
index acacf15..1bda4a5 100644
--- a/scripts/t/190_Dpkg_Shlibs_Cppfilt.t
+++ b/scripts/t/190_Dpkg_Shlibs_Cppfilt.t
@@ -77,8 +77,8 @@ my @demangledtext = split(/\n+/s, <<'END');
 00000000002f6160  w   DO .data.rel.ro   0000000000000050  VTT for 
std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> 
>@GLIBCXX_3.4
 END
 
-for (my $try = 1; $try <= 7; $try++) {
-    for (my $i = 0; $i <= $#mangledtext; $i++) {
+for my $try (1 .. 7) {
+    for my $i (0 .. $#mangledtext) {
        my $demangled = cppfilt_demangle_cpp($mangledtext[$i]) || 
$mangledtext[$i];
        is($demangled, $demangledtext[$i], "mass c++ demangling (${try}x" . 
(${i} + 1) . ')');
     }
diff --git a/src/t/100_dpkg_divert.t b/src/t/100_dpkg_divert.t
index 5b976a7..40af7a9 100644
--- a/src/t/100_dpkg_divert.t
+++ b/src/t/100_dpkg_divert.t
@@ -125,9 +125,11 @@ sub diversions_pack {
     my (@data) = @_;
     my @data_packed;
 
+    ## no critic (ControlStructures::ProhibitCStyleForLoops)
     for (my ($i) = 0; $i < $#data; $i += 3) {
         push @data_packed, [ @data[$i .. $i + 2] ];
     }
+    ## use critic
     my @list = sort { $a->[0] cmp $b->[0] } @data_packed;
 
     return @list;
diff --git a/test/100_critic.t b/test/100_critic.t
index bf50cd8..f064e5e 100644
--- a/test/100_critic.t
+++ b/test/100_critic.t
@@ -46,6 +46,7 @@ my @policies = qw(
     ClassHierarchies::ProhibitOneArgBless
     CodeLayout::ProhibitQuotedWordLists
     CodeLayout::RequireConsistentNewlines
+    ControlStructures::ProhibitCStyleForLoops
     ControlStructures::ProhibitLabelsWithSpecialBlockNames
     ControlStructures::ProhibitUntilBlocks
     Documentation::RequirePackageMatchesPodName
diff --git a/utils/t/100_update_alternatives.t 
b/utils/t/100_update_alternatives.t
index 1a46e3d..6df0504 100644
--- a/utils/t/100_update_alternatives.t
+++ b/utils/t/100_update_alternatives.t
@@ -175,7 +175,7 @@ sub get_slaves_status {
     my %slaves;
     # None of the slaves are installed
     foreach my $alt (@choices) {
-       for(my $i = 0; $i < @{$alt->{slaves}}; $i++) {
+       for my $i (0 .. @{$alt->{slaves}} - 1) {
            $slaves{$alt->{slaves}[$i]{name}} = $alt->{slaves}[$i];
            $slaves{$alt->{slaves}[$i]{name}}{installed} = 0;
        }
@@ -183,7 +183,7 @@ sub get_slaves_status {
     # except those of the current alternative (minus optional slaves)
     if (defined($id)) {
        my $alt = $choices[$id];
-       for(my $i = 0; $i < @{$alt->{slaves}}; $i++) {
+       for my $i (0 .. @{$alt->{slaves}} - 1) {
            $slaves{$alt->{slaves}[$i]{name}} = $alt->{slaves}[$i];
            if (-e $alt->{slaves}[$i]{path}) {
                $slaves{$alt->{slaves}[$i]{name}}{installed} = 1;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to