|
|
1.1 root 1: sed -e 's/\\f(..//g' -e 's/\\f[a-z0-9A-Z]//g' -e 's/\\em//' -e 's/ ,/,/' -e 's/\\\&//g' -e 's/,/ /' -e 's/^ //' -e 's/ / /' x|sed 's/ \([^A-Za-z]\)/ \1/'|sort -f|sed -e 's/ / /' -e 's/\b//'|
2: awk '
3: #single
4: #s
5: #Sfor cw
6: #p for 1cw
7: #r for 2cw
8: #t for 4cw
9: #q for 3cw
10: #x for 4&6
11: #y for 1&3
12: #z for 2&4
13: #Z for 3&5
14: #Y for 1,2,&4
15: #
16: #global
17: #g
18: #G for CW
19: #P for 1cw
20: #R for 2cw
21: #
22: #c cw
23: #f 1st cw
24: #C paper name to cw
25: BEGIN {
26: while((getline<"contents") > 0){
27: names[$1] = $2
28: last[$1] = $3
29: }
30: FS=" "
31: }
32: {
33: junk=$0
34: caps=gsub(/[A-HJ-Z]/,"",junk)
35: constant=0
36: control=0
37: if($1 == term){
38: ck = global = substr($2,2,index($2,",")-2)
39: if(ck in names && ((NF>2 && $NF !~ /C/)||NF < 3)){
40: sub(/^ /, " \\fI", $2)
41: sub(/,/,"\\fP,", $2)
42: }
43: if($2 ~ /[A-Z_$][A-Z_][A-Z_$0-9& ]*/){
44: if($2 !~ /[a-z]/)caps = caps/2
45: control=8*gsub(/[A-Z_$][A-Z_$][A-Z_$0-9& ]*/,"\\s-2&\\s+2")
46: }
47: sub(/^ /,"",$2)
48: if(NF == 3){
49: rside = ckcw($2,0,$NF)
50: if(global in names){
51: if( $3~ /[gGPR]/)
52: printit(" \\fI" global "\\fP, " names[global] "-" last[global],1,control)
53: else if($2 ~ /\\fI/)printit(" " $2, 1, control)
54: else printit(" " rside, 1, control)
55: next
56: }
57: }
58: else rside = $2
59: printit(" " rside, 1, control) #removed space
60: }
61: else {
62: term = $1
63: control=0
64: if(hadamatch){
65: printf("\n")
66: }
67: if(term in names){
68: if(!hadamatch)printf("\n")
69: hadamatch=1
70: newt="\\fI" term "\\fP, " names[term] "-" last[term]
71: printit(newt, 0, 0)
72: if($2 ~ /[A-Z_$][A-Z_$][A-Z_$0-9& ]*/){
73: if($2 !~ /[a-z]/)caps /= 2
74: control=8*gsub(/[A-Z_$][A-Z_$][A-Z_$0-9& ]*/,"\\s-2&\\s+2")
75: }
76: sub(/^ /,"",$2)
77: if(NF == 3)
78: rside = ckcw($2,0,$NF)
79: else rside = $2
80: printit(" " rside, 1, control) #removed space
81: }
82: else {
83: hadamatch=0
84: if($1 ~ /[A-Z_$][A-Z_$][A-Z_$0-9& ]*/){
85: control=8*gsub(/[A-Z_$][A-Z_$][A-Z_$0-9& ]*/,"\\s-2&\\s+2")
86: }
87: lside = $1
88: if(NF == 3){
89: lside = ckcw($1,1,$NF)
90: if($NF ~ /[gGPR]/){
91: r = substr($2,2,index($2,",")-2)
92: if(r in names ){
93: control += 6
94: printit(lside ", \\fI" r "\\fP, " names[r] "-" last[r],0,control)
95: next
96: }
97: else {
98: print "term not in names:" r|"cat 1>&2"
99: sub(/ ./,"")
100: }
101: }
102: }
103: control += 6
104: sub(",","\\fP,",$2)
105: printit(lside ",\\fI" $2, 0, control)
106: }
107: }}
108: function ckcw(rterm,first,code){
109: constant=0
110: savit=rterm
111: if(rterm ~ /^-/){
112: control += 2
113: sub(/^-/,"\\(em",rterm)
114: }
115: if(rterm ~ /^\./){
116: control += 2
117: sub(/^\./,"\\\\&&",rterm)
118: }
119: if(code ~ /[gs]/)return(rterm)
120: if(code ~ /[GcSC]/){
121: if(first)rterm = addit(rterm)
122: else {
123: constant = index(rterm,",")-1
124: if(rterm ~ /s[-+]2/){
125: constant -= 8
126: gsub(/s\+2/,"s+1", rterm)
127: gsub(/s\-2/,"s-1", rterm)
128: rterm = "\\s-1\\f(CW" rterm
129: sub(/,/,"\\fP\\s+1,",rterm)
130: }
131: else {
132: rterm = "\\s-1\\f(CW" rterm
133: sub(/,/,"\\fP\\s+1,",rterm)
134: }
135: }
136: }
137: else if(code ~ /[pPf]/){
138: constant = index(rterm," ")-1
139: if(rterm ~ /s[-+]2/){
140: constant -= 8
141: gsub(/s\+2/,"s+1", rterm)
142: gsub(/s\-2/,"s-1", rterm)
143: rterm = "\\s-1\\f(CW" rterm
144: sub(/ /,"\\fP\\s+1 ", rterm)
145: }
146: else {
147: rterm = "\\s-1\\f(CW" rterm
148: sub(/ /,"\\fP\\s+1 ", rterm)
149: }
150: }
151: else{
152: n=split(rterm, arr, " ")
153: if(code ~ /[Yy]/)rterm = addit(arr[1])
154: else rterm = arr[1]
155: for(i=2;i<=n;i++){
156: if(i==2 && code~/[rRzY]/)rterm = rterm " " addit(arr[i])
157: else if(i==3 && code~/[qyZ]/)rterm=rterm " " addit(arr[i])
158: else if(i==4 && code~/[txzY]/)rterm=rterm " " addit(arr[i])
159: else if(i==5 && code~/[Z]/)rterm=rterm " " addit(arr[i])
160: else if(i==6 && code~/x/)rterm=rterm " " addit(arr[i])
161: else {
162: if(arr[i] ~ /s\+2/)sub(/s\+2/,"s+1",arr[i])
163: rterm = rterm " " arr[i]
164: }
165: }
166: }
167: if(code ~ /[xyz]/)control+=16
168: control += 16
169: return(rterm)
170: }
171: function addit(string){
172: constant += length(string)
173: if(string ~ /s[-+]2/){
174: constant -= 8
175: gsub(/s\+2/,"s+1", string)
176: gsub(/s\-2/,"s-1", string)
177: return("\\s-1\\f(CW" string "\\fP\\s+1")
178: }
179: else return("\\s-1\\f(CW" string "\\fP\\s+1")
180: }
181: function printit(line, space, control){
182: if(!constant)
183: limit=43+control - caps*.5 #was 46 at 8 pt - 43 with italic change
184: else limit = 43 - constant*.4 + 1 + control - caps*.5
185: print "lim " limit " leng " length(line) " cons:ctl:caps " constant ":" control ":" caps " " line|"cat 1>&2"
186: if(space == 0)limit += 2
187: if(length(line)< limit)print line
188: else {
189: n=split(line, a, ",")
190: if(length(a[1])>=limit-6 || space){ #adjust for italic change
191: if(!space)limit -=6
192: m=split(a[1],b," ")
193: nline=b[1]
194: if(space)nline = " " b[1]
195: if(m > 1)for(i=2;i<=m;i++){
196: if(length(nline)+length(b[i])+1>=limit){
197: if(nline ~ /s-2/ && nline !~ /s+2/){
198: print nline "\\s+2"
199: nline = " \\s-2" b[i]
200: }
201: else {
202: print nline
203: nline = " " b[i]
204: }
205: }
206: else nline = nline " " b[i]
207: }
208: for(i=2; i<=n;i++){
209: leng=length(a[i])
210: if(a[i] ~ /-/)leng--
211: if(length(nline)+leng >= limit){
212: print nline ","
213: nline = " " a[i]
214: }
215: else nline = nline "," a[i]
216: }
217: print nline
218: return
219: }
220: nline=a[1]
221: for(i=2;i<=n;i++){
222: if(length(nline)+ length(a[i])>= limit){ #used to be -6
223: print nline ","
224: nline = " " a[i]
225: }
226: else nline = nline "," a[i]
227: }
228: if(length(nline) > 0)print nline
229: }
230: }'
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.