Debian Codegraph @

texk/web2c/alephdir/omfi.ch

raw
1 % omfi.ch: Primitives for extra level of infinity.
2 %
3 % This file is part of the Omega project, which
4 % is based on the web2c distribution of TeX.
5 %
6 % Copyright (c) 1994--2000 John Plaice and Yannis Haralambous
7 %
8 % This library is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU Library General Public
10 % License as published by the Free Software Foundation; either
11 % version 2 of the License, or (at your option) any later version.
12 %
13 % This library is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 % Library General Public License for more details.
17 %
18 % You should have received a copy of the GNU Library General Public
19 % License along with this library; if not, write to the Free Software
20 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 %
22 %---------------------------------------
23 @x [10] m.135 l.2878 - Omega fi order of infinity
24 specifies the order of infinity to which glue setting applies (|normal|,
25 |fil|, |fill|, or |filll|). The |subtype| field is not used.
26 @y
27 specifies the order of infinity to which glue setting applies (|normal|,
28 |sfi|, |fil|, |fill|, or |filll|). The |subtype| field is not used.
29 @z
30 %---------------------------------------
31 @x [10] m.150 l.3136 - Omega fi order of infinity
32 orders of infinity (|normal|, |fil|, |fill|, or |filll|)
33 @y
34 orders of infinity (|normal|, |sfi|, |fil|, |fill|, or |filll|)
35 @z
36 %---------------------------------------
37 @x [10] m.150 l.3145 - Omega fi order of infinity
38 @d fil=1 {first-order infinity}
39 @d fill=2 {second-order infinity}
40 @d filll=3 {third-order infinity}
41 @y
42 @d sfi=1 {first-order infinity}
43 @d fil=2 {second-order infinity}
44 @d fill=3 {third-order infinity}
45 @d filll=4 {fourth-order infinity}
46 @z
47 %---------------------------------------
48 @x [10] m.150 l.3150 - Omega fi order of infinity
49 @!glue_ord=normal..filll; {infinity to the 0, 1, 2, or 3 power}
50 @y
51 @!glue_ord=normal..filll; {infinity to the 0, 1, 2, 3, or 4 power}
52 @z
53 %---------------------------------------
54 @x [11] m.162 l.3296 - Omega fi order of infinity
55 @d fil_glue==zero_glue+glue_spec_size {\.{0pt plus 1fil minus 0pt}}
56 @y
57 @d sfi_glue==zero_glue+glue_spec_size {\.{0pt plus 1fi minus 0pt}}
58 @d fil_glue==sfi_glue+glue_spec_size {\.{0pt plus 1fil minus 0pt}}
59 @z
60 %---------------------------------------
61 @x [11] m.164 l.3296 - Omega fi order of infinity
62 stretch(fil_glue):=unity; stretch_order(fil_glue):=fil;@/
63 @y
64 stretch(sfi_glue):=unity; stretch_order(sfi_glue):=sfi;@/
65 stretch(fil_glue):=unity; stretch_order(fil_glue):=fil;@/
66 @z
67 %---------------------------------------
68 @x [12] m.177 l.3591 - Omega fi order of infinity
69 begin print("fil");
70 while order>fil do
71 @y
72 begin print("fi");
73 while order>sfi do
74 @z
75 %---------------------------------------
76 @x [26] m.454 l.8924 - Omega fi order of infinity
77 if scan_keyword("fil") then
78 @.fil@>
79 begin cur_order:=fil;
80 @y
81 if scan_keyword("fi") then
82 @.fil@>
83 begin cur_order:=sfi;
84 @z
85 %---------------------------------------
86 @x [33] m.650 l.12877 - Omega fi order of infinity
87 total_stretch[fil]:=0; total_shrink[fil]:=0;
88 @y
89 total_stretch[sfi]:=0; total_shrink[sfi]:=0;
90 total_stretch[fil]:=0; total_shrink[fil]:=0;
91 @z
92 %---------------------------------------
93 @x [33] m.659 l.12996 - Omega fi order of infinity
94 else if total_stretch[fil]<>0 then o:=fil
95 @y
96 else if total_stretch[fil]<>0 then o:=fil
97 else if total_stretch[sfi]<>0 then o:=sfi
98 @z
99 %---------------------------------------
100 @x [33] m.665 l.13061 - Omega fi order of infinity
101 else if total_shrink[fil]<>0 then o:=fil
102 @y
103 else if total_shrink[fil]<>0 then o:=fil
104 else if total_shrink[sfi]<>0 then o:=sfi
105 @z
106 %---------------------------------------
107 @x [38] m.822 l.16135 - Omega fi order of infinity
108 contains six scaled numbers, since it must record the net change in glue
109 stretchability with respect to all orders of infinity. The natural width
110 difference appears in |mem[q+1].sc|; the stretch differences in units of
111 pt, fil, fill, and filll appear in |mem[q+2..q+5].sc|; and the shrink difference
112 appears in |mem[q+6].sc|. The |subtype| field of a delta node is not used.
113
114 @d delta_node_size=7 {number of words in a delta node}
115 @y
116 contains seven scaled numbers, since it must record the net change in glue
117 stretchability with respect to all orders of infinity. The natural width
118 difference appears in |mem[q+1].sc|; the stretch differences in units of
119 pt, sfi, fil, fill, and filll appear in |mem[q+2..q+6].sc|; and the shrink
120 difference appears in |mem[q+7].sc|. The |subtype| field of a delta node
121 is not used.
122
123 @d delta_node_size=8 {number of words in a delta node}
124 @z
125 %---------------------------------------
126 @x [38] m.823 l.16144 - Omega fi order of infinity
127 @ As the algorithm runs, it maintains a set of six delta-like registers
128 for the length of the line following the first active breakpoint to the
129 current position in the given hlist. When it makes a pass through the
130 active list, it also maintains a similar set of six registers for the
131 @y
132 @ As the algorithm runs, it maintains a set of seven delta-like registers
133 for the length of the line following the first active breakpoint to the
134 current position in the given hlist. When it makes a pass through the
135 active list, it also maintains a similar set of seven registers for the
136 @z
137 %---------------------------------------
138 @x [38] m.823 l.16154 - Omega fi order of infinity
139 k:=1 to 6 do cur_active_width[k]:=cur_active_width[k]+mem[q+k].sc|};$$ and we
140 want to do this without the overhead of |for| loops. The |do_all_six|
141 macro makes such six-tuples convenient.
142
143 @d do_all_six(#)==#(1);#(2);#(3);#(4);#(5);#(6)
144
145 @<Glob...@>=
146 @!active_width:array[1..6] of scaled;
147 {distance from first active node to~|cur_p|}
148 @!cur_active_width:array[1..6] of scaled; {distance from current active node}
149 @!background:array[1..6] of scaled; {length of an ``empty'' line}
150 @!break_width:array[1..6] of scaled; {length being computed after current break}
151 @y
152 k:=1 to 7 do cur_active_width[k]:=cur_active_width[k]+mem[q+k].sc|};$$ and we
153 want to do this without the overhead of |for| loops. The |do_all_six|
154 macro makes such six-tuples convenient.
155
156 @d do_all_six(#)==#(1);#(2);#(3);#(4);#(5);#(6);#(7)
157
158 @<Glo...@>=
159 @!active_width:array[1..7] of scaled;
160 {distance from first active node to~|cur_p|}
161 @!cur_active_width:array[1..7] of scaled; {distance from current active node}
162 @!background:array[1..7] of scaled; {length of an ``empty'' line}
163 @!break_width:array[1..7] of scaled; {length being computed after current break}
164 @z
165 %---------------------------------------
166 @x [38] m.827 l.16242 - Omega fi order of infinity
167 background[2]:=0; background[3]:=0; background[4]:=0; background[5]:=0;@/
168 @y
169 background[2]:=0; background[3]:=0; background[4]:=0; background[5]:=0;@/
170 background[6]:=0;@/
171 @z
172 %---------------------------------------
173 @x [38] m.827 l.16260 - Omega fi order of infinity
174 background[6]:=shrink(q)+shrink(r);
175 @y
176 background[7]:=shrink(q)+shrink(r);
177 @z
178 %---------------------------------------
179 @x [38] m.838 l.16470 - Omega fi order of infinity
180 break_width[6]:=break_width[6]-shrink(v);
181 @y
182 break_width[7]:=break_width[7]-shrink(v);
183 @z
184 %---------------------------------------
185 @x [38] m.852 l.16713 - Omega fi order of infinity
186 subarray |cur_active_width[2..5]|, in units of points, fil, fill, and filll.
187 @y
188 subarray |cur_active_width[2..6]|, in units of points, sfi, fil, fill and filll.
189 @z
190 %---------------------------------------
191 @x [38] m.852 l.16722 - Omega fi order of infinity
192 if (cur_active_width[3]<>0)or(cur_active_width[4]<>0)or@|
193 (cur_active_width[5]<>0) then
194 @y
195 if (cur_active_width[3]<>0)or(cur_active_width[4]<>0)or@|
196 (cur_active_width[5]<>0)or(cur_active_width[6]<>0) then
197 @z
198 %---------------------------------------
199 @x [38] m.853 l.16738 - Omega fi order of infinity
200 we can shrink the line from |r| to |cur_p| by at most |cur_active_width[6]|.
201
202 @<Set the value of |b| to the badness for shrinking...@>=
203 begin if -shortfall>cur_active_width[6] then b:=inf_bad+1
204 else b:=badness(-shortfall,cur_active_width[6]);
205 @y
206 we can shrink the line from |r| to |cur_p| by at most |cur_active_width[7]|.
207
208 @<Set the value of |b| to the badness for shrinking...@>=
209 begin if -shortfall>cur_active_width[7] then b:=inf_bad+1
210 else b:=badness(-shortfall,cur_active_width[7]);
211 @z
212 %---------------------------------------
213 @x [39] m.868 l.17054 - Omega fi order of infinity
214 active_width[6]:=active_width[6]+shrink(q)
215 @y
216 active_width[7]:=active_width[7]+shrink(q)
217 @z
218 %---------------------------------------
219 @x [44] m.975 l.18932 - Omega fi order of infinity
220 if (active_height[3]<>0) or (active_height[4]<>0) or
221 (active_height[5]<>0) then b:=0
222 else b:=badness(h-cur_height,active_height[2])
223 else if cur_height-h>active_height[6] then b:=awful_bad
224 else b:=badness(cur_height-h,active_height[6])
225 @y
226 if (active_height[3]<>0) or (active_height[4]<>0) or
227 (active_height[5]<>0) or (active_height[6]<>0) then b:=0
228 else b:=badness(h-cur_height,active_height[2])
229 else if cur_height-h>active_height[7] then b:=awful_bad
230 else b:=badness(cur_height-h,active_height[7])
231 @z
232 %---------------------------------------
233 @x [44] m.976 l.18947 - Omega fi order of infinity
234 active_height[6]:=active_height[6]+shrink(q);
235 @y
236 active_height[7]:=active_height[7]+shrink(q);
237 @z
238 %---------------------------------------
239 @x [48] m.1201 l.22454 - Omega fi order of infinity
240 (total_shrink[fil]<>0)or(total_shrink[fill]<>0)or
241 (total_shrink[filll]<>0)) then
242 @y
243 (total_shrink[sfi]<>0)or(total_shrink[fil]<>0)or
244 (total_shrink[fill]<>0)or(total_shrink[filll]<>0)) then
245 @z
246