pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files - Not only check for the defini...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d667806d7444
branches:  trunk
changeset: 507709:d667806d7444
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Feb 07 09:20:17 2006 +0000

description:
- Not only check for the definition of deprecated variables, but also for
  using them.
- The :Q operator should not be used in double quotes.

diffstat:

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

diffs (75 lines):

diff -r 85d37d20cc1c -r d667806d7444 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Tue Feb 07 09:07:19 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Tue Feb 07 09:20:17 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.501 2006/02/06 10:07:23 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.502 2006/02/07 09:20:17 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2202,7 +2202,7 @@
 
 sub checkline_mk_text($$) {
        my ($line, $text) = @_;
-       my ($rest, $state, $vartools);
+       my ($rest, $state, $vartools, $depr_map);
 
        if ($text =~ qr"^(?:[^#]*[^\$])?\$(\w+)") {
                my ($varname) = ($1);
@@ -2220,11 +2220,17 @@
        }
 
        $rest = $text;
-       while ($rest =~ s/(?:^|[^\$])\$\{([-A-Z0-9a-z_]+)(?::[^\}]+)?\}//) {
-               my ($varname) = ($1);
-
-               if (exists(get_deprecated_map()->{$varname})) {
-                       $line->log_warning("Use of ${varname} is deprecated. ".get_deprecated_map()->{$varname});
+       $depr_map = get_deprecated_map();
+       while ($rest =~ s/(?:^|[^\$])\$\{([-A-Z0-9a-z_]+)(\.[\-0-9A-Z_a-z]+)?(?::[^\}]+)?\}//) {
+               my ($varbase, $varext) = ($1, $2);
+               my $varname = $varbase . (defined($varext) ? $varext : "");
+               my $instead =
+                     (exists($depr_map->{$varname})) ? $depr_map->{$varname}
+                   : (exists($depr_map->{$varbase})) ? $depr_map->{$varbase}
+                   : undef;
+
+               if (defined($instead)) {
+                       $line->log_warning("Use of ${varname} is deprecated. ${instead}");
                }
        }
 
@@ -2301,16 +2307,19 @@
                ||  $rest =~ s/^\$\((${regex_varname})(:[^\)]+)?\)//) {
                        my ($varname, $mod) = ($1, $2);
 
-                       if (!$opt_warn_quoting) {
-                               # Skip the following checks.
-
-                       } elsif ($state == SWST_PLAIN && defined($mod) && $mod =~ qr":Q$") {
+                       if ($state == SWST_PLAIN && defined($mod) && $mod =~ qr":Q$") {
                                # Fine.
 
                        } elsif ($state == SWST_SQUOT && $varname =~ qr"(?:DIRS?|FILES?|PATH|^PREFIX|^LOCALBASE|^PKGNAME)$") {
                                # Fine, too.
 
-                       } else {
+                       } elsif ($state == SWST_DQUOT && defined($mod) && $mod =~ qr":Q$") {
+                               $line->log_warning("Please don't use the :Q operator in double quotes.");
+                               $line->explain(
+                                       "Either remove the :Q or the double quotes. In most cases, it is more",
+                                       "appropriate to remove the double quotes.");
+
+                       } elsif ($opt_warn_quoting) {
                                $line->log_warning("Possibly misquoted make variable ${varname} in " . user_statename->[$state] . ".");
                                if ($state == SWST_PLAIN && !defined($mod)) {
                                        $line->replace("\${${varname}}", "\${${varname}:Q}");
@@ -3143,6 +3152,7 @@
                }
        }
 
+       checkline_mk_text($line, $value);
        checkline_mk_vartype($line, $varname, $op, $value, $comment);
 
        if (!$is_internal && $varname =~ qr"^_") {



Home | Main Index | Thread Index | Old Index