3
# Print out the ATTRIBUTE's which are defined only once on input,
4
# and any VALUE's which are defined for those attributes. It does NOT
5
# print out unique VALUEs for multiple-defined attributes, though.
7
# Usage: cat dictionary1 dictionary2 | ./attrnew.pl > unique
9
# This is a bit of a hack. In order to make it work, you've got to
10
# add a "fake" attribute to the end of dictionary1, so that you know
11
# which attributes belong to which dictionary...
13
# $Id: attrnew.pl,v 1.1.2.1 2005/11/30 22:17:18 aland Exp $
23
if (/^ATTRIBUTE\s+([\w-]+)\s+(\w+)\s+(\w+)(.*)/) {
29
$value =~ tr/[A-F]/[a-f]/; # normal form for hex
32
if ($value =~ /^0x/) {
38
if (defined $attributes{$index}) {
41
$first_ref{$line} = $index;
44
$attributes{$index} = "$name $value $type$stuff";
45
$name2val{$name} = $index;
52
if (/^VALUE\s+([\w-]+)\s+([\w-\/,.]+)\s+(\w+)(.*)/) {
58
$value =~ tr/[A-F]/[a-f]/; # normal form for hex
61
if ($value =~ /^0x/) {
67
if (!defined $name2val{$attr}) {
68
print "# FIXME: FORWARD REF?\nVALUE $attr $name $value$stuff\n";
72
$values{$name2val{$attr}}{$index} = "$attr $name $value$stuff";
78
# Print out the attributes sorted by number.
80
foreach $line (sort {$a <=> $b} keys %first_ref) {
81
$attr_val = $first_ref{$line};
83
next if (defined $dup{$attr_val});
85
print "ATTRIBUTE ", $attributes{$attr_val}, "\n";
87
next if (!defined %{$values{$attr_val}});
89
foreach $value (sort {$a <=> $b} keys %{$values{$attr_val}}) {
90
print "VALUE ", $values{$attr_val}{$value}, "\n";