OSDN Git Service

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