mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-12-19 03:20:44 +02:00
m1r1/dsc/bomshelf: new tag X to delete a part number (and all references)
This commit is contained in:
parent
4bcaa5fb3c
commit
0750ed855d
@ -23,6 +23,29 @@ sub csv
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub lookup
|
||||
{
|
||||
my $p = $_[0];
|
||||
my $add = $_[1];
|
||||
my @a;
|
||||
|
||||
return $p if defined $cr{$p};
|
||||
@a = grep { $_ =~ /^$p/ } keys %cr;
|
||||
die "key $p* is ambiguous" if scalar @a > 1;
|
||||
if (!@a) {
|
||||
@a = grep { $_ =~ /$p/ } keys %cr;
|
||||
die "key *$p* is ambiguous" if scalar @a > 1;
|
||||
if (!@a) {
|
||||
die "key $p matches nothing" unless $add;
|
||||
warn "adding $p as supplement";
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
return $a[0];
|
||||
}
|
||||
|
||||
|
||||
while (<>) {
|
||||
chop;
|
||||
@f = &csv($_);
|
||||
@ -43,6 +66,15 @@ while (<F>) {
|
||||
chop;
|
||||
next if /^\s*#/;
|
||||
next if /^\s*$/;
|
||||
if (/^[Xx]:\s*/) {
|
||||
$p = &lookup($', 0);
|
||||
delete $cr{$p}, $url{$p}, $dsc{$p};
|
||||
for (keys %r) {
|
||||
delete $r{$_} if $r{$_} eq $p;
|
||||
}
|
||||
undef $p;
|
||||
next;
|
||||
}
|
||||
if (/^[Cc]:\s*/) {
|
||||
undef $p if $clear;
|
||||
$clear = 0;
|
||||
@ -60,20 +92,8 @@ while (<F>) {
|
||||
next;
|
||||
}
|
||||
if (/^[Pp]:\s*/) {
|
||||
$p = $';
|
||||
$p = &lookup($', 1);
|
||||
$clear = 0;
|
||||
next if defined $cr{$p};
|
||||
@a = grep { $_ =~ /^$p/ } keys %cr;
|
||||
die "key $p* is ambiguous" if scalar @a > 1;
|
||||
if (!@a) {
|
||||
@a = grep { $_ =~ /$p/ } keys %cr;
|
||||
die "key *$p* is ambiguous" if scalar @a > 1;
|
||||
if (!@a) {
|
||||
warn "adding $p as supplement";
|
||||
next;
|
||||
}
|
||||
}
|
||||
$p = $a[0];
|
||||
next;
|
||||
}
|
||||
if (/^[Aa]:\s*/) {
|
||||
|
Loading…
Reference in New Issue
Block a user