summaryrefslogtreecommitdiff
path: root/pkgtools/lintpkgsrc
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2022-08-17 18:45:16 +0000
committerrillig <rillig@pkgsrc.org>2022-08-17 18:45:16 +0000
commit6beb96154caee1d3ea59f4e9775f73a48f7221e3 (patch)
treee85158df6d6e9041d350aa8e05632bd1aa50f3bf /pkgtools/lintpkgsrc
parentf458bb0944b6011fde960ccbb9e9a2796e1162bd (diff)
downloadpkgsrc-6beb96154caee1d3ea59f4e9775f73a48f7221e3.tar.gz
lintpkgsrc: cleanup: untangle parsing of .include directives
Diffstat (limited to 'pkgtools/lintpkgsrc')
-rwxr-xr-xpkgtools/lintpkgsrc/files/lintpkgsrc.pl41
1 files changed, 22 insertions, 19 deletions
diff --git a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
index f79f49f6335..9ac25b33219 100755
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
@@ -1,5 +1,5 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.115 2022/08/17 18:36:10 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.116 2022/08/17 18:45:16 rillig Exp $
# Written by David Brownlee <abs@netbsd.org>.
#
@@ -451,17 +451,18 @@ sub parse_makefile_line_include($file, $incfile,
verbose("Cannot open '$incfile' (from $file): $_ $!\n");
return;
}
-
- # FIXME: .CURDIR doesn't change, but .PARSEDIR does.
- my $NEWCURDIR = $incfile;
- $NEWCURDIR =~ s#/[^/]*$##;
- push @$incdirs, $NEWCURDIR
- unless grep { $_ eq $NEWCURDIR } @$incdirs;
- unshift @$lines, ".CURDIR=" . $vars->{'.CURDIR'};
chomp(my @inc_lines = <FILE>);
- unshift @$lines, @inc_lines;
- unshift @$lines, ".CURDIR=$NEWCURDIR";
close(FILE);
+
+ my $new_curdir = dirname $incfile;
+ push @$incdirs, $new_curdir
+ unless grep { $_ eq $new_curdir } @$incdirs;
+
+ # FIXME: .CURDIR doesn't change, but .PARSEDIR does.
+ unshift @$lines,
+ ".CURDIR=$new_curdir",
+ @inc_lines,
+ ".CURDIR=" . $vars->{'.CURDIR'};
}
sub parse_makefile_line_var($varname, $op, $value, $vars) {
@@ -670,22 +671,24 @@ sub parse_makefile_vars($file, $cwd = undef) {
for (my $loop = 1; $loop != 0;) {
$loop = 0;
- foreach my $key (keys %vars) {
- next if index($vars{$key}, '$') == -1;
+ foreach my $varname (keys %vars) {
+ next if index($vars{$varname}, '$') == -1;
- $_ = expand_exprs($vars{$key}, \%vars);
- if ($_ ne $vars{$key}) {
- $vars{$key} = $_;
+ $_ = expand_exprs($vars{$varname}, \%vars);
+ if ($_ ne $vars{$varname}) {
+ $vars{$varname} = $_;
$loop = 1;
- } elsif ($vars{$key} =~ m#\$\{([\w.]+):([CS]([^{}])[^{}\3]+\3[^{}\3]*\3[g1]*(|:[^{}]+)|U[^{}]+)\}#) {
- $loop ||= expand_modifiers($file, $key, $`, $1, $2, $', \%vars);
+ } elsif ($vars{$varname} =~ m#\$\{([\w.]+):([CS]([^{}])[^{}\3]+\3[^{}\3]*\3[g1]*(|:[^{}]+)|U[^{}]+)\}#) {
+ $loop ||= expand_modifiers($file, $varname, $`, $1, $2, $', \%vars);
}
}
}
- foreach my $key (keys %vars) {
- $vars{$key} =~ s/$magic_undefined//;
+ foreach my $varname (keys %vars) {
+ # XXX: Removing only the first magic string is strange; either
+ # all of them or none of them should be removed.
+ $vars{$varname} =~ s/$magic_undefined//;
}
\%vars;
}