This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6419e5f30baa1efb432ac918f316e38ef360fb07 commit 6419e5f30baa1efb432ac918f316e38ef360fb07 Author: Guillem Jover <[email protected]> AuthorDate: Sun Jan 1 04:25:46 2023 +0100 perl: Fold if into previous else This simplifies the code and reduces the indentation levels. --- dselect/methods/ftp/install.pl | 30 +++++++++++++----------------- scripts/Dpkg/BuildOptions.pm | 10 ++++------ scripts/Dpkg/Changelog/Entry.pm | 16 +++++++--------- scripts/Dpkg/Deps/Simple.pm | 8 +++----- scripts/Dpkg/Shlibs/Symbol.pm | 28 +++++++++++----------------- scripts/Dpkg/Source/Package/V1.pm | 22 ++++++++++------------ scripts/dpkg-shlibdeps.pl | 14 ++++++-------- scripts/dpkg-source.pl | 8 +++----- 8 files changed, 57 insertions(+), 79 deletions(-) diff --git a/dselect/methods/ftp/install.pl b/dselect/methods/ftp/install.pl index ea6ea7160..75647bd61 100755 --- a/dselect/methods/ftp/install.pl +++ b/dselect/methods/ftp/install.pl @@ -297,16 +297,14 @@ if($totsize == 0) { if ($rsize + $totsize > $avsp) { print "no room for: $fn\n"; delete $downloads{$fn}; - } else { - if(yesno($def, $downloads{$fn} - ? "download: $fn ${rsize}k/${csize}k (total = ${totsize}k)" - : "download: $fn ${rsize}k (total = ${totsize}k)")) { - $def = 'y'; - $totsize += $rsize; - } else { - $def = 'n'; - delete $downloads{$fn}; - } + } elsif (yesno($def, $downloads{$fn} + ? "download: $fn ${rsize}k/${csize}k (total = ${totsize}k)" + : "download: $fn ${rsize}k (total = ${totsize}k)")) { + $def = 'y'; + $totsize += $rsize; + } else { + $def = 'n'; + delete $downloads{$fn}; } } } @@ -588,13 +586,11 @@ sub removeinstalled { my($pkg, $ver) = getdebinfo($fn); if(!defined($pkg) || !defined($ver)) { print "Could not get info for: $dir/$fn\n"; - } else { - if ($curpkgs{$pkg} and dcmpvers($ver, 'le', $curpkgs{$pkg})) { - print "deleting: $dir/$fn\n"; - unlink $fn; - } else { - print "leaving: $dir/$fn\n"; - } + } elsif ($curpkgs{$pkg} and dcmpvers($ver, 'le', $curpkgs{$pkg})) { + print "deleting: $dir/$fn\n"; + unlink $fn; + } else { + print "leaving: $dir/$fn\n"; } } else { print "non-debian: $dir/$fn\n"; diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm index 5b5365558..6c2a18972 100644 --- a/scripts/Dpkg/BuildOptions.pm +++ b/scripts/Dpkg/BuildOptions.pm @@ -180,13 +180,11 @@ sub parse_features { my $value = ($1 eq '+') ? 1 : 0; if ($feature eq 'all') { $use_feature->{$_} = $value foreach keys %{$use_feature}; + } elsif (exists $use_feature->{$feature}) { + $use_feature->{$feature} = $value; } else { - if (exists $use_feature->{$feature}) { - $use_feature->{$feature} = $value; - } else { - warning(g_('unknown %s feature in %s variable: %s'), - $option, $self->{envvar}, $feature); - } + warning(g_('unknown %s feature in %s variable: %s'), + $option, $self->{envvar}, $feature); } } else { warning(g_('incorrect value in %s option of %s variable: %s'), diff --git a/scripts/Dpkg/Changelog/Entry.pm b/scripts/Dpkg/Changelog/Entry.pm index e572909ff..d55e5fd29 100644 --- a/scripts/Dpkg/Changelog/Entry.pm +++ b/scripts/Dpkg/Changelog/Entry.pm @@ -154,16 +154,14 @@ sub extend_part { } else { push @{$self->{$part}}, $value; } + } elsif (defined $self->{$part}) { + if (ref($value)) { + $self->{$part} = [ $self->{$part}, @$value ]; + } else { + $self->{$part} .= $value; + } } else { - if (defined($self->{$part})) { - if (ref($value)) { - $self->{$part} = [ $self->{$part}, @$value ]; - } else { - $self->{$part} .= $value; - } - } else { - $self->{$part} = $value; - } + $self->{$part} = $value; } } diff --git a/scripts/Dpkg/Deps/Simple.pm b/scripts/Dpkg/Deps/Simple.pm index a2ab2b125..e4888edc0 100644 --- a/scripts/Dpkg/Deps/Simple.pm +++ b/scripts/Dpkg/Deps/Simple.pm @@ -438,12 +438,10 @@ sub implies { if (defined $implication) { if (not defined $res) { $res = $implication; + } elsif ($implication) { + $res = 1; } else { - if ($implication) { - $res = 1; - } else { - $res = 0; - } + $res = 0; } last if defined $res and $res == 1; } diff --git a/scripts/Dpkg/Shlibs/Symbol.pm b/scripts/Dpkg/Shlibs/Symbol.pm index f4955bb55..3b38a8c94 100644 --- a/scripts/Dpkg/Shlibs/Symbol.pm +++ b/scripts/Dpkg/Shlibs/Symbol.pm @@ -115,23 +115,19 @@ sub parse_symbolspec { $symbol_templ = $2; $symbol = $2; $rest = $3; - } else { - if ($symbol =~ m/^(\S+)(.*)$/) { - $symbol_templ = $1; - $symbol = $1; - $rest = $2; - } + } elsif ($symbol =~ m/^(\S+)(.*)$/) { + $symbol_templ = $1; + $symbol = $1; + $rest = $2; } error(g_('symbol name unspecified: %s'), $symbolspec) if (!$symbol); - } else { + } elsif ($symbolspec =~ m/^(\S+)(.*)$/) { # No tag specification. Symbol name is up to the first space # foobarsymbol@Base 1.0 1 - if ($symbolspec =~ m/^(\S+)(.*)$/) { - $symbol = $1; - $rest = $2; - } else { - return 0; - } + $symbol = $1; + $rest = $2; + } else { + return 0; } $self->{symbol} = $symbol; $self->{symbol_templ} = $symbol_templ; @@ -463,12 +459,10 @@ sub mark_found_in_library { # Symbol reappeared somehow $self->{deprecated} = 0; $self->{minver} = $minver if (not $self->is_optional()); - } else { + } elsif (version_compare($minver, $self->{minver}) < 0) { # We assume that the right dependency information is already # there. - if (version_compare($minver, $self->{minver}) < 0) { - $self->{minver} = $minver; - } + $self->{minver} = $minver; } # Never remove arch tags from patterns if (not $self->is_pattern()) { diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index 170ffe138..bdf2c8725 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -347,18 +347,16 @@ sub do_build { # creating a native .tar.gz if ($origtargz) { $sourcestyle =~ y/aA/pP/; # .orig.tar.<ext> - } else { - if (stat($origdir)) { - unless (-d _) { - error(g_("unpacked orig '%s' exists but is not a directory"), - $origdir); - } - $sourcestyle =~ y/aA/rR/; # .orig directory - } elsif ($! != ENOENT) { - syserr(g_("unable to stat putative unpacked orig '%s'"), $origdir); - } else { - $sourcestyle =~ y/aA/nn/; # Native tar.gz - } + } elsif (stat($origdir)) { + unless (-d _) { + error(g_("unpacked orig '%s' exists but is not a directory"), + $origdir); + } + $sourcestyle =~ y/aA/rR/; # .orig directory + } elsif ($! != ENOENT) { + syserr(g_("unable to stat putative unpacked orig '%s'"), $origdir); + } else { + $sourcestyle =~ y/aA/nn/; # Native tar.gz } } diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 96c0b0bbd..240b0bc50 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -133,15 +133,13 @@ foreach (@ARGV) { push @exclude, $1; } elsif (m/^-/) { usageerr(g_("unknown option '%s'"), $_); + } elsif (exists $exec{$_}) { + # Affect the binary to the most important field + if ($depstrength{$dependencyfield} > $depstrength{$exec{$_}}) { + $exec{$_} = $dependencyfield; + } } else { - if (exists $exec{$_}) { - # Affect the binary to the most important field - if ($depstrength{$dependencyfield} > $depstrength{$exec{$_}}) { - $exec{$_} = $dependencyfield; - } - } else { - $exec{$_} = $dependencyfield; - } + $exec{$_} = $dependencyfield; } } usageerr(g_('need at least one executable')) unless scalar keys %exec; diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 664f39c76..c27a954ab 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -482,12 +482,10 @@ if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) { unless ($options{no_check}) { if ($srcpkg->is_signed()) { $srcpkg->check_signature(); + } elsif ($options{require_valid_signature}) { + error(g_("%s doesn't contain a valid OpenPGP signature"), $dsc); } else { - if ($options{require_valid_signature}) { - error(g_("%s doesn't contain a valid OpenPGP signature"), $dsc); - } else { - warning(g_('extracting unsigned source package (%s)'), $dsc); - } + warning(g_('extracting unsigned source package (%s)'), $dsc); } $srcpkg->check_checksums(); } -- Dpkg.Org's dpkg

