Date:2012-03-06 22:42:42 (7 years 5 months ago)
Author:Werner Almesberger
Commit:0750ed855d521c9b5c91691dc3b1fa1b25c5fb3f
Message:m1r1/dsc/bomshelf: new tag X to delete a part number (and all references)

Files: m1r4/dsv/bomshelf (3 diffs)

Change Details

m1r4/dsv/bomshelf
2323
2424}
2525
26
27sub lookup
28{
29    my $p = $_[0];
30    my $add = $_[1];
31    my @a;
32
33    return $p if defined $cr{$p};
34    @a = grep { $_ =~ /^$p/ } keys %cr;
35    die "key $p* is ambiguous" if scalar @a > 1;
36    if (!@a) {
37        @a = grep { $_ =~ /$p/ } keys %cr;
38        die "key *$p* is ambiguous" if scalar @a > 1;
39        if (!@a) {
40            die "key $p matches nothing" unless $add;
41            warn "adding $p as supplement";
42            return $p;
43        }
44    }
45    return $a[0];
46}
47
48
2649while (<>) {
2750    chop;
2851    @f = &csv($_);
...... 
4366    chop;
4467    next if /^\s*#/;
4568    next if /^\s*$/;
69    if (/^[Xx]:\s*/) {
70        $p = &lookup($', 0);
71        delete $cr{$p}, $url{$p}, $dsc{$p};
72        for (keys %r) {
73            delete $r{$_} if $r{$_} eq $p;
74        }
75        undef $p;
76        next;
77    }
4678    if (/^[Cc]:\s*/) {
4779        undef $p if $clear;
4880        $clear = 0;
...... 
6092        next;
6193    }
6294    if (/^[Pp]:\s*/) {
63        $p = $';
95        $p = &lookup($', 1);
6496        $clear = 0;
65        next if defined $cr{$p};
66        @a = grep { $_ =~ /^$p/ } keys %cr;
67        die "key $p* is ambiguous" if scalar @a > 1;
68        if (!@a) {
69            @a = grep { $_ =~ /$p/ } keys %cr;
70            die "key *$p* is ambiguous" if scalar @a > 1;
71            if (!@a) {
72                warn "adding $p as supplement";
73                next;
74            }
75        }
76        $p = $a[0];
7797        next;
7898    }
7999    if (/^[Aa]:\s*/) {

Archive Download the corresponding diff file

Branches:
master



interactive