Debian Codegraph @

texk/web2c/euptexdir/fam256.ch

raw
1 % fam256.ch
2 % (C) 2009--2017 by Hironori Kitagawa.
3 %
4 % This patch is derived from om16bit.ch and omfi.ch (both in Omega).
5 % (Omega is copyright by John Plaice and Yannis Haralambous.)
6 %
7 %-----------------------------------------------
8 @x
9 @d hyph_prime=607 {another prime for hashing \.{\\hyphenation} exceptions;
10 if you change this, you should also change |iinf_hyphen_size|.}
11 @y
12 @d hyph_prime=607 {another prime for hashing \.{\\hyphenation} exceptions;
13 if you change this, you should also change |iinf_hyphen_size|.}
14 @d text_size=0 {size code for the largest size in a family}
15 @d script_size=256 {size code for the medium size in a family}
16 @d script_script_size=512 {size code for the smallest size in a family}
17 @z
18 %-----------------------------------------------
19 @x
20 @d not_found4=49 {like |not_found|, when there's more than four}
21 @y
22 @d not_found4=49 {like |not_found|, when there's more than four}
23 @d not_found5=50 {like |not_found|, when there's more than five}
24 @z
25 %-----------------------------------------------
26 @x
27 specifies the order of infinity to which glue setting applies (|normal|,
28 |fil|, |fill|, or |filll|). The |subtype| field is not used in \TeX.
29 @y
30 specifies the order of infinity to which glue setting applies (|normal|,
31 |sfi|, |fil|, |fill|, or |filll|). The |subtype| field is not used in \TeX.
32 @z
33 %-----------------------------------------------
34 @x
35 orders of infinity (|normal|, |fil|, |fill|, or |filll|)
36 @y
37 orders of infinity (|normal|, |sfi|, |fil|, |fill|, or |filll|)
38 @z
39 %-----------------------------------------------
40 @x
41 @d fil=1 {first-order infinity}
42 @d fill=2 {second-order infinity}
43 @d filll=3 {third-order infinity}
44 @y
45 @d sfi=1 {first-order infinity}
46 @d fil=2 {second-order infinity}
47 @d fill=3 {third-order infinity}
48 @d filll=4 {fourth-order infinity}
49 @z
50 %-----------------------------------------------
51 @x
52 @!glue_ord=normal..filll; {infinity to the 0, 1, 2, or 3 power}
53 @y
54 @!glue_ord=normal..filll; {infinity to the 0, 1, 2, 3, or 4 power}
55 @z
56 %-----------------------------------------------
57 @x
58 @d fil_glue==zero_glue+glue_spec_size {\.{0pt plus 1fil minus 0pt}}
59 @y
60 @d sfi_glue==zero_glue+glue_spec_size {\.{0pt plus 1fi minus 0pt}}
61 @d fil_glue==sfi_glue+glue_spec_size {\.{0pt plus 1fil minus 0pt}}
62 @z
63 %-----------------------------------------------
64 @x
65 stretch(fil_glue):=unity; stretch_order(fil_glue):=fil;@/
66 stretch(fill_glue):=unity; stretch_order(fill_glue):=fill;@/
67 @y
68 stretch(sfi_glue):=unity; stretch_order(sfi_glue):=sfi;@/
69 stretch(fil_glue):=unity; stretch_order(fil_glue):=fil;@/
70 stretch(fill_glue):=unity; stretch_order(fill_glue):=fill;@/
71 @z
72 %-----------------------------------------------
73 @x
74 begin print("fil");
75 while order>fil do
76 @y
77 begin print("fi");
78 while order>sfi do
79 @z
80 %-----------------------------------------------
81 @x
82 @d last_item=math_given+1 {most recent item ( \.{\\lastpenalty},
83 @y
84 @d omath_given=math_given+1 {math code defined by \.{\\omathchardef}}
85 @d last_item=omath_given+1 {most recent item ( \.{\\lastpenalty},
86 @z
87 %-----------------------------------------------
88 @x
89 @d math_font_base=cur_font_loc+1 {table of 48 math font numbers}
90 @d cur_jfont_loc=math_font_base+48
91 @y
92 @d math_font_base=cur_font_loc+1 {table of 768 math font numbers}
93 @d cur_jfont_loc=math_font_base+768
94 @z
95 %-----------------------------------------------
96 @x
97 @d var_code==@'70000 {math code meaning ``use the current family''}
98 @y
99 @d var_code==@"70000 {math code meaning ``use the current family''}
100 @z
101 %-----------------------------------------------
102 @x
103 for k:=math_font_base to math_font_base+47 do eqtb[k]:=eqtb[cur_font_loc];
104 @y
105 for k:=math_font_base to math_font_base+767 do eqtb[k]:=eqtb[cur_font_loc];
106 @z
107 %-----------------------------------------------
108 @x
109 begin if n=cur_font_loc then print("current font")
110 else if n<math_font_base+16 then
111 begin print_esc("textfont"); print_int(n-math_font_base);
112 end
113 else if n<math_font_base+32 then
114 begin print_esc("scriptfont"); print_int(n-math_font_base-16);
115 end
116 else begin print_esc("scriptscriptfont"); print_int(n-math_font_base-32);
117 @y
118 begin if n=cur_font_loc then print("current font")
119 else if n<math_font_base+script_size then
120 begin print_esc("textfont"); print_int(n-math_font_base);
121 end
122 else if n<math_font_base+script_script_size then
123 begin print_esc("scriptfont"); print_int(n-math_font_base-script_size);
124 end
125 else begin print_esc("scriptscriptfont");
126 print_int(n-math_font_base-script_script_size);
127 @z
128 %-----------------------------------------------
129 @x
130 @d del_code(#)==eqtb[del_code_base+#].int
131 @y
132 @d del_code(#)==eqtb[del_code_base+#].int
133 @d del_code1(#)==getintone(eqtb[del_code_base+#])
134 @z
135 %-----------------------------------------------
136 @x
137 for k:=0 to 255 do del_code(k):=-1;
138 del_code("."):=0; {this null delimiter is used in error recovery}
139 @y
140 for k:=0 to 255 do
141 begin del_code(k):=-1; setintone(eqtb[del_code_base+k],-1);
142 end;
143 del_code("."):=0; setintone(eqtb[del_code_base+"."],0);
144 {this null delimiter is used in error recovery}
145 @z
146 %-----------------------------------------------
147 @x
148 primitive("delimiter",delim_num,0);@/
149 @!@:delimiter_}{\.{\\delimiter} primitive@>
150 @y
151 primitive("delimiter",delim_num,0);@/
152 @!@:delimiter_}{\.{\\delimiter} primitive@>
153 primitive("odelimiter",delim_num,1);@/
154 @!@:delimiter_}{\.{\\odelimiter} primitive@>
155 @z
156 %-----------------------------------------------
157 @x
158 primitive("mathaccent",math_accent,0);@/
159 @!@:math_accent_}{\.{\\mathaccent} primitive@>
160 primitive("mathchar",math_char_num,0);@/
161 @!@:math_char_}{\.{\\mathchar} primitive@>
162 @y
163 primitive("mathaccent",math_accent,0);@/
164 @!@:math_accent_}{\.{\\mathaccent} primitive@>
165 primitive("mathchar",math_char_num,0);@/
166 @!@:math_char_}{\.{\\mathchar} primitive@>
167 primitive("omathaccent",math_accent,1);@/
168 @!@:math_accent_}{\.{\\omathaccent} primitive@>
169 primitive("omathchar",math_char_num,1);@/
170 @!@:math_char_}{\.{\\omathchar} primitive@>
171 @z
172 %-----------------------------------------------
173 @x
174 primitive("radical",radical,0);@/
175 @!@:radical_}{\.{\\radical} primitive@>
176 @y
177 primitive("radical",radical,0);@/
178 @!@:radical_}{\.{\\radical} primitive@>
179 primitive("oradical",radical,1);@/
180 @!@:radical_}{\.{\\oradical} primitive@>
181 @z
182 %-----------------------------------------------
183 @x
184 delim_num: print_esc("delimiter");
185 @y
186 delim_num: if chr_code=0 then print_esc("delimiter")
187 else print_esc("odelimiter");
188 @z
189 @x
190 math_accent: print_esc("mathaccent");
191 math_char_num: print_esc("mathchar");
192 @y
193 math_accent: if chr_code=0 then print_esc("mathaccent")
194 else print_esc("omathaccent");
195 math_char_num: if chr_code=0 then print_esc("mathchar")
196 else print_esc("omathchar");
197 @z
198 @x
199 radical: print_esc("radical");
200 @y
201 radical: if chr_code=0 then print_esc("radical")
202 else print_esc("oradical");
203 @z
204 %-----------------------------------------------
205 @x
206 @p procedure eq_word_define(@!p:pointer;@!w:integer);
207 label exit;
208 begin if eTeX_ex and(eqtb[p].int=w) then
209 begin assign_trace(p,"reassigning")@;@/
210 return;
211 end;
212 assign_trace(p,"changing")@;@/
213 if xeq_level[p]<>cur_level then
214 begin eq_save(p,xeq_level[p]); xeq_level[p]:=cur_level;
215 end;
216 eqtb[p].int:=w;
217 assign_trace(p,"into")@;@/
218 exit:end;
219 @y
220 @p procedure eq_word_define(@!p:pointer;@!w:integer);
221 label exit;
222 begin if eTeX_ex and(eqtb[p].int=w) then
223 begin assign_trace(p,"reassigning")@;@/
224 return;
225 end;
226 assign_trace(p,"changing")@;@/
227 if xeq_level[p]<>cur_level then
228 begin eq_save(p,xeq_level[p]); xeq_level[p]:=cur_level;
229 end;
230 eqtb[p].int:=w;
231 assign_trace(p,"into")@;@/
232 exit:end;
233 @#
234 procedure del_eq_word_define(@!p:pointer;@!w,wone:integer);
235 label exit;
236 begin if eTeX_ex and(eqtb[p].int=w)and(getintone(eqtb[p])=wone) then
237 begin assign_trace(p,"reassigning")@;@/
238 return;
239 end;
240 assign_trace(p,"changing")@;@/
241 if xeq_level[p]<>cur_level then
242 begin eq_save(p,xeq_level[p]); xeq_level[p]:=cur_level;
243 end;
244 eqtb[p].int:=w; setintone(eqtb[p],wone);
245 assign_trace(p,"into")@;@/
246 exit:end;
247 @z
248 %-----------------------------------------------
249 @x
250 procedure geq_word_define(@!p:pointer;@!w:integer); {global |eq_word_define|}
251 begin assign_trace(p,"globally changing")@;@/
252 begin eqtb[p].int:=w; xeq_level[p]:=level_one;
253 end;
254 assign_trace(p,"into")@;@/
255 end;
256 @y
257 procedure geq_word_define(@!p:pointer;@!w:integer); {global |eq_word_define|}
258 begin assign_trace(p,"globally changing")@;@/
259 begin eqtb[p].int:=w; xeq_level[p]:=level_one;
260 end;
261 assign_trace(p,"into")@;@/
262 end;
263 @#
264 procedure del_geq_word_define(@!p:pointer;@!w,wone:integer);
265 {global |del_eq_word_define|}
266 begin assign_trace(p,"globally changing")@;@/
267 begin eqtb[p].int:=w; setintone(eqtb[p],wone); xeq_level[p]:=level_one;
268 end;
269 assign_trace(p,"into")@;@/
270 end;
271 @z
272 %-----------------------------------------------
273 @x
274 @d tok_val=5 {token lists}
275
276 @<Glob...@>=
277 @!cur_val:integer; {value returned by numeric scanners}
278 @y
279 @d tok_val=5 {token lists}
280
281 @<Glob...@>=
282 @!cur_val:integer; {value returned by numeric scanners}
283 @!cur_val1:integer;
284 @z
285 %-----------------------------------------------
286 @x
287 char_given,math_given: scanned_result(cur_chr)(int_val);
288 @y
289 omath_given,
290 char_given,math_given: scanned_result(cur_chr)(int_val);
291 @z
292 %-----------------------------------------------
293 @x
294 @ @<Fetch a character code from some table@>=
295 begin
296 if m=math_code_base then
297 begin scan_ascii_num;
298 scanned_result(ho(math_code(cur_val)))(int_val); end
299 @y
300 @ @<Fetch a character code from some table@>=
301 begin
302 if m=math_code_base then begin
303 scan_ascii_num; cur_val1:=ho(math_code(cur_val));
304 if ((cur_val1 div @"10000)>8) or
305 (((cur_val1 mod @"10000) div @"100)>15) then
306 begin print_err("Extended mathchar used as mathchar");
307 @.Bad mathchar@>
308 help2("A mathchar number must be between 0 and ""7FFF.")@/
309 ("I changed this one to zero."); int_error(cur_val1);
310 scanned_result(0)(int_val)
311 end;
312 cur_val1:=(cur_val1 div @"10000)*@"1000+cur_val1 mod @"1000;
313 scanned_result(cur_val1)(int_val);
314 end
315 else if m=(math_code_base+128) then begin
316 scan_ascii_num; cur_val1:=ho(math_code(cur_val));
317 cur_val:=(cur_val1 div @"10000) * @"1000000
318 +((cur_val1 div @"100) mod @"100) * @"10000
319 +(cur_val1 mod @"100);
320 scanned_result(cur_val)(int_val);
321 end
322 else if m=del_code_base then begin
323 scan_ascii_num; cur_val1:=del_code(cur_val); cur_val:=del_code1(cur_val);
324 if ((cur_val1 div @"100) mod @"100 >= 16) or (cur_val>=@"1000) then
325 begin print_err("Extended delimiter code used as delcode");
326 @.Bad delimiter code@>
327 help2("A numeric delimiter code must be between 0 and 2^{27}-1.")@/
328 ("I changed this one to zero."); error;
329 scanned_result(0)(int_val);
330 end
331 else if cur_val1<0 then
332 scanned_result(cur_val)(int_val)
333 else
334 scanned_result(cur_val1*@"1000+cur_val)(int_val);
335 end
336 else if m=(del_code_base+128) then begin
337 { Aleph seems \.{\\odelcode} always returns $-1$.}
338 scan_ascii_num; scanned_result(-1)(int_val);
339 end
340 @z
341 %-----------------------------------------------
342 @x
343 procedure scan_four_bit_int;
344 begin scan_int;
345 if (cur_val<0)or(cur_val>15) then
346 begin print_err("Bad number");
347 @.Bad number@>
348 help2("Since I expected to read a number between 0 and 15,")@/
349 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
350 end;
351 end;
352 @y
353 procedure scan_four_bit_int;
354 begin scan_int;
355 if (cur_val<0)or(cur_val>15) then
356 begin print_err("Bad number");
357 @.Bad number@>
358 help2("Since I expected to read a number between 0 and 15,")@/
359 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
360 end;
361 end;
362 @#
363 procedure scan_big_four_bit_int;
364 begin scan_int;
365 if (cur_val<0)or(cur_val>255) then
366 begin print_err("Bad number");
367 @.Bad register code@>
368 help2("Since I expected to read a number between 0 and 255,")@/
369 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
370 end;
371 end;
372 @z
373 %-----------------------------------------------
374 @x
375 procedure scan_fifteen_bit_int;
376 begin scan_int;
377 if (cur_val<0)or(cur_val>@'77777) then
378 begin print_err("Bad mathchar");
379 @.Bad mathchar@>
380 help2("A mathchar number must be between 0 and 32767.")@/
381 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
382 end;
383 end;
384 @y
385 procedure scan_fifteen_bit_int;
386 begin scan_int;
387 if (cur_val<0)or(cur_val>@'77777) then
388 begin print_err("Bad mathchar");
389 @.Bad mathchar@>
390 help2("A mathchar number must be between 0 and 32767.")@/
391 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
392 end;
393 cur_val:=((cur_val div @"1000) * @"10000)+(cur_val mod @"1000);
394 end;
395 @#
396 procedure scan_real_fifteen_bit_int;
397 begin scan_int;
398 if (cur_val<0)or(cur_val>@'77777) then
399 begin print_err("Bad mathchar");
400 @.Bad mathchar@>
401 help2("A mathchar number must be between 0 and 32767.")@/
402 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
403 end;
404 end;
405 @#
406 procedure scan_big_fifteen_bit_int;
407 begin scan_int;
408 if (cur_val<0)or(cur_val>@"7FFFFFF) then
409 begin print_err("Bad extended mathchar");
410 @.Bad mathchar@>
411 help2("An extended mathchar number must be between 0 and ""7FFFFFF.")@/
412 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
413 end;
414 { e-pTeX doesn't support 65536 characters for math font. }
415 cur_val:=((cur_val div @"10000) * @"100)+(cur_val mod @"100);
416 end;
417 @#
418 procedure scan_omega_fifteen_bit_int;
419 begin scan_int;
420 if (cur_val<0)or(cur_val>@"7FFFFFF) then
421 begin print_err("Bad extended mathchar");
422 @.Bad mathchar@>
423 help2("An extended mathchar number must be between 0 and ""7FFFFFF.")@/
424 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
425 end;
426 end;
427 @z
428 %-----------------------------------------------
429 @x
430 procedure scan_twenty_seven_bit_int;
431 begin scan_int;
432 if (cur_val<0)or(cur_val>@'777777777) then
433 begin print_err("Bad delimiter code");
434 @.Bad delimiter code@>
435 help2("A numeric delimiter code must be between 0 and 2^{27}-1.")@/
436 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
437 end;
438 end;
439 @y
440 procedure scan_twenty_seven_bit_int;
441 begin scan_int;
442 if (cur_val<0)or(cur_val>@'777777777) then
443 begin print_err("Bad delimiter code");
444 @.Bad delimiter code@>
445 help2("A numeric delimiter code must be between 0 and 2^{27}-1.")@/
446 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
447 end;
448 cur_val1 := cur_val mod @"1000; cur_val := cur_val div @"1000;
449 cur_val := ((cur_val div @"1000) * @"10000) + (cur_val mod @"1000);
450 end;
451 @#
452 procedure scan_fifty_one_bit_int;
453 var iiii:integer;
454 begin scan_int;
455 if (cur_val<0)or(cur_val>@'777777777) then
456 begin print_err("Bad delimiter code");
457 @.Bad delimiter code@>
458 help2("A numeric delimiter (first part) must be between 0 and 2^{27}-1.")
459 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
460 end;
461 iiii:=((cur_val div @"10000) * @"100) + (cur_val mod @"100);
462 scan_int;
463 if (cur_val<0)or(cur_val>@"FFFFFF) then
464 begin print_err("Bad delimiter code");
465 @.Bad delimiter code@>
466 help2("A numeric delimiter (second part) must be between 0 and 2^{24}-1.")@/
467 ("I changed this one to zero."); int_error(cur_val); cur_val:=0;
468 end;
469 { e-pTeX doesn't support 65536 characters for math font. }
470 cur_val1:=((cur_val div @"10000) * @"100) + (cur_val mod @"100);
471 cur_val:=iiii;
472 end;
473 @z
474 %-----------------------------------------------
475 @x
476 @<Scan for \(f)\.{fil} units...@>=
477 if scan_keyword("fil") then
478 @.fil@>
479 begin cur_order:=fil;
480 @y
481 @<Scan for \(f)\.{fil} units...@>=
482 if scan_keyword("fi") then
483 @.fil@>
484 begin cur_order:=sfi;
485 @z
486 %-----------------------------------------------
487 @x
488 else if cur_cmd=def_family then
489 begin m:=cur_chr; scan_four_bit_int; f:=equiv(m+cur_val);
490 @y
491 else if cur_cmd=def_family then
492 begin m:=cur_chr; scan_big_four_bit_int; f:=equiv(m+cur_val);
493 @z
494 %-----------------------------------------------
495 @x
496 total_stretch[normal]:=0; total_shrink[normal]:=0;
497 @y
498 total_stretch[normal]:=0; total_shrink[normal]:=0;
499 total_stretch[sfi]:=0; total_shrink[sfi]:=0;
500 @z
501 %-----------------------------------------------
502 @x
503 else if total_stretch[fil]<>0 then o:=fil
504 @y
505 else if total_stretch[fil]<>0 then o:=fil
506 else if total_stretch[sfi]<>0 then o:=sfi
507 @z
508 %-----------------------------------------------
509 @x
510 else if total_shrink[fil]<>0 then o:=fil
511 @y
512 else if total_shrink[fil]<>0 then o:=fil
513 else if total_shrink[sfi]<>0 then o:=sfi
514 @z
515 %-----------------------------------------------
516 @x
517 \yskip\hang|math_type(q)=math_char| means that |fam(q)| refers to one of
518 the sixteen font families, and |character(q)| is the number of a character
519 @y
520 \yskip\hang|math_type(q)=math_char| means that |fam(q)| refers to one of
521 the 256 font families, and |character(q)| is the number of a character
522 @z
523 %-----------------------------------------------
524 @x
525 procedure print_fam_and_char(@!p:pointer;@!t:small_number);
526 @y
527 procedure print_fam_and_char(@!p:pointer;@!t:integer);
528 @z
529 %-----------------------------------------------
530 @x
531 other font information. A size code, which is a multiple of 16, is added to a
532 family number to get an index into the table of internal font numbers
533 for each combination of family and size. (Be alert: Size codes get
534 larger as the type gets smaller.)
535
536 @d text_size=0 {size code for the largest size in a family}
537 @d script_size=16 {size code for the medium size in a family}
538 @d script_script_size=32 {size code for the smallest size in a family}
539 @y
540 other font information. A size code, which is a multiple of 256, is added to a
541 family number to get an index into the table of internal font numbers
542 for each combination of family and size. (Be alert: Size codes get
543 larger as the type gets smaller.)
544 @z
545 %-----------------------------------------------
546 @x
547 else cur_size:=16*((cur_style-text_style) div 2);
548 @y
549 else cur_size:=script_size*((cur_style-text_style) div 2);
550 @z
551 %-----------------------------------------------
552 @x
553 function var_delimiter(@!d:pointer;@!s:small_number;@!v:scaled):pointer;
554 @y
555 function var_delimiter(@!d:pointer;@!s:integer;@!v:scaled):pointer;
556 @z
557 %-----------------------------------------------
558 @x
559 @!hd: sixteen_bits; {height-depth byte}
560 @!r: four_quarters; {extensible pieces}
561 @!z: small_number; {runs through font family members}
562 @y
563 @!hd: sixteen_bits; {height-depth byte}
564 @!r: four_quarters; {extensible pieces}
565 @!z: integer; {runs through font family members}
566 @z
567 %-----------------------------------------------
568 @x
569 begin z:=z+s+16;
570 repeat z:=z-16; g:=fam_fnt(z);
571 @y
572 begin z:=z+s+script_size;
573 repeat z:=z-script_size; g:=fam_fnt(z);
574 @z
575 %-----------------------------------------------
576 @x
577 until z<16;
578 @y
579 until z<script_size;
580 @z
581 %-----------------------------------------------
582 @x
583 @!cur_mlist:pointer; {beginning of mlist to be translated}
584 @!cur_style:small_number; {style code at current place in the list}
585 @!cur_size:small_number; {size code corresponding to |cur_style|}
586 @y
587 @!cur_mlist:pointer; {beginning of mlist to be translated}
588 @!cur_style:small_number; {style code at current place in the list}
589 @!cur_size:integer; {size code corresponding to |cur_style|}
590 @z
591 %-----------------------------------------------
592 @x
593 @!p,@!x,@!y,@!z: pointer; {temporary registers for list construction}
594 @!pen:integer; {a penalty to be inserted}
595 @!s:small_number; {the size of a noad to be deleted}
596 @y
597 @!p,@!x,@!y,@!z: pointer; {temporary registers for list construction}
598 @!pen:integer; {a penalty to be inserted}
599 @!s:integer; {the size of a noad to be deleted}
600 @z
601 %-----------------------------------------------
602 @x
603 procedure make_scripts(@!q:pointer;@!delta:scaled);
604 var p,@!x,@!y,@!z:pointer; {temporary registers for box construction}
605 @!shift_up,@!shift_down,@!clr:scaled; {dimensions in the calculation}
606 @!t:small_number; {subsidiary size code}
607 @y
608 procedure make_scripts(@!q:pointer;@!delta:scaled);
609 var p,@!x,@!y,@!z:pointer; {temporary registers for box construction}
610 @!shift_up,@!shift_down,@!clr:scaled; {dimensions in the calculation}
611 @!t:integer; {subsidiary size code}
612 @z
613 %-----------------------------------------------
614 @x
615 contains six scaled numbers, since it must record the net change in glue
616 stretchability with respect to all orders of infinity. The natural width
617 difference appears in |mem[q+1].sc|; the stretch differences in units of
618 pt, fil, fill, and filll appear in |mem[q+2..q+5].sc|; and the shrink difference
619 appears in |mem[q+6].sc|. The |subtype| field of a delta node is not used.
620
621 @d delta_node_size=7 {number of words in a delta node}
622 @y
623 contains seven scaled numbers, since it must record the net change in glue
624 stretchability with respect to all orders of infinity. The natural width
625 difference appears in |mem[q+1].sc|; the stretch differences in units of
626 pt, sfi, fil, fill, and filll appear in |mem[q+2..q+6].sc|; and the shrink
627 difference appears in |mem[q+7].sc|. The |subtype| field of a delta node
628 is not used.
629
630 @d delta_node_size=8 {number of words in a delta node}
631 @z
632 %-----------------------------------------------
633 @x
634 @ As the algorithm runs, it maintains a set of six delta-like registers
635 for the length of the line following the first active breakpoint to the
636 current position in the given hlist. When it makes a pass through the
637 active list, it also maintains a similar set of six registers for the
638 @y
639 @ As the algorithm runs, it maintains a set of seven delta-like registers
640 for the length of the line following the first active breakpoint to the
641 current position in the given hlist. When it makes a pass through the
642 active list, it also maintains a similar set of seven registers for the
643 @z
644 %-----------------------------------------------
645 @x
646 k:=1 to 6 do cur_active_width[k]:=cur_active_width[k]+mem[q+k].sc|};$$ and we
647 want to do this without the overhead of |for| loops. The |do_all_six|
648 macro makes such six-tuples convenient.
649
650 @d do_all_six(#)==#(1);#(2);#(3);#(4);#(5);#(6)
651 @y
652 k:=1 to 7 do cur_active_width[k]:=cur_active_width[k]+mem[q+k].sc|};$$ and we
653 want to do this without the overhead of |for| loops. The |do_all_six|
654 macro makes such seven-tuples convenient.
655
656 @d do_all_six(#)==#(1);#(2);#(3);#(4);#(5);#(6);#(7)
657 @z
658 %-----------------------------------------------
659 @x
660 @!active_width:array[1..6] of scaled;
661 {distance from first active node to~|cur_p|}
662 @!cur_active_width:array[1..6] of scaled; {distance from current active node}
663 @!background:array[1..6] of scaled; {length of an ``empty'' line}
664 @!break_width:array[1..6] of scaled; {length being computed after current break}
665 @y
666 @!active_width:array[1..7] of scaled;
667 {distance from first active node to~|cur_p|}
668 @!cur_active_width:array[1..7] of scaled; {distance from current active node}
669 @!background:array[1..7] of scaled; {length of an ``empty'' line}
670 @!break_width:array[1..7] of scaled; {length being computed after current break}
671 @z
672 %-----------------------------------------------
673 @x
674 background[2]:=0; background[3]:=0; background[4]:=0; background[5]:=0;@/
675 background[2+stretch_order(q)]:=stretch(q);@/
676 background[2+stretch_order(r)]:=@|background[2+stretch_order(r)]+stretch(r);@/
677 background[6]:=shrink(q)+shrink(r);
678 @y
679 background[2]:=0; background[3]:=0; background[4]:=0; background[5]:=0;@/
680 background[6]:=0;@/
681 background[2+stretch_order(q)]:=stretch(q);@/
682 background[2+stretch_order(r)]:=@|background[2+stretch_order(r)]+stretch(r);@/
683 background[7]:=shrink(q)+shrink(r);
684 @z
685 %-----------------------------------------------
686 @x
687 break_width[6]:=break_width[6]-shrink(cur_kanji_skip);
688 @y
689 break_width[7]:=break_width[7]-shrink(cur_kanji_skip);
690 @z
691 %-----------------------------------------------
692 @x
693 break_width[6]:=break_width[6]-shrink(v);
694 @y
695 break_width[7]:=break_width[7]-shrink(v);
696 @z
697 %-----------------------------------------------
698 @x
699 subarray |cur_active_width[2..5]|, in units of points, fil, fill, and filll.
700 @y
701 subarray |cur_active_width[2..6]|, in units of points, sfi, fil, fill and filll.
702 @z
703 %-----------------------------------------------
704 @x
705 if (cur_active_width[3]<>0)or(cur_active_width[4]<>0)or@|
706 (cur_active_width[5]<>0) then
707 @y
708 if (cur_active_width[3]<>0)or(cur_active_width[4]<>0)or@|
709 (cur_active_width[5]<>0)or(cur_active_width[6]<>0) then
710 @z
711 %-----------------------------------------------
712 @x
713 @ Shrinkability is never infinite in a paragraph;
714 we can shrink the line from |r| to |cur_p| by at most |cur_active_width[6]|.
715
716 @<Set the value of |b| to the badness for shrinking...@>=
717 begin if -shortfall>cur_active_width[6] then b:=inf_bad+1
718 else b:=badness(-shortfall,cur_active_width[6]);
719 @y
720 @ Shrinkability is never infinite in a paragraph;
721 we can shrink the line from |r| to |cur_p| by at most |cur_active_width[7]|.
722
723 @<Set the value of |b| to the badness for shrinking...@>=
724 begin if -shortfall>cur_active_width[7] then b:=inf_bad+1
725 else b:=badness(-shortfall,cur_active_width[7]);
726 @z
727 %-----------------------------------------------
728 @x
729 active_width[6]:=active_width[6]+shrink(cur_kanji_skip);
730 @y
731 active_width[7]:=active_width[7]+shrink(cur_kanji_skip);
732 @z
733 %-----------------------------------------------
734 @x
735 active_width[6]:=active_width[6]+shrink(q)
736 @y
737 active_width[7]:=active_width[7]+shrink(q)
738 @z
739 %-----------------------------------------------
740 @x
741 if (active_height[3]<>0) or (active_height[4]<>0) or
742 (active_height[5]<>0) then b:=0
743 else b:=badness(h-cur_height,active_height[2])
744 else if cur_height-h>active_height[6] then b:=awful_bad
745 else b:=badness(cur_height-h,active_height[6])
746 @y
747 if (active_height[3]<>0) or (active_height[4]<>0) or
748 (active_height[5]<>0) or (active_height[6]<>0) then b:=0
749 else b:=badness(h-cur_height,active_height[2])
750 else if cur_height-h>active_height[7] then b:=awful_bad
751 else b:=badness(cur_height-h,active_height[7])
752 @z
753 %-----------------------------------------------
754 @x
755 active_height[6]:=active_height[6]+shrink(q);
756 @y
757 active_height[7]:=active_height[7]+shrink(q);
758 @z
759 %-----------------------------------------------
760 @x
761 on the current page. This array contains six |scaled| numbers, like the
762 @y
763 on the current page. This array contains seven |scaled| numbers, like the
764 @z
765 %-----------------------------------------------
766 @x
767 @d page_shrink==page_so_far[6] {shrinkability of the current page}
768 @d page_depth==page_so_far[7] {depth of the current page}
769 @y
770 @d page_shrink==page_so_far[7] {shrinkability of the current page}
771 @d page_depth==page_so_far[8] {depth of the current page}
772 @z
773 %-----------------------------------------------
774 @x
775 @<Glob...@>=
776 @!page_so_far:array [0..7] of scaled; {height and glue of the current page}
777 @y
778 @<Glob...@>=
779 @!page_so_far:array [0..8] of scaled; {height and glue of the current page}
780 @z
781 %-----------------------------------------------
782 @x
783 primitive("pagefilstretch",set_page_dimen,3);
784 @!@:page_fil_stretch_}{\.{\\pagefilstretch} primitive@>
785 primitive("pagefillstretch",set_page_dimen,4);
786 @!@:page_fill_stretch_}{\.{\\pagefillstretch} primitive@>
787 primitive("pagefilllstretch",set_page_dimen,5);
788 @!@:page_filll_stretch_}{\.{\\pagefilllstretch} primitive@>
789 primitive("pageshrink",set_page_dimen,6);
790 @!@:page_shrink_}{\.{\\pageshrink} primitive@>
791 primitive("pagedepth",set_page_dimen,7);
792 @!@:page_depth_}{\.{\\pagedepth} primitive@>
793 @y
794 primitive("pagefistretch",set_page_dimen,3);
795 @!@:page_fi_stretch_}{\.{\\pagefistretch} primitive@>
796 primitive("pagefilstretch",set_page_dimen,4);
797 @!@:page_fil_stretch_}{\.{\\pagefilstretch} primitive@>
798 primitive("pagefillstretch",set_page_dimen,5);
799 @!@:page_fill_stretch_}{\.{\\pagefillstretch} primitive@>
800 primitive("pagefilllstretch",set_page_dimen,6);
801 @!@:page_filll_stretch_}{\.{\\pagefilllstretch} primitive@>
802 primitive("pageshrink",set_page_dimen,7);
803 @!@:page_shrink_}{\.{\\pageshrink} primitive@>
804 primitive("pagedepth",set_page_dimen,8);
805 @!@:page_depth_}{\.{\\pagedepth} primitive@>
806 @z
807 %-----------------------------------------------
808 @x
809 3: print_esc("pagefilstretch");
810 4: print_esc("pagefillstretch");
811 5: print_esc("pagefilllstretch");
812 6: print_esc("pageshrink");
813 @y
814 3: print_esc("pagefistretch");
815 4: print_esc("pagefilstretch");
816 5: print_esc("pagefillstretch");
817 6: print_esc("pagefilllstretch");
818 7: print_esc("pageshrink");
819 @z
820 %-----------------------------------------------
821 @x
822 print_plus(3)("fil");
823 print_plus(4)("fill");
824 print_plus(5)("filll");
825 @y
826 print_plus(3)("fi");
827 print_plus(4)("fil");
828 print_plus(5)("fill");
829 print_plus(6)("filll");
830 @z
831 %-----------------------------------------------
832 @x
833 if (page_so_far[3]<>0) or (page_so_far[4]<>0) or@|
834 (page_so_far[5]<>0) then b:=0
835 @y
836 if (page_so_far[3]<>0) or (page_so_far[4]<>0) or@|
837 (page_so_far[5]<>0) or (page_so_far[6]<>0) then b:=0
838 @z
839 %-----------------------------------------------
840 @x
841 non_math(math_given), non_math(math_comp), non_math(delim_num),
842 @y
843 non_math(math_given), non_math(omath_given),
844 non_math(math_comp), non_math(delim_num),
845 @z
846 %-----------------------------------------------
847 @x
848 @d fil_code=0 {identifies \.{\\hfil} and \.{\\vfil}}
849 @d fill_code=1 {identifies \.{\\hfill} and \.{\\vfill}}
850 @d ss_code=2 {identifies \.{\\hss} and \.{\\vss}}
851 @d fil_neg_code=3 {identifies \.{\\hfilneg} and \.{\\vfilneg}}
852 @d skip_code=4 {identifies \.{\\hskip} and \.{\\vskip}}
853 @d mskip_code=5 {identifies \.{\\mskip}}
854 @y
855 @d sfi_code=0 {identifies \.{\\hfi} and \.{\\vfi}}
856 @d fil_code=1 {identifies \.{\\hfil} and \.{\\vfil}}
857 @d fill_code=2 {identifies \.{\\hfill} and \.{\\vfill}}
858 @d ss_code=3 {identifies \.{\\hss} and \.{\\vss}}
859 @d fil_neg_code=4 {identifies \.{\\hfilneg} and \.{\\vfilneg}}
860 @d skip_code=5 {identifies \.{\\hskip} and \.{\\vskip}}
861 @d mskip_code=6 {identifies \.{\\mskip}}
862 @z
863 %-----------------------------------------------
864 @x
865 primitive("hfil",hskip,fil_code);
866 @!@:hfil_}{\.{\\hfil} primitive@>
867 @y
868 primitive("hfi",hskip,sfi_code);
869 @!@:hfi_}{\.{\\hfi} primitive@>
870 primitive("hfil",hskip,fil_code);
871 @!@:hfil_}{\.{\\hfil} primitive@>
872 @z
873 %-----------------------------------------------
874 @x
875 primitive("vfil",vskip,fil_code);
876 @!@:vfil_}{\.{\\vfil} primitive@>
877 @y
878 primitive("vfi",vskip,sfi_code);
879 @!@:vfi_}{\.{\\vfi} primitive@>
880 primitive("vfil",vskip,fil_code);
881 @!@:vfil_}{\.{\\vfil} primitive@>
882 @z
883 %-----------------------------------------------
884 @x
885 hskip: case chr_code of
886 skip_code:print_esc("hskip");
887 @y
888 hskip: case chr_code of
889 skip_code:print_esc("hskip");
890 sfi_code:print_esc("hfi");
891 @z
892 %-----------------------------------------------
893 @x
894 vskip: case chr_code of
895 skip_code:print_esc("vskip");
896 @y
897 vskip: case chr_code of
898 skip_code:print_esc("vskip");
899 sfi_code:print_esc("vfi");
900 @z
901 %-----------------------------------------------
902 @x
903 begin s:=cur_chr;
904 case s of
905 fil_code: cur_val:=fil_glue;
906 @y
907 begin s:=cur_chr;
908 case s of
909 sfi_code: cur_val:=sfi_glue;
910 fil_code: cur_val:=fil_glue;
911 @z
912 %-----------------------------------------------
913 @x
914 |global_box_flag-1| represent `\.{\\setbox0}' through `\.{\\setbox32767}';
915 codes |global_box_flag| through |ship_out_flag-1| represent
916 `\.{\\global\\setbox0}' through `\.{\\global\\setbox32767}';
917 @y
918 |global_box_flag-1| represent `\.{\\setbox0}' through `\.{\\setbox65535}';
919 codes |global_box_flag| through |ship_out_flag-1| represent
920 `\.{\\global\\setbox0}' through `\.{\\global\\setbox65535}';
921 @z
922 %-----------------------------------------------
923 @x
924 @d box_flag==@'10000000000 {context code for `\.{\\setbox0}'}
925 @d global_box_flag==@'10000100000 {context code for `\.{\\global\\setbox0}'}
926 @d ship_out_flag==@'10000200000 {context code for `\.{\\shipout}'}
927 @d leader_flag==@'10000200001 {context code for `\.{\\leaders}'}
928 @y
929 @d box_flag==@"40000000 {context code for `\.{\\setbox0}'}
930 @d global_box_flag==@"40010000 {context code for `\.{\\global\\setbox0}'}
931 @d ship_out_flag==@"40020000 {context code for `\.{\\shipout}'}
932 @d leader_flag==@"40020001 {context code for `\.{\\leaders}'}
933 @z
934 %-----------------------------------------------
935 @x
936 @d fam_in_range==((cur_fam>=0)and(cur_fam<16))
937 @y
938 @d fam_in_range==((cur_fam>=0)and(cur_fam<script_size))
939 @z
940 %-----------------------------------------------
941 @x
942 c:=ho(math_code(cur_chr));
943 if c=@'100000 then
944 @y
945 c:=ho(math_code(cur_chr));
946 if c=@"80000 then
947 @z
948 %-----------------------------------------------
949 @x
950 math_char_num: begin scan_fifteen_bit_int; c:=cur_val;
951 end;
952 math_given: c:=cur_chr;
953 delim_num: begin scan_twenty_seven_bit_int; c:=cur_val div @'10000;
954 @y
955 math_char_num: begin
956 if cur_chr=0 then scan_fifteen_bit_int
957 else scan_big_fifteen_bit_int;
958 c:=cur_val;
959 end;
960 math_given: c:=((cur_chr div @"1000) * @"10000) + (cur_chr mod @"1000);
961 omath_given: c:=((cur_chr div @"10000) * @"100) + (cur_chr mod @"100);
962 delim_num: begin
963 if cur_chr=0 then scan_twenty_seven_bit_int
964 else scan_fifty_one_bit_int;
965 c:=cur_val;
966 @z
967 %-----------------------------------------------
968 @x
969 if (c>=var_code)and(fam_in_range) then fam(p):=cur_fam
970 else fam(p):=(c div 256) mod 16;
971 @y
972 if (c>=var_code)and(fam_in_range) then fam(p):=cur_fam
973 else fam(p):=(c div 256) mod 256;
974 @z
975 %-----------------------------------------------
976 @x
977 mmode+math_char_num: begin scan_fifteen_bit_int; set_math_char(cur_val);
978 end;
979 mmode+math_given: set_math_char(cur_chr);
980 mmode+delim_num: begin scan_twenty_seven_bit_int;
981 set_math_char(cur_val div @'10000);
982 @y
983 mmode+math_char_num: begin
984 if cur_chr=0 then scan_fifteen_bit_int
985 else scan_big_fifteen_bit_int;
986 set_math_char(cur_val);
987 end;
988 mmode+math_given: begin
989 set_math_char(((cur_chr div @"1000) * @"10000)+(cur_chr mod @"1000));
990 end;
991 mmode+omath_given: begin
992 set_math_char(((cur_chr div @"10000) * @"100)+(cur_chr mod @"100));
993 end;
994 mmode+delim_num: begin
995 if cur_chr=0 then scan_twenty_seven_bit_int
996 else scan_fifty_one_bit_int;
997 set_math_char(cur_val); {character code of left delimiter}
998 @z
999 %-----------------------------------------------
1000 @x
1001 procedure set_math_char(@!c:integer);
1002 var p:pointer; {the new noad}
1003 begin if c>=@'100000 then
1004 @<Treat |cur_chr|...@>
1005 else begin p:=new_noad; math_type(nucleus(p)):=math_char;
1006 character(nucleus(p)):=qi(c mod 256);
1007 fam(nucleus(p)):=(c div 256) mod 16;
1008 if c>=var_code then
1009 begin if fam_in_range then fam(nucleus(p)):=cur_fam;
1010 type(p):=ord_noad;
1011 end
1012 else type(p):=ord_noad+(c div @'10000);
1013 link(tail):=p; tail:=p;
1014 if font_dir[fam_fnt(fam(nucleus(p))+cur_size)]<>dir_default then begin
1015 @y
1016 procedure set_math_char(@!c:integer);
1017 var p:pointer; {the new noad}
1018 begin if c>=@"80000 then
1019 @<Treat |cur_chr|...@>
1020 else begin p:=new_noad; math_type(nucleus(p)):=math_char;
1021 character(nucleus(p)):=qi(c mod 256);
1022 fam(nucleus(p)):=(c div 256) mod 256;
1023 if c>=var_code then
1024 begin if fam_in_range then fam(nucleus(p)):=cur_fam;
1025 type(p):=ord_noad;
1026 end
1027 else type(p):=ord_noad+(c div @"10000);
1028 link(tail):=p; tail:=p;
1029 if font_dir[fam_fnt(fam(nucleus(p))+cur_size)]<>dir_default then begin
1030 @z
1031 %-----------------------------------------------
1032 @x
1033 @<Declare act...@>=
1034 procedure scan_delimiter(@!p:pointer;@!r:boolean);
1035 begin if r then scan_twenty_seven_bit_int
1036 else begin @<Get the next non-blank non-relax...@>;
1037 case cur_cmd of
1038 letter,other_char: cur_val:=del_code(cur_chr);
1039 delim_num: scan_twenty_seven_bit_int;
1040 othercases cur_val:=-1
1041 endcases;
1042 end;
1043 if cur_val<0 then @<Report that an invalid delimiter code is being changed
1044 to null; set~|cur_val:=0|@>;
1045 small_fam(p):=(cur_val div @'4000000) mod 16;
1046 small_char(p):=qi((cur_val div @'10000) mod 256);
1047 large_fam(p):=(cur_val div 256) mod 16;
1048 large_char(p):=qi(cur_val mod 256);
1049 end;
1050 @y
1051 @<Declare act...@>=
1052 procedure scan_delimiter(@!p:pointer;@!r:boolean);
1053 begin if r=1 then scan_twenty_seven_bit_int
1054 else if r=2 then scan_fifty_one_bit_int
1055 else begin @<Get the next non-blank non-relax...@>;
1056 case cur_cmd of
1057 letter,other_char: begin
1058 cur_val:=del_code(cur_chr); cur_val1:=del_code1(cur_chr);
1059 end;
1060 delim_num: if cur_chr=0 then scan_twenty_seven_bit_int
1061 else scan_fifty_one_bit_int;
1062 othercases begin cur_val:=-1; cur_val1:=-1; end;
1063 endcases;
1064 end;
1065 if cur_val<0 then begin @<Report that an invalid delimiter code is being changed
1066 to null; set~|cur_val:=0|@>;
1067 cur_val1:=0;
1068 end;
1069 small_fam(p):=(cur_val div @"100) mod @"100;
1070 small_char(p):=qi(cur_val mod @"100);
1071 large_fam(p):=(cur_val1 div @"100) mod @"100;
1072 large_char(p):=qi(cur_val1 mod @"100);
1073 end;
1074 @z
1075 %-----------------------------------------------
1076 @x
1077 scan_delimiter(left_delimiter(tail),true);
1078 @y
1079 scan_delimiter(left_delimiter(tail),cur_chr+1);
1080 @z
1081 %-----------------------------------------------
1082 @x
1083 scan_fifteen_bit_int;
1084 character(accent_chr(tail)):=qi(cur_val mod 256);
1085 if (cur_val>=var_code)and fam_in_range then fam(accent_chr(tail)):=cur_fam
1086 else fam(accent_chr(tail)):=(cur_val div 256) mod 16;
1087 @y
1088 if cur_chr=0 then scan_fifteen_bit_int
1089 else scan_big_fifteen_bit_int;
1090 character(accent_chr(tail)):=qi(cur_val mod 256);
1091 if (cur_val>=var_code)and fam_in_range then fam(accent_chr(tail)):=cur_fam
1092 else fam(accent_chr(tail)):=(cur_val div 256) mod 256;
1093 @z
1094 %-----------------------------------------------
1095 @x
1096 begin if (e<>0)and((w-total_shrink[normal]+q<=z)or@|
1097 (total_shrink[fil]<>0)or(total_shrink[fill]<>0)or
1098 (total_shrink[filll]<>0)) then
1099 @y
1100 begin if (e<>0)and((w-total_shrink[normal]+q<=z)or@|
1101 (total_shrink[sfi]<>0)or(total_shrink[fil]<>0)or
1102 (total_shrink[fill]<>0)or(total_shrink[filll]<>0)) then
1103 @z
1104 %-----------------------------------------------
1105 @x
1106 @d word_define(#)==if global then geq_word_define(#)@+else eq_word_define(#)
1107 @y
1108 @d word_define(#)==if global then geq_word_define(#)@+else eq_word_define(#)
1109 @d del_word_define(#)==if global
1110 then del_geq_word_define(#)@+else del_eq_word_define(#)
1111 @z
1112 %-----------------------------------------------
1113 @x
1114 @d count_def_code=2 {|shorthand_def| for \.{\\countdef}}
1115 @d dimen_def_code=3 {|shorthand_def| for \.{\\dimendef}}
1116 @d skip_def_code=4 {|shorthand_def| for \.{\\skipdef}}
1117 @d mu_skip_def_code=5 {|shorthand_def| for \.{\\muskipdef}}
1118 @d toks_def_code=6 {|shorthand_def| for \.{\\toksdef}}
1119 @d char_sub_def_code=7 {|shorthand_def| for \.{\\charsubdef}}
1120 @y
1121 @d omath_char_def_code=2 {|shorthand_def| for \.{\\omathchardef}}
1122 @d count_def_code=3 {|shorthand_def| for \.{\\countdef}}
1123 @d dimen_def_code=4 {|shorthand_def| for \.{\\dimendef}}
1124 @d skip_def_code=5 {|shorthand_def| for \.{\\skipdef}}
1125 @d mu_skip_def_code=6 {|shorthand_def| for \.{\\muskipdef}}
1126 @d toks_def_code=7 {|shorthand_def| for \.{\\toksdef}}
1127 @d char_sub_def_code=8 {|shorthand_def| for \.{\\charsubdef}}
1128 @z
1129 %-----------------------------------------------
1130 @x
1131 primitive("mathchardef",shorthand_def,math_char_def_code);@/
1132 @!@:math_char_def_}{\.{\\mathchardef} primitive@>
1133 @y
1134 primitive("mathchardef",shorthand_def,math_char_def_code);@/
1135 @!@:math_char_def_}{\.{\\mathchardef} primitive@>
1136 primitive("omathchardef",shorthand_def,omath_char_def_code);@/
1137 @!@:math_char_def_}{\.{\\omathchardef} primitive@>
1138 @z
1139 %-----------------------------------------------
1140 @x
1141 math_char_def_code: print_esc("mathchardef");
1142 @y
1143 math_char_def_code: print_esc("mathchardef");
1144 omath_char_def_code: print_esc("omathchardef");
1145 @z
1146 %-----------------------------------------------
1147 @x
1148 math_given: begin print_esc("mathchar"); print_hex(chr_code);
1149 end;
1150 @y
1151 math_given: begin print_esc("mathchar"); print_hex(chr_code);
1152 end;
1153 omath_given: begin print_esc("omathchar"); print_hex(chr_code);
1154 end;
1155 @z
1156 %-----------------------------------------------
1157 @x
1158 math_char_def_code: begin scan_fifteen_bit_int; define(p,math_given,cur_val);
1159 @y
1160 math_char_def_code: begin scan_real_fifteen_bit_int;
1161 define(p,math_given,cur_val);
1162 end;
1163 omath_char_def_code: begin scan_omega_fifteen_bit_int;
1164 define(p,omath_given,cur_val);
1165 @z
1166 %-----------------------------------------------
1167 @x
1168 primitive("mathcode",def_code,math_code_base);
1169 @!@:math_code_}{\.{\\mathcode} primitive@>
1170 @y
1171 primitive("mathcode",def_code,math_code_base);
1172 @!@:math_code_}{\.{\\mathcode} primitive@>
1173 primitive("omathcode",def_code,math_code_base+128);
1174 @!@:math_code_}{\.{\\omathcode} primitive@>
1175 @z
1176 %-----------------------------------------------
1177 @x
1178 primitive("delcode",def_code,del_code_base);
1179 @!@:del_code_}{\.{\\delcode} primitive@>
1180 @y
1181 primitive("delcode",def_code,del_code_base);
1182 @!@:del_code_}{\.{\\delcode} primitive@>
1183 primitive("odelcode",def_code,del_code_base+128);
1184 @!@:del_code_}{\.{\\odelcode} primitive@>
1185 @z
1186 %-----------------------------------------------
1187 @x
1188 else if chr_code=lc_code_base then print_esc("lccode")
1189 else if chr_code=uc_code_base then print_esc("uccode")
1190 else if chr_code=sf_code_base then print_esc("sfcode")
1191 else print_esc("delcode");
1192 @y
1193 else if chr_code=math_code_base+128 then print_esc("omathcode")
1194 else if chr_code=lc_code_base then print_esc("lccode")
1195 else if chr_code=uc_code_base then print_esc("uccode")
1196 else if chr_code=sf_code_base then print_esc("sfcode")
1197 else if chr_code=del_code_base then print_esc("delcode")
1198 else print_esc("odelcode");
1199 @z
1200 %-----------------------------------------------
1201 @x
1202 @<Assignments@>=
1203 def_code: begin
1204 @<Let |m| be the minimal legal code value, based on |cur_chr|@>;
1205 @<Let |n| be the largest legal code value, based on |cur_chr|@>;
1206 p:=cur_chr;
1207 if p=kcat_code_base then
1208 begin scan_char_num; p:=p+kcatcodekey(cur_val);
1209 if cur_val>=max_latin_val then m:=not_cjk; end
1210 else if p<math_code_base then
1211 begin scan_latin_num; p:=p+cur_val; end
1212 else begin scan_ascii_num; p:=p+cur_val; end;
1213 scan_optional_equals; scan_int;
1214 if ((cur_val<m)and(p<del_code_base))or(cur_val>n) then
1215 begin print_err("Invalid code ("); print_int(cur_val);
1216 @.Invalid code@>
1217 if p<del_code_base then
1218 begin print("), should be in the range "); print_int(m); print("..");
1219 end
1220 else print("), should be at most ");
1221 print_int(n);
1222 if m=0 then
1223 begin help1("I'm going to use 0 instead of that illegal code value.");@/
1224 error; cur_val:=0;
1225 end
1226 else
1227 begin help1("I'm going to use 16 instead of that illegal code value.");@/
1228 error; cur_val:=16;
1229 end;
1230 end;
1231 if p<math_code_base then define(p,data,cur_val)
1232 else if p<del_code_base then define(p,data,hi(cur_val))
1233 else word_define(p,cur_val);
1234 end;
1235 @y
1236 @<Assignments@>=
1237 def_code: begin
1238 if cur_chr=(del_code_base+128) then begin
1239 p:=cur_chr-128; scan_ascii_num; p:=p+cur_val; scan_optional_equals;
1240 scan_int; cur_val1:=cur_val; scan_int; {backwards}
1241 if (cur_val1>@"FFFFFF) or (cur_val>@"FFFFFF) then
1242 begin print_err("Invalid code ("); print_int(cur_val1); print(" ");
1243 print_int(cur_val);
1244 print("), should be at most ""FFFFFF ""FFFFFF");
1245 help1("I'm going to use 0 instead of that illegal code value.");@/
1246 error; cur_val1:=0; cur_val:=0;
1247 end;
1248 cur_val1:=(cur_val1 div @"10000)*@"100+(cur_val1 mod @"100);
1249 cur_val:=(cur_val div @"10000)*@"100+(cur_val mod @"100);
1250 del_word_define(p,cur_val1,cur_val);
1251 end
1252 else begin
1253 @<Let |m| be the minimal legal code value, based on |cur_chr|@>;
1254 @<Let |n| be the largest legal code value, based on |cur_chr|@>;
1255 p:=cur_chr; cur_val1:=p;
1256 if p=kcat_code_base then begin scan_char_num; p:=p+kcatcodekey(cur_val);
1257 if cur_val>=max_latin_val then m:=not_cjk; end
1258 else if p<math_code_base then begin scan_latin_num; p:=p+cur_val; end
1259 else begin scan_ascii_num; p:=p+cur_val; end;
1260 scan_optional_equals; scan_int;
1261 if ((cur_val<m)and(p<del_code_base))or(cur_val>n) then
1262 begin print_err("Invalid code ("); print_int(cur_val);
1263 @.Invalid code@>
1264 if p<del_code_base then
1265 begin print("), should be in the range "); print_int(m); print("..");
1266 end
1267 else print("), should be at most ");
1268 print_int(n);
1269 if m=0 then
1270 begin help1("I'm going to use 0 instead of that illegal code value.");@/
1271 error; cur_val:=0;
1272 end
1273 else
1274 begin help1("I'm going to use 16 instead of that illegal code value.");@/
1275 error; cur_val:=16;
1276 end;
1277 end;
1278 if p<math_code_base then define(p,data,cur_val)
1279 else if cur_val1=math_code_base then begin
1280 if cur_val=@"8000 then cur_val:=@"80000
1281 else cur_val:=((cur_val div @"1000)*@"10000)+(cur_val mod @"1000);
1282 define(p,data,hi(cur_val));
1283 end
1284 else if cur_val1=math_code_base+128 then begin
1285 cur_val:=((cur_val div @"10000) * @"100) + (cur_val mod @"100);
1286 define(p-128,data,hi(cur_val));
1287 end
1288 else if cur_val1=del_code_base then begin
1289 if cur_val>=0 then begin
1290 cur_val1:=cur_val div @"1000;
1291 cur_val1:=(cur_val1 div @"1000)*@"10000 + cur_val1 mod @"1000;
1292 cur_val:=cur_val mod @"1000;
1293 del_word_define(p,cur_val1,cur_val); end
1294 else
1295 del_word_define(p, -1, cur_val);
1296 end
1297 else define(p,data,cur_val);
1298 end;
1299 end;
1300 @z
1301 %-----------------------------------------------
1302 @x
1303 else if cur_chr=kcat_code_base then n:=max_char_code
1304 else if cur_chr<math_code_base then n:=max_latin_val
1305 else if cur_chr=math_code_base then n:=@'100000
1306 @y
1307 else if cur_chr=kcat_code_base then n:=max_char_code
1308 else if cur_chr<math_code_base then n:=max_latin_val
1309 else if cur_chr=math_code_base then n:=@"8000
1310 else if cur_chr=(math_code_base+128) then n:=@"8000000
1311 @z
1312 %-----------------------------------------------
1313 @x
1314 def_family: begin p:=cur_chr; scan_four_bit_int; p:=p+cur_val;
1315 @y
1316 def_family: begin p:=cur_chr; scan_big_four_bit_int; p:=p+cur_val;
1317 @z
1318 %-----------------------------------------------
1319 @x
1320 @ @<Dump regions 5 and 6 of |eqtb|@>=
1321 repeat j:=k;
1322 while j<eqtb_size do
1323 begin if eqtb[j].int=eqtb[j+1].int then goto found2;
1324 incr(j);
1325 end;
1326 l:=eqtb_size+1; goto done2; {|j=eqtb_size|}
1327 found2: incr(j); l:=j;
1328 while j<eqtb_size do
1329 begin if eqtb[j].int<>eqtb[j+1].int then goto done2;
1330 @y
1331 @ @<Dump regions 5 and 6 of |eqtb|@>=
1332 repeat j:=k;
1333 while j<eqtb_size do
1334 begin if (eqtb[j].int=eqtb[j+1].int) and@|
1335 (getintone(eqtb[j])=getintone(eqtb[j+1])) then goto found2;
1336 incr(j);
1337 end;
1338 l:=eqtb_size+1; goto done2; {|j=eqtb_size|}
1339 found2: incr(j); l:=j;
1340 while j<eqtb_size do
1341 begin if (eqtb[j].int<>eqtb[j+1].int)or@|
1342 (getintone(eqtb[j])<>getintone(eqtb[j+1])) then goto done2;
1343 @z
1344 %-----------------------------------------------
1345 @x
1346 else cur_val:=shrink_order(q);
1347 @y
1348 else cur_val:=shrink_order(q);
1349 if cur_val>normal then cur_val:=cur_val-1; {compatible to \eTeX}
1350 @z
1351 %-----------------------------------------------
1352 @x FAM256 65536 Registers
1353 @ \eTeX\ (in extended mode) supports 32768 (i.e., $2^{15}$) count,
1354 @y
1355 @ \epTeX\ (in extended mode) supports 65536 (i.e., $2^{16}$) count,
1356 @z
1357 %-----------------------------------------------
1358 @x
1359 Similarly there are 32768 mark classes; the command \.{\\marks}|n|
1360 creates a mark node for a given mark class |0<=n<=32767| (where
1361 @y
1362 Similarly there are 65536 mark classes; the command \.{\\marks}|n|
1363 creates a mark node for a given mark class |0<=n<=65535| (where
1364 @z
1365 %-----------------------------------------------
1366 @x
1367 not exceed 255 in compatibility mode resp.\ 32767 in extended mode.
1368 @y
1369 not exceed 255 in compatibility mode resp.\ 65535 in extended mode.
1370 @z
1371 %-----------------------------------------------
1372 @x
1373 max_reg_num:=32767;
1374 max_reg_help_line:="A register number must be between 0 and 32767.";
1375 @y
1376 max_reg_num:=65535;
1377 max_reg_help_line:="A register number must be between 0 and 65535.";
1378 @z
1379 %-----------------------------------------------
1380 @x
1381 sparse array of the up to 32512 additional registers of each kind and
1382 one for the sparse array of the up to 32767 additional mark classes.
1383 The root of each such tree, if it exists, is an index node containing 16
1384 pointers to subtrees for 4096 consecutive array elements. Similar index
1385 nodes are the starting points for all nonempty subtrees for 4096, 256,
1386 and 16 consecutive array elements. These four levels of index nodes are
1387 followed by a fifth level with nodes for the individual array elements.
1388 @y
1389 sparse array of the up to 65280 additional registers of each kind and
1390 one for the sparse array of the up to 65535 additional mark classes.
1391 The root of each such tree, if it exists, is an index node containing 16
1392 pointers to subtrees for 65536 consecutive array elements. Similar index
1393 nodes are the starting points for all nonempty subtrees for 65536, 4096,
1394 256, and 16 consecutive array elements. These five levels of index nodes
1395 are followed by a sixth level with nodes for the individual array elements.
1396 @z
1397 %-----------------------------------------------
1398 @x
1399 @d hex_dig1(#)==# div 4096 {the fourth lowest hexadecimal digit}
1400 @d hex_dig2(#)==(# div 256) mod 16 {the third lowest hexadecimal digit}
1401 @d hex_dig3(#)==(# div 16) mod 16 {the second lowest hexadecimal digit}
1402 @d hex_dig4(#)==# mod 16 {the lowest hexadecimal digit}
1403 @y
1404 @d hex_dig1(#)==# div 65536 {the fifth lowest hexadecimal digit}
1405 @d hex_dig2(#)==(# div 4096) mod 16 {the fourth lowest hexadecimal digit}
1406 @d hex_dig3(#)==(# div 256) mod 16 {the third lowest hexadecimal digit}
1407 @d hex_dig4(#)==(# div 16) mod 16 {the second lowest hexadecimal digit}
1408 @d hex_dig5(#)==# mod 16 {the lowest hexadecimal digit}
1409 @z
1410 %-----------------------------------------------
1411 @x
1412 procedure find_sa_element(@!t:small_number;@!n:halfword;@!w:boolean);
1413 {sets |cur_val| to sparse array element location or |null|}
1414 label not_found,not_found1,not_found2,not_found3,not_found4,exit;
1415 var q:pointer; {for list manipulations}
1416 @!i:small_number; {a four bit index}
1417 begin cur_ptr:=sa_root[t];
1418 if_cur_ptr_is_null_then_return_or_goto(not_found);@/
1419 q:=cur_ptr; i:=hex_dig1(n); get_sa_ptr;
1420 if_cur_ptr_is_null_then_return_or_goto(not_found1);@/
1421 q:=cur_ptr; i:=hex_dig2(n); get_sa_ptr;
1422 if_cur_ptr_is_null_then_return_or_goto(not_found2);@/
1423 q:=cur_ptr; i:=hex_dig3(n); get_sa_ptr;
1424 if_cur_ptr_is_null_then_return_or_goto(not_found3);@/
1425 q:=cur_ptr; i:=hex_dig4(n); get_sa_ptr;
1426 if (cur_ptr=null)and w then goto not_found4;
1427 return;
1428 not_found: new_index(t,null); {create first level index node}
1429 sa_root[t]:=cur_ptr; q:=cur_ptr; i:=hex_dig1(n);
1430 not_found1: new_index(i,q); {create second level index node}
1431 add_sa_ptr; q:=cur_ptr; i:=hex_dig2(n);
1432 not_found2: new_index(i,q); {create third level index node}
1433 add_sa_ptr; q:=cur_ptr; i:=hex_dig3(n);
1434 not_found3: new_index(i,q); {create fourth level index node}
1435 add_sa_ptr; q:=cur_ptr; i:=hex_dig4(n);
1436 not_found4: @<Create a new array element of type |t| with index |i|@>;
1437 link(cur_ptr):=q; add_sa_ptr;
1438 exit:end;
1439 @y
1440 procedure find_sa_element(@!t:small_number;@!n:halfword;@!w:boolean);
1441 {sets |cur_val| to sparse array element location or |null|}
1442 label not_found,not_found1,not_found2,not_found3,not_found4,not_found5,exit;
1443 var q:pointer; {for list manipulations}
1444 @!i:small_number; {a four bit index}
1445 begin cur_ptr:=sa_root[t];
1446 if_cur_ptr_is_null_then_return_or_goto(not_found);@/
1447 q:=cur_ptr; i:=hex_dig1(n); get_sa_ptr;
1448 if_cur_ptr_is_null_then_return_or_goto(not_found1);@/
1449 q:=cur_ptr; i:=hex_dig2(n); get_sa_ptr;
1450 if_cur_ptr_is_null_then_return_or_goto(not_found2);@/
1451 q:=cur_ptr; i:=hex_dig3(n); get_sa_ptr;
1452 if_cur_ptr_is_null_then_return_or_goto(not_found3);@/
1453 q:=cur_ptr; i:=hex_dig4(n); get_sa_ptr;
1454 if_cur_ptr_is_null_then_return_or_goto(not_found4);@/
1455 q:=cur_ptr; i:=hex_dig5(n); get_sa_ptr;
1456 if (cur_ptr=null)and w then goto not_found5;
1457 return;
1458 not_found: new_index(t,null); {create first level index node}
1459 sa_root[t]:=cur_ptr; q:=cur_ptr; i:=hex_dig1(n);
1460 not_found1: new_index(i,q); {create second level index node}
1461 add_sa_ptr; q:=cur_ptr; i:=hex_dig2(n);
1462 not_found2: new_index(i,q); {create third level index node}
1463 add_sa_ptr; q:=cur_ptr; i:=hex_dig3(n);
1464 not_found3: new_index(i,q); {create fourth level index node}
1465 add_sa_ptr; q:=cur_ptr; i:=hex_dig4(n);
1466 not_found4: new_index(i,q); {create fifth level index node}
1467 add_sa_ptr; q:=cur_ptr; i:=hex_dig5(n);
1468 not_found5: @<Create a new array element of type |t| with index |i|@>;
1469 link(cur_ptr):=q; add_sa_ptr;
1470 exit:end;
1471 @z
1472 %-----------------------------------------------
1473 @x
1474 repeat i:=hex_dig4(sa_index(q)); p:=q; q:=link(p); free_node(p,s);
1475 @y
1476 repeat i:=hex_dig5(sa_index(q)); p:=q; q:=link(p); free_node(p,s);
1477 @z
1478 %-----------------------------------------------
1479 @x
1480 else begin n:=hex_dig4(sa_index(q)); q:=link(q); n:=n+16*sa_index(q);
1481 q:=link(q); n:=n+256*(sa_index(q)+16*sa_index(link(q)));
1482 @y
1483 else begin n:=hex_dig5(sa_index(q)); q:=link(q); n:=n+16*sa_index(q);
1484 q:=link(q); n:=n+256*(sa_index(q)+16*sa_index(link(q)));
1485 q:=link(link(q)); n:=n+65536*sa_index(q);
1486 @z
1487 %-----------------------------------------------
1488 @x
1489 begin if l<4 then {|q| is an index node}
1490 @y
1491 begin if l<5 then {|q| is an index node}
1492 @z
1493 %-----------------------------------------------
1494 @x
1495 @!fill_width:array[0..2] of scaled; {infinite stretch components of
1496 @y
1497 @!fill_width:array[0..3] of scaled; {infinite stretch components of
1498 @z
1499 %-----------------------------------------------
1500 @x
1501 if (background[3]=0)and(background[4]=0)and(background[5]=0) then
1502 begin do_last_line_fit:=true;
1503 active_node_size:=active_node_size_extended;
1504 fill_width[0]:=0; fill_width[1]:=0; fill_width[2]:=0;
1505 @y
1506 if (background[3]=0)and(background[4]=0)and@|
1507 (background[5]=0)and(background[6]=0) then
1508 begin do_last_line_fit:=true;
1509 active_node_size:=active_node_size_extended;
1510 fill_width[0]:=0; fill_width[1]:=0; fill_width[2]:=0; fill_width[3]:=0;
1511 @z
1512 %-----------------------------------------------
1513 @x
1514 if (cur_active_width[3]<>fill_width[0])or@|
1515 (cur_active_width[4]<>fill_width[1])or@|
1516 (cur_active_width[5]<>fill_width[2]) then goto not_found;
1517 {infinite stretch of this line not entirely due to |par_fill_skip|}
1518 if active_short(r)>0 then g:=cur_active_width[2]
1519 else g:=cur_active_width[6];
1520 @y
1521 if (cur_active_width[3]<>fill_width[0])or@|
1522 (cur_active_width[4]<>fill_width[1])or@|
1523 (cur_active_width[5]<>fill_width[2])or@|
1524 (cur_active_width[6]<>fill_width[3]) then goto not_found;
1525 {infinite stretch of this line not entirely due to |par_fill_skip|}
1526 if active_short(r)>0 then g:=cur_active_width[2]
1527 else g:=cur_active_width[7];
1528 @z
1529 %---------------------------------------
1530 @x
1531 begin if -g>cur_active_width[6] then g:=-cur_active_width[6];
1532 b:=badness(-g,cur_active_width[6]);
1533 @y
1534 begin if -g>cur_active_width[7] then g:=-cur_active_width[7];
1535 b:=badness(-g,cur_active_width[7]);
1536 @z
1537 %-----------------------------------------------
1538 @x
1539 if shortfall>0 then g:=cur_active_width[2]
1540 else if shortfall<0 then g:=cur_active_width[6]
1541 @y
1542 if shortfall>0 then g:=cur_active_width[2]
1543 else if shortfall<0 then g:=cur_active_width[7]
1544 @z