From b652e8230ab0b0c3ff226a0a9fc5f3eeddbe10cb Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 26 Aug 2022 12:16:09 -0500 Subject: [PATCH] Improve expandVars.pl debug output --- src/tools/expandVars.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/tools/expandVars.pl b/src/tools/expandVars.pl index a0941f7cb..6d624962e 100644 --- a/src/tools/expandVars.pl +++ b/src/tools/expandVars.pl @@ -43,7 +43,6 @@ my $outfile = shift # Where are we? my $top = AbsPath($opt_t); -print "TOP = $top\n" if $opt_d; # Read RELEASE file into vars my %vars = (TOP => $top); @@ -56,20 +55,30 @@ $vars{'ARCH'} = $opt_a if $opt_a; while ($_ = shift @opt_D) { m/^ (\w+) \s* = \s* (.*) $/x; $vars{$1} = $2; - print "$1 = $2\n" if $opt_d; } +print "Variables defined:\n", + map " $_ = $vars{$_}\n", sort keys %vars + if $opt_d; + # Generate the expanded output open(my $SRC, '<', $infile) or die "$! reading $infile\n"; + +my $vf=0; +my %nf; my $output = join '', map { # Substitute any @VARS@ in the text s{@([A-Za-z0-9_]+)@} - {exists $vars{$1} ? $vars{$1} : "\@$1\@"}eg; + {exists $vars{$1} ? (++$vf, $vars{$1}) : (++$nf{$1}, "\@$1\@")}eg; $_ } <$SRC>; close $SRC; -print "expandVars.pl: $infile expands to:\n$output\n" if $opt_d; + +my $vn = scalar %nf; +print "Expanded $infile => $outfile with $vf successes, $vn failures\n", + map {" \@$_\@ - " . $nf{$_} . " instance(s)\n"} keys %nf + if $opt_d; # Check if the output file matches my $DST;