OSDN Git Service

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