prt-auf: clean up the formatting of 'dependent' output

This commit is contained in:
John McQuah 2023-02-16 06:41:52 -05:00
parent 18b7b6fd3f
commit 46dba884e9

View File

@ -81,15 +81,14 @@ if ($action eq "path") { @results = find_port_by_name($query[0],1,1,0);
#################### Post-transaction reports #######################
$strf = "%s\n";
if (($action =~ /^(listinst|listorphans)/)
or (($action eq "dependent") and ($odepends{all}==0))) {
if ($action =~ /^(listinst|listorphans)/) {
foreach my $result (sort @results) {
$result .= " $V_INST{$result}" if $osearch{verbose}==1;
$result .= " $V_INST{$result}\n$DESC{$result}\n" if $osearch{verbose}>1;
printf $strf, $result;
}
} elsif ($action =~ /^(list|search|dsearch|path|dependent)/) {
foreach my $result (sort @results) {
foreach my $result (@results) {
next if ((! $result) or ($result =~ /^\s*$/));
$result =~ s/.*\/(.*)$/$1/ if (($action ne "path") and ($osearch{path}==0));
$result .= " $V_REPO{$result}" if (($osearch{verbose}==1) and ($action ne "path"));
@ -182,7 +181,7 @@ sub parse_args {
} elsif ($arg =~ /^(diff|quickdiff|printf|listinst|listorphans)$/) { $action = $1;
} elsif ($arg =~ /^(depends|deptree|quickdep|dependent|dup)$/) { $action = $1;
} elsif ($arg =~ /^(readme|cat|edit|ls|help|version|cache)$/) { $action = $1;
} elsif ($arg eq "--tree") { $odepends{tree} = 1; $odepends{recursive} = 1;
} elsif ($arg eq "--tree") { $odepends{tree} = 1;
} elsif ($arg eq "--all") { $odepends{all} = 1;
} elsif ($arg eq "--recursive") { $odepends{recursive} = 1;
} elsif ($arg eq "--cache") { $osearch{cache} = 1;
@ -508,18 +507,20 @@ sub list_ports {
} elsif ($subset eq "inst") { @found = keys %V_INST;
} elsif ($subset eq "locked") { @found=@LOCKED;
} elsif ($subset =~ /^(orphans|dependent)$/) {
my $seed=shift if ($subset eq "dependent");
if (($subset eq "dependent") and (! find_port_by_name($seed,1,1,0))) {
print "$seed not found in the ports tree.\n"; return;
}
# workaround for any port with a plus sign in its name
$seed =~ s/\+/\\\+/g if ($subset eq "dependent");
my $seed; my $sseed;
our @searchspace=(($subset eq "orphans") or ($odepends{all}==0)) ?
keys %V_INST : keys %DEPENDS;
@searchspace = grep { defined $DEPENDS{$_} } @searchspace;
if ($subset eq "dependent") {
$seed=shift; $sseed = $seed;
if (! find_port_by_name($seed,1,1,0)) {
print "$seed not found in the ports tree.\n"; return;
}
# workaround for any port with a plus sign in its name
$sseed =~ s/\+/\\\+/g
}
if ($subset eq "orphans") {
my %not_orphans = map { $_ => 0 } keys %V_INST; my @ndd;
foreach my $port (@searchspace) {
@ -528,11 +529,14 @@ sub list_ports {
}
@found = grep { $not_orphans{$_} eq 0 } keys %V_INST;
} elsif (($subset eq "dependent") and ($odepends{recursive}==0)) {
@found = grep { " $DEPENDS{$_} " =~ / $seed / } @searchspace;
@found = grep { " $DEPENDS{$_} " =~ / $sseed / } @searchspace;
if ($odepends{tree}==1) {
@found = grep { s/^/ / } @found; unshift (@found, "$seed");
}
} elsif (($subset eq "dependent") and ($odepends{recursive}==1)) {
push @outfile, "$seed";
my @children = grep { " $DEPENDS{$_} " =~ / $seed / } @searchspace;
my @children = grep { " $DEPENDS{$_} " =~ / $sseed / } @searchspace;
foreach my $sd (@children) { recurse_offtree($sd); }
sub recurse_offtree {
@ -555,13 +559,14 @@ sub list_ports {
@outfile = grep { !m/^\s*$/ } @outfile;
@outfile = sort(@outfile) unless ($odepends{tree}==1);
@found = ($odepends{tree}==1) ? grep { s/0 / /g } @outfile :
grep !$seen{$_}++, grep { s/0 //g } @outfile;
unshift (@found, $seed);
grep !$seen{$_}++, grep { s/0 //g } grep { /0 / } @outfile ;
unshift (@found, $seed) if ($odepends{tree}==1);
}
# possibilities for the recursive switch have been exhausted
else { }
} # possibilities for the filter have been exhausted
else { }
@found = sort(@found) unless (($subset) and ($subset eq "dependent") and ($odepends{tree}==1));
return @found if ((! $subset) or ($subset =~ /^(orphans|dependent|locked)$/));
if (! $osearch{filter}) { return @found; }
else { return grep {$_ !~ /$osearch{filter}/} @found; }