OSDN Git Service

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