1 /* Copyright 2014 Clerk Ma
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.
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.
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
23 void math_fraction (void)
29 if (incompleat_noad != 0)
31 if (c >= delimited_code)
33 scan_delimiter(garbage, false);
34 scan_delimiter(garbage, false);
37 if (c % delimited_code == 0)
38 scan_dimen(false, false, false);
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}'.");
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;
59 if (c >= delimited_code)
61 scan_delimiter(left_delimiter(incompleat_noad), false);
62 scan_delimiter(right_delimiter(incompleat_noad), false);
65 switch (c % delimited_code)
68 scan_dimen(false, false, false);
69 thickness(incompleat_noad) = cur_val;
73 thickness(incompleat_noad) = default_code;
77 thickness(incompleat_noad) = 0;
83 void math_left_right (void)
90 if ((t == right_noad) && (cur_group != math_left_group))
92 if (cur_group == math_shift_group)
94 scan_delimiter(garbage, false);
97 help1("I'm ignoring a \\right that had no matching \\left.");
109 scan_delimiter(delimiter(p), false);
113 push_math(math_left_group);
121 tail_append(new_noad());
122 type(tail) = inner_noad;
123 math_type(nucleus(tail)) = sub_mlist;
124 info(nucleus(tail)) = p;
129 void after_math (void)
149 if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
150 (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
151 (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
153 print_err("Math formula deleted: Insufficient symbol fonts");
154 help3("Sorry, but I can't typeset math unless \\textfont 2",
155 "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
156 "the \\fontdimen values needed in math symbol fonts.");
161 else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
162 (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
163 (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
165 print_err("Math formula deleted: Insufficient extension fonts");
166 help3("Sorry, but I can't typeset math unless \\textfont 3",
167 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
168 "the \\fontdimen values needed in math extension fonts.");
178 if (mode == - (integer) m)
183 if (cur_cmd != math_shift)
185 print_err("Display math should end with $$");
186 help2("The `$' that I just saw supposedly matches a previous `$$'.",
187 "So I shall assume that you typed `$$' both times.");
193 cur_style = text_style;
194 mlist_penalties = false;
196 a = hpack(link(temp_head), 0, 1);
205 if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
206 (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
207 (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
209 print_err("Math formula deleted: Insufficient symbol fonts");
210 help3("Sorry, but I can't typeset math unless \\textfont 2",
211 "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
212 "the \\fontdimen values needed in math symbol fonts.");
217 else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
218 (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
219 (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
221 print_err("Math formula deleted: Insufficient extension fonts");
222 help3("Sorry, but I can't typeset math unless \\textfont 3",
223 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
224 "the \\fontdimen values needed in math extension fonts.");
238 tail_append(new_math(math_surround, 0));
240 cur_style = text_style;
241 mlist_penalties = (mode > 0);
243 link(tail) = link(temp_head);
245 while(link(tail) != 0)
248 tail_append(new_math(math_surround, 1));
258 if (cur_cmd != math_shift)
260 print_err("Display math should end with $$");
261 help2("The `$' that I just saw supposedly matches a previous `$$'.",
262 "So I shall assume that you typed `$$' both times.");
268 cur_style = display_style;
269 mlist_penalties = false;
272 adjust_tail = adjust_head;
281 if ((a == 0) || danger)
289 q = e + math_quad(text_size);
294 if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) ||
295 (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))
297 free_node(b, box_node_size);
298 b = hpack(p, z - q, 0);
306 free_node(b, box_node_size);
315 if ((e > 0) && (d < 2 * e))
320 if (!(p >= hi_mem_min))
321 if (type(p) == glue_node)
325 tail_append(new_penalty(pre_display_penalty));
327 if ((d + s <= pre_display_size) || l)
329 g1 = above_display_skip_code;
330 g2 = below_display_skip_code;
334 g1 = above_display_short_skip_code;
335 g2 = below_display_short_skip_code;
341 tail_append(new_penalty(10000));
345 tail_append(new_param_glue(g1));
350 r = new_kern(z - w - e - d);
367 shift_amount(b) = s + d;
370 if ((a != 0) && (e == 0) && !l)
372 tail_append(new_penalty(10000));
373 shift_amount(a) = s + z - width(a);
378 if (t != adjust_head)
380 link(tail) = link(adjust_head);
384 tail_append(new_penalty(post_display_penalty));
388 tail_append(new_param_glue(g2));
391 resume_after_display();
395 void resume_after_display (void)
397 if (cur_group != math_shift_group)
399 confusion("display");
400 return; // abort_flag set
404 prev_graf = prev_graf + 3;
410 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
415 if (cur_cmd != spacer)
425 void get_r_token (void)
432 while (!(cur_tok != space_token));
434 if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))
436 print_err("Missing control sequence inserted");
437 help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
438 "I've inserted an inaccessible control sequence so that your",
439 "definition will be completed without mixing me up too badly.",
440 "You can recover graciously from this error, if you're",
441 "careful; see exercise 27.2 in The TeXbook.");
446 cur_tok = cs_token_flag + frozen_protection;
452 void trap_zero_glue (void)
454 if ((width(cur_val) == 0) && (stretch(cur_val) == 0) && (shrink(cur_val) == 0))
456 add_glue_ref(zero_glue);
457 delete_glue_ref(cur_val);
462 void do_register_command_ (small_number a)
470 if (q != tex_register)
474 if ((cur_cmd >= assign_int) && (cur_cmd <= assign_mu_glue))
477 p = cur_cmd - assign_int;
481 if (cur_cmd != tex_register)
483 print_err("You can't use `");
484 print_cmd_chr(cur_cmd, cur_chr);
485 print_string("' after ");
487 help1("I'm forgetting what you said and not changing anything.");
494 scan_eight_bit_int();
499 l = cur_val + count_base;
503 l = cur_val + scaled_base;
507 l = cur_val + skip_base;
511 l = cur_val + mu_skip_base;
517 if (q == tex_register)
518 scan_optional_equals();
520 if (scan_keyword("by"));
530 scan_dimen(false, false, false);
533 cur_val = cur_val + eqtb[l].cint;
541 q = new_spec(cur_val);
543 delete_glue_ref(cur_val);
544 width(q) = width(q) + width(r);
547 stretch_order(q) = normal;
549 if (stretch_order(q) == stretch_order(r))
550 stretch(q) = stretch(q) + stretch(r);
551 else if ((stretch_order(q) < stretch_order(r)) && (stretch(r) != 0))
553 stretch(q) = stretch(r);
554 stretch_order(q) = stretch_order(r);
558 shrink_order(q) = normal;
560 if (shrink_order(q) == shrink_order(r))
561 shrink(q) = shrink(q) + shrink(r);
562 else if ((shrink_order(q) < shrink_order(r)) && (shrink(r) != 0))
564 shrink(q) = shrink(r);
565 shrink_order(q) = shrink_order(r);
577 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); /* 2^31 - 1 */
579 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); /* 2^30 - 1 */
581 cur_val = x_over_n(eqtb[l].cint, cur_val);
589 width(r) = mult_and_add(width(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
590 stretch(r) = mult_and_add(stretch(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
591 shrink(r) = mult_and_add(shrink(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
595 width(r) = x_over_n(width(s), cur_val);
596 stretch(r) = x_over_n(stretch(s), cur_val);
597 shrink(r) = x_over_n(shrink(s), cur_val);
605 print_err("Arithmetic overflow");
606 help2("I can't carry out that multiplication or division,",
607 "since the result is out of range.");
610 delete_glue_ref(cur_val);
619 geq_word_define(l, cur_val);
621 eq_word_define(l, cur_val);
628 geq_define(l, glue_ref, cur_val);
630 eq_define(l, glue_ref, cur_val);
634 void alter_aux (void)
638 if (cur_chr != abs(mode))
640 report_illegal_case();
645 scan_optional_equals();
649 scan_dimen(false, false, false);
650 prev_depth = cur_val;
656 if ((cur_val <= 0) || (cur_val > 32767))
658 print_err("Bad space factor");
659 help1("I allow only values in the range 1..32767 here.");
663 space_factor = cur_val;
668 void alter_prev_graf (void)
672 nest[nest_ptr] = cur_list;
675 while (abs(nest[p].mode_field) != vmode)
678 scan_optional_equals();
684 print_esc("prevgraf");
685 help1("I allow only nonnegative values here.");
690 nest[p].pg_field = cur_val;
691 cur_list = nest[nest_ptr];
695 void alter_page_so_far (void)
700 scan_optional_equals();
701 scan_dimen(false, false, false);
702 page_so_far[c] = cur_val;
705 void alter_integer (void)
710 scan_optional_equals();
714 dead_cycles = cur_val;
716 insert_penalties = cur_val;
719 void alter_box_dimen (void)
725 scan_eight_bit_int();
727 scan_optional_equals();
728 scan_dimen(false, false, false);
731 mem[box(b) + c].cint = cur_val;
734 void new_font_(small_number a)
738 internal_font_number f;
741 str_number flushable_string;
751 else if (u >= single_base)
758 old_setting = selector;
759 selector = new_string;
760 print_string("FONT");
761 print(u - active_base);
762 selector = old_setting;
768 geq_define(u, set_font, 0);
770 eq_define(u, set_font, 0);
772 scan_optional_equals();
775 name_in_progress = true;
777 if (scan_keyword("at"))
779 scan_dimen(false, false, false);
782 if ((s <= 0) || (s >= 134217728L)) /* 2^27 */
784 print_err("Improper `at' size (");
786 print_string("pt), replaced by 10pt");
787 help2("I can only handle fonts at positive sizes that are",
788 "less than 2048pt, so I've changed what you said to 10pt.");
793 else if (scan_keyword("scaled"))
796 s = - (integer) cur_val;
798 if ((cur_val <= 0) || (cur_val > 32768L))
800 print_err("Illegal magnification has been changed to 1000");
801 help1("The magnification ratio must be between 1 and 32768.");
809 name_in_progress = false;
811 flushable_string = str_ptr - 1;
815 int i, k1, k2, l1, l2;
816 char *sch = log_line;
817 k1 = str_start[cur_area];
818 k2 = str_start[cur_name];
819 l1 = length(cur_area);
820 l2 = length(cur_name);
822 show_line("FONT ", 0);
824 for (i = 0; i < l1; i++)
826 *sch++ = str_pool[i + k1];
829 for (i = 0; i < l2; i++)
831 *sch++ = str_pool[i + k2];
836 show_line(log_line, 0);
839 for (f = font_base + 1; f < font_ptr; f++)
841 if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))
843 if (cur_name == flushable_string)
846 cur_name = font_name[f];
851 if (s == font_size[f])
853 if (ignore_frozen == 0 || f > frozen_font_ptr)
857 sprintf(log_line, "SKIPPING %ld ", s);
858 show_line(log_line, 0);
864 else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))
866 if (ignore_frozen == 0 || f > frozen_font_ptr)
870 sprintf(log_line, "SKIPPING %ld ", s);
871 show_line(log_line, 0);
880 show_line("READING ", 0);
882 f = read_font_info(u, cur_name, cur_area, s);
887 sprintf(log_line, "NEW FONT %d ", f);
888 show_line(log_line, 0);
892 eqtb[font_id_base + f] = eqtb[u];
897 sprintf(log_line, "ERROR: %s too large %d\n", "hash_used", t);
898 show_line(log_line, 1);
904 void new_interaction (void)
907 interaction = cur_chr;
909 if (interaction == batch_mode)
912 selector = term_only;
915 selector = selector + 2;
918 void do_assignments (void)
926 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
928 if (cur_cmd <= max_non_prefixed_command)
931 set_box_allowed = false;
933 set_box_allowed = true;
937 void open_or_close_in (void)
946 if (read_open[n] != closed)
948 (void) a_close(read_file[n]);
949 read_open[n] = closed;
954 scan_optional_equals();
956 pack_file_name(cur_name, cur_area, cur_ext);
958 if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
960 else if ((cur_ext != 785) && (name_length + 5 < PATHMAX))
962 strncpy((char *) name_of_file + name_length + 1, ".tex ", 5);
963 name_length = name_length + 4;
965 if (a_open_in(read_file[n], TEXINPUTPATH))
966 read_open[n] = just_open;
969 name_length = name_length - 4;
970 name_of_file[name_length + 1] = ' ';
972 if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
979 void issue_message (void)
986 link(garbage) = scan_toks(false, true);
987 old_setting = selector;
988 selector = new_string;
990 selector = old_setting;
997 if (term_offset + length(s) > max_print_line - 2)
999 else if ((term_offset > 0) || (file_offset > 0))
1014 use_err_help = true;
1015 else if (long_help_seen)
1016 help1("(That was another \\errmessage.)");
1019 if (interaction < error_stop_mode)
1020 long_help_seen = true;
1022 help4("This error message was generated by an \\errmessage",
1023 "command, so I can't give any explicit help.",
1024 "Pretend that you're Hercule Poirot: Examine all clues,",
1025 "and deduce the truth by order and method.");
1029 use_err_help = false;
1035 void shift_case (void)
1043 p = scan_toks(false, false);
1050 if (t < cs_token_flag + single_base)
1054 if (equiv(b + c) != 0)
1055 info(p) = t - c + equiv(b + c);
1061 begin_token_list(link(def_ref), 3);
1062 free_avail(def_ref);
1065 void show_whatever (void)
1080 scan_eight_bit_int();
1082 print_nl("> \\box");
1086 if (box(cur_val) == 0)
1087 print_string("void");
1089 show_box(box(cur_val));
1097 if (interaction == error_stop_mode)
1117 if (interaction == error_stop_mode)
1121 token_show(temp_head);
1122 flush_list(link(temp_head));
1128 end_diagnostic(true);
1131 if (selector == term_and_log)
1132 if (tracing_online <= 0)
1134 selector = term_only;
1135 print_string(" (see the transcript file)");
1136 selector = term_and_log;
1141 if (interaction < error_stop_mode)
1146 else if (tracing_online > 0)
1148 help3("This isn't an error message; I'm just \\showing something.",
1149 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1150 "\\showthe\\count10, \\showbox255, \\showlists).");
1154 help5("This isn't an error message; I'm just \\showing something.",
1155 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1156 "\\showthe\\count10, \\showbox255, \\showlists).",
1157 "And type `I\\tracingonline=1\\show...' to show boxes and",
1158 "lists on your terminal as well as in the transcript file.");
1164 void new_whatsit_(small_number s, small_number w)
1169 type(p) = whatsit_node;
1175 void new_write_whatsit_(small_number w)
1177 new_whatsit(cur_chr, w);
1179 if (w != write_node_size)
1181 scan_four_bit_int();
1189 else if (cur_val > 15)
1193 write_stream(tail) = cur_val;
1196 void do_extension (void)
1205 new_write_whatsit(open_node_size);
1206 scan_optional_equals();
1208 open_name(tail) = cur_name;
1209 open_area(tail) = cur_area;
1210 open_ext(tail) = cur_ext;
1217 new_write_whatsit(write_node_size);
1219 p = scan_toks(false, false);
1220 write_tokens(tail) = def_ref;
1226 new_write_whatsit(write_node_size);
1227 write_tokens(tail) = 0;
1233 new_whatsit(special_node, write_node_size);
1234 write_stream(tail) = 0;
1235 p = scan_toks(false, true);
1236 write_tokens(tail) = def_ref;
1240 case immediate_code:
1244 if ((cur_cmd == extension) && (cur_chr <= close_node))
1249 flush_node_list(tail);
1258 case set_language_code:
1259 if (abs(mode) != hmode)
1261 report_illegal_case();
1265 new_whatsit(language_node, small_node_size);
1270 else if (cur_val > 255)
1275 what_lang(tail) = clang;
1276 what_lhm(tail) = norm_min(left_hyphen_min);
1277 what_rhm(tail) = norm_min(right_hyphen_min);
1284 return; // abort_flag set
1290 void fix_language (void)
1293 int l; /* 95/Jan/7 */
1297 else if (language > 255)
1304 new_whatsit(language_node, small_node_size);
1305 what_lang(tail) = l;
1307 what_lhm(tail) = norm_min(left_hyphen_min);
1308 what_rhm(tail) = norm_min(right_hyphen_min);
1312 void handle_right_brace (void)
1326 print_err("Too many }'s");
1327 help2("You've closed more groups than you opened.",
1328 "Such booboos are generally harmless, so keep going.");
1333 case semi_simple_group:
1334 case math_shift_group:
1335 case math_left_group:
1336 extra_right_brace();
1343 case adjust_hbox_group:
1345 adjust_tail = adjust_head;
1369 d = split_max_depth;
1370 f = floating_penalty;
1373 p = vpackage(link(head), 0, 1, 1073741823L); /* 2^30 - 1 */
1378 tail_append(get_node(ins_node_size));
1379 type(tail) = ins_node;
1380 subtype(tail) = saved(0);
1381 height(tail) = height(p) + depth(p);
1382 ins_ptr(tail) = list_ptr(p);
1383 split_top_ptr(tail) = q;
1385 float_cost(tail) = f;
1389 tail_append(get_node(small_node_size));
1390 type(tail) = adjust_node;
1392 adjust_ptr(tail) = list_ptr(p);
1395 free_node(p, box_node_size);
1405 if ((cur_input.loc_field != 0) || ((token_type != output_text) && (token_type != backed_up)))
1407 print_err("Unbalanced output routine");
1408 help2("Your sneaky output routine has problematic {'s and/or }'s.",
1409 "I can't handle that very well; good luck.");
1416 while (!(cur_input.loc_field == 0));
1422 output_active = false;
1423 insert_penalties = 0;
1427 print_err("Output routine didn't use all of ");
1430 help3("Your \\output commands should empty \\box255,",
1431 "e.g., by saying `\\shipout\\box255'.",
1432 "Proceed; I'll discard its present contents.");
1438 link(page_tail) = link(head);
1442 if (link(page_head) != 0)
1444 if (link(contrib_head) == 0)
1445 nest[0].tail_field = page_tail;
1447 link(page_tail) = link(contrib_head);
1448 link(contrib_head) = link(page_head);
1449 link(page_head) = 0;
1450 page_tail = page_head;
1458 build_discretionary();
1464 cur_tok = cs_token_flag + frozen_cr;
1465 print_err("Missing ");
1467 print_string("inserted");
1468 help1("I'm guessing that you meant to end an alignment here.");
1473 case no_align_group:
1485 save_ptr = save_ptr - 2;
1486 p = vpackage(link(head), saved(1), saved(0), 1073741823L); /* 2^30 - 1 */
1488 tail_append(new_noad());
1489 type(tail) = vcenter_noad;
1490 math_type(nucleus(tail)) = sub_box;
1491 info(nucleus(tail)) = p;
1495 case math_choice_group:
1503 math_type(saved(0)) = sub_mlist;
1509 if (type(p) == ord_noad)
1511 if (math_type(subscr(p)) == 0)
1512 if (math_type(supscr(p)) == 0)
1514 mem[saved(0)].hh = mem[nucleus(p)].hh;
1515 free_node(p, noad_size);
1518 else if (type(p) == accent_noad)
1519 if (saved(0) == nucleus(tail))
1520 if (type(tail) == ord_noad)
1524 while(link(q) != tail)
1528 free_node(tail, noad_size);
1535 confusion("rightbrace");
1536 return; // abort_flag set
1542 void main_control (void)
1545 integer bSuppress; /* 199/Jan/5 */
1548 begin_token_list(every_job, every_job_text);
1551 get_x_token(); /* big_switch */
1555 if (OK_to_interrupt)
1561 pause_for_instructions();
1572 if (tracing_commands > 0)
1575 /* the big switch --- don't bother to test abort_flag ??? */
1576 switch(abs(mode) + cur_cmd)
1578 case hmode + letter:
1579 case hmode + other_char:
1580 case hmode + char_given:
1584 case hmode + char_num:
1592 case hmode + no_boundary:
1596 if ((cur_cmd == letter) || (cur_cmd == other_char) ||
1597 (cur_cmd == char_given) || (cur_cmd == char_num))
1598 cancel_boundary = true;
1603 case hmode + spacer:
1604 if (space_factor == 1000)
1610 case hmode + ex_space:
1611 case mmode + ex_space:
1615 case any_mode(relax):
1616 case vmode + spacer:
1617 case mmode + spacer:
1618 case mmode + no_boundary:
1622 case any_mode(ignore_spaces):
1628 while(!(cur_cmd != spacer));
1641 case any_mode(last_item):
1642 case vmode + vadjust:
1643 case vmode + ital_corr:
1644 case non_math(eq_no):
1645 case any_mode(mac_param):
1646 report_illegal_case();
1649 case non_math(sup_mark):
1650 case non_math(sub_mark):
1651 case non_math(math_char_num):
1652 case non_math(math_given):
1653 case non_math(math_comp):
1654 case non_math(delim_num):
1655 case non_math(left_right):
1656 case non_math(above):
1657 case non_math(radical):
1658 case non_math(math_style):
1659 case non_math(math_choice):
1660 case non_math(vcenter):
1661 case non_math(non_script):
1662 case non_math(mkern):
1663 case non_math(limit_switch):
1664 case non_math(mskip):
1665 case non_math(math_accent):
1667 case mmode + par_end:
1670 case mmode + un_vbox:
1671 case mmode + valign:
1673 insert_dollar_sign();
1680 tail_append(scan_rule_spec());
1682 if (abs(mode) == vmode)
1683 prev_depth = ignore_depth;
1684 else if (abs(mode) == hmode)
1685 space_factor = 1000;
1696 case any_mode(kern):
1701 case non_math(left_brace):
1702 new_save_level(simple_group);
1705 case any_mode(begin_group):
1706 new_save_level(semi_simple_group);
1709 case any_mode(end_group):
1710 if (cur_group == semi_simple_group)
1716 case any_mode(right_brace):
1717 handle_right_brace();
1725 scan_dimen(false, false, false);
1730 scan_box(- (integer) cur_val);
1734 case any_mode(leader_ship):
1735 scan_box(leader_flag - a_leaders + cur_chr);
1738 case any_mode(make_box):
1742 case vmode + start_par:
1743 new_graf(cur_chr > 0);
1746 case vmode + letter:
1747 case vmode + other_char:
1748 case vmode + char_num:
1749 case vmode + char_given:
1750 case vmode + math_shift:
1751 case vmode + un_hbox:
1753 case vmode + accent:
1754 case vmode + discretionary:
1756 case vmode + valign:
1757 case vmode + ex_space:
1758 case vmode + no_boundary:
1765 case hmode + start_par:
1766 case mmode + start_par:
1770 case vmode + par_end:
1779 case hmode + par_end:
1781 if (align_state < 0)
1794 case hmode + un_vbox:
1795 case hmode + halign:
1799 case any_mode(insert):
1800 case hmode + vadjust:
1801 case mmode + vadjust:
1802 begin_insert_or_adjust();
1805 case any_mode(mark):
1809 case any_mode(break_penalty):
1813 case any_mode(remove_item):
1817 case vmode + un_vbox:
1818 case hmode + un_hbox:
1819 case mmode + un_hbox:
1823 case hmode + ital_corr:
1824 append_italic_correction();
1827 case mmode + ital_corr:
1828 tail_append(new_kern(0));
1831 case hmode + discretionary:
1832 case mmode + discretionary:
1833 append_discretionary();
1836 case hmode + accent:
1840 case any_mode(car_ret):
1841 case any_mode(tab_mark):
1845 case any_mode(no_align):
1849 case any_mode(omit):
1853 case vmode + halign:
1854 case hmode + valign:
1858 case mmode + halign:
1860 if (cur_group == math_shift_group)
1871 case any_mode(end_cs_name):
1875 case hmode + math_shift:
1881 if (cur_group == math_shift_group)
1887 case mmode + left_brace:
1889 tail_append(new_noad());
1891 scan_math(nucleus(tail));
1895 case mmode + letter:
1896 case mmode + other_char:
1897 case mmode + char_given:
1898 set_math_char(math_code(cur_chr));
1901 case mmode + char_num:
1905 set_math_char(math_code(cur_chr));
1909 case mmode + math_char_num:
1911 scan_fifteen_bit_int();
1912 set_math_char(cur_val);
1916 case mmode + math_given:
1917 set_math_char(cur_chr);
1920 case mmode + delim_num:
1922 scan_twenty_seven_bit_int();
1923 set_math_char(cur_val / 4096);
1927 case mmode + math_comp:
1929 tail_append(new_noad());
1930 type(tail) = cur_chr;
1931 scan_math(nucleus(tail));
1935 case mmode + limit_switch:
1936 math_limit_switch();
1939 case mmode + radical:
1943 case mmode + accent:
1944 case mmode + math_accent:
1948 case mmode + vcenter:
1950 scan_spec(vcenter_group, false);
1954 prev_depth = ignore_depth;
1956 if (every_vbox != 0)
1957 begin_token_list(every_vbox, every_vbox_text);
1961 case mmode + math_style:
1962 tail_append(new_style(cur_chr));
1965 case mmode + non_script:
1967 tail_append(new_glue(0));
1968 subtype(tail) = cond_math_glue;
1972 case mmode + math_choice:
1976 case mmode + sub_mark:
1977 case mmode + sup_mark:
1985 case mmode + left_right:
1989 case mmode + math_shift:
1990 if (cur_group == math_shift_group)
1996 case any_mode(toks_register):
1997 case any_mode(assign_toks):
1998 case any_mode(assign_int):
1999 case any_mode(assign_dimen):
2000 case any_mode(assign_glue):
2001 case any_mode(assign_mu_glue):
2002 case any_mode(assign_font_dimen):
2003 case any_mode(assign_font_int):
2004 case any_mode(set_aux):
2005 case any_mode(set_prev_graf):
2006 case any_mode(set_page_dimen):
2007 case any_mode(set_page_int):
2008 case any_mode(set_box_dimen):
2009 case any_mode(set_shape):
2010 case any_mode(def_code):
2011 case any_mode(def_family):
2012 case any_mode(set_font):
2013 case any_mode(def_font):
2014 case any_mode(tex_register):
2015 case any_mode(advance):
2016 case any_mode(multiply):
2017 case any_mode(divide):
2018 case any_mode(prefix):
2020 case any_mode(shorthand_def):
2021 case any_mode(read_to_cs):
2023 case any_mode(set_box):
2024 case any_mode(hyph_data):
2025 case any_mode(set_interaction):
2029 case any_mode(after_assignment):
2032 after_token = cur_tok;
2036 case any_mode(after_group):
2039 save_for_after(cur_tok);
2043 case any_mode(in_stream):
2047 case any_mode(message):
2051 case any_mode(case_shift):
2055 case any_mode(xray):
2059 case any_mode(extension):
2062 } /* end of big switch */
2063 goto lab60; /* main_loop */
2066 adjust_space_factor();
2068 bchar = font_bchar[main_f];
2069 false_bchar = font_false_bchar[main_f];
2072 if (language != clang)
2078 lig_stack = get_avail();
2081 avail = mem[lig_stack].hh.v.RH;
2082 mem[lig_stack].hh.v.RH = 0;
2089 font(lig_stack) = main_f;
2091 character(lig_stack) = cur_l;
2094 if (cancel_boundary)
2096 cancel_boundary = false;
2097 main_k = non_address;
2100 main_k = bchar_label[main_f];
2102 if (main_k == non_address)
2112 /* main_loop_move */
2118 cur_l = character(lig_stack);
2121 if (!(lig_stack >= hi_mem_min))
2125 if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f]))
2127 char_warning(main_f, cur_chr);
2128 free_avail(lig_stack);
2132 main_i = char_info(main_f, cur_l);
2134 if (!(main_i.b0 > 0))
2136 char_warning(main_f, cur_chr);
2137 free_avail(lig_stack);
2141 link(tail) = lig_stack;
2145 /* main_loop_lookahead */
2149 if (cur_cmd == letter)
2151 if (cur_cmd == other_char)
2153 if (cur_cmd == char_given)
2158 if (cur_cmd == letter)
2160 if (cur_cmd == other_char)
2162 if (cur_cmd == char_given)
2165 if (cur_cmd == char_num)
2172 if (cur_cmd == no_boundary)
2180 adjust_space_factor();
2186 lig_stack = get_avail();
2189 avail = mem[lig_stack].hh.v.RH;
2190 mem[lig_stack].hh.v.RH = 0;
2197 font(lig_stack) = main_f;
2199 character(lig_stack) = cur_r;
2201 if (cur_r == false_bchar)
2204 // main_lig_loop:@<If there's a ligature/kern command relevant to |cur_l| and
2205 // |cur_r|, adjust the text appropriately; exit to |main_loop_wrapup|@>;
2208 if (char_tag(main_i) != lig_tag)
2211 if (cur_r == non_char)
2214 main_k = lig_kern_start(main_f, main_i);
2215 main_j = font_info[main_k].qqqq;
2217 if (skip_byte(main_j) <= stop_flag)
2220 main_k = lig_kern_restart(main_f, main_j);
2222 /* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */
2224 main_j = font_info[main_k].qqqq;
2227 /* provide for suppression of f-ligatures 99/Jan/5 */
2230 if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag)
2236 if (next_char(main_j) == cur_r && bSuppress == 0) /* 99/Jan/5 */
2237 if (skip_byte(main_j) <= stop_flag)
2239 if (op_byte(main_j) >= kern_flag)
2242 tail_append(new_kern(char_kern(main_f, main_j)));
2246 if (cur_l == non_char)
2248 else if (lig_stack == 0)
2254 pause_for_instructions();
2258 switch (op_byte(main_j))
2263 cur_l = rem_byte(main_j);
2264 main_i = char_info(main_f, cur_l);
2265 ligature_present = true;
2271 cur_r = rem_byte(main_j);
2275 lig_stack = new_lig_item(cur_r);
2278 else if ((lig_stack >= hi_mem_min))
2281 lig_stack = new_lig_item(cur_r);
2282 lig_ptr(lig_stack) = main_p;
2285 character(lig_stack) = cur_r;
2290 cur_r = rem_byte(main_j);
2292 lig_stack = new_lig_item(cur_r);
2293 link(lig_stack) = main_p;
2301 cur_l = rem_byte(main_j);
2302 main_i = char_info(main_f, cur_l);
2303 ligature_present = true;
2308 cur_l = rem_byte(main_j);
2309 ligature_present = true;
2319 if (op_byte(main_j) > 4)
2320 if (op_byte(main_j) != 7)
2323 if (cur_l < non_char)
2326 main_k = bchar_label[main_f];
2330 if (skip_byte(main_j) == 0)
2334 if (skip_byte(main_j) >= stop_flag)
2337 main_k = main_k + skip_byte(main_j) + 1;
2344 main_p = lig_ptr(lig_stack);
2346 if (main_p != 0) /* BUG FIX */
2347 tail_append(main_p);
2349 temp_ptr = lig_stack;
2350 lig_stack = link(temp_ptr);
2351 free_node(temp_ptr, small_node_size);
2352 main_i = char_info(main_f, cur_l);
2353 ligature_present = true;
2356 if (main_p != 0) /* BUG FIX */
2361 cur_r = character(lig_stack);
2365 /* append_normal_space */
2367 if (space_skip == 0)
2370 main_p = font_glue[cur_font];
2374 main_p = new_spec(zero_glue);
2375 main_k = param_base[cur_font] + space_code;
2376 width(main_p) = font_info[main_k].cint;
2377 stretch(main_p) = font_info[main_k + 1].cint;
2378 shrink(main_p) = font_info[main_k + 2].cint;
2379 font_glue[cur_font] = main_p;
2382 temp_ptr = new_glue(main_p);
2385 temp_ptr = new_param_glue(space_skip_code);
2387 link(tail) = temp_ptr;
2391 /* give_err_help etc followed here in the old tex8.c */