pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/lintpkgsrc/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Tue Aug 16 19:40:24 UTC 2022

Modified Files:
        pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl

Log Message:
lintpkgsrc: cleanup: condense package_globmatch


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
diff -u pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.102 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.103
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.102        Tue Aug 16 19:20:06 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Tue Aug 16 19:40:24 2022
@@ -1,5 +1,5 @@
 #!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.102 2022/08/16 19:20:06 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.103 2022/08/16 19:40:24 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -829,29 +829,21 @@ sub glob2regex($glob) {
 sub package_globmatch($pkgmatch) {
 
        if ($pkgmatch =~ /^ ([^*?[]+) (<|>|<=|>=|-) (\d[^*?[{]*) $/x) {
-               # TODO: rename $matchpkgname to be more accurate.
-               my ($matchpkgname, $op, $matchver) = ($1, $2, $3);
+               my ($match_base, $op, $match_ver) = ($1, $2, $3);
 
-               if (my @pkgvers = $pkgdb->pkgvers_by_pkgbase($matchpkgname)) {
-                       foreach my $pkgver (@pkgvers) {
-                               if ($op eq '-') {
-                                       if ($pkgver->pkgversion eq $matchver) {
-                                               $matchver = undef;
-                                               last;
-                                       }
-                               } else {
-                                       if (pkgversion_cmp($pkgver->pkgversion, $op, $matchver)) {
-                                               $matchver = undef;
-                                               last;
-                                       }
-                               }
+               my @pkgvers = $pkgdb->pkgvers_by_pkgbase($match_base);
+               foreach my $pkgver (@pkgvers) {
+                       if ($op eq '-'
+                           ? $pkgver->pkgversion eq $match_ver
+                           : pkgversion_cmp($pkgver->pkgversion, $op, $match_ver)) {
+                               return ($match_base, undef);
                        }
+               }
 
-                       if ($matchver && $op ne '-') {
-                               $matchver = "$op$matchver";
-                       }
+               if (@pkgvers && $match_ver && $op ne '-') {
+                       $match_ver = "$op$match_ver";
                }
-               ($matchpkgname, $matchver);
+               ($match_base, $match_ver);
 
        } elsif ($pkgmatch =~ /^ ([^[]+) - ([\d*?{[].*) $/x) {
                my ($matchpkgname, $matchver) = ($1, $2);



Home | Main Index | Thread Index | Old Index