From b8a25c88bba7e597dd0c148e15693672d2a30f85 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 6 Nov 2002 17:38:26 +0000 Subject: replace complex "unless"s with "if"s --- perl-install/bootloader.pm | 4 ++-- perl-install/detect_devices.pm | 2 +- perl-install/diskdrake/interactive.pm | 2 +- perl-install/harddrake/sound.pm | 2 +- perl-install/install_any.pm | 2 +- perl-install/install_steps.pm | 2 +- perl-install/install_steps_interactive.pm | 2 +- perl-install/network/isdn.pm | 2 +- perl-install/network/netconnect.pm | 8 ++++---- perl-install/network/network.pm | 4 ++-- perl-install/partition_table.pm | 2 +- perl-install/printerdrake.pm | 24 +++++++++++------------- 12 files changed, 27 insertions(+), 29 deletions(-) diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index bd506f210..86d370856 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -1041,8 +1041,8 @@ sub install_loadlin { my $boot; ($boot) = grep { $lilo->{boot} eq "/dev/$_->{device}" } @$fstab; - ($boot) = grep { loopback::carryRootLoopback($_) } @$fstab unless $boot && $boot->{device_windobe}; - ($boot) = grep { isFat($_) } @$fstab unless $boot && $boot->{device_windobe}; + ($boot) = grep { loopback::carryRootLoopback($_) } @$fstab if !$boot || !$boot->{device_windobe}; + ($boot) = grep { isFat($_) } @$fstab if !$boot || !$boot->{device_windobe}; log::l("loadlin device is $boot->{device} (windobe $boot->{device_windobe})"); $lilo->{boot_drive} = $boot->{device_windobe}; diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 2c8c71f3d..365c42be7 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -385,7 +385,7 @@ sub getSerialModem { } #- add an alias for macserial on PPC - modules::add_alias('serial', $serdev) if (arch() =~ /ppc/ && $modem->{device}); + modules::add_alias('serial', $serdev) if arch() =~ /ppc/ && $modem->{device}; my @devs = pcmcia_probe(); foreach (@devs) { $_->{type} =~ /serial/ and $modem->{device} = $_->{device}; diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index c28000c95..4d4a7f702 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -515,7 +515,7 @@ sub Delete { fsedit::recompute_loopbacks($all_hds); } else { if (arch() =~ /ppc/) { - undef $partition_table::mac::bootstrap_part if (isAppleBootstrap($part) && ($part->{device} = $partition_table::mac::bootstrap_part)); + undef $partition_table::mac::bootstrap_part if isAppleBootstrap($part) && ($part->{device} = $partition_table::mac::bootstrap_part); } partition_table::remove($hd, $part); warn_if_renumbered($in, $hd); diff --git a/perl-install/harddrake/sound.pm b/perl-install/harddrake/sound.pm index 9b1bf5949..a1da2d25f 100644 --- a/perl-install/harddrake/sound.pm +++ b/perl-install/harddrake/sound.pm @@ -195,7 +195,7 @@ To use alsa, one can either use: } ])) { - return if ($new_driver eq $driver); + return if $new_driver eq $driver; standalone::explanations("switching audio driver from '$driver' to '$new_driver'\n"); $in->ask_warn(N("Warning"), N("The old \"%s\" driver is blacklisted.\n It has been reported to oopses the kernel on unloading.\n diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 76eab06ad..312785491 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -126,7 +126,7 @@ sub getFile { #- handling changing a media when some of the file on the first CD has been copied #- to other to avoid media change... my $f2 = "$postinstall_rpms/$f"; - $f2 = "/tmp/image/$rel" unless $postinstall_rpms && -e $f2; + $f2 = "/tmp/image/$rel" if !$postinstall_rpms || !-e $f2; open GETFILE, $f2 and *GETFILE; } } || errorOpeningFile($f); diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 2f40121f6..e62de662d 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -206,7 +206,7 @@ sub ask_mntpoint_s { my %m; foreach (@$fstab) { my $m = $_->{mntpoint}; - next unless $m && $m ne 'swap'; #- there may be a lot of swap. + next if !$m || $m eq 'swap'; #- there may be a lot of swap. $m{$m} and die N("Duplicate mount point %s", $m); $m{$m} = 1; diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 8e5e45ef6..668a3fa06 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -1317,7 +1317,7 @@ sub generateAutoInstFloppy { sub exitInstall { my ($o, $alldone) = @_; - return $o->{step} = '' unless $alldone || $o->ask_yesorno('', + return $o->{step} = '' if !$alldone && !$o->ask_yesorno('', N("Some steps are not completed. Do you really want to quit now?"), 0); diff --git a/perl-install/network/isdn.pm b/perl-install/network/isdn.pm index cd084bb2a..029f75bcf 100644 --- a/perl-install/network/isdn.pm +++ b/perl-install/network/isdn.pm @@ -277,7 +277,7 @@ sub isdn_get_list { sub isdn_get_info { my ($desc) = @_; foreach (@isdndata) { - return $_ if ($_->{description} eq $desc); + return $_ if $_->{description} eq $desc; } } diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index f515d85ef..592092a06 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -46,10 +46,10 @@ sub intro { translate($text), sub { $_[0]{description} }, \@l); - run_program::rooted($prefix, $connect_prog) if ($e->{c}==1); - run_program::rooted($prefix, $disconnect_file) if ($e->{c}==2); - main($prefix, $netcnx, $netc, $mouse, $in, $intf, 0, 0) if ($e->{c}==3); - $in->exit(0) if ($e->{c}==4); + run_program::rooted($prefix, $connect_prog) if $e->{c}==1; + run_program::rooted($prefix, $disconnect_file) if $e->{c}==2; + main($prefix, $netcnx, $netc, $mouse, $in, $intf, 0, 0) if $e->{c}==3; + $in->exit(0) if $e->{c}==4; } else { main($prefix, $netcnx, $netc, $mouse, $in, $intf, 0, 0); } diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 4c92ead01..ed5c7f0f5 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -84,7 +84,7 @@ sub write_resolv_conf { #- get the list of used dns. my %used_dns; @used_dns{$netc->{dnsServer}, $netc->{dnsServer2}, $netc->{dnsServer3}} = (1, 2, 3); - unless ($netc->{DOMAINNAME} || $netc->{DOMAINNAME2} || keys %used_dns > 0) { + if (!$netc->{DOMAINNAME} && !$netc->{DOMAINNAME2} && !%used_dns) { unlink($file); log::l("neither domain name nor dns server are configured"); return 0; @@ -107,7 +107,7 @@ sub write_resolv_conf { unlink $file; #- workaround situation when /etc/resolv.conf is an absolute link to /etc/ppp/resolv.conf or whatever open F, ">$file" or die "cannot write $file: $!"; print F "# search $_\n" foreach grep { $_ ne "$netc->{DOMAINNAME} $netc->{DOMAINNAME2}" } sort { $search{$a} <=> $search{$b} } keys %search; - print F "search $netc->{DOMAINNAME} $netc->{DOMAINNAME2}\n" if ($netc->{DOMAINNAME} || $netc->{DOMAINNAME2}); + print F "search $netc->{DOMAINNAME} $netc->{DOMAINNAME2}\n" if $netc->{DOMAINNAME} || $netc->{DOMAINNAME2}; #- print F "$options\n\n"; print F "# nameserver $_\n" foreach grep { ! exists $used_dns{$_} } sort { $dns{$a} <=> $dns{$b} } keys %dns; print F "nameserver $_\n" foreach sort { $used_dns{$a} <=> $used_dns{$b} } grep { $_ } keys %used_dns; diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index d7e0ccbce..c9428b006 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -410,7 +410,7 @@ sub adjust_main_extended { $l->{start} = $hd->{primary}{extended}{start} = $start; $l->{size} = $hd->{primary}{extended}{size} = $end - $start; } - unless (@{$hd->{extended} || []} || !$hd->{primary}{extended}) { + if (!@{$hd->{extended} || []} && $hd->{primary}{extended}) { %{$hd->{primary}{extended}} = (); #- modify the raw entry delete $hd->{primary}{extended}; } diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm index 394c105e5..bdfa1315f 100644 --- a/perl-install/printerdrake.pm +++ b/perl-install/printerdrake.pm @@ -19,7 +19,7 @@ sub choose_printer_type { my $queue = $printer->{OLD_QUEUE}; $printer->{str_type} = $printer::printer_type_inv{$printer->{TYPE}}; my $autodetect = 0; - $autodetect = 1 if ($printer->{AUTODETECT}); + $autodetect = 1 if $printer->{AUTODETECT}; my @printertypes = printer::printer_type($printer); $in->ask_from_( { title => N("Select Printer Connection"), @@ -87,7 +87,7 @@ sub config_cups { ($::expert ? "\n" . N(" Normally, CUPS is automatically configured according to your network environment, so that you can access the printers on the CUPS servers in your local network. If this does not work correctly, turn off \"Automatic CUPS configuration\" and edit your file /etc/cups/cupsd.conf manually. Do not forget to restart CUPS afterwards (command: \"service cups restart\").") : ()), callbacks => { complete => sub { - unless (!$server || network::is_ip($server)) { + if ($server && !network::is_ip($server)) { $in->ask_warn('', N("The IP address should look like 192.168.1.20")); return (1,0); } @@ -596,7 +596,7 @@ sub setup_local_autoscan { } } else { my $manualconf = 0; - $manualconf = 1 if (($printer->{MANUAL}) || (!$do_auto_detect)); + $manualconf = 1 if $printer->{MANUAL} || !$do_auto_detect; if (!$in->ask_from_ ( { title => ($expert_or_modify ? @@ -874,19 +874,19 @@ sub setup_smb { allow_empty_list => 1, type => 'combo' } : ()) ], complete => sub { - unless ((network::is_ip($smbserverip)) || ($smbserverip eq "")) { + if (!network::is_ip($smbserverip) && $smbserverip ne "") { $in->ask_warn('', N("IP address should be in format 1.2.3.4")); return (1,1); } - unless (($smbserver ne "") || ($smbserverip ne "")) { + if ($smbserver eq "" && $smbserverip eq "") { $in->ask_warn('', N("Either the server name or the server's IP must be given!")); return (1,0); } - unless ($smbshare ne "") { + if ($smbshare eq "") { $in->ask_warn('', N("Samba share name missing!")); return (1,2); } - unless ($smbpassword eq "") { + if ($smbpassword ne "") { local $::isWizard = 0; my $yes = $in->ask_yesorno (N("SECURITY WARNING!"), @@ -2079,16 +2079,15 @@ You should make sure that the page size and the ink type/printing mode (if avail my $i; for ($i = 0; $i <= $#{$printer->{ARGS}}; $i++) { if (($printer->{ARGS}[$i]{type} eq 'int') || ($printer->{ARGS}[$i]{type} eq 'float')) { - unless (($printer->{ARGS}[$i]{type} ne 'int') || ($userinputs[$i] =~ /^[\-\+]?[0-9]+$/)) { + if ($printer->{ARGS}[$i]{type} eq 'int' && $userinputs[$i] !~ /^[\-\+]?[0-9]+$/) { $in->ask_warn('', N("Option %s must be an integer number!", $printer->{ARGS}[$i]{comment})); return (1, $i); } - unless (($printer->{ARGS}[$i]{type} ne 'float') || ($userinputs[$i] =~ /^[\-\+]?[0-9\.]+$/)) { + if ($printer->{ARGS}[$i]{type} eq 'float' && $userinputs[$i] !~ /^[\-\+]?[0-9\.]+$/) { $in->ask_warn('', N("Option %s must be a number!", $printer->{ARGS}[$i]{comment})); return (1, $i); } - unless (($userinputs[$i] >= $printer->{ARGS}[$i]{min}) && - ($userinputs[$i] <= $printer->{ARGS}[$i]{max})) { + if ($userinputs[$i] < $printer->{ARGS}[$i]{min} || $userinputs[$i] > $printer->{ARGS}[$i]{max}) { $in->ask_warn('', N("Option %s out of range!", $printer->{ARGS}[$i]{comment})); return (1, $i); } @@ -3090,8 +3089,7 @@ sub main { # Show a queue list window when there is at least one queue, # when we are in expert mode, or when we are not in the # installation. - unless ((!%{$printer->{configured} || {}}) && - (!$::expert) && ($::isInstall)) { + if (%{$printer->{configured} || {}} || $::expert || !$::isInstall) { $in->set_help('mainMenu') if $::isInstall; # Cancelling the printer type dialog should leed to this # dialog -- cgit v1.2.1