OSDN Git Service

code clean. Codes of DVI production are removed (a bug).
[putex/putex.git] / src / texsourc / tex8.c
1 #ifdef _WINDOWS
2   #define NOCOMM
3   #define NOSOUND
4   #define NODRIVERS
5   #define STRICT
6   #pragma warning(disable:4115) // kill rpcasync.h complaint
7   #include <windows.h>
8   #define MYLIBAPI __declspec(dllexport)
9 #endif
10
11 #include "texwin.h"
12
13 #pragma warning(disable:4996)
14 #pragma warning(disable:4131) // old style declarator
15 #pragma warning(disable:4135) // conversion between different integral types 
16 #pragma warning(disable:4127) // conditional expression is constant
17
18 #include <setjmp.h>
19
20 #define EXTERN extern
21
22 #include "texd.h"
23
24 #pragma warning(disable:4244)       /* 96/Jan/10 */
25
26 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
27
28 /* math_fraction etc used to be in tex7.c */
29 /* sec 1181 */
30 void math_fraction (void) 
31 {
32   small_number c; 
33   c = cur_chr; 
34   if (cur_list.aux_field.cint != 0)
35   {
36     if (c >= 3)
37     {
38       scan_delimiter(lig_trick, false); 
39       scan_delimiter(lig_trick, false); 
40     } 
41     if (c % 3 == 0)
42     scan_dimen(false, false, false);
43         print_err("Ambiguous; you need another { and }");
44         help3("I'm ignoring this fraction specification, since I don't",
45                 "know whether a construction like `x \\over y \\over z'",
46                 "means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");
47     error(); 
48   } 
49   else {
50       
51     cur_list.aux_field.cint = get_node(6); 
52     mem[cur_list.aux_field.cint].hh.b0 = 25; 
53     mem[cur_list.aux_field.cint].hh.b1 = 0; 
54     mem[cur_list.aux_field.cint + 2].hh.v.RH = 3; 
55     mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[head]
56    .hh.v.RH; 
57     mem[cur_list.aux_field.cint + 3].hh = empty_field; 
58     mem[cur_list.aux_field.cint + 4].qqqq = null_delimiter; 
59     mem[cur_list.aux_field.cint + 5].qqqq = null_delimiter; 
60     mem[head].hh.v.RH = 0; 
61     tail = head; 
62     if (c >= 3)
63     {
64       scan_delimiter(cur_list.aux_field.cint + 4, false); 
65       scan_delimiter(cur_list.aux_field.cint + 5, false); 
66     } 
67     switch(c % 3)
68     {case 0 : 
69       {
70   scan_dimen(false, false, false); 
71   mem[cur_list.aux_field.cint + 1].cint = cur_val; 
72       } 
73       break; 
74     case 1 : 
75       mem[cur_list.aux_field.cint + 1].cint = 1073741824L;  /* 2^30 */
76       break; 
77     case 2 : 
78       mem[cur_list.aux_field.cint + 1].cint = 0; 
79       break; 
80     } 
81   } 
82 }
83 /* sec 1191 */
84 void math_left_right (void) 
85
86   small_number t; 
87   halfword p; 
88   t = cur_chr; 
89   if ((t == 31)&&(cur_group != 16)) 
90   {
91     if (cur_group == 15)
92     {
93       scan_delimiter(lig_trick, false);
94           print_err("Extra "); 
95       print_esc("right");
96           help1("I'm ignoring a \\right that had no matching \\left."); 
97       error(); 
98     } 
99     else {
100     off_save();
101   }
102   } 
103   else {
104       
105     p = new_noad(); 
106     mem[p].hh.b0 = t; 
107     scan_delimiter(p + 1, false); 
108     if (t == 30)
109     {
110       push_math(16); 
111       mem[head].hh.v.RH = p; 
112       tail = p; 
113     } 
114     else {
115   
116       p = fin_mlist(p); 
117       unsave(); 
118       {
119   mem[tail].hh.v.RH = new_noad(); 
120   tail = mem[tail].hh.v.RH; 
121       } 
122       mem[tail].hh.b0 = 23; 
123       mem[tail + 1].hh.v.RH = 3; 
124       mem[tail + 1].hh.v.LH = p; 
125     } 
126   } 
127 }
128 /* sec 1194 */
129 void after_math (void) 
130
131   bool l; 
132   bool danger; 
133   integer m; 
134   halfword p; 
135   halfword a; 
136   halfword b; 
137   scaled w; 
138   scaled z; 
139   scaled e; 
140   scaled q; 
141   scaled d; 
142   scaled s; 
143   small_number g1, g2; 
144   halfword r; 
145   halfword t; 
146   danger = false; 
147   if ((font_params[eqtb[(hash_size + 1837)].hh.v.RH]< 22)||
148     (font_params[eqtb[(hash_size + 1853)].hh.v.RH]< 22)||
149     (font_params[eqtb[(hash_size + 1869)].hh.v.RH]< 22)) 
150   {
151           print_err("Math formula deleted: Insufficient symbol fonts");
152           help3("Sorry, but I can't typeset math unless \\textfont Sorry, but I can't typeset math unless \\textfont 2",
153                   "and \\scriptfont 2 and \\scriptscriptfont 2 have and \\scriptfont 2 and \\scriptscriptfont 2 have all",
154                   "the \\fontdimen values needed in math symbol the \\fontdimen values needed in math symbol fonts.."); 
155     error(); 
156     flush_math(); 
157     danger = true; 
158   } 
159   else if ((font_params[eqtb[(hash_size + 1838)].hh.v.RH]< 13)||
160       (font_params[eqtb[(hash_size + 1854)].hh.v.RH]< 13)||
161       (font_params[eqtb[(hash_size + 1870)].hh.v.RH]< 13)) 
162   {
163           print_err("Math formula deleted: Insufficient extension fonts");
164           help3("Sorry, but I can't typeset math unless \\textfont 3",
165                   "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
166                   "the \\fontdimen values needed in math extension fonts.");
167     error(); 
168     flush_math(); 
169     danger = true; 
170   } 
171   m = mode; 
172   l = false; 
173   p = fin_mlist(0); 
174   if (mode == - (integer) m)
175   {
176     {
177       get_x_token(); 
178       if (cur_cmd != 3)
179       {
180                   print_err("Display math should end with $$");
181                   help2("The `$' that I just saw supposedly matches a previous `$$'.",
182                           "So I shall assume that you typed `$$' both times.");
183   back_error(); 
184       } 
185     } 
186     cur_mlist = p; 
187     cur_style = 2; 
188     mlist_penalties = false; 
189     mlist_to_hlist(); 
190     a = hpack(mem[temp_head].hh.v.RH, 0, 1); 
191     unsave(); 
192     decr(save_ptr); 
193     if (save_stack[save_ptr + 0].cint == 1)
194     l = true; 
195     danger = false; 
196     if ((font_params[eqtb[(hash_size + 1837)].hh.v.RH]< 22)||
197     (font_params[eqtb[(hash_size + 1853)].hh.v.RH]< 22)||
198     (font_params[eqtb[(hash_size + 1869)].hh.v.RH]< 22)) 
199     {
200                 print_err("Math formula deleted: Insufficient symbol fonts");
201                 help3("Sorry, but I can't typeset math unless \\textfont 2",
202                         "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
203                         "the \\fontdimen values needed in math symbol fonts.");
204       error(); 
205       flush_math(); 
206       danger = true; 
207     } 
208     else if ((font_params[eqtb[(hash_size + 1838)].hh.v.RH]< 13)||
209        (font_params[eqtb[(hash_size + 1854)].hh.v.RH]< 13)|| 
210        (font_params[eqtb[(hash_size + 1870)].hh.v.RH]< 13)) 
211     {
212                 print_err("Math formula deleted: Insufficient extension fonts");
213                 help3("Sorry, but I can't typeset math unless \\textfont 3",
214                         "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
215                         "the \\fontdimen values needed in math extension fonts.");
216       error(); 
217       flush_math(); 
218       danger = true; 
219     } 
220     m = mode; 
221     p = fin_mlist(0); 
222   } 
223   else a = 0; 
224   if (m < 0)
225   {
226     {
227       mem[tail].hh.v.RH = new_math(math_surround, 0); 
228       tail = mem[tail].hh.v.RH; 
229     } 
230     cur_mlist = p; 
231     cur_style = 2; 
232     mlist_penalties =(mode > 0); 
233     mlist_to_hlist(); 
234     mem[tail].hh.v.RH = mem[temp_head].hh.v.RH; 
235     while(mem[tail].hh.v.RH != 0)tail = 
236     mem[tail].hh.v.RH; 
237     {
238       mem[tail].hh.v.RH = new_math(math_surround, 1); 
239       tail = mem[tail].hh.v.RH; 
240     } 
241     space_factor = 1000; 
242     unsave(); 
243   } 
244   else {
245       
246     if (a == 0)
247     {
248       get_x_token(); 
249       if (cur_cmd != 3) {
250                   print_err("Display math should end with $$");
251                   help2("The `$' that I just saw supposedly matches a previous `$$'.",
252                           "So I shall assume that you typed `$$' both times.");
253   back_error(); 
254       } 
255     } 
256     cur_mlist = p; 
257     cur_style = 0; 
258     mlist_penalties = false; 
259     mlist_to_hlist(); 
260     p = mem[temp_head].hh.v.RH; 
261     adjust_tail = adjust_head; 
262     b = hpack(p, 0, 1); 
263     p = mem[b + 5].hh.v.RH; 
264     t = adjust_tail; 
265     adjust_tail = 0; 
266     w = mem[b + 1].cint; 
267     z = display_width; 
268     s = display_indent; 
269     if ((a == 0)|| danger)
270     {
271       e = 0; 
272       q = 0; 
273     } 
274     else {
275   
276       e = mem[a + 1].cint; 
277       q = e + font_info[6 + param_base[eqtb[(hash_size + 1837)].hh.v.RH]].cint; 
278     } 
279     if (w + q > z)
280     {
281       if ((e != 0)&&((w - totalshrink[0]+ q <= z)||(totalshrink 
282      [1]!= 0)||(totalshrink[2]!= 0)||(totalshrink[3]!= 0)
283     )) 
284       {
285   free_node(b, 7); 
286   b = hpack(p, z - q, 0); 
287       } 
288       else {
289     
290   e = 0; 
291   if (w > z)
292   {
293     free_node(b, 7); 
294     b = hpack(p, z, 0); 
295   } 
296       } 
297       w = mem[b + 1].cint; 
298     } 
299     d = half(z - w); 
300     if ((e > 0)&&(d < 2 * e)) 
301     {
302       d = half(z - w - e); 
303       if (p != 0)
304       if (!(p >= hi_mem_min)) 
305       if (mem[p].hh.b0 == 10)
306       d = 0; 
307     } 
308     {
309       mem[tail].hh.v.RH = new_penalty(pre_display_penalty); 
310       tail = mem[tail].hh.v.RH; 
311     } 
312     if ((d + s <= pre_display_size)|| l)
313     {
314       g1 = 3; 
315       g2 = 4; 
316     } 
317     else {
318   
319       g1 = 5; 
320       g2 = 6; 
321     } 
322     if (l &&(e == 0)) 
323     {
324       mem[a + 4].cint = s; 
325       append_to_vlist(a); 
326       {
327   mem[tail].hh.v.RH = new_penalty(10000); 
328   tail = mem[tail].hh.v.RH; 
329       } 
330     } 
331     else {
332   
333       mem[tail].hh.v.RH = new_param_glue(g1); 
334       tail = mem[tail].hh.v.RH; 
335     } 
336     if (e != 0)
337     {
338       r = new_kern(z - w - e - d); 
339       if (l)
340       {
341   mem[a].hh.v.RH = r; 
342   mem[r].hh.v.RH = b; 
343   b = a; 
344   d = 0; 
345       } 
346       else {
347     
348   mem[b].hh.v.RH = r; 
349   mem[r].hh.v.RH = a; 
350       } 
351       b = hpack(b, 0, 1); 
352     } 
353     mem[b + 4].cint = s + d; 
354     append_to_vlist(b); 
355     if ((a != 0)&&(e == 0)&& ! l)
356     {
357       {
358   mem[tail].hh.v.RH = new_penalty(10000); 
359   tail = mem[tail].hh.v.RH; 
360       } 
361       mem[a + 4].cint = s + z - mem[a + 1].cint; 
362       append_to_vlist(a); 
363       g2 = 0; 
364     } 
365     if (t != adjust_head)
366     {
367       mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH; 
368       tail = t; 
369     } 
370     {
371       mem[tail].hh.v.RH = new_penalty(post_display_penalty); 
372       tail = mem[tail].hh.v.RH; 
373     } 
374     if (g2 > 0)
375     {
376       mem[tail].hh.v.RH = new_param_glue(g2); 
377       tail = mem[tail].hh.v.RH; 
378     } 
379     resume_after_display(); 
380   } 
381 }
382 /* sec 1200 */
383 void resume_after_display (void) 
384
385
386    if (cur_group != 15){
387     confusion("display");
388     return;       // abort_flag set
389   }
390   unsave(); 
391   prev_graf = prev_graf + 3; 
392   push_nest(); 
393   mode = 102; 
394   space_factor = 1000; 
395 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
396 /* was   clang = 0; etc in 3.141 new stuff follows */
397   if (language <= 0)
398   cur_lang = 0; 
399   else if (language > 255)
400   cur_lang = 0; 
401   else cur_lang = language; 
402   clang = cur_lang; 
403   prev_graf =(norm_min(left_hyphen_min) * 64 +
404      norm_min(right_hyphen_min)) * 65536L + cur_lang; 
405 /* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
406 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
407   {
408     get_x_token(); 
409     if (cur_cmd != 10) back_input(); 
410   } 
411   if (nest_ptr == 1){
412     build_page();
413   }
414 }
415 /* sec 1215 */
416 void get_r_token (void) 
417 {/* 20 */ 
418 lab20:
419   do {
420     get_token(); 
421   } while(!(cur_tok != 2592)); 
422 /*  if ((cur_cs == 0)||(cur_cs > (hash_size + 514))) */  /* 95/Jan/10 */
423   if ((cur_cs == 0)||(cur_cs > (hash_size + hash_extra + 514))) {
424           print_err("Missing control sequence inserted");
425           help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
426                   "I've inserted an inaccessible control sequence so that your",
427                   "definition will be completed without mixing me up too badly.",
428                   "You can recover graciously from this error, if you're",
429                   "careful; see exercise 27.2 in The TeXbook.");
430     if (cur_cs == 0)
431     back_input(); 
432 /*    cur_tok = (hash_size + 4609);  */
433 /*    cur_tok = (hash_size + 4095 + 514);  */
434     cur_tok = (hash_size + hash_extra + 4095 + 514); /* 96/Jan/10 */
435     ins_error(); 
436     goto lab20; 
437   } 
438 }
439 /* sec 1229 */
440 void trap_zero_glue (void) 
441 {
442   if ((mem[cur_val + 1].cint == 0)&&(mem[cur_val + 2].cint == 0)
443   &&(mem[cur_val + 3].cint == 0)) 
444   {
445     incr(mem[0].hh.v.RH); /* mem[mem_bot]? */ /* mem[null]? */
446     delete_glue_ref(cur_val); 
447     cur_val = 0; 
448   } 
449 }
450 /* sec 1236 */
451 void do_register_command_ (small_number a) 
452 {/* 40 10 */ 
453   halfword l, q, r, s; 
454   char p; 
455   q = cur_cmd; 
456   {
457     if (q != 89)
458     {
459       get_x_token(); 
460       if ((cur_cmd >= 73)&&(cur_cmd <= 76)) 
461       {
462   l = cur_chr; 
463   p = cur_cmd - 73; 
464   goto lab40; 
465       } 
466       if (cur_cmd != 89)
467       {
468                   print_err("You can't use `");
469   print_cmd_chr(cur_cmd, cur_chr); 
470   print_string("' after ");
471   print_cmd_chr(q, 0); 
472   help1("I'm forgetting what you said and not changing anything.");
473   error(); 
474   return; 
475       } 
476     } 
477     p = cur_chr; 
478     scan_eight_bit_int(); 
479     switch(p)
480     {case 0 : 
481       l = cur_val + (hash_size + 3218); 
482       break; 
483     case 1 : 
484       l = cur_val + (hash_size + 3751); 
485       break; 
486     case 2 : 
487       l = cur_val + (hash_size + 800); 
488       break; 
489     case 3 : 
490       l = cur_val + (hash_size + 1056); 
491       break; 
492     } 
493   } 
494   lab40:; 
495   if (q == 89)
496   scan_optional_equals(); 
497   else if (scan_keyword("by"))   /* by */
498
499   arith_error = false; 
500   if (q < 91)
501   if (p < 2)
502   {
503     if (p == 0){
504     scan_int();
505   }
506     else {
507     scan_dimen(false, false, false);
508   }
509     if (q == 90)
510     cur_val = cur_val + eqtb[l].cint; 
511   } 
512   else {
513       
514     scan_glue(p); 
515     if (q == 90){
516       q = new_spec(cur_val); 
517       r = eqtb[l].hh.v.RH; 
518       delete_glue_ref(cur_val); 
519       mem[q + 1].cint = mem[q + 1].cint + mem[r + 1].cint; 
520       if (mem[q + 2].cint == 0)
521       mem[q].hh.b0 = 0; 
522       if (mem[q].hh.b0 == mem[r].hh.b0)
523       mem[q + 2].cint = mem[q + 2].cint + mem[r + 2].cint; 
524       else if ((mem[q].hh.b0 < mem[r].hh.b0)&&(mem[r + 2]
525      .cint != 0)) 
526       {
527   mem[q + 2].cint = mem[r + 2].cint; 
528   mem[q].hh.b0 = mem[r].hh.b0; 
529       } 
530       if (mem[q + 3].cint == 0)
531       mem[q].hh.b1 = 0; 
532       if (mem[q].hh.b1 == mem[r].hh.b1)
533       mem[q + 3].cint = mem[q + 3].cint + mem[r + 3].cint; 
534       else if ((mem[q].hh.b1 < mem[r].hh.b1)&&(mem[r + 3]
535      .cint != 0)) 
536       {
537   mem[q + 3].cint = mem[r + 3].cint; 
538   mem[q].hh.b1 = mem[r].hh.b1; 
539       } 
540       cur_val = q; 
541     } 
542   } 
543   else {
544     scan_int(); 
545     if (p < 2)
546     if (q == 91)
547     if (p == 0)
548     cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); 
549 /*  2^31 - 1 */
550     else cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); 
551 /*  2^30 - 1 */
552     else cur_val = x_over_n(eqtb[l].cint, cur_val); 
553     else {
554       s = eqtb[l].hh.v.RH;  /* l may be used ... */
555       r = new_spec(s); 
556       if (q == 91)
557       {
558   mem[r + 1].cint = mult_and_add(mem[s + 1].cint, cur_val, 0, 
559   1073741823L);  /* 2^30 - 1 */
560   mem[r + 2].cint = mult_and_add(mem[s + 2].cint, cur_val, 0, 
561   1073741823L);  /* 2^30 - 1 */
562   mem[r + 3].cint = mult_and_add(mem[s + 3].cint, cur_val, 0, 
563   1073741823L);  /* 2^30 - 1 */
564       } 
565       else {
566   mem[r + 1].cint = x_over_n(mem[s + 1].cint, cur_val); 
567   mem[r + 2].cint = x_over_n(mem[s + 2].cint, cur_val); 
568   mem[r + 3].cint = x_over_n(mem[s + 3].cint, cur_val); 
569       } 
570       cur_val = r; 
571     } 
572   } 
573   if (arith_error){
574           print_err("Arithmetic overflow");
575           help2("I can't carry out that multiplication or division,",
576                   "since the result is out of range.");
577 /* 423 in tex82.bug */
578           if (p >= 2) delete_glue_ref(cur_val);
579     error(); 
580     return; 
581   } 
582   if (p < 2)
583   if ((a >= 4)) 
584   geq_word_define(l, cur_val); 
585   else eq_word_define(l, cur_val); 
586   else {
587       
588     trap_zero_glue(); 
589     if ((a >= 4)) 
590     geq_define(l, 117, cur_val); 
591     else eq_define(l, 117, cur_val); 
592   } 
593
594 /* called only from itex.c */
595 /* sec 1243 */
596 void alter_aux (void) 
597 {
598   halfword c; 
599   if (cur_chr != abs(mode)) {
600     report_illegal_case();
601   }
602   else {
603     c = cur_chr; 
604     scan_optional_equals(); 
605     if (c == 1)
606     {
607       scan_dimen(false, false, false); 
608       cur_list.aux_field.cint = cur_val; 
609     } 
610     else {
611       scan_int(); 
612       if ((cur_val <= 0)||(cur_val > 32767)) 
613       {
614                   print_err("Bad space factor");
615                   help1("I allow only values in the range 1..32767 here.");
616   int_error(cur_val); 
617       } 
618       else space_factor = cur_val; 
619     } 
620   } 
621 }
622 /* sec 1244 */
623 void alter_prev_graf (void) 
624 {
625   integer p; 
626   nest[nest_ptr]= cur_list; 
627   p = nest_ptr; 
628   while(abs(nest[p].mode_field)!= 1)decr(p); 
629   scan_optional_equals(); 
630   scan_int(); 
631   if (cur_val < 0)
632   {
633           print_err("Bad ");
634     print_esc("prevgraf");
635         help1("I allow only nonnegative values here.");
636     int_error(cur_val); 
637   } 
638   else {
639       
640     nest[p].pg_field = cur_val; 
641     cur_list = nest[nest_ptr]; 
642   } 
643 }
644 /* sec 1245 */
645 void alter_page_so_far (void) 
646 {
647   char c; 
648   c = cur_chr; 
649   scan_optional_equals(); 
650   scan_dimen(false, false, false); 
651   page_so_far[c]= cur_val; 
652 }
653 /* sec 1246 */
654 void alter_integer (void) 
655 {
656   char c; 
657   c = cur_chr; 
658   scan_optional_equals(); 
659   scan_int(); 
660   if (c == 0)dead_cycles = cur_val; 
661   else insert_penalties = cur_val; 
662 }
663 /* sec 1247 */
664 void alter_box_dimen (void) 
665
666   small_number c; 
667   eight_bits b; 
668   c = cur_chr; 
669   scan_eight_bit_int(); 
670   b = cur_val; 
671   scan_optional_equals(); 
672   scan_dimen(false, false, false); 
673   if (eqtb[(hash_size + 1578) + b].hh.v.RH != 0)
674   mem[eqtb[(hash_size + 1578) + b].hh.v.RH + c].cint = cur_val; 
675 }
676 /* sec 1257 */
677 void new_font_(small_number a)
678 {/* 50 */ 
679   halfword u; 
680   scaled s; 
681   internal_font_number f; 
682   str_number t; 
683   char old_setting; 
684   str_number flushablestring; 
685   if (job_name == 0) open_log_file(); 
686   get_r_token(); 
687   u = cur_cs; 
688   if (u >= hash_base)      /* if u >= hash_base then t <- text(u); p.1257 */
689     t = hash[u].v.RH; 
690   else if (u >= single_base)   /* if u >= single_base then ... */
691 /*    if u=null_cs then t:="FONT"@+else t:=u-single_base */
692   if (u == null_cs)
693     t = 1213;     /* FONT */
694   else t = u - single_base;   /* else t <- u - single_base */
695   else {
696     old_setting = selector; 
697     selector = 21; 
698     print_string("FONT");
699     print(u - active_base); 
700     selector = old_setting; 
701     {
702 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
703 #ifdef ALLOCATESTRING
704     if (pool_ptr + 1 > current_pool_size)
705       str_pool = realloc_str_pool (increment_pool_size);
706     if (pool_ptr + 1 > current_pool_size) {     /* 94/Jan/24 */
707       overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/9 */
708       return;     // abort_flag set
709     }
710 #else
711 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
712       if (pool_ptr + 1 > pool_size) {
713       overflow("pool size", pool_size - init_pool_ptr); /* pool size */
714       return;     // abort_flag set
715     }
716 #endif
717     } 
718     t = make_string(); 
719   } 
720   if ((a >= 4)) geq_define(u, 87, 0); 
721   else eq_define(u, 87, 0); 
722   scan_optional_equals(); 
723   scan_file_name(); 
724
725 /* paragraph 1258 */
726   name_in_progress = true; 
727   if (scan_keyword("at"))  /* at */
728   {
729     scan_dimen(false, false, false); 
730     s = cur_val; 
731     if ((s <= 0)||(s >= 134217728L)) /* 2^27 */
732     {
733       print_err("Improper `at' size(");
734       print_scaled(s); 
735       print_string("pt), replaced by 10pt");
736           help2("I can only handle fonts at positive sizes that are",
737                   "less than 2048pt, so I've changed what you said to 10pt.");
738       error(); 
739       s = 10 * 65536L;    /* 10pt */
740     } 
741   } 
742   else if (scan_keyword("scaled")) /* scaled */
743   {
744     scan_int(); 
745     s = - (integer) cur_val; 
746     if ((cur_val <= 0)||(cur_val > 32768L))  {
747                 print_err("Illegal magnification has been changed to 1000");
748                 help1("The magnification ratio must be between 1 and 32768.");
749       int_error(cur_val); 
750       s = -1000; 
751     } 
752   } 
753   else s = -1000; 
754   name_in_progress = false; 
755
756   flushablestring = str_ptr - 1; 
757   if (trace_flag)   {         /* debugging stuff only 98/Oct/5 */
758     int i, k1, k2, l1, l2;
759     char *sch=log_line;
760     k1 = str_start[cur_area];
761     k2 = str_start[cur_name];
762     l1 = str_start[cur_area + 1] - str_start[cur_area];
763     l2 = str_start[cur_name + 1] - str_start[cur_name];
764     show_char('\n');
765     show_line("FONT ", 0);
766     for (i = 0; i < l1; i++) {
767       *sch++ = str_pool[i+k1];
768     }
769     for (i = 0; i < l2; i++) {
770       *sch++ = str_pool[i+k2];
771     }
772     *sch++ = ' ';
773     *sch++ = '\0';
774     show_line(log_line, 0);
775   }
776 /*  if (ignore_frozen) goto lab69; */     /* 98/Oct/5 */
777
778 /* paragraph 1260 for f <- fontbase+1 to font_ptr do */
779   {
780     register integer for_end; 
781     f = 1; 
782     for_end = font_ptr; 
783     if (f <= for_end) 
784       do 
785 /* if str_eq_str(font_name[f],cur_name) ^ str_eq_str(font_area[f],cur_area) */
786         if (str_eq_str(font_name[f], cur_name)&&
787            str_eq_str(font_area[f], cur_area))  {
788           if (cur_name == flushablestring){
789             {
790               decr(str_ptr); 
791               pool_ptr = str_start[str_ptr]; 
792             } 
793             cur_name = font_name[f]; 
794           } 
795 /*    if (ignore_frozen) continue; */       /* 98/Oct/5 */
796           if (s > 0) {   /* if pt size was specified */
797             if (s == font_size[f]){
798 /*              if (ignore_frozen == 0)  */
799               if (ignore_frozen == 0 || f > frozenfontptr) { /* 99/Mar/26 */
800                 if (trace_flag) {
801                   sprintf(log_line, "SKIPPING %ld ", s);
802                   show_line(log_line, 0);
803                 }
804                 goto lab50;
805               }
806             }
807           } 
808 /* else if font_size[f] = xn_over_d(font_dsize[f],-s,1000) then goto common_ending */
809           else if (font_size[f]== xn_over_d(font_dsize[f],
810             - (integer) s, 1000)) { /* if using design size */
811 /*            if (ignore_frozen == 0) */
812             if (ignore_frozen == 0 || f > frozenfontptr) { /* 99/Mar/26 */
813               if (trace_flag) {
814                 sprintf(log_line, "SKIPPING %ld ", s);
815                 show_line(log_line, 0);
816               }
817               goto lab50;
818             }
819           }
820         } 
821     while(f++ < for_end);
822   } 
823
824 /* lab69: */  /* 98/Oct/5 */
825 /* end of paragraph 1257 */
826   if (trace_flag) show_line("READING ", 0);  /* debugging only */
827   f = read_font_info(u, cur_name, cur_area, s); 
828
829 /* common_ending: equiv[u] <- f;  */  /* use existing font info */
830   lab50:
831   if (trace_flag) {
832     sprintf(log_line, "NEW FONT %d ", f); /* debugging only */
833     show_line(log_line, 0);
834   }
835   eqtb[u].hh.v.RH = f; 
836 /*  eqtb[(hash_size + 524) + f]= eqtb[u];*/ /* eqtb[frozen_null+font+f] */
837   eqtb[(hash_size + hash_extra + 524) + f]= eqtb[u]; /* 96/Jan/10 */
838 #ifdef SHORTHASH            /*  debugging only  1996/Jan/20 */
839   if (t > 65535L) {
840     sprintf(log_line, "ERROR: %s too large %d\n",  "hash_used", t);
841     show_line(log_line, 1);
842   }
843 #endif
844 /*  hash[(hash_size + 524) + f].v.RH = t;  */
845   hash[(hash_size + hash_extra + 524) + f].v.RH = t; /* 96/Jan/10 */
846 }
847 /* sec 1265 */
848 void new_interaction (void) 
849
850   print_ln(); 
851   interaction = cur_chr; 
852   if (interaction == 0) selector = 16; 
853   else selector = 17; 
854   if (log_opened) selector = selector + 2; 
855 }
856 /* sec 1270 */
857 void do_assignments (void) 
858 {/* 10 */ 
859   while(true){
860     do {
861     get_x_token(); 
862     } while(!((cur_cmd != 10)&&(cur_cmd != 0))); 
863     if (cur_cmd <= 70)
864     return; 
865     set_box_allowed = false; 
866     prefixed_command(); 
867     set_box_allowed = true; 
868   } 
869 }
870 /* sec 1275 */
871 void open_or_close_in (void) 
872 {
873   char c; 
874   char n; 
875   c = cur_chr; 
876   scan_four_bit_int(); 
877   n = cur_val; 
878   if (read_open[n]!= 2)
879   {
880     (void) a_close(read_file[n]); 
881     read_open[n]= 2; 
882   } 
883   if (c != 0)
884   {
885     scan_optional_equals(); 
886     scan_file_name(); 
887     pack_file_name(cur_name, cur_area, cur_ext); 
888 /* *** some changes in following in 3.14159 *** */
889 /*  if current extension is *not* empty, try to open using name as is */
890 /*  string 335 is "" the empty string */
891     if ((cur_ext != 335)&& a_open_in(read_file[n], TEXINPUTPATH)) 
892     read_open[n]= 1; 
893 /*  we get here if extension is "", or file with extension failed to open */
894 /*  if current extension is not `tex,' and `tex' is not irrelevant, try it */
895 /*  string 785 is  .tex */
896     else if ((cur_ext != 785)&&(name_length + 5 < PATHMAX)&& 
897 /* *** some changes in above file name handling *** */
898 /*       (! extensionirrelevantp(name_of_file, "tex"))) */
899        (! extensionirrelevantp(name_of_file, name_length, "tex")))
900   {
901       name_of_file[name_length + 1]= 46;    /* .tex  */
902       name_of_file[name_length + 2]= 116; 
903       name_of_file[name_length + 3]= 101; 
904       name_of_file[name_length + 4]= 120; 
905       name_of_file[name_length + 5]= 32; 
906       name_length = name_length + 4; 
907       if (a_open_in(read_file[n], TEXINPUTPATH)) 
908       read_open[n]= 1; 
909       else {
910 /*    more changes here in 3.14159 *** */
911       name_length = name_length - 4;      /* remove ".tex" again */
912       name_of_file[name_length + 1]= 32;  /* '  '  */
913 /*    string 335 is "" the empty string */
914       if ((cur_ext == 335)&& a_open_in(read_file[n], TEXINPUTPATH)) 
915         read_open[n]= 1; 
916       else if (maketextex () && a_open_in(read_file[n], TEXINPUTPATH)) 
917         read_open[n]= 1; 
918     } 
919     } 
920   } 
921 }
922 /* sec 1279 */
923 void issue_message (void) 
924 {
925   char old_setting; 
926   char c; 
927   str_number s; 
928   c = cur_chr; 
929   mem[lig_trick].hh.v.RH = scan_toks(false, true); 
930   old_setting = selector; 
931   selector = 21; 
932   token_show(def_ref); 
933   selector = old_setting; 
934   flush_list(def_ref); 
935   {
936 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
937 #ifdef ALLOCATESTRING
938   if (pool_ptr + 1 > current_pool_size)
939       str_pool = realloc_str_pool (increment_pool_size);
940   if (pool_ptr + 1 > current_pool_size){ /* in case it failed 94/Jan/24 */
941     overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
942     return;     // abort_flag set
943   }
944 #else
945 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
946     if (pool_ptr + 1 > pool_size){
947     overflow("pool size", pool_size - init_pool_ptr); /* pool size */
948     return;     // abort_flag set
949   }
950 #endif
951   } 
952   s = make_string(); 
953   if (c == 0)
954   {
955     if (term_offset +(str_start[s + 1]- str_start[s])> max_print_line - 
956     2)
957     print_ln(); 
958     else if ((term_offset > 0)||(file_offset > 0)) 
959     print_char(' ');
960     slow_print(s); 
961 #ifndef f_WINDOWS
962     fflush(stdout); 
963 #endif
964   } 
965   else {
966     print_err("");  
967     slow_print(s); 
968     if (eqtb[(hash_size + 1321)].hh.v.RH != 0)
969     use_err_help = true; 
970     else if (long_help_seen)
971                 help1("(That was another \\errmessage.)");
972     else {
973   
974       if (interaction < 3)
975       long_help_seen = true; 
976           help4("This error message was generated by an \\errmessage",
977                   "command, so I can't give any explicit help.",
978                   "Pretend that you're Hercule Poirot: Examine all clues,",
979                   "and deduce the truth by order and method."); 
980     } 
981     error(); 
982     use_err_help = false; 
983   } 
984   {
985     decr(str_ptr); 
986     pool_ptr = str_start[str_ptr]; 
987   } 
988 }
989 /* sec 1288 */
990 void shift_case (void) 
991 {
992   halfword b; 
993   halfword p; 
994   halfword t; 
995   eight_bits c; 
996   b = cur_chr; 
997   p = scan_toks(false, false); 
998   p = mem[def_ref].hh.v.RH;
999   while (p != 0) {      /* while p <> null ... p.1288 */
1000     t = info(p); /* t <- info(p) p.1289 */ 
1001 /*    if (t < 4352) */
1002     if (t < 4095 + single_base)    /* 4095 + 257 = cs_tokenflag + single_base */
1003     {
1004       c = t % 256;  
1005       if (eqtb[b + c].hh.v.RH != 0)
1006       mem[p].hh.v.LH = t - c + eqtb[b + c].hh.v.RH; 
1007     } 
1008     p = link(p); 
1009   } 
1010   begin_token_list(mem[def_ref].hh.v.RH, 3); 
1011   {
1012     mem[def_ref].hh.v.RH = avail; 
1013     avail = def_ref; 
1014   ;
1015 #ifdef STAT
1016     decr(dyn_used); 
1017 #endif /* STAT */
1018   } 
1019 }
1020 /* sec 1293 */
1021 void show_whatever (void) 
1022 {
1023   halfword p; 
1024   switch(cur_chr)
1025   {
1026   case 3:
1027     {
1028       begin_diagnostic();
1029       show_activities();
1030     }
1031     break;
1032   case 1:
1033     {
1034       scan_eight_bit_int();
1035       begin_diagnostic();
1036       print_nl("> \box");
1037       print_int(cur_val);
1038       print_char('=');
1039       if (eqtb[(hash_size + 1578) + cur_val].hh.v.RH == 0)
1040         print_string("void");
1041       else
1042         show_box(eqtb[(hash_size + 1578) + cur_val].hh.v.RH);
1043     }
1044     break;
1045   case 0:
1046     {
1047       get_token();
1048       if (interaction == 3)
1049         ;
1050       print_nl("> ");
1051       if (cur_cs != 0)
1052       {
1053         sprint_cs(cur_cs);
1054         print_char('=');
1055       }
1056       print_meaning();
1057       goto lab50;
1058     }
1059     break;
1060   default:
1061     {
1062       p = the_toks();
1063       if (interaction == 3)
1064         ; 
1065       print_nl(" > ");
1066       token_show(temp_head);
1067       flush_list(mem[temp_head].hh.v.RH);
1068       goto lab50;
1069     }
1070     break;
1071   }
1072   end_diagnostic(true);
1073   print_err("OK");
1074   if (selector == 19)
1075   if (tracing_online <= 0)
1076   {
1077     selector = 17;
1078     print_string(" (see the transcript file)");
1079     selector = 19;
1080   }
1081 lab50:
1082   if (interaction < 3) {
1083     help_ptr = 0;
1084     decr(error_count);
1085   } else if (tracing_online > 0) {
1086           help3("This isn't an error message; I'm just \\showing something.",
1087                   "Type `I\\show...' to show more (e.g., \\show\\cs,",
1088                   "\\showthe\\count10, \\showbox255, \\showlists).");
1089   } else {
1090     help5("This isn't an error message; I'm just \\showing something.",
1091       "Type `I\\show...' to show more (e.g., \\show\\cs,",
1092       "\\showthe\\count10, \\showbox255, \\showlists).",
1093                   "And type `I\\tracingonline=1\\show...' to show boxes and",
1094                   "lists on your terminal as well as in the transcript file."); 
1095   }
1096   error();
1097
1098 /* sec 1339 */
1099 void new_whatsit_(small_number s, small_number w)
1100 {
1101   halfword p; 
1102   p = get_node(w); 
1103   mem[p].hh.b0 = 8; 
1104   mem[p].hh.b1 = s; 
1105   mem[tail].hh.v.RH = p; 
1106   tail = p; 
1107
1108 /* sec 1350 */
1109 void new_write_whatsit_(small_number w)
1110 {
1111   new_whatsit(cur_chr, w); 
1112   if (w != 2) {
1113     scan_four_bit_int();
1114   } else {
1115     scan_int(); 
1116     if (cur_val < 0)
1117       cur_val = 17; 
1118     else if (cur_val > 15)
1119       cur_val = 16; 
1120   }
1121   mem[tail + 1].hh.v.LH = cur_val;
1122 }
1123 /* sec 1348 */
1124 void do_extension (void) 
1125 {
1126 /*  integer i, j, k;  */
1127   integer k; 
1128 /*  halfword p, q, r;  */
1129   halfword p; 
1130   switch(cur_chr)
1131   {case 0 : 
1132     {
1133       new_write_whatsit(3); 
1134       scan_optional_equals(); 
1135       scan_file_name(); 
1136       mem[tail + 1].hh.v.RH = cur_name; 
1137       mem[tail + 2].hh.v.LH = cur_area; 
1138       mem[tail + 2].hh.v.RH = cur_ext; 
1139     } 
1140     break; 
1141   case 1 : 
1142     {
1143       k = cur_cs; 
1144       new_write_whatsit(2); 
1145       cur_cs = k; 
1146       p = scan_toks(false, false); 
1147       mem[tail + 1].hh.v.RH = def_ref; 
1148     } 
1149     break; 
1150   case 2 : 
1151     {
1152       new_write_whatsit(2); 
1153       mem[tail + 1].hh.v.RH = 0; 
1154     } 
1155     break; 
1156   case 3 : 
1157     {
1158       new_whatsit(3, 2); 
1159       mem[tail + 1].hh.v.LH = 0; 
1160       p = scan_toks(false, true); 
1161       mem[tail + 1].hh.v.RH = def_ref; 
1162     } 
1163     break; 
1164   case 4 : 
1165     {
1166       get_x_token(); 
1167       if ((cur_cmd == 59)&&(cur_chr <= 2)) 
1168       {
1169   p = tail; 
1170   do_extension(); 
1171   out_what(tail);
1172   flush_node_list(tail); 
1173   tail = p; 
1174   mem[p].hh.v.RH = 0; 
1175       } 
1176       else back_input(); 
1177     } 
1178     break; 
1179   case 5 : 
1180     if (abs(mode)!= 102){
1181     report_illegal_case();
1182   }
1183     else {
1184       new_whatsit(4, 2); 
1185       scan_int(); 
1186       if (cur_val <= 0) clang = 0; 
1187       else if (cur_val > 255)
1188       clang = 0; 
1189       else clang = cur_val; 
1190       mem[tail + 1].hh.v.RH = clang; 
1191       mem[tail + 1].hh.b0 = norm_min(left_hyphen_min); 
1192       mem[tail + 1].hh.b1 = norm_min(right_hyphen_min); 
1193     } 
1194     break; 
1195     default: 
1196     {
1197       confusion("display");
1198       return;       // abort_flag set
1199     }
1200     break; 
1201   } 
1202
1203 /* sec 1376 */
1204 void fix_language (void) 
1205
1206 /*  ASCII_code l;  */
1207   int l;                  /* 95/Jan/7 */
1208   if (language <= 0)
1209     l = 0; 
1210   else if (language > 255)
1211     l = 0;
1212   else l = language;
1213   if (l != clang) {
1214     new_whatsit(4, 2);
1215     mem[tail + 1].hh.v.RH = l;
1216     clang = l;
1217     mem[tail + 1].hh.b0 = norm_min(left_hyphen_min);
1218     mem[tail + 1].hh.b1 = norm_min(right_hyphen_min);
1219   }
1220 }
1221 /* sec 1068 */
1222 void handle_right_brace (void) 
1223
1224   halfword p, q; 
1225   scaled d; 
1226   integer f; 
1227
1228   switch(cur_group)
1229   {case 1 : 
1230     unsave(); 
1231     break; 
1232   case 0 : 
1233     {
1234                   print_err("Too many }'s");
1235                 help2("You've closed more groups than you opened.",
1236                         "Such booboos are generally harmless, so keep going.");
1237         error();
1238     } 
1239     break; 
1240   case 14 : 
1241   case 15 : 
1242   case 16 : 
1243     extra_right_brace();
1244     break; 
1245   case 2 : 
1246     package(0); 
1247     break; 
1248   case 3 : 
1249     {
1250       adjust_tail = adjust_head; 
1251       package(0); 
1252     } 
1253     break; 
1254   case 4 : 
1255     {
1256       end_graf(); 
1257       package(0); 
1258     } 
1259     break; 
1260   case 5 : 
1261     {
1262       end_graf();
1263       package(4);
1264     } 
1265     break; 
1266   case 11 : 
1267     {
1268       end_graf(); 
1269       q = eqtb[(hash_size + 792)].hh.v.RH; 
1270       incr(mem[q].hh.v.RH); 
1271       d = split_max_depth; 
1272       f = floating_penalty; 
1273       unsave(); 
1274       decr(save_ptr); 
1275       p = vpackage(mem[head].hh.v.RH, 0, 1, 1073741823L);  /* 2^30 - 1 */
1276       pop_nest(); 
1277       if (save_stack[save_ptr + 0].cint < 255) {
1278         {
1279           mem[tail].hh.v.RH = get_node(5);
1280           tail = mem[tail].hh.v.RH;
1281         }
1282         mem[tail].hh.b0 = 3;
1283         mem[tail].hh.b1 = save_stack[save_ptr + 0].cint;
1284         mem[tail + 3].cint = mem[p + 3].cint + mem[p + 2].cint;
1285         mem[tail + 4].hh.v.LH = mem[p + 5].hh.v.RH;
1286         mem[tail + 4].hh.v.RH = q;
1287         mem[tail + 2].cint = d;
1288         mem[tail + 1].cint = f; 
1289       } else {
1290         {
1291           mem[tail].hh.v.RH = get_node(2);
1292           tail = mem[tail].hh.v.RH;
1293         }
1294         mem[tail].hh.b0 = 5;
1295         mem[tail].hh.b1 = 0;
1296         mem[tail + 1].cint = mem[p + 5].hh.v.RH;
1297         delete_glue_ref(q);
1298       } 
1299       free_node(p, 7); 
1300       if (nest_ptr == 0) {
1301         build_page();
1302       }
1303     } 
1304     break; 
1305   case 8 : 
1306     {
1307       if ((cur_input.loc_field != 0)||((cur_input.index_field != 6)&&(
1308       cur_input.index_field != 3)))
1309       {
1310                   print_err("Unbalanced output routine");
1311                   help2("Your sneaky output routine has problematic {'s and/or }'s.",
1312                           "I can't handle that very well; good luck.");
1313   error(); 
1314   do {
1315       get_token(); 
1316   } while(!(cur_input.loc_field == 0)); 
1317       } 
1318       end_token_list(); 
1319       end_graf(); 
1320       unsave(); 
1321       output_active = false; 
1322       insert_penalties = 0; 
1323       if (eqtb[(hash_size + 1833)].hh.v.RH != 0)
1324       {
1325                   print_err("Output routine didn't use all of ");
1326       print_esc("box");
1327       print_int(255); 
1328           help3("Your \\output commands should empty \\box255,",
1329                   "e.g., by saying `\\ship_out\\box255'.",
1330                   "Proceed; I'll discard its present contents.");
1331       box_error(255); 
1332     }
1333       if (tail != head)
1334       {
1335   mem[page_tail].hh.v.RH = mem[head].hh.v.RH; 
1336   page_tail = tail; 
1337       } 
1338       if (mem[page_head].hh.v.RH != 0)
1339       {
1340   if (mem[contrib_head].hh.v.RH == 0)
1341   nest[0].tail_field = page_tail; 
1342   mem[page_tail].hh.v.RH = mem[contrib_head].hh.v.RH; 
1343   mem[contrib_head].hh.v.RH = mem[page_head].hh.v.RH; 
1344   mem[page_head].hh.v.RH = 0; 
1345   page_tail = page_head; 
1346       } 
1347       pop_nest(); 
1348       build_page(); 
1349     } 
1350     break; 
1351   case 10 : 
1352     build_discretionary(); 
1353     break; 
1354   case 6 : 
1355 /* align_group: begin back_input; cur_tok:=cs_token_flag+frozen_cr; */
1356     {
1357       back_input(); 
1358 /*      cur_tok = (hash_size + 4610);  */
1359 /*      cur_tok = (hash_size + 4095 + 515);  */
1360       cur_tok = (hash_size + hash_extra + 4095 + 515);
1361           print_err("Missing ");
1362       print_esc("cr");
1363       print_string("inserted");
1364           help1("I'm guessing that you meant to end an alignment here.");
1365       ins_error(); 
1366     } 
1367     break; 
1368   case 7 : 
1369     {
1370       end_graf(); 
1371       unsave(); 
1372       align_peek(); 
1373     } 
1374     break; 
1375   case 12 : 
1376     {
1377       end_graf(); 
1378       unsave(); 
1379       save_ptr = save_ptr - 2; 
1380       p = vpackage(mem[head].hh.v.RH, save_stack[
1381       save_ptr + 1].cint, save_stack[save_ptr + 0].cint,
1382       1073741823L);   /* 2^30 - 1 */
1383       pop_nest(); 
1384       {
1385   mem[tail].hh.v.RH = new_noad(); 
1386   tail = mem[tail].hh.v.RH; 
1387       } 
1388       mem[tail].hh.b0 = 29; 
1389       mem[tail + 1].hh.v.RH = 2; 
1390       mem[tail + 1].hh.v.LH = p; 
1391     } 
1392     break; 
1393   case 13 : 
1394     build_choices(); 
1395     break; 
1396   case 9 : 
1397     {
1398       unsave(); 
1399       decr(save_ptr); 
1400       mem[save_stack[save_ptr + 0].cint].hh.v.RH = 3; 
1401       p = fin_mlist(0); 
1402       mem[save_stack[save_ptr + 0].cint].hh.v.LH = p; 
1403       if (p != 0)
1404       if (mem[p].hh.v.RH == 0)
1405       if (mem[p].hh.b0 == 16)
1406       {
1407   if (mem[p + 3].hh.v.RH == 0)
1408   if (mem[p + 2].hh.v.RH == 0)
1409   {
1410     mem[save_stack[save_ptr + 0].cint].hh = mem[p + 1].hh; 
1411     free_node(p, 4); 
1412   } 
1413       } 
1414       else if (mem[p].hh.b0 == 28)
1415       if (save_stack[save_ptr + 0].cint == tail + 1)
1416       if (mem[tail].hh.b0 == 16)
1417       {
1418   q = head; 
1419   while(mem[q].hh.v.RH != tail)q = mem[q].hh 
1420   .v.RH; 
1421   mem[q].hh.v.RH = p; 
1422   free_node(tail, 4); 
1423   tail = p; 
1424       } 
1425     } 
1426     break; 
1427     default: 
1428     {
1429       confusion("rightbrace");
1430       return;       // abort_flag set
1431     }
1432     break; 
1433   } 
1434
1435 /* sec 1030 */
1436 /* main control loop */
1437 void main_control (void) 
1438 {/* 60 21 70 80 90 91 92 95 100 101 110 111 112 120 10 */
1439     integer t; 
1440   integer bSuppress;    /* 199/Jan/5 */
1441
1442   if (eqtb[(hash_size + 1319)].hh.v.RH != 0)/* everyjob */
1443     begin_token_list(eqtb[(hash_size + 1319)].hh.v.RH, 12); 
1444
1445 lab60:
1446   get_x_token();       /* big_switch */
1447 lab21:
1448   if (interrupt != 0)
1449     if (OK_to_interrupt){
1450       back_input(); 
1451       {
1452         if (interrupt != 0){
1453           pause_for_instructions();
1454         }
1455       }  
1456       goto lab60; 
1457     } 
1458   ;
1459 #ifdef DEBUG
1460   if (panicking)check_mem(false); 
1461 #endif /* DEBUG */
1462   if (tracing_commands > 0)
1463     show_cur_cmd_chr(); 
1464
1465 /*  the big switch --- don't bother to test abort_flag ??? */
1466   switch(abs(mode)+ cur_cmd){
1467        case 113 : 
1468        case 114 : 
1469        case 170 : 
1470          goto lab70; 
1471          break; 
1472        case 118 : 
1473        {
1474          scan_char_num(); 
1475          cur_chr = cur_val; 
1476          goto lab70; 
1477        } 
1478        break; 
1479        case 167 : 
1480        {
1481          get_x_token(); 
1482          if ((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68)||(
1483            cur_cmd == 16)) 
1484            cancel_boundary = true; 
1485          goto lab21; 
1486        } 
1487        break; 
1488   case 112 : 
1489     if (space_factor == 1000)goto lab120; 
1490     else {
1491     app_space();
1492   }
1493     break; 
1494   case 166 : 
1495   case 267 : 
1496     goto lab120; 
1497     break; 
1498   case 1 : 
1499   case 102 : 
1500   case 203 : 
1501   case 11 : 
1502   case 213 : 
1503   case 268 : 
1504  ; 
1505     break; 
1506   case 40 : 
1507   case 141 : 
1508   case 242 : 
1509     {
1510       do {
1511       get_x_token(); 
1512       } while(!(cur_cmd != 10)); 
1513       goto lab21; 
1514     } 
1515     break; 
1516   case 15 : 
1517     if (its_all_over ())return; 
1518     break; 
1519   case 23 : 
1520   case 123 : 
1521   case 224 : 
1522   case 71 : 
1523   case 172 : 
1524   case 273 : 
1525   case 39 : 
1526   case 45 : 
1527   case 49 : 
1528   case 150 : 
1529   case 7 : 
1530   case 108 : 
1531   case 209 : 
1532     report_illegal_case(); 
1533     break; 
1534   case 8 : 
1535   case 109 : 
1536   case 9 : 
1537   case 110 : 
1538   case 18 : 
1539   case 119 : 
1540   case 70 : 
1541   case 171 : 
1542   case 51 : 
1543   case 152 : 
1544   case 16 : 
1545   case 117 : 
1546   case 50 : 
1547   case 151 : 
1548   case 53 : 
1549   case 154 : 
1550   case 67 : 
1551   case 168 : 
1552   case 54 : 
1553   case 155 : 
1554   case 55 : 
1555   case 156 : 
1556   case 57 : 
1557   case 158 : 
1558   case 56 : 
1559   case 157 : 
1560   case 31 : 
1561   case 132 : 
1562   case 52 : 
1563   case 153 : 
1564   case 29 : 
1565   case 130 : 
1566   case 47 : 
1567   case 148 : 
1568   case 212 : 
1569   case 216 : 
1570   case 217 : 
1571   case 230 : 
1572   case 227 : 
1573   case 236 : 
1574   case 239 : 
1575     insert_dollar_sign(); 
1576     break; 
1577   case 37 : 
1578   case 137 : 
1579   case 238 : 
1580     {
1581       {
1582       mem[tail].hh.v.RH = scan_rule_spec(); 
1583       tail = mem[tail].hh.v.RH; 
1584       } 
1585       if (abs(mode)== 1)
1586       cur_list.aux_field.cint = ignore_depth; 
1587       else if (abs(mode)== 102)
1588       space_factor = 1000; 
1589     } 
1590     break; 
1591   case 28 : 
1592   case 128 : 
1593   case 229 : 
1594   case 231 : 
1595     append_glue(); 
1596     break; 
1597   case 30 : 
1598   case 131 : 
1599   case 232 : 
1600   case 233 : 
1601     append_kern(); 
1602     break; 
1603   case 2 : 
1604   case 103 : 
1605     new_save_level(1); 
1606     break; 
1607   case 62 : 
1608   case 163 : 
1609   case 264 : 
1610     new_save_level(14); 
1611     break; 
1612   case 63 : 
1613   case 164 : 
1614   case 265 : 
1615     if (cur_group == 14) unsave(); 
1616     else off_save();
1617     break; 
1618   case 3 : 
1619   case 104 : 
1620   case 205 : 
1621     handle_right_brace(); 
1622     break; 
1623   case 22 : 
1624   case 124 : 
1625   case 225 : 
1626     {
1627       t = cur_chr; 
1628       scan_dimen(false, false, false); 
1629       if (t == 0)scan_box(cur_val);
1630       else scan_box(- (integer) cur_val);
1631     } 
1632     break; 
1633   case 32 : 
1634   case 133 : 
1635   case 234 : 
1636 /* scan_box(leader_flag-a_leaders+cur_chr); */
1637     scan_box(1073742237L + cur_chr); /* 2^30 + 513 - 100 ? */
1638     break; 
1639   case 21 : 
1640   case 122 : 
1641   case 223 : 
1642     begin_box(0); 
1643     break; 
1644   case 44 : 
1645     new_graf(cur_chr > 0); 
1646     break; 
1647   case 12 : 
1648   case 13 : 
1649   case 17 : 
1650   case 69 : 
1651   case 4 : 
1652   case 24 : 
1653   case 36 : 
1654   case 46 : 
1655   case 48 : 
1656   case 27 : 
1657   case 34 : 
1658   case 65 : 
1659   case 66 : 
1660     {
1661       back_input(); 
1662       new_graf(true); 
1663     } 
1664     break; 
1665   case 145 : 
1666   case 246 : 
1667     indent_in_hmode(); 
1668     break; 
1669   case 14 : 
1670     {
1671       normal_paragraph(); 
1672       if (mode > 0){
1673       build_page();
1674     }
1675     } 
1676     break; 
1677   case 115 : 
1678     {
1679       if (align_state < 0){
1680       off_save();
1681     }
1682       end_graf(); 
1683       if (mode == 1){
1684       build_page();
1685     }
1686     } 
1687     break; 
1688   case 116 : 
1689   case 129 : 
1690   case 138 : 
1691   case 126 : 
1692   case 134 : 
1693     head_for_vmode(); 
1694     break; 
1695   case 38 : 
1696   case 139 : 
1697   case 240 : 
1698   case 140 : 
1699   case 241 : 
1700     begin_insert_or_adjust(); 
1701     break; 
1702   case 19 : 
1703   case 120 : 
1704   case 221 : 
1705     make_mark(); 
1706     break; 
1707   case 43 : 
1708   case 144 : 
1709   case 245 : 
1710     append_penalty(); 
1711     break; 
1712   case 26 : 
1713   case 127 : 
1714   case 228 : 
1715     delete_last(); 
1716     break; 
1717   case 25 : 
1718   case 125 : 
1719   case 226 : 
1720     unpackage(); 
1721     break; 
1722   case 146 : 
1723     append_italic_correction(); 
1724     break; 
1725   case 247 : 
1726     {
1727       mem[tail].hh.v.RH = new_kern(0); 
1728       tail = mem[tail].hh.v.RH; 
1729     } 
1730     break; 
1731   case 149 : 
1732   case 250 : 
1733     append_discretionary(); 
1734     break; 
1735   case 147 : 
1736     make_accent(); 
1737     break; 
1738   case 6 : 
1739   case 107 : 
1740   case 208 : 
1741   case 5 : 
1742   case 106 : 
1743   case 207 : 
1744     align_error(); 
1745     break; 
1746   case 35 : 
1747   case 136 : 
1748   case 237 : 
1749     noalign_error(); 
1750     break; 
1751   case 64 : 
1752   case 165 : 
1753   case 266 : 
1754     omit_error(); 
1755     break; 
1756   case 33 : 
1757   case 135 : 
1758     init_align(); 
1759     break; 
1760   case 235 : 
1761     if (privileged ())
1762     if (cur_group == 15)init_align();
1763     else off_save();
1764
1765     break; 
1766   case 10 : 
1767   case 111 : 
1768     do_endv(); 
1769     break; 
1770   case 68 : 
1771   case 169 : 
1772   case 270 : 
1773     cs_error(); 
1774     break; 
1775   case 105 : 
1776     init_math(); 
1777     break; 
1778   case 251 : 
1779     if (privileged ())
1780     if (cur_group == 15) start_eq_no(); 
1781     else off_save();
1782     break; 
1783   case 204 : 
1784     {
1785       {
1786   mem[tail].hh.v.RH = new_noad(); 
1787   tail = mem[tail].hh.v.RH; 
1788       } 
1789       back_input(); 
1790       scan_math(tail + 1); 
1791     } 
1792     break; 
1793   case 214 : 
1794   case 215 : 
1795   case 271 : 
1796     set_math_char(eqtb[(hash_size + 2907) + cur_chr].hh.v.RH); 
1797     break; 
1798   case 219 : 
1799     {
1800       scan_char_num(); 
1801       cur_chr = cur_val; 
1802       set_math_char(eqtb[(hash_size + 2907) + cur_chr].hh.v.RH); 
1803     } 
1804     break; 
1805   case 220 : 
1806     {
1807       scan_fifteen_bit_int(); 
1808       set_math_char(cur_val); 
1809     } 
1810     break; 
1811   case 272 : 
1812     set_math_char(cur_chr); 
1813     break; 
1814   case 218 : 
1815     {
1816       scan_twenty_seven_bit_int(); 
1817       set_math_char(cur_val / 4096);  
1818 /*      set_math_char(cur_val >> 12); */
1819     } 
1820     break; 
1821   case 253 : 
1822     {
1823       {
1824       mem[tail].hh.v.RH = new_noad(); 
1825       tail = mem[tail].hh.v.RH; 
1826       } 
1827       mem[tail].hh.b0 = cur_chr; 
1828       scan_math(tail + 1); 
1829     } 
1830     break; 
1831   case 254 : 
1832     math_limit_switch(); 
1833     break; 
1834   case 269 : 
1835     math_radical(); 
1836     break; 
1837   case 248 : 
1838   case 249 : 
1839     math_ac(); 
1840     break; 
1841   case 259 : 
1842     {
1843       scan_spec(12, false); 
1844       normal_paragraph(); 
1845       push_nest(); 
1846       mode = -1; 
1847       cur_list.aux_field.cint = ignore_depth; 
1848       if (eqtb[(hash_size + 1318)].hh.v.RH != 0)/* everyvbox */
1849       begin_token_list(eqtb[(hash_size + 1318)].hh.v.RH, 11); 
1850     } 
1851     break; 
1852   case 256 : 
1853     {
1854       mem[tail].hh.v.RH = new_style(cur_chr); 
1855       tail = mem[tail].hh.v.RH; 
1856     } 
1857     break; 
1858   case 258 : 
1859     {
1860       {
1861       mem[tail].hh.v.RH = new_glue(0); 
1862       tail = mem[tail].hh.v.RH; 
1863       } 
1864       mem[tail].hh.b1 = 98; 
1865     } 
1866     break; 
1867   case 257 : 
1868     append_choices(); 
1869     break; 
1870   case 211 : 
1871   case 210 : 
1872     sub_sup(); 
1873     break; 
1874   case 255 : 
1875     math_fraction(); 
1876     break; 
1877   case 252 : 
1878     math_left_right(); 
1879     break; 
1880   case 206 : 
1881     if (cur_group == 15)after_math(); 
1882     else off_save();
1883     break; 
1884   case 72 : 
1885   case 173 : 
1886   case 274 : 
1887   case 73 : 
1888   case 174 : 
1889   case 275 : 
1890   case 74 : 
1891   case 175 : 
1892   case 276 : 
1893   case 75 : 
1894   case 176 : 
1895   case 277 : 
1896   case 76 : 
1897   case 177 : 
1898   case 278 : 
1899   case 77 : 
1900   case 178 : 
1901   case 279 : 
1902   case 78 : 
1903   case 179 : 
1904   case 280 : 
1905   case 79 : 
1906   case 180 : 
1907   case 281 : 
1908   case 80 : 
1909   case 181 : 
1910   case 282 : 
1911   case 81 : 
1912   case 182 : 
1913   case 283 : 
1914   case 82 : 
1915   case 183 : 
1916   case 284 : 
1917   case 83 : 
1918   case 184 : 
1919   case 285 : 
1920   case 84 : 
1921   case 185 : 
1922   case 286 : 
1923   case 85 : 
1924   case 186 : 
1925   case 287 : 
1926   case 86 : 
1927   case 187 : 
1928   case 288 : 
1929   case 87 : 
1930   case 188 : 
1931   case 289 : 
1932   case 88 : 
1933   case 189 : 
1934   case 290 : 
1935   case 89 : 
1936   case 190 : 
1937   case 291 : 
1938   case 90 : 
1939   case 191 : 
1940   case 292 : 
1941   case 91 : 
1942   case 192 : 
1943   case 293 : 
1944   case 92 : 
1945   case 193 : 
1946   case 294 : 
1947   case 93 : 
1948   case 194 : 
1949   case 295 : 
1950   case 94 : 
1951   case 195 : 
1952   case 296 : 
1953   case 95 : 
1954   case 196 : 
1955   case 297 : 
1956   case 96 : 
1957   case 197 : 
1958   case 298 : 
1959   case 97 : 
1960   case 198 : 
1961   case 299 : 
1962   case 98 : 
1963   case 199 : 
1964   case 300 : 
1965   case 99 : 
1966   case 200 : 
1967   case 301 : 
1968   case 100 : 
1969   case 201 : 
1970   case 302 : 
1971   case 101 : 
1972   case 202 : 
1973   case 303 : 
1974     prefixed_command(); 
1975     break; 
1976   case 41 : 
1977   case 142 : 
1978   case 243 : 
1979     {
1980       get_token(); 
1981       after_token = cur_tok; 
1982     } 
1983     break; 
1984   case 42 : 
1985   case 143 : 
1986   case 244 : 
1987     {
1988       get_token(); 
1989       save_for_after(cur_tok); 
1990     } 
1991     break; 
1992   case 61 : 
1993   case 162 : 
1994   case 263 : 
1995     open_or_close_in(); 
1996     break; 
1997   case 59 : 
1998   case 160 : 
1999   case 261 : 
2000     issue_message(); 
2001     break; 
2002   case 58 : 
2003   case 159 : 
2004   case 260 : 
2005     shift_case(); 
2006     break; 
2007   case 20 : 
2008   case 121 : 
2009   case 222 : 
2010     show_whatever(); 
2011     break; 
2012   case 60 : 
2013   case 161 : 
2014   case 262 : 
2015     do_extension(); 
2016     break; 
2017   } /* end of big switch */
2018   goto lab60; /*  main_loop */
2019
2020 lab70:
2021   main_s = eqtb[(hash_size + 2651) + cur_chr].hh.v.RH; 
2022   if (main_s == 1000)
2023     space_factor = 1000; 
2024   else if (main_s < 1000)
2025   {
2026     if (main_s > 0)
2027     space_factor = main_s; 
2028   } 
2029   else if (space_factor < 1000)
2030     space_factor = 1000; 
2031   else space_factor = main_s; 
2032   main_f = eqtb[(hash_size + 1834)].hh.v.RH; 
2033   bchar = font_bchar[main_f]; 
2034   false_bchar = font_false_bchar[main_f]; 
2035   if (mode > 0)
2036   if (language != clang)
2037   fix_language(); 
2038   {
2039     lig_stack = avail; 
2040     if (lig_stack == 0)
2041     lig_stack = get_avail(); 
2042     else {
2043       avail = mem[lig_stack].hh.v.RH; 
2044       mem[lig_stack].hh.v.RH = 0; 
2045   ;
2046 #ifdef STAT
2047       incr(dyn_used); 
2048 #endif /* STAT */
2049     } 
2050   } 
2051   mem[lig_stack].hh.b0 = main_f; 
2052   cur_l = cur_chr; 
2053   mem[lig_stack].hh.b1 = cur_l; 
2054   cur_q = tail; 
2055   if (cancel_boundary)
2056   {
2057 /*  begin cancel_boundary:=false; main_k:=non_address; l.20093 */
2058     cancel_boundary = false; 
2059 /* main_k:=non_address 3.14159 */
2060 /*    main_k = font_mem_size; */    /* OK ? 1993/Nov/29 */
2061     main_k = non_address;     /* i.e. --- 1995/Jan/15 3.14159 */
2062   } 
2063   else main_k = bchar_label[main_f]; 
2064 /* if main_k=non_address then goto main_loop_move+2; l.20096 */
2065 /*  if (main_k == font_mem_size) */
2066   if (main_k == non_address)   /* i.e. 0 --- 1995/Jan/15 */
2067 /* cur_r:=cur_l; cur_l:=non_char; */
2068   goto lab92; 
2069   cur_r = cur_l; 
2070   cur_l = 256;            /* cur_l:=non_char; */
2071 /* goto main_lig_loop+1; l.20071 */
2072   goto lab111; 
2073
2074 /* main_loop_wrapup:@<Make a ligature node, if |ligature_present|;
2075   insert a null discretionary, if appropriate@>; */
2076 /* @d wrapup(#)==if cur_l<non_char then */
2077 /*  main_loop_wrapup */
2078 lab80: if (cur_l < 256)
2079   {
2080 /*  begin if character(tail)=qi(hyphen_char[main_f]) then
2081   if link(cur_q)>null then ... l.20107 */
2082     if (mem[tail].hh.b1 == hyphen_char[main_f])
2083 /*    if (mem[cur_q].hh.v.RH > 0) */ /* NO! */
2084     if (mem[cur_q].hh.v.RH != 0) /* BUG FIX l.20107 */
2085     ins_disc = true; 
2086     if (ligature_present)
2087     {
2088       main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH); 
2089       if (lft_hit)
2090       {
2091   mem[main_p].hh.b1 = 2; 
2092   lft_hit = false; 
2093       } 
2094       if (rt_hit)
2095       if (lig_stack == 0)
2096       {
2097   incr(mem[main_p].hh.b1); 
2098   rt_hit = false; 
2099       } 
2100       mem[cur_q].hh.v.RH = main_p; 
2101       tail = main_p; 
2102       ligature_present = false; 
2103     } 
2104 /*   if ins_disc then l.20110 */
2105     if (ins_disc)
2106     {
2107       ins_disc = false; 
2108 /*   if mode>0 then tail_append(new_disc); l.20112 */
2109       if (mode > 0)
2110       {
2111   mem[tail].hh.v.RH = new_disc(); 
2112   tail = mem[tail].hh.v.RH; 
2113       } 
2114     } 
2115   } 
2116
2117 /*  main_loop_move */
2118 lab90:
2119   if (lig_stack == 0) goto lab21; 
2120   cur_q = tail; 
2121   cur_l = mem[lig_stack].hh.b1; 
2122
2123 lab91:
2124   if (!(lig_stack >= hi_mem_min)) goto lab95; 
2125
2126 lab92: if ((cur_chr < font_bc[main_f])||(cur_chr > font_ec[main_f])) 
2127   {
2128     char_warning(main_f, cur_chr); 
2129     {
2130       mem[lig_stack].hh.v.RH = avail; 
2131       avail = lig_stack; 
2132   ;
2133 #ifdef STAT
2134       decr(dyn_used); 
2135 #endif /* STAT */
2136     } 
2137     goto lab60; 
2138   } 
2139   main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
2140   if (!(main_i.b0 > 0)) 
2141   {
2142     char_warning(main_f, cur_chr); 
2143     {
2144       mem[lig_stack].hh.v.RH = avail; 
2145       avail = lig_stack; 
2146   ;
2147 #ifdef STAT
2148       decr(dyn_used); 
2149 #endif /* STAT */
2150     } 
2151     goto lab60; 
2152   } 
2153   {
2154     link(tail) = lig_stack; 
2155     tail = lig_stack; 
2156   } 
2157
2158 /*  main_loop_lookahead */
2159 lab100:
2160   get_next(); 
2161   if (cur_cmd == 11) goto lab101; 
2162   if (cur_cmd == 12) goto lab101; 
2163   if (cur_cmd == 68) goto lab101; 
2164   x_token(); 
2165   if (cur_cmd == 11) goto lab101; 
2166   if (cur_cmd == 12) goto lab101; 
2167   if (cur_cmd == 68) goto lab101; 
2168   if (cur_cmd == 16) {
2169     scan_char_num(); 
2170     cur_chr = cur_val; 
2171     goto lab101; 
2172   } 
2173   if (cur_cmd == 65) bchar = 256; 
2174   cur_r = bchar; 
2175   lig_stack = 0; 
2176   goto lab110; 
2177
2178 lab101: main_s = eqtb[(hash_size + 2651) + cur_chr].hh.v.RH; 
2179   if (main_s == 1000)
2180   space_factor = 1000; 
2181   else if (main_s < 1000)
2182   {
2183     if (main_s > 0)
2184     space_factor = main_s; 
2185   } 
2186   else if (space_factor < 1000)
2187   space_factor = 1000; 
2188   else space_factor = main_s; 
2189   {
2190     lig_stack = avail; 
2191     if (lig_stack == 0)
2192     lig_stack = get_avail(); 
2193     else {
2194       avail = mem[lig_stack].hh.v.RH; 
2195       mem[lig_stack].hh.v.RH = 0; 
2196   ;
2197 #ifdef STAT
2198       incr(dyn_used); 
2199 #endif /* STAT */
2200     } 
2201   } 
2202   mem[lig_stack].hh.b0 = main_f; 
2203   cur_r = cur_chr; 
2204   mem[lig_stack].hh.b1 = cur_r; 
2205   if (cur_r == false_bchar)
2206     cur_r = 256; 
2207
2208 // main_lig_loop:@<If there's a ligature/kern command relevant to |cur_l| and
2209 //  |cur_r|, adjust the text appropriately; exit to |main_loop_wrapup|@>;
2210 lab110:
2211 /*  if char_tag(main_i)<>lig_tag then goto main_loop_wrapup; */
2212   if (((main_i.b2) % 4)!= 1)
2213     goto lab80;
2214 /* 425 in tex82.bug */
2215   if (cur_r == 256)
2216           goto lab80;
2217 /*  main_k:=lig_kern_start(main_f)(main_i); */
2218   main_k = lig_kern_base[main_f]+ main_i.b3; 
2219 /*  main_j:=font_info[main_k].qqqq; */
2220   main_j = font_info[main_k].qqqq; 
2221 /* if skip_byte(main_j)<=stop_flag then goto main_lig_loop+2; */
2222   if (main_j.b0 <= 128)goto lab112; 
2223 /* main_k:=lig_kern_restart(main_f)(main_j); */
2224   main_k = lig_kern_base[main_f]+ 256 * main_j.b2 + main_j.b3 + 32768L - 256 * 
2225  (128); 
2226
2227 /* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */
2228 lab111: main_j = font_info[main_k].qqqq; 
2229
2230 /* main_lig_loop+2:if next_char(main_j)=cur_r then l.20184 */
2231 lab112:
2232 /*  provide for suppression of f-ligatures 99/Jan/5 */
2233   bSuppress = 0;
2234   if (suppress_f_ligs && main_j.b1 == cur_r && main_j.b2 == 0) {
2235     if (cur_l == 'f') 
2236         bSuppress = 1;
2237   }
2238
2239 /*  if (main_j.b1 == cur_r)*/
2240   if (main_j.b1 == cur_r && bSuppress == 0)  /* 99/Jan/5 */
2241 /*  if skip_byte(main_j)<=stop_flag then l.20185 */
2242 //   @<Do ligature or kern command, returning to |main_lig_loop|
2243 //    or |main_loop_wrapup| or |main_loop_move|@>;
2244   if (main_j.b0 <= 128)
2245   {
2246 /* begin if op_byte(main_j)>=kern_flag then l.20225 */
2247     if (main_j.b2 >= 128)
2248     {
2249 /* @d wrapup(#)==if cur_l<non_char then */
2250       if (cur_l < 256)
2251       {
2252 /* if character(tail)=qi(hyphen_char[main_f]) then if link(cur_q)>null */
2253   if (mem[tail].hh.b1 == hyphen_char[main_f])
2254 /*  if (mem[cur_q].hh.v.RH > 0) */ /* 94/Mar/22 ?????????????? */
2255   if (mem[cur_q].hh.v.RH != 0) /* BUG FIX l.20107l.20186  */
2256   ins_disc = true; 
2257 /*   if ligature_present then pack_lig(#); */
2258   if (ligature_present)
2259   {
2260     main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH); 
2261     if (lft_hit)
2262     {
2263       mem[main_p].hh.b1 = 2; 
2264       lft_hit = false; 
2265     } 
2266     if (rt_hit)
2267     if (lig_stack == 0)
2268     {
2269       incr(mem[main_p].hh.b1); 
2270       rt_hit = false; 
2271     } 
2272     mem[cur_q].hh.v.RH = main_p; 
2273     tail = main_p; 
2274     ligature_present = false; 
2275   } 
2276   if (ins_disc)
2277   {
2278     ins_disc = false; 
2279     if (mode > 0)
2280     {
2281       mem[tail].hh.v.RH = new_disc(); 
2282       tail = mem[tail].hh.v.RH; 
2283     } 
2284   } 
2285       } 
2286       {
2287   mem[tail].hh.v.RH = new_kern(font_info[kern_base[
2288   main_f]+ 256 * main_j.b2 + main_j.b3].cint); 
2289   tail = mem[tail].hh.v.RH; 
2290       } 
2291       goto lab90; 
2292     } 
2293 /* begin if cur_l=non_char then lft_hit:=true; */
2294     if (cur_l == 256)
2295     lft_hit = true; 
2296     else if (lig_stack == 0)
2297     rt_hit = true; 
2298     {
2299       if (interrupt != 0){
2300       pause_for_instructions();
2301     }
2302     } 
2303     switch(main_j.b2)
2304     {case 1 : 
2305     case 5 : 
2306       {
2307   cur_l = main_j.b3; 
2308   main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
2309   ligature_present = true; 
2310       } 
2311       break; 
2312     case 2 : 
2313     case 6 : 
2314       {
2315   cur_r = main_j.b3; 
2316   if (lig_stack == 0)
2317   {
2318     lig_stack = new_lig_item(cur_r); 
2319     bchar = 256; 
2320   } 
2321   else if ((lig_stack >= hi_mem_min)) 
2322   {
2323     main_p = lig_stack; 
2324     lig_stack = new_lig_item(cur_r); 
2325     mem[lig_stack + 1].hh.v.RH = main_p; 
2326   } 
2327   else mem[lig_stack].hh.b1 = cur_r; 
2328       } 
2329       break; 
2330     case 3 : 
2331       {
2332   cur_r = main_j.b3; 
2333   main_p = lig_stack; 
2334   lig_stack = new_lig_item(cur_r); 
2335   mem[lig_stack].hh.v.RH = main_p; 
2336       } 
2337       break; 
2338     case 7 : 
2339     case 11 : 
2340       {
2341   if (cur_l < 256) /* if cur_l<non_char then  */
2342 /*  begin if character(tail)=qi(hyphen_char[main_f]) then if link(cur_q)>null
2343 then */
2344   {
2345     if (mem[tail].hh.b1 == hyphen_char[main_f])
2346 /*    if (mem[cur_q].hh.v.RH > 0) */  /* 94/Mar/22 */
2347     if (mem[cur_q].hh.v.RH != 0) /* BUG FIX ???????????? */
2348     ins_disc = true; 
2349     if (ligature_present)
2350     {
2351       main_p = new_ligature(main_f, cur_l, mem[cur_q].hh.v.RH); 
2352       if (lft_hit)
2353       {
2354         mem[main_p].hh.b1 = 2; 
2355         lft_hit = false; 
2356       } 
2357 /*      if (false)
2358       if (lig_stack == 0){
2359         incr(mem[main_p].hh.b1); 
2360         rt_hit = false; 
2361       } */              /* removed 99/Jan/6 */
2362     mem[cur_q].hh.v.RH = main_p; 
2363       tail = main_p; 
2364       ligature_present = false; 
2365     } 
2366     if (ins_disc)
2367     {
2368       ins_disc = false; 
2369       if (mode > 0)
2370       {
2371         mem[tail].hh.v.RH = new_disc(); 
2372         tail = mem[tail].hh.v.RH; 
2373       } 
2374     } 
2375   } 
2376   cur_q = tail; 
2377   cur_l = main_j.b3; 
2378   main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
2379   ligature_present = true; 
2380       } 
2381       break; 
2382       default: 
2383       {
2384   cur_l = main_j.b3; 
2385   ligature_present = true; 
2386   if (lig_stack == 0)
2387   goto lab80; 
2388   else goto lab91; 
2389       } 
2390       break; 
2391     } 
2392     if (main_j.b2 > 4)
2393     if (main_j.b2 != 7)
2394     goto lab80; 
2395     if (cur_l < 256)
2396     goto lab110; 
2397     main_k = bchar_label[main_f]; 
2398     goto lab111; 
2399   } 
2400   if (main_j.b0 == 0)
2401   incr(main_k); 
2402   else {
2403     if (main_j.b0 >= 128)
2404     goto lab80; 
2405     main_k = main_k + main_j.b0 + 1; 
2406   } 
2407   goto lab111; 
2408
2409 /*  main_move_log */
2410 lab95: main_p = mem[lig_stack + 1].hh.v.RH; 
2411 /* if main_p>null then tail_append(main_p); l.20137 */
2412 /*  if (main_p > 0) */ /* 92/Mar/22 */
2413   if (main_p != 0)     /* BUG FIX */
2414   {
2415     mem[tail].hh.v.RH = main_p; 
2416     tail = mem[tail].hh.v.RH; 
2417   } 
2418   temp_ptr = lig_stack; 
2419   lig_stack = mem[temp_ptr].hh.v.RH; 
2420   free_node(temp_ptr, 2); 
2421   main_i = font_info[char_base[main_f]+ cur_l].qqqq; 
2422   ligature_present = true; 
2423   if (lig_stack == 0)
2424 /*   if main_p>null then goto main_loop_lookahead l.20142 */
2425 /*  if (main_p > 0) */ /* 94/Mar/2 */
2426   if (main_p != 0)   /* BUG FIX */
2427   goto lab100; 
2428   else cur_r = bchar; 
2429   else cur_r = mem[lig_stack].hh.b1; 
2430   goto lab110; 
2431
2432 /*  append_normal_space */
2433 lab120: if (eqtb[(hash_size + 794)].hh.v.RH == 0)
2434   {
2435     {
2436       main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH]; 
2437       if (main_p == 0)
2438       {
2439   main_p = new_spec(0); 
2440   main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2; 
2441   mem[main_p + 1].cint = font_info[main_k].cint; 
2442   mem[main_p + 2].cint = font_info[main_k + 1].cint; 
2443   mem[main_p + 3].cint = font_info[main_k + 2].cint; 
2444   font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p; 
2445       } 
2446     } 
2447     temp_ptr = new_glue(main_p); 
2448   } 
2449   else temp_ptr = new_param_glue(12); 
2450   mem[tail].hh.v.RH = temp_ptr; 
2451   tail = temp_ptr; 
2452   goto lab60; 
2453 } /* end of main_control */
2454 /* give_err_help etc followed here in the old tex8.c */