From 0ad63425d0107f2535132871a327c1dce47f56c6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 15 Jan 2007 03:19:54 +0000 Subject: [PATCH] Make all perl scripts use static and warnings, to ease catching errors. --- ChangeLog | 8 ++ debian/changelog | 1 + scripts/cleanup-info.pl | 4 +- scripts/dpkg-divert.pl | 57 ++++++++----- scripts/dpkg-gettext.pl | 3 +- scripts/dpkg-statoverride.pl | 40 +++++---- scripts/update-alternatives.pl | 146 +++++++++++++++++++-------------- 7 files changed, 162 insertions(+), 97 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e7c0f3b..bf3f11ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-01-15 Guillem Jover + + * scripts/dpkg-gettext.pl: Remove duplicate 'use static'. + * scripts/cleanup-info.pl: Use static and warnings. + * scripts/dpkg-divert.pl: Likewise. Declare variables with 'my'. + * scripts/dpkg-statoverride.pl: Likewise. + * scripts/update-alternatives.pl: Likewise. + 2007-01-12 Mark Rosenstand * src/help.c (checkpath): Check for the value of the macro diff --git a/debian/changelog b/debian/changelog index b5575045..a7455464 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ dpkg (1.14.0) UNRELEASED; urgency=low * Do not bail out in dpkg when building without start-stop-daemon support, by checking if the macro value is true instead of it being defined. Thanks to Mark Rosenstand. + * Make all perl scripts use static and warnings, to ease catching errors. [ Updated dpkg translations ] * Romanian (Eddy Petrișor). diff --git a/scripts/cleanup-info.pl b/scripts/cleanup-info.pl index 585b1437..7324d197 100755 --- a/scripts/cleanup-info.pl +++ b/scripts/cleanup-info.pl @@ -21,8 +21,8 @@ # using the man pages. Hopefully this is a short enough program to # debug. -# don't put that in for production. -# use strict; +use strict; +use warnings; my $dpkglibdir = "."; # This line modified by Makefile push(@INC,$dpkglibdir); diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index ed42d23c..df1cfe2b 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -1,15 +1,18 @@ #!/usr/bin/perl -- -$version= '1.0.11'; # This line modified by Makefile -$admindir= "/var/lib/dpkg"; # This line modified by Makefile -$dpkglibdir= "../utils"; # This line modified by Makefile +use strict; +use warnings; + +my $version = '1.0.11'; # This line modified by Makefile +my $admindir = "/var/lib/dpkg"; # This line modified by Makefile +my $dpkglibdir = "../utils"; # This line modified by Makefile ($0) = $0 =~ m:.*/(.+):; push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); -$enoent=`$dpkglibdir/enoent` || die sprintf(_g("Cannot get ENOENT value from %s: %s"), "$dpkglibdir/enoent", $!); +my $enoent = `$dpkglibdir/enoent` || die sprintf(_g("Cannot get ENOENT value from %s: %s"), "$dpkglibdir/enoent", $!); sub ENOENT { $enoent; } sub version { @@ -53,12 +56,23 @@ Package preinst/postrm scripts should always specify --package and --divert. "), $0); } -$testmode= 0; -$dorename= 0; -$verbose= 1; -$mode=''; +my $testmode = 0; +my $dorename = 0; +my $verbose = 1; +my $mode = ''; +my $package = ''; +my $divertto = ''; +my @contest; +my @altname; +my @package; +my $file; $|=1; + +# FIXME: those should be local. +my ($rsrc, $rdest); +my (@ssrc, @sdest); + sub checkmanymodes { return unless $mode; &badusage(sprintf(_g("two modes specified: %s and --%s"), $_, $mode)); @@ -130,7 +144,7 @@ if ($mode eq 'add') { $divertto= "$file.distrib" unless defined($divertto); $divertto =~ m#^/# || &badusage(sprintf(_g("filename \"%s\" is not absolute"), $divertto)); $package= ':' unless defined($package); - for ($i=0; $i<=$#contest; $i++) { + for (my $i = 0; $i <= $#contest; $i++) { if ($contest[$i] eq $file || $altname[$i] eq $file || $contest[$i] eq $divertto || $altname[$i] eq $divertto) { if ($contest[$i] eq $file && $altname[$i] eq $divertto && @@ -152,15 +166,15 @@ if ($mode eq 'add') { } elsif ($mode eq 'remove') { @ARGV == 1 || &badusage(sprintf(_g("--%s needs a single argument"), "remove")); $file= $ARGV[0]; - for ($i=0; $i<=$#contest; $i++) { + for (my $i = 0; $i <= $#contest; $i++) { next unless $file eq $contest[$i]; &quit(sprintf(_g("mismatch on divert-to\n when removing \`%s'\n found \`%s'"), &infoa, &infon($i))) if defined($divertto) && $altname[$i] ne $divertto; &quit(sprintf(_g("mismatch on package\n when removing \`%s'\n found \`%s'"), &infoa, &infon($i))) if defined($package) && $package[$i] ne $package; printf(_g("Removing \`%s'")."\n", &infon($i)) if $verbose > 0; - $orgfile= $contest[$i]; - $orgdivertto= $altname[$i]; + my $orgfile = $contest[$i]; + my $orgdivertto = $altname[$i]; @contest= (($i > 0 ? @contest[0..$i-1] : ()), ($i < $#contest ? @contest[$i+1..$#contest] : ())); @altname= (($i > 0 ? @altname[0..$i-1] : ()), @@ -176,15 +190,16 @@ if ($mode eq 'add') { printf(_g("No diversion \`%s', none removed")."\n", &infoa) if $verbose > 0; exit(0); } elsif ($mode eq 'list') { - @ilist= @ARGV ? @ARGV : ('*'); + my @list; + my @ilist = @ARGV ? @ARGV : ('*'); while (defined($_=shift(@ilist))) { s/\W/\\$&/g; s/\\\?/./g; s/\\\*/.*/g; push(@list,"^$_\$"); } - $pat= join('|',@list); - for ($i=0; $i<=$#contest; $i++) { + my $pat = join('|', @list); + for (my $i = 0; $i <= $#contest; $i++) { next unless ($contest[$i] =~ m/$pat/o || $altname[$i] =~ m/$pat/o || $package[$i] =~ m/$pat/o); @@ -194,7 +209,7 @@ if ($mode eq 'add') { } elsif ($mode eq 'truename') { @ARGV == 1 || &badusage(sprintf(_g("--%s needs a single argument"), "truename")); $file= $ARGV[0]; - for ($i=0; $i<=$#contest; $i++) { + for (my $i = 0; $i <= $#contest; $i++) { next unless $file eq $contest[$i]; print $altname[$i], "\n"; exit(0); @@ -226,7 +241,7 @@ sub checkrename { # same name as the diversions but with an extension that # (hopefully) wont overwrite anything. If it succeeds, we # assume a writable filesystem. - foreach $file ($rsrc,$rdest) { + foreach my $file ($rsrc, $rdest) { if (open (TMP, ">> ${file}.dpkg-devert.tmp")) { close TMP; unlink ("${file}.dpkg-devert.tmp"); @@ -259,7 +274,7 @@ sub save { return if $testmode; open(N,"> $admindir/diversions-new") || &quit(sprintf(_g("create diversions-new: %s"), $!)); chmod 0644, "$admindir/diversions-new"; - for ($i=0; $i<=$#contest; $i++) { + for (my $i = 0; $i <= $#contest; $i++) { print(N "$contest[$i]\n$altname[$i]\n$package[$i]\n") || &quit(sprintf(_g("write diversions-new: %s"), $!)); } @@ -273,7 +288,11 @@ sub save { } sub infoa { &infol($file,$divertto,$package); } -sub infon { &infol($contest[$i],$altname[$i],$package[$i]); } +sub infon +{ + my $i = shift; + &infol($contest[$i], $altname[$i], $package[$i]); +} sub quit { diff --git a/scripts/dpkg-gettext.pl b/scripts/dpkg-gettext.pl index 6bbfb3c1..c7dca780 100644 --- a/scripts/dpkg-gettext.pl +++ b/scripts/dpkg-gettext.pl @@ -1,9 +1,8 @@ #!/usr/bin/perl -w -use strict; -use warnings; # Copied from /usr/share/perl5/Debconf/Gettext.pm use strict; +use warnings; BEGIN { eval 'use Locale::gettext'; diff --git a/scripts/dpkg-statoverride.pl b/scripts/dpkg-statoverride.pl index 9023e69e..1f7fcd6d 100755 --- a/scripts/dpkg-statoverride.pl +++ b/scripts/dpkg-statoverride.pl @@ -1,10 +1,13 @@ #! /usr/bin/perl +use strict; +use warnings; + use POSIX; use POSIX qw(:errno_h :signal_h); -$admindir= "/var/lib/dpkg"; # This line modified by Makefile -$version= '1.3.0'; # This line modified by Makefile +my $admindir = "/var/lib/dpkg"; # This line modified by Makefile +my $version = '1.3.0'; # This line modified by Makefile ($0) = $0 =~ m:.*/(.+):; @@ -13,10 +16,14 @@ push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); -$verbose= 1; -$doforce= 0; -$doupdate= 0; -$mode= ""; +my $verbose = 1; +my $doforce = 0; +my $doupdate = 0; +my $mode = ""; + +my %owner; +my %group; +my %mode; sub version { printf _g("Debian %s version %s.\n"), $0, $version; @@ -87,8 +94,8 @@ while (@ARGV) { } } -$dowrite=0; -$exitcode=0; +my $dowrite = 0; +my $exitcode = 0; &badusage(_g("no mode specified")) unless $mode; &ReadOverrides; @@ -96,25 +103,30 @@ $exitcode=0; if ($mode eq "add") { @ARGV==4 || &badusage(_g("--add needs four arguments")); - $user=$ARGV[0]; + my $user = $ARGV[0]; + my $uid = 0; + my $gid = 0; + if ($user =~ m/^#([0-9]+)$/) { $uid=$1; &badusage(sprintf(_g("illegal user %s"), $user)) if ($uid<0); } else { + my ($name, $pw); (($name,$pw,$uid)=getpwnam($user)) || &badusage(sprintf(_g("non-existing user %s"), $user)); } - $group=$ARGV[1]; + my $group = $ARGV[1]; if ($group =~ m/^#([0-9]+)$/) { $gid=$1; &badusage(sprintf(_g("illegal group %s"), $group)) if ($gid<0); } else { + my ($name, $pw); (($name,$pw,$gid)=getgrnam($group)) || &badusage(sprintf(_g("non-existing group %s"), $group)); } - $mode= $ARGV[2]; + my $mode = $ARGV[2]; (($mode<0) or (oct($mode)>07777) or ($mode !~ m/\d+/)) && &badusage(sprintf(_g("illegal mode %s"), $mode)); - $file= $ARGV[3]; + my $file = $ARGV[3]; $file =~ m/\n/ && &badusage(_g("file may not contain newlines")); $file =~ s,/+$,, && print STDERR _g("stripping trailing /")."\n"; @@ -142,7 +154,7 @@ if ($mode eq "add") { } } elsif ($mode eq "remove") { @ARGV==1 || &badusage(sprintf(_g("--%s needs a single argument"), "remove")); - $file=$ARGV[0]; + my $file = $ARGV[0]; $file =~ s,/+$,, && print STDERR _g("stripping trailing /")."\n"; if (not defined $owner{$file}) { print STDERR _g("No override present.")."\n"; @@ -165,7 +177,7 @@ if ($mode eq "add") { s,/+$,, && print STDERR _g("stripping trailing /")."\n"; push(@list,"^$_\$"); } - $pat= join('|',@list); + my $pat = join('|', @list); $exitcode=1; for $file (keys %owner) { next unless ($file =~ m/$pat/o); diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl index 7da0ea65..7d39b84b 100755 --- a/scripts/update-alternatives.pl +++ b/scripts/update-alternatives.pl @@ -1,8 +1,11 @@ #!/usr/bin/perl -- -$admindir= "/var/lib/dpkg"; # This line modified by Makefile -$dpkglibdir= "../utils"; # This line modified by Makefile -$version= '0.93.80'; # This line modified by Makefile +use strict; +use warnings; + +my $admindir = "/var/lib/dpkg"; # This line modified by Makefile +my $dpkglibdir = "../utils"; # This line modified by Makefile +my $version = '0.93.80'; # This line modified by Makefile push (@INC, $dpkglibdir); require 'dpkg-gettext.pl'; textdomain("dpkg"); @@ -10,27 +13,44 @@ textdomain("dpkg"); ($0) = $0 =~ m:.*/(.+):; # Global variables: -# $alink Alternative we are managing (ie the symlink we're making/removing) (install only) -# $name Name of the alternative (the symlink) we are processing -# $apath Path of alternative we are offering -# $apriority Priority of link (only when we are installing an alternative) -# $mode action to perform (display / install / remove / display / auto / config) -# $manual update-mode for alternative (manual / auto) -# $state State of alternative: -# expected: alternative with highest priority is the active alternative -# expected-inprogress: busy selecting alternative with highest priority -# unexpected: alternative another alternative is active / error during readlink -# nonexistent: alternative-symlink does not exist -# $link Link we are working with -# @slavenames List with names of slavelinks -# %slavenum Map from name of slavelink to slave-index (into @slavelinks) -# @slavelinks List of slavelinks (indexed by slave-index) -# %versionnum Map from currently available versions into @versions and @priorities -# @versions List of available versions for alternative -# %priorities Map from @version-index to priority -# %slavepath Map from (@version-index,slavename) to slave-path - -$enoent=`$dpkglibdir/enoent` || die sprintf(_g("Cannot get ENOENT value from %s: %s"), "$dpkglibdir/enoent", $!); +my $mode = ''; # Action to perform (display / install / remove / display / auto / config) +my $manual = 'auto'; # Update mode for alternative (manual / auto) +my $state; # State of alternative: + # expected: alternative with highest priority is the active alternative + # expected-inprogress: busy selecting alternative with highest priority + # unexpected: alternative another alternative is active / error during readlink + # nonexistent: alternative-symlink does not exist +my $dataread; + +my %versionnum; # Map from currently available versions into @versions and @priorities +my @versions; # List of available versions for alternative +my @priorities; # Map from @version-index to priority + +my $best; +my $bestpri; +my $bestnum; + +my $link; # Link we are working with +my $linkname; + +my $alink; # Alternative we are managing (ie the symlink we're making/removing) (install only) +my $name; # Name of the alternative (the symlink) we are processing +my $apath; # Path of alternative we are offering +my $apriority; # Priority of link (only when we are installing an alternative) +my %aslavelink; +my %aslavepath; +my %aslavelinkcount; + +my $slink; +my $sname; +my $spath; +my @slavenames; # List with names of slavelinks +my %slavenum; # Map from name of slavelink to slave-index (into @slavelinks) +my @slavelinks; # List of slavelinks (indexed by slave-index) +my %slavepath; # Map from (@version-index,slavename) to slave-path +my %slavelinkcount; + +my $enoent = `$dpkglibdir/enoent` || die sprintf(_g("Cannot get ENOENT value from %s: %s"), "$dpkglibdir/enoent", $!); sub ENOENT { $enoent; } sub version { @@ -97,12 +117,11 @@ sub badusage exit(2); } -$altdir= '/etc/alternatives'; -$admindir= $admindir . '/alternatives'; -$testmode= 0; -$verbosemode= 0; -$mode=''; -$manual= 'auto'; +my $altdir = '/etc/alternatives'; +# FIXME: this should not override the previous assignment. +$admindir = $admindir . '/alternatives'; +my $testmode = 0; +my $verbosemode = 0; $|=1; sub checkmanymodes { @@ -188,11 +207,12 @@ if (open(AF,"$admindir/$name")) { defined($versionnum{$version}) && &badfmt(sprintf(_g("duplicate path %s"), $version)); if ( -r $version ) { push(@versions,$version); + my $i; $versionnum{$version}= $i= $#versions; - $priority= &gl("priority"); + my $priority = &gl("priority"); $priority =~ m/^[-+]?\d+$/ || &badfmt(sprintf(_g("priority %s %s"), $version, $priority)); $priorities[$i]= $priority; - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { $slavepath{$i,$j}= &gl("spath"); } } else { @@ -200,7 +220,7 @@ if (open(AF,"$admindir/$name")) { &pr(sprintf(_g("Alternative for %s points to %s - which wasn't found. Removing from list of alternatives."), $name, $version)) if $verbosemode > 0; &gl("priority"); - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { &gl("spath"); } } @@ -225,13 +245,14 @@ if ($mode eq 'display') { &pr(sprintf(_g(" link unreadable - %s"), $!)); } $best= ''; - for ($i=0; $i<=$#versions; $i++) { + for (my $i = 0; $i <= $#versions; $i++) { if ($best eq '' || $priorities[$i] > $bestpri) { $best= $versions[$i]; $bestpri= $priorities[$i]; } &pr(sprintf(_g("%s - priority %s"), $versions[$i], $priorities[$i])); - for ($j=0; $j<=$#slavenames; $j++) { - next unless length($tspath= $slavepath{$i,$j}); + for (my $j = 0; $j <= $#slavenames; $j++) { + my $tspath = $slavepath{$i, $j}; + next unless length($tspath); &pr(sprintf(_g(" slave %s: %s"), $slavenames[$j], $tspath)); } } @@ -246,7 +267,7 @@ if ($mode eq 'display') { if ($mode eq 'list') { if ($dataread) { - for ($i = 0; $i<=$#versions; $i++) { + for (my $i = 0; $i <= $#versions; $i++) { &pr("$versions[$i]"); } } @@ -254,7 +275,7 @@ if ($mode eq 'list') { } $best= ''; -for ($i=0; $i<=$#versions; $i++) { +for (my $i = 0; $i <= $#versions; $i++) { if ($best eq '' || $priorities[$i] > $bestpri) { $best= $versions[$i]; $bestpri= $priorities[$i]; } @@ -337,18 +358,20 @@ if ($mode eq 'install') { &quit(sprintf(_g("unable to rename %s to %s: %s"), $link, $alink, $!)); } $link= $alink; + my $i; if (!defined($i= $versionnum{$apath})) { push(@versions,$apath); $versionnum{$apath}= $i= $#versions; } $priorities[$i]= $apriority; for $sname (keys %aslavelink) { + my $j; if (!defined($j= $slavenum{$sname})) { push(@slavenames,$sname); $slavenum{$sname}= $j= $#slavenames; } - $oldslavelink= $slavelinks[$j]; - $newslavelink= $aslavelink{$sname}; + my $oldslavelink = $slavelinks[$j]; + my $newslavelink = $aslavelink{$sname}; $slavelinkcount{$oldslavelink}-- if $oldslavelink ne ''; $slavelinkcount{$newslavelink}++ && &quit(sprintf(_g("slave link name %s duplicated"), $newslavelink)); @@ -360,23 +383,24 @@ if ($mode eq 'install') { } $slavelinks[$j]= $newslavelink; } - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { $slavepath{$i,$j}= $aslavepath{$slavenames[$j]}; } } if ($mode eq 'remove') { + my $hits = 0; if ($manual eq "manual" and $state ne "expected" and (map { $hits += $apath eq $_ } @versions) and $hits and $linkname eq $apath) { &pr(_g("Removing manually selected alternative - switching to auto mode")); $manual= "auto"; } - if (defined($i= $versionnum{$apath})) { - $k= $#versions; + if (defined(my $i = $versionnum{$apath})) { + my $k = $#versions; $versionnum{$versions[$k]}= $i; delete $versionnum{$versions[$i]}; $versions[$i]= $versions[$k]; $#versions--; $priorities[$i]= $priorities[$k]; $#priorities--; - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { $slavepath{$i,$j}= $slavepath{$k,$j}; delete $slavepath{$k,$j}; } @@ -388,12 +412,12 @@ if ($mode eq 'remove') { if ($mode eq 'remove-all') { $manual= "auto"; - $k= $#versions; - for ($i=0; $i<=$#versions; $i++) { + my $k = $#versions; + for (my $i = 0; $i <= $#versions; $i++) { $k--; delete $versionnum{$versions[$i]}; $#priorities--; - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { $slavepath{$i,$j}= $slavepath{$k,$j}; delete $slavepath{$k,$j}; } @@ -402,8 +426,9 @@ if ($mode eq 'remove-all') { } -for ($j=0; $j<=$#slavenames; $j++) { - for ($i=0; $i<=$#versions; $i++) { +for (my $j = 0; $j <= $#slavenames; $j++) { + my $i; + for ($i = 0; $i <= $#versions; $i++) { last if $slavepath{$i,$j} ne ''; } if ($i > $#versions) { @@ -413,13 +438,13 @@ for ($j=0; $j<=$#slavenames; $j++) { &quit(sprintf(_g("unable to remove %s: %s"), "$altdir/$slavenames[$j]", $!)); unlink($slavelinks[$j]) || $! == &ENOENT || &quit(sprintf(_g("unable to remove %s: %s"), $slavelinks[$j], $!)); - $k= $#slavenames; + my $k = $#slavenames; $slavenum{$slavenames[$k]}= $j; delete $slavenum{$slavenames[$j]}; $slavelinkcount{$slavelinks[$j]}--; $slavenames[$j]= $slavenames[$k]; $#slavenames--; $slavelinks[$j]= $slavelinks[$k]; $#slavelinks--; - for ($i=0; $i<=$#versions; $i++) { + for (my $i = 0; $i <= $#versions; $i++) { $slavepath{$i,$j}= $slavepath{$i,$k}; delete $slavepath{$i,$k}; } @@ -452,19 +477,19 @@ open(AF,">$admindir/$name.dpkg-new") || &quit(sprintf(_g("unable to open %s for write: %s"), "$admindir/$name.dpkg-new", $!)); &paf($manual); &paf($link); -for ($j=0; $j<=$#slavenames; $j++) { +for (my $j = 0; $j <= $#slavenames; $j++) { &paf($slavenames[$j]); &paf($slavelinks[$j]); } &paf(''); $best= ''; -for ($i=0; $i<=$#versions; $i++) { +for (my $i = 0; $i <= $#versions; $i++) { if ($best eq '' || $priorities[$i] > $bestpri) { $best= $versions[$i]; $bestpri= $priorities[$i]; $bestnum= $i; } &paf($versions[$i]); &paf($priorities[$i]); - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { &paf($slavepath{$i,$j}); } } @@ -516,7 +541,7 @@ rename_mv("$admindir/$name.dpkg-new","$admindir/$name") || if ($manual eq 'auto') { rename_mv("$altdir/$name.dpkg-tmp","$altdir/$name") || &quit(sprintf(_g("unable to install %s as %s: %s"), "$altdir/$name.dpkg-tmp", "$altdir/$name", $!)); - for ($j=0; $j<=$#slavenames; $j++) { + for (my $j = 0; $j <= $#slavenames; $j++) { $sname= $slavenames[$j]; $slink= $slavelinks[$j]; if (!defined($linkname= readlink($slink)) && $! != &ENOENT) { @@ -569,7 +594,7 @@ sub config_message { " Selection Alternative\n". "-----------------------------------------------\n"), $#versions+1, $name); - for ($i=0; $i<=$#versions; $i++) { + for (my $i = 0; $i <= $#versions; $i++) { printf(STDOUT "%s%s %8s %s\n", (readlink("$altdir/$name") eq $versions[$i]) ? '*' : ' ', ($best eq $versions[$i]) ? '+' : ' ', @@ -579,6 +604,7 @@ sub config_message { } sub config_alternatives { + my $preferred; do { &config_message; if ($#versions == 0) { return; } @@ -616,8 +642,8 @@ sub config_alternatives { sub set_alternatives { $manual = "manual"; # Get prefered number - $preferred = -1; - for ($i=0; $i<=$#versions; $i++) { + my $preferred = -1; + for (my $i = 0; $i <= $#versions; $i++) { if($versions[$i] eq $apath) { $preferred = $i; last; @@ -632,8 +658,8 @@ sub set_alternatives { rename_mv("$altdir/$name.dpkg-tmp","$altdir/$name") || &quit(sprintf(_g("unable to install %s as %s: %s"), "$altdir/$name.dpkg-tmp", "$altdir/$name", $!)); # Link slaves... - for( $slnum = 0; $slnum < @slavenames; $slnum++ ) { - $slave = $slavenames[$slnum]; + for (my $slnum = 0; $slnum < @slavenames; $slnum++ ) { + my $slave = $slavenames[$slnum]; if ($slavepath{$preferred,$slnum} ne '') { checked_symlink($slavepath{$preferred,$slnum}, "$altdir/$slave.dpkg-tmp"); -- 2.39.5