pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files - The checkline_mk_vartype_basi...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b1bdab9a4e45
branches:  trunk
changeset: 508369:b1bdab9a4e45
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Feb 18 14:48:58 2006 +0000

description:
- The checkline_mk_vartype_basic routine needs to know whether the value
  it is checking is used in list context or in scalar context -- just
  like in Perl.
- The :Q operator should only be used in list context or in shell commands.

diffstat:

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

diffs (77 lines):

diff -r c9b4eb5e515a -r b1bdab9a4e45 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Sat Feb 18 14:25:03 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Sat Feb 18 14:48:58 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.525 2006/02/18 14:18:44 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.526 2006/02/18 14:48:58 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2703,13 +2703,17 @@
        checkline_mk_shelltext($line, $shellcmd);
 }
 
-sub checkline_mk_vartype_basic($$$$$$);
-sub checkline_mk_vartype_basic($$$$$$) {
-       my ($line, $varname, $type, $op, $value, $comment) = @_;
+sub checkline_mk_vartype_basic($$$$$$$);
+sub checkline_mk_vartype_basic($$$$$$$) {
+       my ($line, $varname, $type, $op, $value, $comment, $list_context) = @_;
        my ($value_novar);
 
        $value_novar = $value;
-       while ($value_novar =~ s/\$\{[^{}]*\}//g) {
+       while ($value_novar =~ s/\$\{([^{}]*)\}//g) {
+               my ($varuse) = ($1);
+               if (!$list_context && $varuse =~ qr":Q$") {
+                       $line->log_warning("The :Q operator should only be used in lists and shell commands.");
+               }
        }
 
        if ($type eq "AwkCommand") {
@@ -2960,7 +2964,7 @@
                my (@paths) = split(qr":", $value_novar);
 
                foreach my $p (@paths) {
-                       checkline_mk_vartype_basic($line, $varname, "Pathname", $op, $p, $comment);
+                       checkline_mk_vartype_basic($line, $varname, "Pathname", $op, $p, $comment, false);
                }
 
        } elsif ($type eq "Pathmask") {
@@ -2984,7 +2988,7 @@
                }
 
        } elsif ($type eq "PkgOptionsVar") {
-               checkline_mk_vartype_basic($line, $varname, "Varname", $op, $value, $comment);
+               checkline_mk_vartype_basic($line, $varname, "Varname", $op, $value, $comment, false);
                if ($value =~ qr"\$\{PKGBASE[:\}]") {
                        $line->log_error("PKGBASE must not be used in PKG_OPTIONS_VAR.");
                        $line->explain(
@@ -3157,7 +3161,7 @@
 
        } elsif ($type eq "YesNoFromCommand") {
                if ($op ne "!=") {
-                       checkline_mk_vartype_basic($line, $varname, "YesNo", $op, $value, $comment);
+                       checkline_mk_vartype_basic($line, $varname, "YesNo", $op, $value, $comment, false);
                }
 
        } elsif ($type =~ qr"^\{\s*(.*?)\s*\}$") {
@@ -3253,7 +3257,7 @@
 
                        foreach my $word (@words) {
                                if (defined($element_type)) {
-                                       checkline_mk_vartype_basic($line, $varname, $element_type, $op, $word, $comment);
+                                       checkline_mk_vartype_basic($line, $varname, $element_type, $op, $word, $comment, true);
                                }
                        }
 
@@ -3262,7 +3266,7 @@
                        }
 
                } else {
-                       checkline_mk_vartype_basic($line, $varname, $type, $op, $value, $comment);
+                       checkline_mk_vartype_basic($line, $varname, $type, $op, $value, $comment, false);
                }
 }
 



Home | Main Index | Thread Index | Old Index