pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Replaced the algorithm in check...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/eb15a77c9622
branches:  trunk
changeset: 494478:eb15a77c9622
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue May 24 20:17:31 2005 +0000

description:
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:

 pkgtools/pkglint/files/pkglint.pl |  24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diffs (43 lines):

diff -r 99706db3d935 -r eb15a77c9622 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Tue May 24 19:14:19 2005 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Tue May 24 20:17:31 2005 +0000
@@ -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 @@
 
        @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++;
                }
        }
 



Home | Main Index | Thread Index | Old Index