}
our %varref;
+our %varref_exp;
our ($dir_prefix, $dir_suffix, $dir_name,
$var_prefix, $var_prefix_name);
# accurate, since it is only going to be used for advice to the user.
my $note_varref = sub {
my ($vn,$amp) = @_;
- $varref{$vn}{$amp}{"$f:$."} = 1;
+ my $exp = !!$varref_exp{$vn}{$amp};
+ $varref{$vn}{$exp}{$amp}{"$f:$."} = 1;
};
while (<$input>) {
next;
} elsif (s#^\s*$esc\:local\+global\s+(\S.*)$##) {
foreach my $vn (split /\s+/, $1) {
- $vn =~ s{^$esc}{};
- $varref{$vn}{NoWarn} = 1;
+ my $pos = !($vn =~ s{^!}{});
+ my $amp = $vn =~ s{^$esc}{};
+ $varref_exp{$vn}{!!$amp} = $pos;
}
next;
} elsif (s#^\s*$esc\:(?=(-?)include|macro)##) {
elsif (s{^\$\-}{}) { $ddbl=undef; }
elsif (s{^\$\+}{}) { $ddbl=1; }
elsif (s{^\$\(}{}) {
- ddbl_only($&); oud "\$(";
+ ddbl_only($&); oud "\${";
$note_varref->($2,!!$1) if m{^($esc)?([^()\$]+\))};
}
- elsif (s{^\$(\d+)}{}) { ddbl_only($&); oud "\$($1)"; }
+ elsif (s{^\$(\d+)}{}) { ddbl_only($&); oud "\${$1}"; }
elsif (s{^\$\{}{}) {
err 'macro invocation cannot be re-$-doubled' if $ddbl;
od '${eval ${call ';
#use Data::Dumper;
#print STDERR Dumper(\@_);
+ local %varref_exp;
+
my $dir_prefix = dir_prefix($path);
# ^ this is the only var which we need before we come back from
# the recursion.
sub print_varref_warnings () {
foreach my $vn (sort keys %varref) {
my $vv = $varref{$vn};
- next unless $vv->{''} && $vv->{1};
- next if $vv->{NoWarn};
+ next unless $vv->{''}{''} && $vv->{''}{1};
wrncore 'local+global', "saw both $vn and &$vn" or return;
+ foreach my $exp ('', 1) {
foreach my $amp ('', 1) {
- printf STDERR " saw %s%s at %s\n",
+ printf STDERR
+ ($exp
+ ? " expectedly saw %s%s at %s\n"
+ : " saw %s%s at %s\n"),
($amp ? '&' : ''), $vn, $_
foreach
sort { flmap($a) cmp flmap($b) }
- keys %{ $vv->{$amp} };
+ keys %{ $vv->{$exp}{$amp} };
}
+ }
}
}