summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2019-01-07 22:32:22 +0100
committerGuillem Jover <guillem@debian.org>2019-01-15 03:42:39 +0100
commit55cdf5fac707895e42a356b3d32d9d648e28fc40 (patch)
tree6caa349b0c30d32bca89c2465ba0b2d110f1edc8
parent5d4ab4ae7d11c736bdabb51af4bc7e66c69cdd23 (diff)
downloaddpkg-55cdf5fac707895e42a356b3d32d9d648e28fc40.tar.gz
dpkg-scanpackages: Unroll a single iteration loop
When not in multi-version mode, we can only ever have one package in the %packages hash, remove the confusing loop and replace with an explicit assignment using the first array reference element.
-rw-r--r--debian/changelog1
-rwxr-xr-xscripts/dpkg-scanpackages.pl28
2 files changed, 15 insertions, 14 deletions
diff --git a/debian/changelog b/debian/changelog
index b244c8d3b..6fac0102c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -54,6 +54,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium
- dpkg-source: Move source format selection earlier in the build.
- dpkg-source: Use new format argument for Dpkg::Source::Package->new().
- dpkg-shlibdeps: Remove unused variable.
+ - dpkg-scanpackages: Unroll a single iteration loop.
* Build system:
- get-version: Use a format string with printf.
- run-script: Use $() instead of deprecated ``.
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index dd4308641..bb0bebcf2 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -174,20 +174,20 @@ sub process_deb {
if not defined $p;
if (defined($packages{$p}) and not $options{multiversion}) {
- foreach my $pkg (@{$packages{$p}}) {
- if (version_compare_relation($fields->{'Version'}, REL_GT,
- $pkg->{'Version'}))
- {
- warning(g_('package %s (filename %s) is repeat but newer ' .
- 'version; used that one and ignored data from %s!'),
- $p, $fn, $pkg->{Filename});
- $packages{$p} = [];
- } else {
- warning(g_('package %s (filename %s) is repeat; ' .
- 'ignored that one and using data from %s!'),
- $p, $fn, $pkg->{Filename});
- return;
- }
+ my $pkg = ${$packages{$p}}[0];
+
+ if (version_compare_relation($fields->{'Version'}, REL_GT,
+ $pkg->{'Version'}))
+ {
+ warning(g_('package %s (filename %s) is repeat but newer ' .
+ 'version; used that one and ignored data from %s!'),
+ $p, $fn, $pkg->{Filename});
+ $packages{$p} = [];
+ } else {
+ warning(g_('package %s (filename %s) is repeat; ' .
+ 'ignored that one and using data from %s!'),
+ $p, $fn, $pkg->{Filename});
+ return;
}
}