1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#!/bin/bash
set -e
set -o pipefail
rm -f rules/foundries
rm -f rules/*.rules rules/foundries.new
chars () {
for c in $rest; do
case " $c " in
" "?" ")
ord=`perl -e 'print ord($ARGV[0]),"\n" or die $!' "$c"`
;;
" "d?*" ")
ord="${c#d}"
c=`perl -e 'printf "%c", $ARGV[0]' "$ord"`
;;
*)
echo >&2 "??? $c"
exit 1
;;
esac
./printrule >&3 "$bad" "$good" $height \
"^ENCODING $ord$" $partial "$c"
done
}
seenrules=/
seenfoundries=/
while read keyword rest; do
case "$keyword" in
'#'|'') continue ;;
pcf)
pcf=$rest
for f in good bad; do
out=$f/$pcf.bdf
zcat $f/$pcf.pcf.gz | pcf2bdf >$out
eval "$f=\$out"
done
;;
rules)
newfoundry=$rest
eval `perl -ne '
next unless s/^BBX\s+//;
s/\s+$//;
s/\s+/,/g;
s/[-+]?\b\d+\b/ sprintf "%d", $& /ge;
m/^\d+\,(\d+)\b/ or die;
print "key=$_; height=$1\n" or die $!;
exit;
' <$good`
oldfoundry=`perl -ne '
next unless s/^FOUNDRY\s+\"?//;
s/\"?\s+$//;
print or die $!;
exit;
' <$good`
case "$seenfoundries" in
*/"$oldfoundry,$newfoundry"/*)
;;
*/"$oldfoundry,"*)
echo >&2 "inconsistent foundry mapping"
exit 1
;;
*)
seenfoundries=$seenfoundries$oldfoundry,$newfoundry/
printf >>rules/foundries.new \
"%s %s\n" "$oldfoundry" "$newfoundry"
;;
esac
case "$seenrules" in
*/"$newfoundry,$key"/*)
exec 3>>rules/$newfoundry,$key.rules
;;
*)
exec 3>rules/$newfoundry,$key.rules
echo >&3 '# -*- perl -*-'
echo >&3 '# autogenerated by mkrules'
echo >&3 'sub {'
seenrules=$seenrules$newfoundry,$key/
;;
esac
echo >&3 " # $pcf"
;;
endrules)
exec 3</dev/null
;;
entire)
partial=0
chars
;;
partial)
partial=1
chars
;;
verbatim)
echo >&3 " $rest"
;;
*)
echo >&2 "??? $keyword"
exit 1
;;
esac
done
while :; do
case "$seenrules" in /) break ;; esac
seenrules=${seenrules#/}
rulefile=${seenrules%%/*}
seenrules=/${seenrules#*/}
echo "}" >>rules/$rulefile.rules
done
mv rules/foundries.new rules/foundries
|