summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2005-05-24 20:17:31 +0000
committerrillig <rillig@pkgsrc.org>2005-05-24 20:17:31 +0000
commitf519bf67f7964c9b8a75fd629125465ba5dab233 (patch)
tree53c2224c77eedca9fff2d9c8294c9d0268971854 /pkgtools
parentdfb3e8627faeb54b25a8c7cb1393e4ebc1c1d88f (diff)
downloadpkgsrc-f519bf67f7964c9b8a75fd629125465ba5dab233.tar.gz
Replaced the algorithm in check_category with one that is fast, correct and
always terminates. I somehow got the old algorithm into an endless loop.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/pkglint.pl24
1 files changed, 14 insertions, 10 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index 5b68528647b..1703ed45bc2 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -11,7 +11,7 @@
# Freely redistributable. Absolutely no warranty.
#
# From Id: portlint.pl,v 1.64 1998/02/28 02:34:05 itojun Exp
-# $NetBSD: pkglint.pl,v 1.176 2005/05/24 19:14:19 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.177 2005/05/24 20:17:31 rillig Exp $
#
# This version contains lots of changes necessary for NetBSD packages
# done by:
@@ -2094,17 +2094,21 @@ sub check_category($) {
@filesys_subdirs = sort(@filesys_subdirs);
@makefile_subdirs = sort(@makefile_subdirs);
- while (scalar(@filesys_subdirs) > 0 || scalar(@makefile_subdirs) > 0) {
- my ($f, $m) = ($filesys_subdirs[0] || "", $makefile_subdirs[0] || "");
- if ($f eq $m) {
- shift(@filesys_subdirs);
- shift(@makefile_subdirs);
- } elsif ($m eq "" || $f lt $m) {
+ my ($findex, $mindex) = (0, 0);
+ my ($fmax, $mmax) = (scalar(@filesys_subdirs), scalar(@makefile_subdirs));
+ while ($findex < $fmax || $mindex < $mmax) {
+ my $f = ($findex < $fmax) ? $filesys_subdirs[$findex] : undef;
+ my $m = ($mindex < $mmax) ? $makefile_subdirs[$mindex] : undef;
+
+ if ($findex < $fmax && ($mindex == $mmax || $f lt $m)) {
log_error($fname, NO_LINE_NUMBER, "$f exists in the file system, but not in the Makefile.");
- shift(@filesys_subdirs);
- } else {
+ $findex++;
+ } elsif ($mindex < $mmax && ($findex == $fmax || $m lt $f)) {
log_error($fname, NO_LINE_NUMBER, "$m exists in the Makefile, but not in the file system.");
- shift(@makefile_subdirs);
+ $mindex++;
+ } else { # $findex < $fmax && $mindex < $mmax && $f eq $m
+ $findex++;
+ $mindex++;
}
}