From: ian Date: Wed, 14 Apr 2004 22:32:53 +0000 (+0000) Subject: suppression X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=68169d0c10ce0bf817cd917774b2d6be575004ff;p=trains.git suppression --- diff --git a/farnell/control.partlist b/farnell/control.partlist new file mode 100644 index 0000000..ecad651 --- /dev/null +++ b/farnell/control.partlist @@ -0,0 +1,2 @@ +suppress std * +suppress 432-9363 diff --git a/farnell/farnell-find b/farnell/farnell-find index f6edb3b..07088df 100755 --- a/farnell/farnell-find +++ b/farnell/farnell-find @@ -14,6 +14,8 @@ # # Input format: lines, #-comments, blank lines ignored. # Indent level is relevant, but only 0, 1, >1 relevant. +# Order of information in a file is not relevant unless explicitly +# stated below. # # # Starts a circuit. @@ -46,6 +48,12 @@ # no more specific description, and the constructed description # is with a space and the remainder of the part # name appended. +# +# suppress +# suppress +# Suppresses all processing for all parts matching the +# glob. +# # end # Ends the file. Optional. @@ -92,6 +100,9 @@ our(%show); # $show{$item}{Info} ) strings ready to print # $show{$item}{Price} calculated value +our(%suppress_item); +our(@suppress_partre); + our(@sorthow); # list of desc price avail @@ -201,6 +212,14 @@ sub read_spec ($) { if (defined $3) { push @{ $itemdesc{$2} }, "$1: $3"; } + } elsif (m/^suppress\s+($item_re)$/) { + $suppress_item{$1}= 1; + } elsif (m/^suppress\s+(\S.*)$/) { + $_= $1; s/\s+/ /g; + s/\W/ ($& eq '*' ? '.*' : + $& eq '?' ? '.' : + "\\$&") /ge; + push @suppress_partre, $_; } else { die "$_ ?"; } @@ -213,7 +232,10 @@ sub itemsortmap ($) { my ($o, $bi, $how, $title); $o= ''; $bi= $iteminfo{$item}; - if (!defined $bi) { return "? $item\n"; } + if (!defined $bi) { + $bi= { Avail => '?U' }; + $bi->{Description} = $itemdesc{$item} ? $itemdesc{$item}[0] : '?U'; + } foreach $how (@sorthow) { if ($how eq 'price') { $o .= sprintf "%030.20f ", 1.0 / ($show{$item}{Price} + 0.0001); @@ -230,10 +252,28 @@ sub itemsortmap ($) { return $o; } +sub hrule () { print '-'x79, "\n" or die $!; } + +sub iteminstanceprint ($) { + my ($ii) = @_; + my ($ql,$qr); + + $ql= $ii->{Qty}; $qr= ''; + if ($ql =~ s/\D\d+$//) { $qr= $&; } + if ($ql =~ s,(\d+)/[a-z]+$,,) { $qr= "$1/"; } + if ($ql =~ s/\=//) { $qr .= $&; } + return sprintf("%*s %5s%-2s %s\n", + (4+1+4),'', + $ql,$qr, + $ii->{Use}); +} + sub analyse_spec () { my ($part,$pd,$try,@rhs,$sp,$circuit,$iteratable,$count,$pe,$use); my ($item,$totalqty,$ii,$bi,$toorder,$price,$total,$notechar,$desc); - my ($avail,%avail,$desclen,$why,$ql,$qr); + my ($avail,%avail,$desclen,$why,$suppress,%suppress,$pi); + my ($iteminstance); + $desclen= 42; foreach $part (sort keys %partdef) { $item= $partdef{$part}; next if exists $itemdesc{$item}; @@ -266,24 +306,31 @@ sub analyse_spec () { $use= $pe->{Use}; $use= defined $use ? "$circuit: $use" : $circuit; $part= $pe->{Part}; + $suppress= 0; if ($part =~ m/^$item_re$/) { $item= $part; } elsif (exists $partdef{$part}) { + $suppress= 1 if grep { $part =~ m/^$_$/ } @suppress_partre; $item= $partdef{$part}; } else { push @fault, "unknown part $part ($pe->{FileLine})"; next; } - push @{ $iteminstances{$item} }, { + $suppress= 1 if exists $suppress_item{$item}; + $iteminstance= { Use => $use, Qty => $pe->{Qty}, Mult => $count, - FileLine => $pe->{FileLine} - }; + FileLine => $pe->{FileLine}, + }; + if ($suppress) { + push @{ $suppress{$item} }, iteminstanceprint($iteminstance); + } else { + push @{ $iteminstances{$item} }, $iteminstance; + } } } $total= 0; - $desclen= 42; foreach $item (sort keys %iteminstances) { $why= defined $itemdesc{$item} ? $itemdesc{$item}[0].'; ' : ''; $why .= join ",", map { $_->{FileLine} } @{ $iteminstances{$item} }; @@ -317,15 +364,7 @@ sub analyse_spec () { $desc); } foreach $ii (@{ $iteminstances{$item} }) { - $ql= $ii->{Qty}; $qr= ''; - if ($ql =~ s/\D\d+$//) { $qr= $&; } - if ($ql =~ s,(\d+)/[a-z]+$,,) { $qr= "$1/"; } - if ($ql =~ s/\=//) { $qr .= $&; } - $show{$item}{Info} .= - sprintf("%*s %5s%-2s %s\n", - (4+1+4),'', - $ql,$qr, - $ii->{Use}); + $show{$item}{Info} .= iteminstanceprint($ii); } } foreach $item (sort { itemsortmap($a) cmp itemsortmap($b); } @@ -341,7 +380,25 @@ sub analyse_spec () { or die $!; print "\n" or die $!; dump_warnerrs(); - print '-'x70, "\n" or die $!; + if (keys %suppress) { + print "---------- suppressed ----------\n" or die $!; + foreach $item (sort { itemsortmap($a) cmp itemsortmap($b); } + keys %suppress) { + $pi= $item; + foreach $ii (@{ $itemdesc{$item} }) { + printf " %-10s %s\n", $pi, $ii + or die $!; + $pi= ''; + } + if (length $pi) { + print " $pi\n" or die $!; + } + foreach $ii (@{ $suppress{$item} }) { + print $ii or die $!; + } + } + } + hrule(); } sub addqty ($$$$) {