pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Some variables, like WRKSRC, PR...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5eb7f092b6fc
branches:  trunk
changeset: 511227:5eb7f092b6fc
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Apr 12 08:23:49 2006 +0000

description:
Some variables, like WRKSRC, PREFIX, LOCALBASE and *DIR don't need the :Q
operator, since we expect them to never contain special characters. This
change reduces the number of -Wall warnings by approximately 28000.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r cf171b52a2c2 -r 5eb7f092b6fc pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Wed Apr 12 06:03:27 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Wed Apr 12 08:23:49 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.550 2006/04/11 17:44:29 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.551 2006/04/12 08:23:49 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2067,6 +2067,12 @@
        return !($type =~ qr"^(?:List.*|ShellCommand|SedCommands)$");
 }
 
+sub variable_needs_quoting($) {
+       my ($varname) = @_;
+
+       return !($varname =~ qr"^(?:.*DIR|DISTNAME|LOCALBASE|PKGNAME|PREFIX|WRKSRC)$");
+}
+
 my $check_pkglint_version_done = false;
 sub check_pkglint_version() {
 
@@ -2461,7 +2467,7 @@
                if (exists(get_vartypes_map()->{$varname}) && !(defined($mod) && $mod =~ qr":Q$")) {
                        my $vartype = get_vartypes_map()->{$varname};
 
-                       if (type_should_be_quoted($vartype)) {
+                       if (variable_needs_quoting($varname) && type_should_be_quoted($vartype)) {
                                $line->log_warning("[experimental] Please use \${${varname}:Q} instead of \${${varname}}.");
                        }
                } elsif (exists(get_varname_to_toolname()->{$varname})) {
@@ -2546,7 +2552,10 @@
                                        "appropriate to remove the double quotes.");
 
                        } elsif ($opt_warn_quoting) {
-                               if ($state == SWST_PLAIN) {
+                               if (!variable_needs_quoting($varname)) {
+                                       # These variables don't need to be quoted.
+
+                               } elsif ($state == SWST_PLAIN) {
                                        $line->log_warning("Please use \${${varname}:Q} instead of \${${varname}}.");
                                        $line->replace("\${${varname}}", "\${${varname}:Q}");
                                } else {



Home | Main Index | Thread Index | Old Index