3
# Format the dictionaries according to a standard scheme.
5
# Usage: cat dictionary | ./format.pl > new
7
# We don't over-write the dictionaries in place, so that the process
8
# can be double-checked by hand.
10
# This is a bit of a hack.
12
# FIXME: get lengths from variables, rather than hard-coding.
14
# $Id: format.pl,v 1.3.2.1 2005/11/30 22:17:34 aland Exp $
22
# Clear out trailing whitespace
32
# Suppress multiple blank lines
35
next if ($blank == 1);
45
if (/^VENDOR\s+([\w-]+)\s+(\w+)(.*)/) {
50
$lenx += 7; # round up
57
print "VENDOR\t\t$name$tabs$2$3\n";
63
# Remember if we did begin-vendor.
65
if (/^BEGIN-VENDOR\s+([\w-]+)/) {
67
print "BEGIN-VENDOR\t$vendor\n";
74
if (/^ATTRIBUTE\s+([\w-]+)\s+(\w+)\s+(\w+)(.*)/) {
79
$lenx += 7; # round up
95
# See if it's old format, with the vendor at the end of
96
# the line. If so, make it the new format.
98
if ($stuff =~ /$vendor/) {
99
if ($begin_vendor == 0) {
100
print "BEGIN-VENDOR\t$vendor\n\n";
103
$stuff =~ s/$vendor//;
107
print "ATTRIBUTE\t$name$tabs$value\t$type$stuff\n";
114
if (/^VALUE\s+([\w-]+)\s+([\w-\/,.]+)\s+(\w+)(.*)/) {
119
$lenx += 7; # round up
122
$tabsa = "\t" x $lenx;
128
$len += 8 * length $tabsa;
136
# For the code below, we assume that the attribute lengths
147
$lenx = 24 - $lena - $len;
148
$lenx += 7; # round up
151
$tabsn = "\t" x $lenx;
159
print "VALUE\t$attr$tabsa$name$tabsn$3$4\n";
164
# Remember if we did this.
171
# Everything else gets dumped out as-is.
177
# If we changed the format, print the end vendor, too.
180
print "\nEND-VENDOR\t$vendor\n";