summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-11-06 16:47:00 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-11-06 16:47:00 +0000
commit3021e910718c4702abe831c7aa53e8a7bf8b135f (patch)
treee342014ee05783e78a37b18970bd6168610c30f8 /perl-install
parent371749c6a25c7aec0874e21d68ec212b2bf2dab7 (diff)
downloaddrakx-3021e910718c4702abe831c7aa53e8a7bf8b135f.tar
drakx-3021e910718c4702abe831c7aa53e8a7bf8b135f.tar.gz
drakx-3021e910718c4702abe831c7aa53e8a7bf8b135f.tar.bz2
drakx-3021e910718c4702abe831c7aa53e8a7bf8b135f.tar.xz
drakx-3021e910718c4702abe831c7aa53e8a7bf8b135f.zip
please perl_checker:
- local'ize $_ before doing while (<...>) - use "foreach" instead of "for" - remove unneeded parentheses on the right side of infix if/foreach/unless
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/Xconfig/test.pm5
-rw-r--r--perl-install/Xconfig/xfree4.pm2
-rw-r--r--perl-install/bootloader.pm2
-rw-r--r--perl-install/commands.pm20
-rw-r--r--perl-install/detect_devices.pm4
-rw-r--r--perl-install/install_steps.pm2
-rw-r--r--perl-install/pkgs.pm1
-rw-r--r--perl-install/printer.pm70
-rw-r--r--perl-install/printerdrake.pm6
-rw-r--r--perl-install/ugtk.pm2
10 files changed, 60 insertions, 54 deletions
diff --git a/perl-install/Xconfig/test.pm b/perl-install/Xconfig/test.pm
index d5b2f1334..38d9f9377 100644
--- a/perl-install/Xconfig/test.pm
+++ b/perl-install/Xconfig/test.pm
@@ -67,12 +67,14 @@ sub test {
my $b = before_leaving { unlink $f_err };
if (!xtest(":9")) {
- local $_;
local *F; open F, $f_err;
+
+ local $_;
i: while (<F>) {
if (Xconfig::card::using_xf4($card)) {
if (/^\(EE\)/ && !/Disabling/ || /^Fatal\b/) {
my @msg = !/error/ && $_ ;
+ local $_;
while (<F>) {
/reporting a problem/ and last;
push @msg, $_;
@@ -83,6 +85,7 @@ sub test {
} else {
if (/\b(error|not supported)\b/i) {
my @msg = !/error/ && $_ ;
+ local $_;
while (<F>) {
/not fatal/ and last i;
/^$/ and last;
diff --git a/perl-install/Xconfig/xfree4.pm b/perl-install/Xconfig/xfree4.pm
index 542226000..88cad5b06 100644
--- a/perl-install/Xconfig/xfree4.pm
+++ b/perl-install/Xconfig/xfree4.pm
@@ -49,7 +49,7 @@ sub new_mouse_sections {
} (1 .. $nb_new);
push @$layout, { val => qq("Mouse1" "CorePointer") };
- push @$layout, { val => qq("Mouse$_" "SendCoreEvents") } foreach (2 .. $nb_new);
+ push @$layout, { val => qq("Mouse$_" "SendCoreEvents") } foreach 2 .. $nb_new;
@l;
}
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 48879cf31..91691d0ea 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -591,7 +591,7 @@ sub get_of_dev {
run_program::rooted_or_die($::prefix, "/usr/sbin/ofpath $unix_dev", ">", "/tmp/ofpath");
open(FILE, "$::prefix/tmp/ofpath") || die "Can't open $::prefix/tmp/ofpath";
my $of_dev = "";
- local $_ = "";
+ local $_;
while (<FILE>){
$of_dev = $_;
}
diff --git a/perl-install/commands.pm b/perl-install/commands.pm
index 4828c506e..f3503eb10 100644
--- a/perl-install/commands.pm
+++ b/perl-install/commands.pm
@@ -319,11 +319,13 @@ sub head_tail {
$n = $n ? shift : 10;
local *F; @_ ? open(F, $_[0]) || die "error: can't open file $_[0]\n" : (*F = *STDIN);
- local $_;
if ($0 eq 'head') {
+ local $_;
while (<F>) { $n-- or return; print }
} else {
- @_ = (); while (<F>) { push @_, $_; @_ > $n and shift }
+ @_ = ();
+ local $_;
+ while (<F>) { push @_, $_; @_ > $n and shift }
print @_;
}
}
@@ -334,7 +336,9 @@ sub strings {
my ($h, $o, $n) = getopts(\@_, qw(hon));
$h and die "usage: strings [-o] [-n min-length] [<files>]\n";
$n = $n ? shift : 4;
- $/ = "\0"; @ARGV = @_; my $l = 0; while (<>) {
+ $/ = "\0"; @ARGV = @_; my $l = 0;
+ local $_;
+ while (<>) {
while (/[$printable_chars]{$n,}/og) {
printf "%07d ", ($l + length $') if $o;
print "$&\n" ;
@@ -344,7 +348,9 @@ sub strings {
}
sub hexdump {
- my $i = 0; $/ = \16; @ARGV = @_; while (<>) {
+ my $i = 0; $/ = \16; @ARGV = @_;
+ local $_;
+ while (<>) {
printf "%08lX ", $i; $i += 16;
print join(" ", (map { sprintf "%02X", $_ } unpack("C*", $_)),
(s/[^$printable_chars]/./og, $_)[1]), "\n";
@@ -355,8 +361,10 @@ sub more {
@ARGV = @_;
require devices;
my $tty = devices::make('tty');
- local *IN; open IN, "<$tty" or die "can't open $tty\n";
- my $n = 0; while (<>) {
+ my $n = 0;
+ local *IN; open IN, $tty or die "can't open $tty\n";
+ local $_;
+ while (<>) {
if (++$n == 25) {
my $v = <IN>;
$v =~ /^q/ and exit 0;
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm
index f1543f46c..2c8c71f3d 100644
--- a/perl-install/detect_devices.pm
+++ b/perl-install/detect_devices.pm
@@ -617,8 +617,8 @@ sub whatUsbport() {
foreach $i (0..15) {
my $port = "/dev/usb/lp$i";
my $realport = devices::make($port);
- next if (!$realport);
- next if (! -r $realport);
+ next if !$realport;
+ next if ! -r $realport;
open PORT, $realport or do next;
my $idstr = "";
# Calculation of IOCTL function 0x84005001 (to get device ID
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index cb4fbffef..2f40121f6 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -1021,7 +1021,7 @@ sub upNetwork {
#- do not destroy this file if prefix is '' or even '/' (could it happens ?).
if (length($o->{prefix}) > 1) {
- symlinkf("$o->{prefix}/etc/$_", "/etc/$_") foreach (qw(resolv.conf protocols services));
+ symlinkf("$o->{prefix}/etc/$_", "/etc/$_") foreach qw(resolv.conf protocols services);
}
member($o->{method}, qw(ftp http nfs)) and return 1;
modules::write_conf($o->{prefix});
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index ff7f7506f..0dfc07b6f 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -451,6 +451,7 @@ sub read_rpmsrate {
my $line_nb = 0;
my $fatal_error;
my (@l);
+ local $_;
while (<$f>) {
$line_nb++;
/\t/ and die "tabulations not allowed at line $line_nb\n";
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 8f01ea1ba..28f0edddd 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -117,7 +117,7 @@ sub get_default_spooler () {
sub set_default_spooler ($) {
my ($printer) = @_;
# Make Foomatic config directory if it does not exist yet
- mkdir "$prefix$FOOMATICCONFDIR" if (!(-d "$prefix$FOOMATICCONFDIR"));
+ mkdir "$prefix$FOOMATICCONFDIR" if !(-d "$prefix$FOOMATICCONFDIR");
# Mark the default driver in a file
open DEFSPOOL, "> $prefix$FOOMATIC_DEFAULT_SPOOLER" or
die "Cannot create $prefix$FOOMATIC_DEFAULT_SPOOLER!";
@@ -148,13 +148,13 @@ sub set_permissions {
sub restart_service ($) {
my ($service) = @_;
# Exit silently if the service is not installed
- return 1 if (!(-x "$prefix/etc/rc.d/init.d/$service"));
+ return 1 if !(-x "$prefix/etc/rc.d/init.d/$service");
run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "restart");
if (($? >> 8) != 0) {
return 0;
} else {
# CUPS needs some time to come up.
- wait_for_cups() if ($service eq "cups");
+ wait_for_cups() if $service eq "cups";
return 1;
}
}
@@ -162,13 +162,13 @@ sub restart_service ($) {
sub start_service ($) {
my ($service) = @_;
# Exit silently if the service is not installed
- return 1 if (!(-x "$prefix/etc/rc.d/init.d/$service"));
+ return 1 if !(-x "$prefix/etc/rc.d/init.d/$service");
run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "start");
if (($? >> 8) != 0) {
return 0;
} else {
# CUPS needs some time to come up.
- wait_for_cups() if ($service eq "cups");
+ wait_for_cups() if $service eq "cups";
return 1;
}
}
@@ -176,7 +176,7 @@ sub start_service ($) {
sub start_not_running_service ($) {
my ($service) = @_;
# Exit silently if the service is not installed
- return 1 if (!(-x "$prefix/etc/rc.d/init.d/$service"));
+ return 1 if !(-x "$prefix/etc/rc.d/init.d/$service");
run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "status");
# The exit status is not zero when the service is not running
if (($? >> 8) != 0) {
@@ -185,7 +185,7 @@ sub start_not_running_service ($) {
return 0;
} else {
# CUPS needs some time to come up.
- wait_for_cups() if ($service eq "cups");
+ wait_for_cups() if $service eq "cups";
return 1;
}
} else {
@@ -196,7 +196,7 @@ sub start_not_running_service ($) {
sub stop_service ($) {
my ($service) = @_;
# Exit silently if the service is not installed
- return 1 if (!(-x "$prefix/etc/rc.d/init.d/$service"));
+ return 1 if !(-x "$prefix/etc/rc.d/init.d/$service");
run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "stop");
if (($? >> 8) != 0) { return 0 } else { return 1 }
}
@@ -204,7 +204,7 @@ sub stop_service ($) {
sub service_running ($) {
my ($service) = @_;
# Exit silently if the service is not installed
- return 0 if (!(-x "$prefix/etc/rc.d/init.d/$service"));
+ return 0 if !(-x "$prefix/etc/rc.d/init.d/$service");
run_program::rooted($prefix, "/etc/rc.d/init.d/$service", "status");
# The exit status is not zero when the service is not running
if (($? >> 8) != 0) {
@@ -244,7 +244,7 @@ sub SIGHUP_daemon {
# PDQ has no daemon, exit.
if ($service eq "pdq") { return 1 };
# CUPS needs auto-correction for its configuration
- run_program::rooted($prefix, "/usr/sbin/correctcupsconfig") if ($service eq "cups");
+ run_program::rooted($prefix, "/usr/sbin/correctcupsconfig") if $service eq "cups";
# Name of the daemon
my %daemons = (
"lpr" => "lpd",
@@ -254,7 +254,7 @@ sub SIGHUP_daemon {
"devfs" => "devfsd",
);
my $daemon = $daemons{$service};
- $daemon = $service if (! defined $daemon);
+ $daemon = $service if ! defined $daemon;
# if ($service eq "cups") {
# # The current CUPS (1.1.13) dies on SIGHUP, do the normal restart.
# restart_service($service);
@@ -493,12 +493,14 @@ sub getIPsInLocalNetworks {
open F, ($::testing ? "" : "chroot $prefix/ ") .
"/bin/sh -c \"export LC_ALL=C; ping -w 1 -b -n $bcast | cut -f 4 -d ' ' | sed s/:// | egrep '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | uniq | sort\" |"
or next;
+ local $_;
while (<F>) { chomp; push @addresses, $_ }
close F;
if (-x "/usr/bin/nmblookup") {
open F, ($::testing ? "" : "chroot $prefix/ ") .
"/bin/sh -c \"export LC_ALL=C; nmblookup -B $bcast \\* | cut -f 1 -d ' ' | egrep '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | uniq | sort\" |"
or next;
+ local $_;
while (<F>) { chomp;
push @addresses, $_ if !(member($_,@addresses)) }
close F;
@@ -517,8 +519,8 @@ sub whatNetPrinter {
# Which ports should be scanned?
my @portstoscan;
- push @portstoscan, "139" if ($smb);
- push @portstoscan, "4010", "4020", "4030", "5503", "9100-9104" if ($network);
+ push @portstoscan, "139" if $smb;
+ push @portstoscan, "4010", "4020", "4030", "5503", "9100-9104" if $network;
return () if $#portstoscan < 0;
my $portlist = join (",", @portstoscan);
@@ -558,7 +560,7 @@ sub whatNetPrinter {
undef $modelinfo;
} elsif ($line =~ m/^\s*(\d+)\/\S+\s+open\s+/i) {
- next if ($ip eq "");
+ next if $ip eq "";
$port = $1;
# Now we have all info for one printer
@@ -878,8 +880,6 @@ sub read_printer_db(;$) {
my $dbpath = $prefix . $PRINTER_DB_FILE;
- local $_; #- use of while (<...
-
local *DBPATH; #- don't have to do close ... and don't modify globals at least
# Generate the Foomatic printer/driver overview, read it from the
# appropriate file when it is already generated
@@ -895,6 +895,7 @@ sub read_printer_db(;$) {
my $inentry = 0;
my $indrivers = 0;
my $inautodetect = 0;
+ local $_;
while (<DBPATH>) {
chomp;
if ($inentry) {
@@ -1698,7 +1699,7 @@ sub help_output {
open F, ($::testing ? $prefix : "chroot $prefix/ ") . sprintf($spoolers{$spooler}{help}, $queue);
$helptext = join("", <F>);
close F;
- $helptext = "Option list not available!\n" if ($spooler eq 'lpq' && (!$helptext || ($helptext eq "")));
+ $helptext = "Option list not available!\n" if $spooler eq 'lpq' && (!$helptext || ($helptext eq ""));
return $helptext;
}
@@ -1728,7 +1729,6 @@ sub print_optionlist {
sub get_copiable_queues {
my ($oldspooler, $newspooler) = @_;
- local $_; #- use of while (<...
local *QUEUEOUTPUT; #- don't have to do close ... and don't modify globals
#- at least
@@ -1740,6 +1740,7 @@ sub get_copiable_queues {
my $entry = {};
my $inentry = 0;
+ local $_;
while (<QUEUEOUTPUT>) {
chomp;
if ($inentry) {
@@ -1827,6 +1828,7 @@ sub configure_hpoj {
die "unable to open $prefix/usr/sbin/ptal-init";
};
my @ptalinitfunctions; # subroutine definitions in /usr/sbin/ptal-init
+ local $_;
while (<PTALINIT>) {
if (m!sub main!) {
last;
@@ -1892,8 +1894,8 @@ sub configure_hpoj {
} elsif ($device =~ /socket/) {
$bus = "hpjd";
$hostname = $model;
- return "" if ($port) && (($port < 9100) || ($port > 9103));
- if (($port) && ($port != 9100)) {
+ return "" if $port && ($port < 9100 || $port > 9103);
+ if ($port && $port != 9100) {
$port -= 9100;
$hostname .= ":$port";
}
@@ -2865,8 +2867,7 @@ sub addentry {
my $sectionfound = 0;
my $entryinserted = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
if (!$sectionfound) {
if (/^\s*\[\s*$section\s*\]\s*$/) {
$sectionfound = 1;
@@ -2889,8 +2890,7 @@ sub addsection {
my ($section, $filecontent) = @_;
my $entryinserted = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
if (/^\s*\[\s*$section\s*\]\s*$/) {
# section already there, nothing to be done
return $filecontent;
@@ -2904,8 +2904,7 @@ sub removeentry {
my $sectionfound = 0;
my $done = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
$_ = "$_\n";
next if ($done);
if (!$sectionfound) {
@@ -2929,8 +2928,7 @@ sub removesection {
my $sectionfound = 0;
my $done = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
$_ = "$_\n";
next if ($done);
if (!$sectionfound) {
@@ -3182,6 +3180,7 @@ sub findgimpconfigfiles {
my @filestotreat;
local *PASSWD;
open PASSWD, "< $prefix/etc/passwd" or die "Cannot read /etc/passwd!\n";
+ local $_;
while (<PASSWD>) {
chomp;
if (/^([^:]+):[^:]*:([^:]+):([^:]+):[^:]*:([^:]+):[^:]*$/) {
@@ -3240,8 +3239,7 @@ sub addgimpentry {
my $sectionfound = 0;
my $entryinserted = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
if (!$sectionfound) {
if (/^\s*Printer\s*:\s*($section)\s*$/) {
$sectionfound = 1;
@@ -3264,8 +3262,7 @@ sub addgimpprinter {
my ($section, $filecontent) = @_;
my $entryinserted = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
if (/^\s*Printer\s*:\s*($section)\s*$/) {
# section already there, nothing to be done
return $filecontent;
@@ -3279,8 +3276,7 @@ sub removegimpentry {
my $sectionfound = 0;
my $done = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
$_ = "$_\n";
next if ($done);
if (!$sectionfound) {
@@ -3304,8 +3300,7 @@ sub removegimpprinter {
my $sectionfound = 0;
my $done = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
$_ = "$_\n";
next if ($done);
if (!$sectionfound) {
@@ -3332,8 +3327,7 @@ sub isgimpprinterconfigured {
my $ppdfileset = 0;
my $nonrawprinting = 0;
my @lines = split("\n", $filecontent);
- local $_;
- for (@lines) {
+ foreach (@lines) {
last if ($done);
if (!$sectionfound) {
if (/^\s*Printer\s*:\s*($queue)\s*$/) {
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index b5c674702..32edbb867 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -177,7 +177,7 @@ sub detect {
sub first_time_dialog {
my ($printer, $in, $upNetwork) = @_;
- return 1 if (printer::get_default_spooler () or $::isInstall);
+ return 1 if printer::get_default_spooler () or $::isInstall;
# Wait message
my $w = $in->wait_message(N("Printerdrake"),
@@ -2452,7 +2452,7 @@ sub copy_queues_from {
@oldqueues = sort(@oldqueues);
$newspoolerstr = $printer::shortspooler_inv{$newspooler};
$oldspoolerstr = $printer::shortspooler_inv{$oldspooler};
- for (@oldqueues) {
+ foreach (@oldqueues) {
push (@queuesselected, 1);
push (@queueentries, { text => $_, type => 'bool',
val => \$queuesselected[$#queuesselected] });
@@ -2488,7 +2488,7 @@ Mark the printers which you want to transfer and click
\@queueentries
)) {
my $queuecopied = 0;
- for (@oldqueues) {
+ foreach (@oldqueues) {
if (shift(@queuesselected)) {
my $oldqueue = $_;
my $newqueue = $_;
diff --git a/perl-install/ugtk.pm b/perl-install/ugtk.pm
index feee63e83..93001beb6 100644
--- a/perl-install/ugtk.pm
+++ b/perl-install/ugtk.pm
@@ -787,7 +787,7 @@ sub gtkcreate_xpm {
sub gtkcreate_png_pixbuf {
my ($f) = shift;
- die 'gdk-pixbuf library is not available' unless ($use_pixbuf);
+ die 'gdk-pixbuf library is not available' unless $use_pixbuf;
$f =~ /\.(png|jpg)$/ or $f .= '.png';
if ($f !~ /^\//) { -e "$_/$f" and $f = "$_/$f", last foreach icon_paths() }
Gtk::Gdk::Pixbuf->new_from_file($f) or die "gtkcreate_png: missing png file $f";