-/* Copyright 2014 Clerk Ma
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA. */
-
-#define EXTERN extern
-
-#include "texd.h"
-
-/* sec 1181 */
-void math_fraction (void)
-{
- small_number c;
-
- c = cur_chr;
-
- if (incompleat_noad != 0)
- {
- if (c >= delimited_code)
- {
- scan_delimiter(garbage, false);
- scan_delimiter(garbage, false);
- }
-
- if (c % delimited_code == 0)
- scan_dimen(false, false, false);
-
- print_err("Ambiguous; you need another { and }");
- help3("I'm ignoring this fraction specification, since I don't",
- "know whether a construction like `x \\over y \\over z'",
- "means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");
- error();
- }
- else
- {
- incompleat_noad = get_node(fraction_noad_size);
- type(incompleat_noad) = fraction_noad;
- subtype(incompleat_noad) = normal;
- math_type(numerator(incompleat_noad)) = sub_mlist;
- info(numerator(incompleat_noad)) = link(head);
- mem[denominator(incompleat_noad)].hh = empty_field;
- mem[left_delimiter(incompleat_noad)].qqqq = null_delimiter;
- mem[right_delimiter(incompleat_noad)].qqqq = null_delimiter;
- link(head) = 0;
- tail = head;
-
- if (c >= delimited_code)
- {
- scan_delimiter(left_delimiter(incompleat_noad), false);
- scan_delimiter(right_delimiter(incompleat_noad), false);
- }
-
- switch (c % delimited_code)
- {
- case above_code:
- scan_dimen(false, false, false);
- thickness(incompleat_noad) = cur_val;
- break;
-
- case over_code:
- thickness(incompleat_noad) = default_code;
- break;
-
- case atop_code:
- thickness(incompleat_noad) = 0;
- break;
- }
- }
-}
-/* sec 1191 */
-void math_left_right (void)
-{
- small_number t;
- pointer p;
-
- t = cur_chr;
-
- if ((t == right_noad) && (cur_group != math_left_group))
- {
- if (cur_group == math_shift_group)
- {
- scan_delimiter(garbage, false);
- print_err("Extra ");
- print_esc("right");
- help1("I'm ignoring a \\right that had no matching \\left.");
- error();
- }
- else
- off_save();
- }
- else
- {
- p = new_noad();
- type(p) = t;
- scan_delimiter(delimiter(p), false);
-
- if (t == left_noad)
- {
- push_math(math_left_group);
- link(tail) = p;
- tail = p;
- }
- else
- {
- p = fin_mlist(p);
- unsave();
- tail_append(new_noad());
- type(tail) = inner_noad;
- math_type(nucleus(tail)) = sub_mlist;
- info(nucleus(tail)) = p;
- }
- }
-}
-/* sec 1194 */
-void after_math (void)
-{
- boolean l;
- boolean danger;
- integer m;
- pointer p;
- pointer a;
- pointer b;
- scaled w;
- scaled z;
- scaled e;
- scaled q;
- scaled d;
- scaled s;
- small_number g1, g2;
- pointer r;
- pointer t;
-
- danger = false;
-
- if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
- (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
- (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
- {
- print_err("Math formula deleted: Insufficient symbol fonts");
- help3("Sorry, but I can't typeset math unless \\textfont 2",
- "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
- "the \\fontdimen values needed in math symbol fonts.");
- error();
- flush_math();
- danger = true;
- }
- else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
- (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
- (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
- {
- print_err("Math formula deleted: Insufficient extension fonts");
- help3("Sorry, but I can't typeset math unless \\textfont 3",
- "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
- "the \\fontdimen values needed in math extension fonts.");
- error();
- flush_math();
- danger = true;
- }
-
- m = mode;
- l = false;
- p = fin_mlist(0);
-
- if (mode == -m)
- {
- {
- get_x_token();
-
- if (cur_cmd != math_shift)
- {
- print_err("Display math should end with $$");
- help2("The `$' that I just saw supposedly matches a previous `$$'.",
- "So I shall assume that you typed `$$' both times.");
- back_error();
- }
- }
-
- cur_mlist = p;
- cur_style = text_style;
- mlist_penalties = false;
- mlist_to_hlist();
- a = hpack(link(temp_head), 0, 1);
- unsave();
- decr(save_ptr);
-
- if (saved(0) == 1)
- l = true;
-
- danger = false;
-
- if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||
- (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||
- (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))
- {
- print_err("Math formula deleted: Insufficient symbol fonts");
- help3("Sorry, but I can't typeset math unless \\textfont 2",
- "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
- "the \\fontdimen values needed in math symbol fonts.");
- error();
- flush_math();
- danger = true;
- }
- else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||
- (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||
- (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))
- {
- print_err("Math formula deleted: Insufficient extension fonts");
- help3("Sorry, but I can't typeset math unless \\textfont 3",
- "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
- "the \\fontdimen values needed in math extension fonts.");
- error();
- flush_math();
- danger = true;
- }
-
- m = mode;
- p = fin_mlist(0);
- }
- else
- a = 0;
-
- if (m < 0)
- {
- tail_append(new_math(math_surround, 0));
- cur_mlist = p;
- cur_style = text_style;
- mlist_penalties = (mode > 0);
- mlist_to_hlist();
- link(tail) = link(temp_head);
-
- while (link(tail) != 0)
- tail = link(tail);
-
- tail_append(new_math(math_surround, 1));
- space_factor = 1000;
- unsave();
- }
- else
- {
- if (a == 0)
- {
- get_x_token();
-
- if (cur_cmd != math_shift)
- {
- print_err("Display math should end with $$");
- help2("The `$' that I just saw supposedly matches a previous `$$'.",
- "So I shall assume that you typed `$$' both times.");
- back_error();
- }
- }
-
- cur_mlist = p;
- cur_style = display_style;
- mlist_penalties = false;
- mlist_to_hlist();
- p = link(temp_head);
- adjust_tail = adjust_head;
- b = hpack(p, 0, 1);
- p = list_ptr(b);
- t = adjust_tail;
- adjust_tail = 0;
- w = width(b);
- z = display_width;
- s = display_indent;
-
- if ((a == 0) || danger)
- {
- e = 0;
- q = 0;
- }
- else
- {
- e = width(a);
- q = e + math_quad(text_size);
- }
-
- if (w + q > z)
- {
- if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) ||
- (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))
- {
- free_node(b, box_node_size);
- b = hpack(p, z - q, 0);
- }
- else
- {
- e = 0;
-
- if (w > z)
- {
- free_node(b, box_node_size);
- b = hpack(p, z, 0);
- }
- }
- w = width(b);
- }
-
- d = half(z - w);
-
- if ((e > 0) && (d < 2 * e))
- {
- d = half(z - w - e);
-
- if (p != 0)
- if (!is_char_node(p))
- if (type(p) == glue_node)
- d = 0;
- }
-
- tail_append(new_penalty(pre_display_penalty));
-
- if ((d + s <= pre_display_size) || l)
- {
- g1 = above_display_skip_code;
- g2 = below_display_skip_code;
- }
- else
- {
- g1 = above_display_short_skip_code;
- g2 = below_display_short_skip_code;
- }
- if (l && (e == 0))
- {
- shift_amount(a) = s;
- append_to_vlist(a);
- tail_append(new_penalty(10000));
- }
- else
- {
- tail_append(new_param_glue(g1));
- }
-
- if (e != 0)
- {
- r = new_kern(z - w - e - d);
-
- if (l)
- {
- link(a) = r;
- link(r) = b;
- b = a;
- d = 0;
- }
- else
- {
- link(b) = r;
- link(r) = a;
- }
- b = hpack(b, 0, 1);
- }
-
- shift_amount(b) = s + d;
- append_to_vlist(b);
-
- if ((a != 0) && (e == 0) && !l)
- {
- tail_append(new_penalty(10000));
- shift_amount(a) = s + z - width(a);
- append_to_vlist(a);
- g2 = 0;
- }
-
- if (t != adjust_head)
- {
- link(tail) = link(adjust_head);
- tail = t;
- }
-
- tail_append(new_penalty(post_display_penalty));
-
- if (g2 > 0)
- {
- tail_append(new_param_glue(g2));
- }
-
- resume_after_display();
- }
-}
-/* sec 1200 */
-void resume_after_display (void)
-{
- if (cur_group != math_shift_group)
- {
- confusion("display");
- return;
- }
-
- unsave();
- prev_graf = prev_graf + 3;
- push_nest();
- mode = hmode;
- space_factor = 1000;
- set_cur_lang();
- clang = cur_lang;
- prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
-
- {
- get_x_token();
-
- if (cur_cmd != spacer)
- back_input();
- }
-
- if (nest_ptr == 1)
- build_page();
-}
-/* sec 1215 */
-void get_r_token (void)
-{
-lab20:
- do
- {
- get_token();
- }
- while (!(cur_tok != space_token));
-
- if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))
- {
- print_err("Missing control sequence inserted");
- help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
- "I've inserted an inaccessible control sequence so that your",
- "definition will be completed without mixing me up too badly.",
- "You can recover graciously from this error, if you're",
- "careful; see exercise 27.2 in The TeXbook.");
-
- if (cur_cs == 0)
- back_input();
-
- cur_tok = cs_token_flag + frozen_protection;
- ins_error();
- goto lab20;
- }
-}
-/* sec 1229 */
-void trap_zero_glue (void)
-{
- if ((width(cur_val) == 0) && (stretch(cur_val) == 0) && (shrink(cur_val) == 0))
- {
- add_glue_ref(zero_glue);
- delete_glue_ref(cur_val);
- cur_val = 0;
- }
-}
-/* sec 1236 */
-void do_register_command_ (small_number a)
-{
- pointer l, q, r, s;
- char p;
-
- q = cur_cmd;
-
- {
- if (q != tex_register)
- {
- get_x_token();
-
- if ((cur_cmd >= assign_int) && (cur_cmd <= assign_mu_glue))
- {
- l = cur_chr;
- p = cur_cmd - assign_int;
- goto lab40;
- }
-
- if (cur_cmd != tex_register)
- {
- print_err("You can't use `");
- print_cmd_chr(cur_cmd, cur_chr);
- print_string("' after ");
- print_cmd_chr(q, 0);
- help1("I'm forgetting what you said and not changing anything.");
- error();
- return;
- }
- }
-
- p = cur_chr;
- scan_eight_bit_int();
-
- switch (p)
- {
- case int_val:
- l = cur_val + count_base;
- break;
-
- case dimen_val:
- l = cur_val + scaled_base;
- break;
-
- case glue_val:
- l = cur_val + skip_base;
- break;
-
- case mu_val:
- l = cur_val + mu_skip_base;
- break;
- }
- }
-
-lab40:
- if (q == tex_register)
- scan_optional_equals();
- else
- if (scan_keyword("by"));
-
- arith_error = false;
-
- if (q < multiply)
- if (p < glue_val)
- {
- if (p == int_val)
- scan_int();
- else
- scan_dimen(false, false, false);
-
- if (q == advance)
- cur_val = cur_val + eqtb[l].cint;
- }
- else
- {
- scan_glue(p);
-
- if (q == advance)
- {
- q = new_spec(cur_val);
- r = equiv(l);
- delete_glue_ref(cur_val);
- width(q) = width(q) + width(r);
-
- if (stretch(q) == 0)
- stretch_order(q) = normal;
-
- if (stretch_order(q) == stretch_order(r))
- stretch(q) = stretch(q) + stretch(r);
- else if ((stretch_order(q) < stretch_order(r)) && (stretch(r) != 0))
- {
- stretch(q) = stretch(r);
- stretch_order(q) = stretch_order(r);
- }
-
- if (shrink(q) == 0)
- shrink_order(q) = normal;
-
- if (shrink_order(q) == shrink_order(r))
- shrink(q) = shrink(q) + shrink(r);
- else if ((shrink_order(q) < shrink_order(r)) && (shrink(r) != 0))
- {
- shrink(q) = shrink(r);
- shrink_order(q) = shrink_order(r);
- }
- cur_val = q;
- }
- }
- else
- {
- scan_int();
-
- if (p < glue_val)
- if (q == multiply)
- if (p == int_val)
- cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); /* 2^31 - 1 */
- else
- cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); /* 2^30 - 1 */
- else
- cur_val = x_over_n(eqtb[l].cint, cur_val);
- else
- {
- s = equiv(l);
- r = new_spec(s);
-
- if (q == multiply)
- {
- width(r) = mult_and_add(width(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
- stretch(r) = mult_and_add(stretch(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
- shrink(r) = mult_and_add(shrink(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
- }
- else
- {
- width(r) = x_over_n(width(s), cur_val);
- stretch(r) = x_over_n(stretch(s), cur_val);
- shrink(r) = x_over_n(shrink(s), cur_val);
- }
- cur_val = r;
- }
- }
-
- if (arith_error)
- {
- print_err("Arithmetic overflow");
- help2("I can't carry out that multiplication or division,",
- "since the result is out of range.");
-
- if (p >= glue_val)
- delete_glue_ref(cur_val);
-
- error();
- return;
- }
-
- if (p < glue_val)
- word_define(l, cur_val);
- else
- {
- trap_zero_glue();
- define(l, glue_ref, cur_val);
- }
-}
-/* sec 1243 */
-void alter_aux (void)
-{
- halfword c;
-
- if (cur_chr != abs(mode))
- report_illegal_case();
- else
- {
- c = cur_chr;
- scan_optional_equals();
-
- if (c == vmode)
- {
- scan_dimen(false, false, false);
- prev_depth = cur_val;
- }
- else
- {
- scan_int();
-
- if ((cur_val <= 0) || (cur_val > 32767))
- {
- print_err("Bad space factor");
- help1("I allow only values in the range 1..32767 here.");
- int_error(cur_val);
- }
- else
- space_factor = cur_val;
- }
- }
-}
-/* sec 1244 */
-void alter_prev_graf (void)
-{
- integer p;
-
- nest[nest_ptr] = cur_list;
- p = nest_ptr;
-
- while (abs(nest[p].mode_field) != vmode)
- decr(p);
-
- scan_optional_equals();
- scan_int();
-
- if (cur_val < 0)
- {
- print_err("Bad ");
- print_esc("prevgraf");
- help1("I allow only nonnegative values here.");
- int_error(cur_val);
- }
- else
- {
- nest[p].pg_field = cur_val;
- cur_list = nest[nest_ptr];
- }
-}
-/* sec 1245 */
-void alter_page_so_far (void)
-{
- char c;
-
- c = cur_chr;
- scan_optional_equals();
- scan_dimen(false, false, false);
- page_so_far[c] = cur_val;
-}
-/* sec 1246 */
-void alter_integer (void)
-{
- char c;
-
- c = cur_chr;
- scan_optional_equals();
- scan_int();
-
- if (c == 0)
- dead_cycles = cur_val;
- else
- insert_penalties = cur_val;
-}
-/* sec 1247 */
-void alter_box_dimen (void)
-{
- small_number c;
- eight_bits b;
-
- c = cur_chr;
- scan_eight_bit_int();
- b = cur_val;
- scan_optional_equals();
- scan_dimen(false, false, false);
-
- if (box(b) != 0)
- mem[box(b) + c].cint = cur_val;
-}
-/* sec 1257 */
-void new_font_(small_number a)
-{
- pointer u;
- scaled s;
- internal_font_number f;
- str_number t;
- char old_setting;
- str_number flushable_string;
-
- if (job_name == 0)
- open_log_file();
-
- get_r_token();
- u = cur_cs;
-
- if (u >= hash_base)
- t = text(u);
- else if (u >= single_base)
- if (u == null_cs)
- t = 1213; /* FONT */
- else
- t = u - single_base;
- else
- {
- old_setting = selector;
- selector = new_string;
- print_string("FONT");
- print(u - active_base);
- selector = old_setting;
- str_room(1);
- t = make_string();
- }
-
- define(u, set_font, null_font);
- scan_optional_equals();
- scan_file_name();
-
- name_in_progress = true;
-
- if (scan_keyword("at"))
- {
- scan_dimen(false, false, false);
- s = cur_val;
-
- if ((s <= 0) || (s >= 134217728L)) /* 2^27 */
- {
- print_err("Improper `at' size (");
- print_scaled(s);
- print_string("pt), replaced by 10pt");
- help2("I can only handle fonts at positive sizes that are",
- "less than 2048pt, so I've changed what you said to 10pt.");
- error();
- s = 10 * unity;
- }
- }
- else if (scan_keyword("scaled"))
- {
- scan_int();
- s = -cur_val;
-
- if ((cur_val <= 0) || (cur_val > 32768L))
- {
- print_err("Illegal magnification has been changed to 1000");
- help1("The magnification ratio must be between 1 and 32768.");
- int_error(cur_val);
- s = -1000;
- }
- }
- else
- s = -1000;
-
- name_in_progress = false;
-
- flushable_string = str_ptr - 1;
-
- if (trace_flag)
- {
- int i, k1, k2, l1, l2;
- char *sch = log_line;
- k1 = str_start[cur_area];
- k2 = str_start[cur_name];
- l1 = length(cur_area);
- l2 = length(cur_name);
- show_char('\n');
- puts("FONT ");
-
- for (i = 0; i < l1; i++)
- {
- *sch++ = str_pool[i + k1];
- }
-
- for (i = 0; i < l2; i++)
- {
- *sch++ = str_pool[i + k2];
- }
-
- *sch++ = ' ';
- *sch++ = '\0';
- show_line(log_line, 0);
- }
-
- for (f = font_base + 1; f < font_ptr; f++)
- {
- if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))
- {
- if (cur_name == flushable_string)
- {
- flush_string();
- cur_name = font_name[f];
- }
-
- if (s > 0)
- {
- if (s == font_size[f])
- {
- if (ignore_frozen == 0 || f > frozen_font_ptr)
- {
- if (trace_flag)
- {
- sprintf(log_line, "SKIPPING %ld ", s);
- show_line(log_line, 0);
- }
- goto lab50;
- }
- }
- }
- else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))
- {
- if (ignore_frozen == 0 || f > frozen_font_ptr)
- {
- if (trace_flag)
- {
- sprintf(log_line, "SKIPPING %ld ", s);
- show_line(log_line, 0);
- }
- goto lab50;
- }
- }
- }
- }
-
- if (trace_flag)
- show_line("READING ", 0);
-
- f = read_font_info(u, cur_name, cur_area, s);
-
-lab50:
- if (trace_flag)
- {
- sprintf(log_line, "NEW FONT %d ", f);
- show_line(log_line, 0);
- }
-
- equiv(u) = f;
- eqtb[font_id_base + f] = eqtb[u];
-
-#ifdef SHORTHASH
- if (t > 65535L)
- {
- sprintf(log_line, "ERROR: %s too large %d\n", "hash_used", t);
- show_line(log_line, 1);
- }
-#endif
- font_id_text(f) = t;
-}
-/* sec 1265 */
-void new_interaction (void)
-{
- print_ln();
- interaction = cur_chr;
-
- if (interaction == batch_mode)
- selector = no_print;
- else
- selector = term_only;
-
- if (log_opened)
- selector = selector + 2;
-}
-/* sec 1270 */
-void do_assignments (void)
-{
- while (true)
- {
- do
- {
- get_x_token();
- }
- while (!((cur_cmd != spacer) && (cur_cmd != relax)));
-
- if (cur_cmd <= max_non_prefixed_command)
- return;
-
- set_box_allowed = false;
- prefixed_command();
- set_box_allowed = true;
- }
-}
-/* sec 1275 */
-void open_or_close_in (void)
-{
- char c;
- char n;
-
- c = cur_chr;
- scan_four_bit_int();
- n = cur_val;
-
- if (read_open[n] != closed)
- {
- a_close(read_file[n]);
- read_open[n] = closed;
- }
-
- if (c != 0)
- {
- scan_optional_equals();
- scan_file_name();
- pack_file_name(cur_name, cur_area, cur_ext);
-
- if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n] = 1;
- else if ((cur_ext != 785) && (name_length + 5 < file_name_size))
- {
- strncpy((char *) name_of_file + name_length + 1, ".tex ", 5);
- name_length = name_length + 4;
-
- if (a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n] = just_open;
- else
- {
- name_length = name_length - 4;
- name_of_file[name_length + 1] = ' ';
-
- if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
- read_open[n] = 1;
- }
- }
- }
-}
-/* sec 1279 */
-void issue_message (void)
-{
- char old_setting;
- char c;
- str_number s;
-
- c = cur_chr;
- link(garbage) = scan_toks(false, true);
- old_setting = selector;
- selector = new_string;
- token_show(def_ref);
- selector = old_setting;
- flush_list(def_ref);
- str_room(1);
- s = make_string();
-
- if (c == 0)
- {
- if (term_offset + length(s) > max_print_line - 2)
- print_ln();
- else if ((term_offset > 0) || (file_offset > 0))
- print_char(' ');
-
- slow_print(s);
-
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
- }
- else
- {
- print_err("");
- slow_print(s);
-
- if (err_help != 0)
- use_err_help = true;
- else if (long_help_seen)
- help1("(That was another \\errmessage.)");
- else
- {
- if (interaction < error_stop_mode)
- long_help_seen = true;
-
- help4("This error message was generated by an \\errmessage",
- "command, so I can't give any explicit help.",
- "Pretend that you're Hercule Poirot: Examine all clues,",
- "and deduce the truth by order and method.");
- }
-
- error();
- use_err_help = false;
- }
-
- flush_string();
-}
-/* sec 1288 */
-void shift_case (void)
-{
- pointer b;
- pointer p;
- halfword t;
- eight_bits c;
-
- b = cur_chr;
- p = scan_toks(false, false);
- p = link(def_ref);
-
- while (p != 0)
- {
- t = info(p);
-
- if (t < cs_token_flag + single_base)
- {
- c = t % 256;
-
- if (equiv(b + c) != 0)
- info(p) = t - c + equiv(b + c);
- }
-
- p = link(p);
- }
-
- begin_token_list(link(def_ref), 3);
- free_avail(def_ref);
-}
-/* sec 1293 */
-void show_whatever (void)
-{
- pointer p;
-
- switch (cur_chr)
- {
- case show_lists:
- {
- begin_diagnostic();
- show_activities();
- }
- break;
-
- case show_box_code:
- {
- scan_eight_bit_int();
- begin_diagnostic();
- print_nl("> \\box");
- print_int(cur_val);
- print_char('=');
-
- if (box(cur_val) == 0)
- print_string("void");
- else
- show_box(box(cur_val));
- }
- break;
-
- case show_code:
- {
- get_token();
-
- if (interaction == error_stop_mode)
- ;
-
- print_nl("> ");
-
- if (cur_cs != 0)
- {
- sprint_cs(cur_cs);
- print_char('=');
- }
-
- print_meaning();
- goto lab50;
- }
- break;
-
- default:
- {
- p = the_toks();
-
- if (interaction == error_stop_mode)
- ;
-
- print_nl("> ");
- token_show(temp_head);
- flush_list(link(temp_head));
- goto lab50;
- }
- break;
- }
-
- end_diagnostic(true);
- print_err("OK");
-
- if (selector == term_and_log)
- if (tracing_online <= 0)
- {
- selector = term_only;
- print_string(" (see the transcript file)");
- selector = term_and_log;
- }
-
-lab50:
-
- if (interaction < error_stop_mode)
- {
- help_ptr = 0;
- decr(error_count);
- }
- else if (tracing_online > 0)
- help3("This isn't an error message; I'm just \\showing something.",
- "Type `I\\show...' to show more (e.g., \\show\\cs,",
- "\\showthe\\count10, \\showbox255, \\showlists).");
- else
- help5("This isn't an error message; I'm just \\showing something.",
- "Type `I\\show...' to show more (e.g., \\show\\cs,",
- "\\showthe\\count10, \\showbox255, \\showlists).",
- "And type `I\\tracingonline=1\\show...' to show boxes and",
- "lists on your terminal as well as in the transcript file.");
-
- error();
-}
-/* sec 1349 */
-void new_whatsit_(small_number s, small_number w)
-{
- pointer p;
-
- p = get_node(w);
- type(p) = whatsit_node;
- subtype(p) = s;
- link(tail) = p;
- tail = p;
-}
-/* sec 1350 */
-void new_write_whatsit_(small_number w)
-{
- new_whatsit(cur_chr, w);
-
- if (w != write_node_size)
- {
- scan_four_bit_int();
- }
- else
- {
- scan_int();
-
- if (cur_val < 0)
- cur_val = 17;
- else if (cur_val > 15)
- cur_val = 16;
- }
-
- write_stream(tail) = cur_val;
-}
-/* sec 1348 */
-void do_extension (void)
-{
- integer k;
- pointer p;
-
- switch(cur_chr)
- {
- case open_node:
- {
- new_write_whatsit(open_node_size);
- scan_optional_equals();
- scan_file_name();
- open_name(tail) = cur_name;
- open_area(tail) = cur_area;
- open_ext(tail) = cur_ext;
- }
- break;
-
- case write_node:
- {
- k = cur_cs;
- new_write_whatsit(write_node_size);
- cur_cs = k;
- p = scan_toks(false, false);
- write_tokens(tail) = def_ref;
- }
- break;
-
- case close_node:
- {
- new_write_whatsit(write_node_size);
- write_tokens(tail) = 0;
- }
- break;
-
- case special_node:
- {
- new_whatsit(special_node, write_node_size);
- write_stream(tail) = 0;
- p = scan_toks(false, true);
- write_tokens(tail) = def_ref;
- }
- break;
-
- case immediate_code:
- {
- get_x_token();
-
- if ((cur_cmd == extension) && (cur_chr <= close_node))
- {
- p = tail;
- do_extension();
- out_what(tail);
- flush_node_list(tail);
- tail = p;
- link(p) = 0;
- }
- else
- back_input();
- }
- break;
-
- case set_language_code:
- if (abs(mode) != hmode)
- {
- report_illegal_case();
- }
- else
- {
- new_whatsit(language_node, small_node_size);
- scan_int();
-
- if (cur_val <= 0)
- clang = 0;
- else if (cur_val > 255)
- clang = 0;
- else
- clang = cur_val;
-
- what_lang(tail) = clang;
- what_lhm(tail) = norm_min(left_hyphen_min);
- what_rhm(tail) = norm_min(right_hyphen_min);
- }
- break;
-
- default:
- {
- confusion("ext1");
- return;
- }
- break;
- }
-}
-/* sec 1376 */
-void fix_language (void)
-{
-/* ASCII_code l; */
- int l;
-
- if (language <= 0)
- l = 0;
- else if (language > 255)
- l = 0;
- else
- l = language;
-
- if (l != clang)
- {
- new_whatsit(language_node, small_node_size);
- what_lang(tail) = l;
- clang = l;
- what_lhm(tail) = norm_min(left_hyphen_min);
- what_rhm(tail) = norm_min(right_hyphen_min);
- }
-}
-/* sec 1068 */
-void handle_right_brace (void)
-{
- pointer p, q;
- scaled d;
- integer f;
-
- switch(cur_group)
- {
- case simple_group:
- unsave();
- break;
-
- case bottom_level:
- {
- print_err("Too many }'s");
- help2("You've closed more groups than you opened.",
- "Such booboos are generally harmless, so keep going.");
- error();
- }
- break;
-
- case semi_simple_group:
- case math_shift_group:
- case math_left_group:
- extra_right_brace();
- break;
-
- case hbox_group:
- package(0);
- break;
-
- case adjust_hbox_group:
- {
- adjust_tail = adjust_head;
- package(0);
- }
- break;
-
- case vbox_group:
- {
- end_graf();
- package(0);
- }
- break;
-
- case vtop_group:
- {
- end_graf();
- package(vtop_code);
- }
- break;
-
- case insert_group:
- {
- end_graf();
- q = split_top_skip;
- add_glue_ref(q);
- d = split_max_depth;
- f = floating_penalty;
- unsave();
- decr(save_ptr);
- p = vpackage(link(head), 0, 1, 1073741823L); /* 2^30 - 1 */
- pop_nest();
-
- if (saved(0) < 255)
- {
- tail_append(get_node(ins_node_size));
- type(tail) = ins_node;
- subtype(tail) = saved(0);
- height(tail) = height(p) + depth(p);
- ins_ptr(tail) = list_ptr(p);
- split_top_ptr(tail) = q;
- depth(tail) = d;
- float_cost(tail) = f;
- }
- else
- {
- tail_append(get_node(small_node_size));
- type(tail) = adjust_node;
- subtype(tail) = 0;
- adjust_ptr(tail) = list_ptr(p);
- delete_glue_ref(q);
- }
- free_node(p, box_node_size);
-
- if (nest_ptr == 0)
- build_page();
- }
- break;
-
- case output_group:
- {
- if ((loc != 0) || ((token_type != output_text) && (token_type != backed_up)))
- {
- print_err("Unbalanced output routine");
- help2("Your sneaky output routine has problematic {'s and/or }'s.",
- "I can't handle that very well; good luck.");
- error();
-
- do
- {
- get_token();
- }
- while (!(loc == 0));
- }
-
- end_token_list();
- end_graf();
- unsave();
- output_active = false;
- insert_penalties = 0;
-
- if (box(255) != 0)
- {
- print_err("Output routine didn't use all of ");
- print_esc("box");
- print_int(255);
- help3("Your \\output commands should empty \\box255,",
- "e.g., by saying `\\shipout\\box255'.",
- "Proceed; I'll discard its present contents.");
- box_error(255);
- }
-
- if (tail != head)
- {
- link(page_tail) = link(head);
- page_tail = tail;
- }
-
- if (link(page_head) != 0)
- {
- if (link(contrib_head) == 0)
- nest[0].tail_field = page_tail;
-
- link(page_tail) = link(contrib_head);
- link(contrib_head) = link(page_head);
- link(page_head) = 0;
- page_tail = page_head;
- }
-
- pop_nest();
- build_page();
- }
- break;
-
- case disc_group:
- build_discretionary();
- break;
-
- case align_group:
- {
- back_input();
- cur_tok = cs_token_flag + frozen_cr;
- print_err("Missing ");
- print_esc("cr");
- print_string("inserted");
- help1("I'm guessing that you meant to end an alignment here.");
- ins_error();
- }
- break;
-
- case no_align_group:
- {
- end_graf();
- unsave();
- align_peek();
- }
- break;
-
- case vcenter_group:
- {
- end_graf();
- unsave();
- save_ptr = save_ptr - 2;
- p = vpackage(link(head), saved(1), saved(0), 1073741823L); /* 2^30 - 1 */
- pop_nest();
- tail_append(new_noad());
- type(tail) = vcenter_noad;
- math_type(nucleus(tail)) = sub_box;
- info(nucleus(tail)) = p;
- }
- break;
-
- case math_choice_group:
- build_choices();
- break;
-
- case math_group:
- {
- unsave();
- decr(save_ptr);
- math_type(saved(0)) = sub_mlist;
- p = fin_mlist(0);
- info(saved(0)) = p;
-
- if (p != 0)
- if (link(p) == 0)
- if (type(p) == ord_noad)
- {
- if (math_type(subscr(p)) == 0)
- if (math_type(supscr(p)) == 0)
- {
- mem[saved(0)].hh = mem[nucleus(p)].hh;
- free_node(p, noad_size);
- }
- }
- else if (type(p) == accent_noad)
- if (saved(0) == nucleus(tail))
- if (type(tail) == ord_noad)
- {
- q = head;
-
- while (link(q) != tail)
- q = link(q);
-
- link(q) = p;
- free_node(tail, noad_size);
- tail = p;
- }
- }
- break;
- default:
- {
- confusion("rightbrace");
- return;
- }
- break;
- }
-}
-/* sec 1030 */
-void main_control (void)
-{
- integer t;
- integer bSuppress; /* 199/Jan/5 */
-
- if (every_job != 0)
- begin_token_list(every_job, every_job_text);
-
-big_switch:
- get_x_token(); /* big_switch */
-
-reswitch:
- if (interrupt != 0)
- if (OK_to_interrupt)
- {
- back_input();
- check_interrupt();
- goto big_switch;
- }
-
-#ifdef DEBUG
- if (panicking)
- check_mem(false);
-#endif
-
- if (tracing_commands > 0)
- show_cur_cmd_chr();
-
- switch(abs(mode) + cur_cmd)
- {
- case hmode + letter:
- case hmode + other_char:
- case hmode + char_given:
- goto main_loop;
- break;
-
- case hmode + char_num:
- {
- scan_char_num();
- cur_chr = cur_val;
- goto main_loop;
- }
- break;
-
- case hmode + no_boundary:
- {
- get_x_token();
-
- if ((cur_cmd == letter) || (cur_cmd == other_char) ||
- (cur_cmd == char_given) || (cur_cmd == char_num))
- cancel_boundary = true;
- goto reswitch;
- }
- break;
-
- case hmode + spacer:
- if (space_factor == 1000)
- goto append_normal_space;
- else
- app_space();
- break;
-
- case hmode + ex_space:
- case mmode + ex_space:
- goto append_normal_space;
- break;
-
- case any_mode(relax):
- case vmode + spacer:
- case mmode + spacer:
- case mmode + no_boundary:
- ;
- break;
-
- case any_mode(ignore_spaces):
- {
- do
- {
- get_x_token();
- }
- while (!(cur_cmd != spacer));
- goto reswitch;
- }
- break;
-
- case vmode + stop:
- if (its_all_over())
- return;
- break;
-
- case vmode + vmove:
- case hmode + hmove:
- case mmode + hmove:
- case any_mode(last_item):
- case vmode + vadjust:
- case vmode + ital_corr:
- case non_math(eq_no):
- case any_mode(mac_param):
- report_illegal_case();
- break;
-
- case non_math(sup_mark):
- case non_math(sub_mark):
- case non_math(math_char_num):
- case non_math(math_given):
- case non_math(math_comp):
- case non_math(delim_num):
- case non_math(left_right):
- case non_math(above):
- case non_math(radical):
- case non_math(math_style):
- case non_math(math_choice):
- case non_math(vcenter):
- case non_math(non_script):
- case non_math(mkern):
- case non_math(limit_switch):
- case non_math(mskip):
- case non_math(math_accent):
- case mmode + endv:
- case mmode + par_end:
- case mmode + stop:
- case mmode + vskip:
- case mmode + un_vbox:
- case mmode + valign:
- case mmode + hrule:
- insert_dollar_sign();
- break;
-
- case vmode + hrule:
- case hmode + vrule:
- case mmode + vrule:
- {
- tail_append(scan_rule_spec());
-
- if (abs(mode) == vmode)
- prev_depth = ignore_depth;
- else if (abs(mode) == hmode)
- space_factor = 1000;
- }
- break;
-
- case vmode + vskip:
- case hmode + hskip:
- case mmode + hskip:
- case mmode + mskip:
- append_glue();
- break;
-
- case any_mode(kern):
- case mmode + mkern:
- append_kern();
- break;
-
- case non_math(left_brace):
- new_save_level(simple_group);
- break;
-
- case any_mode(begin_group):
- new_save_level(semi_simple_group);
- break;
-
- case any_mode(end_group):
- if (cur_group == semi_simple_group)
- unsave();
- else
- off_save();
- break;
-
- case any_mode(right_brace):
- handle_right_brace();
- break;
-
- case vmode + hmove:
- case hmode + vmove:
- case mmode + vmove:
- {
- t = cur_chr;
- scan_dimen(false, false, false);
-
- if (t == 0)
- scan_box(cur_val);
- else
- scan_box(- (integer) cur_val);
- }
- break;
-
- case any_mode(leader_ship):
- scan_box(leader_flag - a_leaders + cur_chr);
- break;
-
- case any_mode(make_box):
- begin_box(0);
- break;
-
- case vmode + start_par:
- new_graf(cur_chr > 0);
- break;
-
- case vmode + letter:
- case vmode + other_char:
- case vmode + char_num:
- case vmode + char_given:
- case vmode + math_shift:
- case vmode + un_hbox:
- case vmode + vrule:
- case vmode + accent:
- case vmode + discretionary:
- case vmode + hskip:
- case vmode + valign:
- case vmode + ex_space:
- case vmode + no_boundary:
- {
- back_input();
- new_graf(true);
- }
- break;
-
- case hmode + start_par:
- case mmode + start_par:
- indent_in_hmode();
- break;
-
- case vmode + par_end:
- {
- normal_paragraph();
-
- if (mode > 0)
- build_page();
- }
- break;
-
- case hmode + par_end:
- {
- if (align_state < 0)
- off_save();
-
- end_graf();
-
- if (mode == 1)
- build_page();
- }
- break;
-
- case hmode + stop:
- case hmode + vskip:
- case hmode + hrule:
- case hmode + un_vbox:
- case hmode + halign:
- head_for_vmode();
- break;
-
- case any_mode(insert):
- case hmode + vadjust:
- case mmode + vadjust:
- begin_insert_or_adjust();
- break;
-
- case any_mode(mark):
- make_mark();
- break;
-
- case any_mode(break_penalty):
- append_penalty();
- break;
-
- case any_mode(remove_item):
- delete_last();
- break;
-
- case vmode + un_vbox:
- case hmode + un_hbox:
- case mmode + un_hbox:
- unpackage();
- break;
-
- case hmode + ital_corr:
- append_italic_correction();
- break;
-
- case mmode + ital_corr:
- tail_append(new_kern(0));
- break;
-
- case hmode + discretionary:
- case mmode + discretionary:
- append_discretionary();
- break;
-
- case hmode + accent:
- make_accent();
- break;
-
- case any_mode(car_ret):
- case any_mode(tab_mark):
- align_error();
- break;
-
- case any_mode(no_align):
- noalign_error();
- break;
-
- case any_mode(omit):
- omit_error();
- break;
-
- case vmode + halign:
- case hmode + valign:
- init_align();
- break;
-
- case mmode + halign:
- if (privileged ())
- if (cur_group == math_shift_group)
- init_align();
- else
- off_save();
- break;
-
- case vmode + endv:
- case hmode + endv:
- do_endv();
- break;
-
- case any_mode(end_cs_name):
- cs_error();
- break;
-
- case hmode + math_shift:
- init_math();
- break;
-
- case mmode + eq_no:
- if (privileged ())
- if (cur_group == math_shift_group)
- start_eq_no();
- else
- off_save();
- break;
-
- case mmode + left_brace:
- {
- tail_append(new_noad());
- back_input();
- scan_math(nucleus(tail));
- }
- break;
-
- case mmode + letter:
- case mmode + other_char:
- case mmode + char_given:
- set_math_char(math_code(cur_chr));
- break;
-
- case mmode + char_num:
- {
- scan_char_num();
- cur_chr = cur_val;
- set_math_char(math_code(cur_chr));
- }
- break;
-
- case mmode + math_char_num:
- {
- scan_fifteen_bit_int();
- set_math_char(cur_val);
- }
- break;
-
- case mmode + math_given:
- set_math_char(cur_chr);
- break;
-
- case mmode + delim_num:
- {
- scan_twenty_seven_bit_int();
- set_math_char(cur_val / 4096);
- }
- break;
-
- case mmode + math_comp:
- {
- tail_append(new_noad());
- type(tail) = cur_chr;
- scan_math(nucleus(tail));
- }
- break;
-
- case mmode + limit_switch:
- math_limit_switch();
- break;
-
- case mmode + radical:
- math_radical();
- break;
-
- case mmode + accent:
- case mmode + math_accent:
- math_ac();
- break;
-
- case mmode + vcenter:
- {
- scan_spec(vcenter_group, false);
- normal_paragraph();
- push_nest();
- mode = -1;
- prev_depth = ignore_depth;
-
- if (every_vbox != 0)
- begin_token_list(every_vbox, every_vbox_text);
- }
- break;
-
- case mmode + math_style:
- tail_append(new_style(cur_chr));
- break;
-
- case mmode + non_script:
- {
- tail_append(new_glue(0));
- subtype(tail) = cond_math_glue;
- }
- break;
-
- case mmode + math_choice:
- append_choices();
- break;
-
- case mmode + sub_mark:
- case mmode + sup_mark:
- sub_sup();
- break;
-
- case mmode + above:
- math_fraction();
- break;
-
- case mmode + left_right:
- math_left_right();
- break;
-
- case mmode + math_shift:
- if (cur_group == math_shift_group)
- after_math();
- else
- off_save();
- break;
-
- case any_mode(toks_register):
- case any_mode(assign_toks):
- case any_mode(assign_int):
- case any_mode(assign_dimen):
- case any_mode(assign_glue):
- case any_mode(assign_mu_glue):
- case any_mode(assign_font_dimen):
- case any_mode(assign_font_int):
- case any_mode(set_aux):
- case any_mode(set_prev_graf):
- case any_mode(set_page_dimen):
- case any_mode(set_page_int):
- case any_mode(set_box_dimen):
- case any_mode(set_shape):
- case any_mode(def_code):
- case any_mode(def_family):
- case any_mode(set_font):
- case any_mode(def_font):
- case any_mode(tex_register):
- case any_mode(advance):
- case any_mode(multiply):
- case any_mode(divide):
- case any_mode(prefix):
- case any_mode(let):
- case any_mode(shorthand_def):
- case any_mode(read_to_cs):
- case any_mode(def):
- case any_mode(set_box):
- case any_mode(hyph_data):
- case any_mode(set_interaction):
- prefixed_command();
- break;
-
- case any_mode(after_assignment):
- {
- get_token();
- after_token = cur_tok;
- }
- break;
-
- case any_mode(after_group):
- {
- get_token();
- save_for_after(cur_tok);
- }
- break;
-
- case any_mode(in_stream):
- open_or_close_in();
- break;
-
- case any_mode(message):
- issue_message();
- break;
-
- case any_mode(case_shift):
- shift_case();
- break;
-
- case any_mode(xray):
- show_whatever();
- break;
-
- case any_mode(extension):
- do_extension();
- break;
- }
-
- goto big_switch;
-
-main_loop:
- adjust_space_factor();
- main_f = cur_font;
- bchar = font_bchar[main_f];
- false_bchar = font_false_bchar[main_f];
-
- if (mode > 0)
- if (language != clang)
- fix_language();
-
- fast_get_avail(lig_stack);
- font(lig_stack) = main_f;
- cur_l = cur_chr;
- character(lig_stack) = cur_l;
- cur_q = tail;
-
- if (cancel_boundary)
- {
- cancel_boundary = false;
- main_k = non_address;
- }
- else
- main_k = bchar_label[main_f];
-
- if (main_k == non_address)
- goto main_loop_move_2;
-
- cur_r = cur_l;
- cur_l = non_char;
- goto main_lig_loop_1;
-
-main_loop_wrapup:
- wrapup(rt_hit);
-
-main_loop_move:
- if (lig_stack == 0)
- goto reswitch;
-
- cur_q = tail;
- cur_l = character(lig_stack);
-
-main_loop_move_1:
- if (!is_char_node(lig_stack))
- goto main_loop_move_lig;
-
-main_loop_move_2:
- if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f]))
- {
- char_warning(main_f, cur_chr);
- free_avail(lig_stack);
- goto big_switch;
- }
-
- main_i = char_info(main_f, cur_l);
-
- if (!(main_i.b0 > 0))
- {
- char_warning(main_f, cur_chr);
- free_avail(lig_stack);
- goto big_switch;
- }
- {
- link(tail) = lig_stack;
- tail = lig_stack;
- }
-
-main_loop_lookahead:
- get_next();
-
- if (cur_cmd == letter)
- goto main_loop_lookahead_1;
- if (cur_cmd == other_char)
- goto main_loop_lookahead_1;
- if (cur_cmd == char_given)
- goto main_loop_lookahead_1;
-
- x_token();
-
- if (cur_cmd == letter)
- goto main_loop_lookahead_1;
- if (cur_cmd == other_char)
- goto main_loop_lookahead_1;
- if (cur_cmd == char_given)
- goto main_loop_lookahead_1;
-
- if (cur_cmd == char_num)
- {
- scan_char_num();
- cur_chr = cur_val;
- goto main_loop_lookahead_1;
- }
-
- if (cur_cmd == no_boundary)
- bchar = non_char;
-
- cur_r = bchar;
- lig_stack = 0;
- goto main_lig_loop;
-
-main_loop_lookahead_1:
- adjust_space_factor();
- fast_get_avail(lig_stack);
- font(lig_stack) = main_f;
- cur_r = cur_chr;
- character(lig_stack) = cur_r;
-
- if (cur_r == false_bchar)
- cur_r = non_char;
-
-main_lig_loop:
- if (char_tag(main_i) != lig_tag)
- goto main_loop_wrapup;
-
- if (cur_r == non_char)
- goto main_loop_wrapup;
-
- main_k = lig_kern_start(main_f, main_i);
- main_j = font_info[main_k].qqqq;
-
- if (skip_byte(main_j) <= stop_flag)
- goto main_lig_loop_2;
-
- main_k = lig_kern_restart(main_f, main_j);
-
-main_lig_loop_1:
- main_j = font_info[main_k].qqqq;
-
-main_lig_loop_2:
- bSuppress = 0;
-
- if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag)
- {
- if (cur_l == 'f')
- bSuppress = 1;
- }
-
- if (next_char(main_j) == cur_r && bSuppress == 0) /* 99/Jan/5 */
- if (skip_byte(main_j) <= stop_flag)
- {
- if (op_byte(main_j) >= kern_flag)
- {
- wrapup(rt_hit);
- tail_append(new_kern(char_kern(main_f, main_j)));
- goto main_loop_move;
- }
-
- if (cur_l == non_char)
- lft_hit = true;
- else if (lig_stack == 0)
- rt_hit = true;
-
- check_interrupt();
-
- switch (op_byte(main_j))
- {
- case 1:
- case 5:
- {
- cur_l = rem_byte(main_j);
- main_i = char_info(main_f, cur_l);
- ligature_present = true;
- }
- break;
- case 2:
- case 6:
- {
- cur_r = rem_byte(main_j);
-
- if (lig_stack == 0)
- {
- lig_stack = new_lig_item(cur_r);
- bchar = non_char;
- }
- else if (is_char_node(lig_stack))
- {
- main_p = lig_stack;
- lig_stack = new_lig_item(cur_r);
- lig_ptr(lig_stack) = main_p;
- }
- else
- character(lig_stack) = cur_r;
- }
- break;
- case 3:
- {
- cur_r = rem_byte(main_j);
- main_p = lig_stack;
- lig_stack = new_lig_item(cur_r);
- link(lig_stack) = main_p;
- }
- break;
- case 7:
- case 11:
- {
- wrapup(false);
- cur_q = tail;
- cur_l = rem_byte(main_j);
- main_i = char_info(main_f, cur_l);
- ligature_present = true;
- }
- break;
- default:
- {
- cur_l = rem_byte(main_j);
- ligature_present = true;
-
- if (lig_stack == 0)
- goto main_loop_wrapup;
- else
- goto main_loop_move_1;
- }
- break;
- }
-
- if (op_byte(main_j) > 4)
- if (op_byte(main_j) != 7)
- goto main_loop_wrapup;
-
- if (cur_l < non_char)
- goto main_lig_loop;
-
- main_k = bchar_label[main_f];
- goto main_lig_loop_1;
- }
-
- if (skip_byte(main_j) == 0)
- incr(main_k);
- else
- {
- if (skip_byte(main_j) >= stop_flag)
- goto main_loop_wrapup;
-
- main_k = main_k + skip_byte(main_j) + 1;
- }
-
- goto main_lig_loop_1;
-
-main_loop_move_lig:
- main_p = lig_ptr(lig_stack);
-
- if (main_p != 0) /* BUG FIX */
- tail_append(main_p);
-
- temp_ptr = lig_stack;
- lig_stack = link(temp_ptr);
- free_node(temp_ptr, small_node_size);
- main_i = char_info(main_f, cur_l);
- ligature_present = true;
-
- if (lig_stack == 0)
- if (main_p != 0) /* BUG FIX */
- goto main_loop_lookahead;
- else
- cur_r = bchar;
- else
- cur_r = character(lig_stack);
-
- goto main_lig_loop;
-
-append_normal_space:
- if (space_skip == 0)
- {
- {
- main_p = font_glue[cur_font];
-
- if (main_p == 0)
- {
- main_p = new_spec(zero_glue);
- main_k = param_base[cur_font] + space_code;
- width(main_p) = font_info[main_k].cint;
- stretch(main_p) = font_info[main_k + 1].cint;
- shrink(main_p) = font_info[main_k + 2].cint;
- font_glue[cur_font] = main_p;
- }
- }
- temp_ptr = new_glue(main_p);
- }
- else
- temp_ptr = new_param_glue(space_skip_code);
-
- link(tail) = temp_ptr;
- tail = temp_ptr;
-
- goto big_switch;
+/*\r
+ Copyright 2014 Clerk Ma\r
+\r
+ This program is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
+ 02110-1301 USA.\r
+*/\r
+\r
+#define EXTERN extern\r
+#include "yandytex.h"\r
+\r
+/* sec 1181 */\r
+void math_fraction (void)\r
+{\r
+ small_number c;\r
+\r
+ c = cur_chr;\r
+\r
+ if (incompleat_noad != 0)\r
+ {\r
+ if (c >= delimited_code)\r
+ {\r
+ scan_delimiter(garbage, false);\r
+ scan_delimiter(garbage, false);\r
+ }\r
+\r
+ if (c % delimited_code == 0)\r
+ scan_dimen(false, false, false);\r
+\r
+ print_err("Ambiguous; you need another { and }");\r
+ help3("I'm ignoring this fraction specification, since I don't",\r
+ "know whether a construction like `x \\over y \\over z'",\r
+ "means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");\r
+ error();\r
+ }\r
+ else\r
+ {\r
+ incompleat_noad = get_node(fraction_noad_size);\r
+ type(incompleat_noad) = fraction_noad;\r
+ subtype(incompleat_noad) = normal;\r
+ math_type(numerator(incompleat_noad)) = sub_mlist;\r
+ info(numerator(incompleat_noad)) = link(head);\r
+ mem[denominator(incompleat_noad)].hh = empty_field;\r
+ mem[left_delimiter(incompleat_noad)].qqqq = null_delimiter;\r
+ mem[right_delimiter(incompleat_noad)].qqqq = null_delimiter;\r
+ link(head) = 0;\r
+ tail = head;\r
+\r
+ if (c >= delimited_code)\r
+ {\r
+ scan_delimiter(left_delimiter(incompleat_noad), false);\r
+ scan_delimiter(right_delimiter(incompleat_noad), false);\r
+ }\r
+\r
+ switch (c % delimited_code)\r
+ {\r
+ case above_code:\r
+ scan_dimen(false, false, false);\r
+ thickness(incompleat_noad) = cur_val;\r
+ break;\r
+\r
+ case over_code:\r
+ thickness(incompleat_noad) = default_code;\r
+ break;\r
+\r
+ case atop_code:\r
+ thickness(incompleat_noad) = 0;\r
+ break;\r
+ }\r
+ }\r
+}\r
+/* sec 1191 */\r
+void math_left_right (void)\r
+{\r
+ small_number t;\r
+ pointer p;\r
+\r
+ t = cur_chr;\r
+\r
+ if ((t == right_noad) && (cur_group != math_left_group))\r
+ {\r
+ if (cur_group == math_shift_group)\r
+ {\r
+ scan_delimiter(garbage, false);\r
+ print_err("Extra ");\r
+ print_esc("right");\r
+ help1("I'm ignoring a \\right that had no matching \\left.");\r
+ error();\r
+ }\r
+ else\r
+ off_save();\r
+ }\r
+ else\r
+ {\r
+ p = new_noad();\r
+ type(p) = t;\r
+ scan_delimiter(delimiter(p), false);\r
+\r
+ if (t == left_noad)\r
+ {\r
+ push_math(math_left_group);\r
+ link(tail) = p;\r
+ tail = p;\r
+ }\r
+ else\r
+ {\r
+ p = fin_mlist(p);\r
+ unsave();\r
+ tail_append(new_noad());\r
+ type(tail) = inner_noad;\r
+ math_type(nucleus(tail)) = sub_mlist;\r
+ info(nucleus(tail)) = p;\r
+ }\r
+ }\r
+}\r
+/* sec 1194 */\r
+void after_math (void)\r
+{\r
+ boolean l;\r
+ boolean danger;\r
+ integer m;\r
+ pointer p;\r
+ pointer a;\r
+ pointer b;\r
+ scaled w;\r
+ scaled z;\r
+ scaled e;\r
+ scaled q;\r
+ scaled d;\r
+ scaled s;\r
+ small_number g1, g2;\r
+ pointer r;\r
+ pointer t;\r
+\r
+ danger = false;\r
+ \r
+ if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||\r
+ (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||\r
+ (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))\r
+ {\r
+ print_err("Math formula deleted: Insufficient symbol fonts");\r
+ help3("Sorry, but I can't typeset math unless \\textfont 2",\r
+ "and \\scriptfont 2 and \\scriptscriptfont 2 have all",\r
+ "the \\fontdimen values needed in math symbol fonts.");\r
+ error();\r
+ flush_math();\r
+ danger = true;\r
+ }\r
+ else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||\r
+ (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||\r
+ (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))\r
+ {\r
+ print_err("Math formula deleted: Insufficient extension fonts");\r
+ help3("Sorry, but I can't typeset math unless \\textfont 3",\r
+ "and \\scriptfont 3 and \\scriptscriptfont 3 have all",\r
+ "the \\fontdimen values needed in math extension fonts.");\r
+ error();\r
+ flush_math();\r
+ danger = true;\r
+ }\r
+\r
+ m = mode;\r
+ l = false;\r
+ p = fin_mlist(0);\r
+\r
+ if (mode == -m)\r
+ {\r
+ {\r
+ get_x_token();\r
+\r
+ if (cur_cmd != math_shift)\r
+ {\r
+ print_err("Display math should end with $$");\r
+ help2("The `$' that I just saw supposedly matches a previous `$$'.",\r
+ "So I shall assume that you typed `$$' both times.");\r
+ back_error();\r
+ }\r
+ }\r
+\r
+ cur_mlist = p;\r
+ cur_style = text_style;\r
+ mlist_penalties = false;\r
+ mlist_to_hlist();\r
+ a = hpack(link(temp_head), 0, 1);\r
+ unsave();\r
+ decr(save_ptr);\r
+\r
+ if (saved(0) == 1)\r
+ l = true;\r
+\r
+ danger = false;\r
+\r
+ if ((font_params[fam_fnt(2 + text_size)] < total_mathsy_params) ||\r
+ (font_params[fam_fnt(2 + script_size)] < total_mathsy_params) ||\r
+ (font_params[fam_fnt(2 + script_script_size)] < total_mathsy_params))\r
+ {\r
+ print_err("Math formula deleted: Insufficient symbol fonts");\r
+ help3("Sorry, but I can't typeset math unless \\textfont 2",\r
+ "and \\scriptfont 2 and \\scriptscriptfont 2 have all",\r
+ "the \\fontdimen values needed in math symbol fonts.");\r
+ error();\r
+ flush_math();\r
+ danger = true;\r
+ }\r
+ else if ((font_params[fam_fnt(3 + text_size)] < total_mathex_params) ||\r
+ (font_params[fam_fnt(3 + script_size)] < total_mathex_params) ||\r
+ (font_params[fam_fnt(3 + script_script_size)] < total_mathex_params))\r
+ {\r
+ print_err("Math formula deleted: Insufficient extension fonts");\r
+ help3("Sorry, but I can't typeset math unless \\textfont 3",\r
+ "and \\scriptfont 3 and \\scriptscriptfont 3 have all",\r
+ "the \\fontdimen values needed in math extension fonts.");\r
+ error();\r
+ flush_math();\r
+ danger = true;\r
+ }\r
+\r
+ m = mode;\r
+ p = fin_mlist(0);\r
+ }\r
+ else\r
+ a = 0;\r
+\r
+ if (m < 0)\r
+ {\r
+ tail_append(new_math(math_surround, before));\r
+ cur_mlist = p;\r
+ cur_style = text_style;\r
+ mlist_penalties = (mode > 0);\r
+ mlist_to_hlist();\r
+ link(tail) = link(temp_head);\r
+\r
+ while (link(tail) != 0)\r
+ tail = link(tail);\r
+\r
+ tail_append(new_math(math_surround, after));\r
+ space_factor = 1000;\r
+ unsave();\r
+ }\r
+ else\r
+ {\r
+ if (a == 0)\r
+ {\r
+ get_x_token();\r
+\r
+ if (cur_cmd != math_shift)\r
+ {\r
+ print_err("Display math should end with $$");\r
+ help2("The `$' that I just saw supposedly matches a previous `$$'.",\r
+ "So I shall assume that you typed `$$' both times.");\r
+ back_error();\r
+ }\r
+ }\r
+\r
+ cur_mlist = p;\r
+ cur_style = display_style;\r
+ mlist_penalties = false;\r
+ mlist_to_hlist();\r
+ p = link(temp_head);\r
+ adjust_tail = adjust_head;\r
+ b = hpack(p, 0, 1);\r
+ p = list_ptr(b);\r
+ t = adjust_tail;\r
+ adjust_tail = 0;\r
+ w = width(b);\r
+ z = display_width;\r
+ s = display_indent;\r
+\r
+ if ((a == 0) || danger)\r
+ {\r
+ e = 0;\r
+ q = 0;\r
+ }\r
+ else\r
+ {\r
+ e = width(a);\r
+ q = e + math_quad(text_size);\r
+ }\r
+\r
+ if (w + q > z)\r
+ {\r
+ if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) ||\r
+ (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))\r
+ {\r
+ free_node(b, box_node_size);\r
+ b = hpack(p, z - q, 0);\r
+ }\r
+ else\r
+ {\r
+ e = 0;\r
+\r
+ if (w > z)\r
+ {\r
+ free_node(b, box_node_size);\r
+ b = hpack(p, z, 0);\r
+ }\r
+ }\r
+ w = width(b);\r
+ }\r
+\r
+ d = half(z - w);\r
+\r
+ if ((e > 0) && (d < 2 * e))\r
+ {\r
+ d = half(z - w - e);\r
+\r
+ if (p != 0)\r
+ if (!is_char_node(p))\r
+ if (type(p) == glue_node)\r
+ d = 0;\r
+ }\r
+\r
+ tail_append(new_penalty(pre_display_penalty));\r
+\r
+ if ((d + s <= pre_display_size) || l)\r
+ {\r
+ g1 = above_display_skip_code;\r
+ g2 = below_display_skip_code;\r
+ }\r
+ else\r
+ {\r
+ g1 = above_display_short_skip_code;\r
+ g2 = below_display_short_skip_code;\r
+ }\r
+ if (l && (e == 0))\r
+ {\r
+ shift_amount(a) = s;\r
+ append_to_vlist(a);\r
+ tail_append(new_penalty(10000));\r
+ }\r
+ else\r
+ {\r
+ tail_append(new_param_glue(g1));\r
+ }\r
+\r
+ if (e != 0)\r
+ {\r
+ r = new_kern(z - w - e - d);\r
+\r
+ if (l)\r
+ {\r
+ link(a) = r;\r
+ link(r) = b;\r
+ b = a;\r
+ d = 0;\r
+ }\r
+ else\r
+ {\r
+ link(b) = r;\r
+ link(r) = a;\r
+ }\r
+ b = hpack(b, 0, 1);\r
+ }\r
+\r
+ shift_amount(b) = s + d;\r
+ append_to_vlist(b);\r
+\r
+ if ((a != 0) && (e == 0) && !l)\r
+ {\r
+ tail_append(new_penalty(10000));\r
+ shift_amount(a) = s + z - width(a);\r
+ append_to_vlist(a);\r
+ g2 = 0;\r
+ }\r
+\r
+ if (t != adjust_head)\r
+ {\r
+ link(tail) = link(adjust_head);\r
+ tail = t;\r
+ }\r
+\r
+ tail_append(new_penalty(post_display_penalty));\r
+\r
+ if (g2 > 0)\r
+ {\r
+ tail_append(new_param_glue(g2));\r
+ }\r
+\r
+ resume_after_display();\r
+ }\r
+}\r
+/* sec 1200 */\r
+void resume_after_display (void)\r
+{\r
+ if (cur_group != math_shift_group)\r
+ {\r
+ confusion("display");\r
+ return;\r
+ }\r
+\r
+ unsave();\r
+ prev_graf = prev_graf + 3;\r
+ push_nest();\r
+ mode = hmode;\r
+ space_factor = 1000;\r
+ set_cur_lang();\r
+ clang = cur_lang;\r
+ prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;\r
+\r
+ {\r
+ get_x_token();\r
+\r
+ if (cur_cmd != spacer)\r
+ back_input();\r
+ }\r
+\r
+ if (nest_ptr == 1)\r
+ build_page();\r
+}\r
+/* sec 1215 */\r
+void get_r_token (void)\r
+{\r
+restart:\r
+ do\r
+ {\r
+ get_token();\r
+ }\r
+ while (!(cur_tok != space_token));\r
+\r
+ if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))\r
+ {\r
+ print_err("Missing control sequence inserted");\r
+ help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",\r
+ "I've inserted an inaccessible control sequence so that your",\r
+ "definition will be completed without mixing me up too badly.",\r
+ "You can recover graciously from this error, if you're",\r
+ "careful; see exercise 27.2 in The TeXbook.");\r
+\r
+ if (cur_cs == 0)\r
+ back_input();\r
+\r
+ cur_tok = cs_token_flag + frozen_protection;\r
+ ins_error();\r
+ goto restart;\r
+ }\r
+}\r
+/* sec 1229 */\r
+void trap_zero_glue (void)\r
+{\r
+ if ((width(cur_val) == 0) && (stretch(cur_val) == 0) && (shrink(cur_val) == 0))\r
+ {\r
+ add_glue_ref(zero_glue);\r
+ delete_glue_ref(cur_val);\r
+ cur_val = 0;\r
+ }\r
+}\r
+/* sec 1236 */\r
+void do_register_command (small_number a)\r
+{\r
+ pointer l, q, r, s;\r
+ char p;\r
+\r
+ q = cur_cmd;\r
+\r
+ {\r
+ if (q != tex_register)\r
+ {\r
+ get_x_token();\r
+\r
+ if ((cur_cmd >= assign_int) && (cur_cmd <= assign_mu_glue))\r
+ {\r
+ l = cur_chr;\r
+ p = cur_cmd - assign_int;\r
+ goto found;\r
+ }\r
+\r
+ if (cur_cmd != tex_register)\r
+ {\r
+ print_err("You can't use `");\r
+ print_cmd_chr(cur_cmd, cur_chr);\r
+ prints("' after ");\r
+ print_cmd_chr(q, 0);\r
+ help1("I'm forgetting what you said and not changing anything.");\r
+ error();\r
+ return;\r
+ }\r
+ }\r
+\r
+ p = cur_chr;\r
+ scan_eight_bit_int();\r
+\r
+ switch (p)\r
+ {\r
+ case int_val:\r
+ l = cur_val + count_base;\r
+ break;\r
+\r
+ case dimen_val:\r
+ l = cur_val + scaled_base;\r
+ break;\r
+\r
+ case glue_val:\r
+ l = cur_val + skip_base;\r
+ break;\r
+\r
+ case mu_val:\r
+ l = cur_val + mu_skip_base;\r
+ break;\r
+ }\r
+ }\r
+\r
+found:\r
+ if (q == tex_register)\r
+ scan_optional_equals();\r
+ else if (scan_keyword("by"))\r
+ do_nothing();\r
+\r
+ arith_error = false;\r
+\r
+ if (q < multiply)\r
+ if (p < glue_val)\r
+ {\r
+ if (p == int_val)\r
+ scan_int();\r
+ else\r
+ scan_dimen(false, false, false);\r
+\r
+ if (q == advance)\r
+ cur_val = cur_val + eqtb[l].cint;\r
+ }\r
+ else\r
+ {\r
+ scan_glue(p);\r
+\r
+ if (q == advance)\r
+ {\r
+ q = new_spec(cur_val);\r
+ r = equiv(l);\r
+ delete_glue_ref(cur_val);\r
+ width(q) = width(q) + width(r);\r
+\r
+ if (stretch(q) == 0)\r
+ stretch_order(q) = normal;\r
+\r
+ if (stretch_order(q) == stretch_order(r))\r
+ stretch(q) = stretch(q) + stretch(r);\r
+ else if ((stretch_order(q) < stretch_order(r)) && (stretch(r) != 0))\r
+ {\r
+ stretch(q) = stretch(r);\r
+ stretch_order(q) = stretch_order(r);\r
+ }\r
+\r
+ if (shrink(q) == 0)\r
+ shrink_order(q) = normal;\r
+\r
+ if (shrink_order(q) == shrink_order(r))\r
+ shrink(q) = shrink(q) + shrink(r);\r
+ else if ((shrink_order(q) < shrink_order(r)) && (shrink(r) != 0))\r
+ {\r
+ shrink(q) = shrink(r);\r
+ shrink_order(q) = shrink_order(r);\r
+ }\r
+ cur_val = q;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ scan_int();\r
+\r
+ if (p < glue_val)\r
+ if (q == multiply)\r
+ if (p == int_val)\r
+ cur_val = mult_integers(eqtb[l].cint, cur_val);\r
+ else\r
+ cur_val = nx_plus_y(eqtb[l].cint, cur_val, 0);\r
+ else\r
+ cur_val = x_over_n(eqtb[l].cint, cur_val);\r
+ else\r
+ {\r
+ s = equiv(l);\r
+ r = new_spec(s);\r
+\r
+ if (q == multiply)\r
+ {\r
+ width(r) = nx_plus_y(width(s), cur_val, 0);\r
+ stretch(r) = nx_plus_y(stretch(s), cur_val, 0);\r
+ shrink(r) = nx_plus_y(shrink(s), cur_val, 0);\r
+ }\r
+ else\r
+ {\r
+ width(r) = x_over_n(width(s), cur_val);\r
+ stretch(r) = x_over_n(stretch(s), cur_val);\r
+ shrink(r) = x_over_n(shrink(s), cur_val);\r
+ }\r
+ cur_val = r;\r
+ }\r
+ }\r
+\r
+ if (arith_error)\r
+ {\r
+ print_err("Arithmetic overflow");\r
+ help2("I can't carry out that multiplication or division,",\r
+ "since the result is out of range.");\r
+\r
+ if (p >= glue_val)\r
+ delete_glue_ref(cur_val);\r
+\r
+ error();\r
+ return;\r
+ }\r
+\r
+ if (p < glue_val)\r
+ word_define(l, cur_val);\r
+ else\r
+ {\r
+ trap_zero_glue();\r
+ define(l, glue_ref, cur_val);\r
+ }\r
+}\r
+/* sec 1243 */\r
+void alter_aux (void)\r
+{\r
+ halfword c;\r
+\r
+ if (cur_chr != abs(mode))\r
+ report_illegal_case();\r
+ else\r
+ {\r
+ c = cur_chr;\r
+ scan_optional_equals();\r
+\r
+ if (c == vmode)\r
+ {\r
+ scan_dimen(false, false, false);\r
+ prev_depth = cur_val;\r
+ }\r
+ else\r
+ {\r
+ scan_int();\r
+\r
+ if ((cur_val <= 0) || (cur_val > 32767))\r
+ {\r
+ print_err("Bad space factor");\r
+ help1("I allow only values in the range 1..32767 here.");\r
+ int_error(cur_val);\r
+ }\r
+ else\r
+ space_factor = cur_val;\r
+ }\r
+ }\r
+}\r
+/* sec 1244 */\r
+void alter_prev_graf (void)\r
+{\r
+ integer p;\r
+\r
+ nest[nest_ptr] = cur_list;\r
+ p = nest_ptr;\r
+\r
+ while (abs(nest[p].mode_field) != vmode)\r
+ decr(p);\r
+\r
+ scan_optional_equals();\r
+ scan_int();\r
+\r
+ if (cur_val < 0)\r
+ {\r
+ print_err("Bad ");\r
+ print_esc("prevgraf");\r
+ help1("I allow only nonnegative values here.");\r
+ int_error(cur_val);\r
+ }\r
+ else\r
+ {\r
+ nest[p].pg_field = cur_val;\r
+ cur_list = nest[nest_ptr];\r
+ }\r
+}\r
+/* sec 1245 */\r
+void alter_page_so_far (void)\r
+{\r
+ char c;\r
+\r
+ c = cur_chr;\r
+ scan_optional_equals();\r
+ scan_dimen(false, false, false);\r
+ page_so_far[c] = cur_val;\r
+}\r
+/* sec 1246 */\r
+void alter_integer (void)\r
+{\r
+ char c;\r
+\r
+ c = cur_chr;\r
+ scan_optional_equals();\r
+ scan_int();\r
+\r
+ if (c == 0)\r
+ dead_cycles = cur_val;\r
+ else\r
+ insert_penalties = cur_val;\r
+}\r
+/* sec 1247 */\r
+void alter_box_dimen (void)\r
+{\r
+ small_number c;\r
+ eight_bits b;\r
+\r
+ c = cur_chr;\r
+ scan_eight_bit_int();\r
+ b = cur_val;\r
+ scan_optional_equals();\r
+ scan_dimen(false, false, false);\r
+\r
+ if (box(b) != 0)\r
+ mem[box(b) + c].cint = cur_val;\r
+}\r
+/* sec 1257 */\r
+void new_font (small_number a)\r
+{\r
+ pointer u;\r
+ scaled s;\r
+ internal_font_number f;\r
+ str_number t;\r
+ char old_setting;\r
+ str_number flushable_string;\r
+\r
+ if (job_name == 0)\r
+ open_log_file();\r
+\r
+ get_r_token();\r
+ u = cur_cs;\r
+\r
+ if (u >= hash_base)\r
+ t = text(u);\r
+ else if (u >= single_base)\r
+ if (u == null_cs)\r
+ t = 1213; /* FONT */\r
+ else\r
+ t = u - single_base;\r
+ else\r
+ {\r
+ old_setting = selector;\r
+ selector = new_string;\r
+ prints("FONT");\r
+ print(u - active_base);\r
+ selector = old_setting;\r
+ str_room(1);\r
+ t = make_string();\r
+ }\r
+\r
+ define(u, set_font, null_font);\r
+ scan_optional_equals();\r
+ scan_file_name();\r
+\r
+ name_in_progress = true;\r
+\r
+ if (scan_keyword("at"))\r
+ {\r
+ scan_dimen(false, false, false);\r
+ s = cur_val; \r
+\r
+ if ((s <= 0) || (s >= 134217728L)) /* 2^27 */\r
+ {\r
+ print_err("Improper `at' size (");\r
+ print_scaled(s);\r
+ prints("pt), replaced by 10pt");\r
+ help2("I can only handle fonts at positive sizes that are",\r
+ "less than 2048pt, so I've changed what you said to 10pt.");\r
+ error();\r
+ s = 10 * unity;\r
+ }\r
+ }\r
+ else if (scan_keyword("scaled"))\r
+ {\r
+ scan_int();\r
+ s = -cur_val;\r
+\r
+ if ((cur_val <= 0) || (cur_val > 32768L))\r
+ {\r
+ print_err("Illegal magnification has been changed to 1000");\r
+ help1("The magnification ratio must be between 1 and 32768.");\r
+ int_error(cur_val);\r
+ s = -1000;\r
+ }\r
+ }\r
+ else\r
+ s = -1000;\r
+\r
+ name_in_progress = false;\r
+\r
+ flushable_string = str_ptr - 1;\r
+\r
+ if (trace_flag)\r
+ {\r
+ int i, k1, k2, l1, l2;\r
+ char *sch = log_line;\r
+ k1 = str_start[cur_area];\r
+ k2 = str_start[cur_name];\r
+ l1 = length(cur_area);\r
+ l2 = length(cur_name);\r
+ wterm_cr();\r
+ puts("FONT ");\r
+\r
+ for (i = 0; i < l1; i++)\r
+ {\r
+ *sch++ = str_pool[i + k1];\r
+ }\r
+\r
+ for (i = 0; i < l2; i++)\r
+ {\r
+ *sch++ = str_pool[i + k2];\r
+ }\r
+\r
+ *sch++ = ' ';\r
+ *sch++ = '\0';\r
+ show_line(log_line, 0);\r
+ }\r
+\r
+ for (f = font_base + 1; f < font_ptr; f++)\r
+ {\r
+ if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))\r
+ {\r
+ if (cur_name == flushable_string)\r
+ {\r
+ flush_string();\r
+ cur_name = font_name[f];\r
+ }\r
+\r
+ if (s > 0)\r
+ {\r
+ if (s == font_size[f])\r
+ {\r
+ if (ignore_frozen == 0 || f > frozen_font_ptr)\r
+ {\r
+ if (trace_flag)\r
+ printf("SKIPPING %lld ", s);\r
+\r
+ goto common_ending;\r
+ }\r
+ }\r
+ }\r
+ else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))\r
+ {\r
+ if (ignore_frozen == 0 || f > frozen_font_ptr)\r
+ {\r
+ if (trace_flag)\r
+ printf("SKIPPING %lld ", s);\r
+ goto common_ending;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (trace_flag)\r
+ show_line("READING ", 0);\r
+\r
+ f = read_font_info(u, cur_name, cur_area, s); \r
+\r
+common_ending:\r
+ if (trace_flag)\r
+ printf("NEW FONT %lld ", f);\r
+\r
+ equiv(u) = f;\r
+ eqtb[font_id_base + f] = eqtb[u];\r
+ font_id_text(f) = t;\r
+}\r
+/* sec 1265 */\r
+void new_interaction (void)\r
+{\r
+ print_ln();\r
+ interaction = cur_chr;\r
+\r
+ if (interaction == batch_mode)\r
+ selector = no_print;\r
+ else\r
+ selector = term_only;\r
+\r
+ if (log_opened)\r
+ selector = selector + 2;\r
+}\r
+/* sec 1270 */\r
+void do_assignments (void)\r
+{\r
+ while (true)\r
+ {\r
+ do\r
+ {\r
+ get_x_token();\r
+ }\r
+ while (!((cur_cmd != spacer) && (cur_cmd != relax)));\r
+\r
+ if (cur_cmd <= max_non_prefixed_command)\r
+ return;\r
+\r
+ set_box_allowed = false;\r
+ prefixed_command();\r
+ set_box_allowed = true;\r
+ }\r
+}\r
+/* sec 1275 */\r
+void open_or_close_in (void)\r
+{\r
+ char c;\r
+ char n;\r
+\r
+ c = cur_chr;\r
+ scan_four_bit_int();\r
+ n = cur_val;\r
+\r
+ if (read_open[n] != closed)\r
+ {\r
+ a_close(read_file[n]);\r
+ read_open[n] = closed;\r
+ }\r
+\r
+ if (c != 0)\r
+ {\r
+ scan_optional_equals();\r
+ scan_file_name();\r
+ pack_file_name(cur_name, cur_area, cur_ext);\r
+\r
+ if ((cur_ext != 335) && a_open_in(read_file[n], kpse_tex_format))\r
+ read_open[n] = 1;\r
+ else if ((cur_ext != 785) && (name_length + 5 < file_name_size))\r
+ {\r
+ strncpy((char *) name_of_file + name_length + 1, ".tex ", 5);\r
+ name_length = name_length + 4;\r
+\r
+ if (a_open_in(read_file[n], kpse_tex_format))\r
+ read_open[n] = just_open;\r
+ else\r
+ {\r
+ name_length = name_length - 4;\r
+ name_of_file[name_length + 1] = ' ';\r
+\r
+ if ((cur_ext == 335) && a_open_in(read_file[n], kpse_tex_format))\r
+ read_open[n] = just_open;\r
+ }\r
+ }\r
+ }\r
+}\r
+/* sec 1279 */\r
+void issue_message (void)\r
+{\r
+ char old_setting;\r
+ char c;\r
+ str_number s;\r
+\r
+ c = cur_chr;\r
+ link(garbage) = scan_toks(false, true);\r
+ old_setting = selector;\r
+ selector = new_string;\r
+ token_show(def_ref);\r
+ selector = old_setting;\r
+ flush_list(def_ref);\r
+ str_room(1);\r
+ s = make_string();\r
+\r
+ if (c == 0)\r
+ {\r
+ if (term_offset + length(s) > max_print_line - 2)\r
+ print_ln();\r
+ else if ((term_offset > 0) || (file_offset > 0))\r
+ print_char(' ');\r
+\r
+ slow_print(s);\r
+ update_terminal();\r
+ }\r
+ else\r
+ {\r
+ print_err("");\r
+ slow_print(s);\r
+\r
+ if (err_help != 0)\r
+ use_err_help = true;\r
+ else if (long_help_seen)\r
+ help1("(That was another \\errmessage.)");\r
+ else\r
+ {\r
+ if (interaction < error_stop_mode)\r
+ long_help_seen = true;\r
+\r
+ help4("This error message was generated by an \\errmessage",\r
+ "command, so I can't give any explicit help.",\r
+ "Pretend that you're Hercule Poirot: Examine all clues,",\r
+ "and deduce the truth by order and method.");\r
+ }\r
+\r
+ error();\r
+ use_err_help = false;\r
+ }\r
+\r
+ flush_string();\r
+}\r
+/* sec 1288 */\r
+void shift_case (void)\r
+{\r
+ pointer b;\r
+ pointer p;\r
+ halfword t;\r
+ eight_bits c;\r
+\r
+ b = cur_chr;\r
+ p = scan_toks(false, false);\r
+ p = link(def_ref);\r
+\r
+ while (p != 0)\r
+ {\r
+ t = info(p); \r
+\r
+ if (t < cs_token_flag + single_base)\r
+ {\r
+ c = t % 256;\r
+\r
+ if (equiv(b + c) != 0)\r
+ info(p) = t - c + equiv(b + c);\r
+ }\r
+\r
+ p = link(p);\r
+ }\r
+\r
+ begin_token_list(link(def_ref), 3);\r
+ free_avail(def_ref);\r
+}\r
+/* sec 1293 */\r
+void show_whatever (void)\r
+{\r
+ pointer p;\r
+\r
+ switch (cur_chr)\r
+ {\r
+ case show_lists:\r
+ {\r
+ begin_diagnostic();\r
+ show_activities();\r
+ }\r
+ break;\r
+\r
+ case show_box_code:\r
+ {\r
+ scan_eight_bit_int();\r
+ begin_diagnostic();\r
+ print_nl("> \\box");\r
+ print_int(cur_val);\r
+ print_char('=');\r
+\r
+ if (box(cur_val) == 0)\r
+ prints("void");\r
+ else\r
+ show_box(box(cur_val));\r
+ }\r
+ break;\r
+\r
+ case show_code:\r
+ {\r
+ get_token();\r
+\r
+ if (interaction == error_stop_mode)\r
+ wake_up_terminal();\r
+\r
+ print_nl("> ");\r
+\r
+ if (cur_cs != 0)\r
+ {\r
+ sprint_cs(cur_cs);\r
+ print_char('=');\r
+ }\r
+\r
+ print_meaning();\r
+ goto common_ending;\r
+ }\r
+ break;\r
+\r
+ default:\r
+ {\r
+ p = the_toks();\r
+\r
+ if (interaction == error_stop_mode)\r
+ wake_up_terminal();\r
+\r
+ print_nl("> ");\r
+ token_show(temp_head);\r
+ flush_list(link(temp_head));\r
+ goto common_ending;\r
+ }\r
+ break;\r
+ }\r
+\r
+ end_diagnostic(true);\r
+ print_err("OK");\r
+\r
+ if (selector == term_and_log)\r
+ if (tracing_online <= 0)\r
+ {\r
+ selector = term_only;\r
+ prints(" (see the transcript file)");\r
+ selector = term_and_log;\r
+ }\r
+\r
+common_ending:\r
+\r
+ if (interaction < error_stop_mode)\r
+ {\r
+ help_ptr = 0;\r
+ decr(error_count);\r
+ }\r
+ else if (tracing_online > 0)\r
+ {\r
+ help3("This isn't an error message; I'm just \\showing something.",\r
+ "Type `I\\show...' to show more (e.g., \\show\\cs,",\r
+ "\\showthe\\count10, \\showbox255, \\showlists).");\r
+ }\r
+ else\r
+ {\r
+ help5("This isn't an error message; I'm just \\showing something.",\r
+ "Type `I\\show...' to show more (e.g., \\show\\cs,",\r
+ "\\showthe\\count10, \\showbox255, \\showlists).",\r
+ "And type `I\\tracingonline=1\\show...' to show boxes and",\r
+ "lists on your terminal as well as in the transcript file.");\r
+ }\r
+\r
+ error();\r
+}\r
+/* sec 1349 */\r
+void new_whatsit_(small_number s, small_number w)\r
+{\r
+ pointer p;\r
+\r
+ p = get_node(w);\r
+ type(p) = whatsit_node;\r
+ subtype(p) = s;\r
+ link(tail) = p;\r
+ tail = p;\r
+}\r
+/* sec 1350 */\r
+void new_write_whatsit (small_number w)\r
+{\r
+ new_whatsit(cur_chr, w);\r
+\r
+ if (w != write_node_size)\r
+ scan_four_bit_int();\r
+ else\r
+ {\r
+ scan_int();\r
+\r
+ if (cur_val < 0)\r
+ cur_val = 17;\r
+ else if (cur_val > 15)\r
+ cur_val = 16;\r
+ }\r
+\r
+ write_stream(tail) = cur_val;\r
+}\r
+/* sec 1348 */\r
+void do_extension (void)\r
+{\r
+ integer k;\r
+ pointer p;\r
+\r
+ switch (cur_chr)\r
+ {\r
+ case open_node:\r
+ {\r
+ new_write_whatsit(open_node_size);\r
+ scan_optional_equals();\r
+ scan_file_name();\r
+ open_name(tail) = cur_name;\r
+ open_area(tail) = cur_area;\r
+ open_ext(tail) = cur_ext;\r
+ }\r
+ break;\r
+\r
+ case write_node:\r
+ {\r
+ k = cur_cs;\r
+ new_write_whatsit(write_node_size);\r
+ cur_cs = k;\r
+ p = scan_toks(false, false);\r
+ write_tokens(tail) = def_ref;\r
+ }\r
+ break;\r
+\r
+ case close_node:\r
+ {\r
+ new_write_whatsit(write_node_size);\r
+ write_tokens(tail) = 0;\r
+ }\r
+ break;\r
+\r
+ case special_node:\r
+ {\r
+ new_whatsit(special_node, write_node_size);\r
+ write_stream(tail) = 0;\r
+ p = scan_toks(false, true);\r
+ write_tokens(tail) = def_ref;\r
+ }\r
+ break;\r
+\r
+ case immediate_code:\r
+ {\r
+ get_x_token();\r
+\r
+ if ((cur_cmd == extension) && (cur_chr <= close_node))\r
+ {\r
+ p = tail;\r
+ do_extension();\r
+ out_what(tail);\r
+ flush_node_list(tail);\r
+ tail = p;\r
+ link(p) = 0;\r
+ }\r
+ else\r
+ back_input();\r
+ }\r
+ break;\r
+\r
+ case set_language_code:\r
+ if (abs(mode) != hmode)\r
+ {\r
+ report_illegal_case();\r
+ }\r
+ else\r
+ {\r
+ new_whatsit(language_node, small_node_size);\r
+ scan_int();\r
+\r
+ if (cur_val <= 0)\r
+ clang = 0;\r
+ else if (cur_val > 255)\r
+ clang = 0;\r
+ else\r
+ clang = cur_val;\r
+\r
+ what_lang(tail) = clang;\r
+ what_lhm(tail) = norm_min(left_hyphen_min);\r
+ what_rhm(tail) = norm_min(right_hyphen_min);\r
+ }\r
+ break;\r
+\r
+ default:\r
+ {\r
+ confusion("ext1");\r
+ return;\r
+ }\r
+ break;\r
+ }\r
+}\r
+/* sec 1376 */\r
+void fix_language (void)\r
+{\r
+ /* ASCII_code l; */\r
+ int l;\r
+\r
+ if (language <= 0)\r
+ l = 0; \r
+ else if (language > 255)\r
+ l = 0;\r
+ else\r
+ l = language;\r
+\r
+ if (l != clang)\r
+ {\r
+ new_whatsit(language_node, small_node_size);\r
+ what_lang(tail) = l;\r
+ clang = l;\r
+ what_lhm(tail) = norm_min(left_hyphen_min);\r
+ what_rhm(tail) = norm_min(right_hyphen_min);\r
+ }\r
+}\r
+/* sec 1068 */\r
+void handle_right_brace (void)\r
+{\r
+ pointer p, q;\r
+ scaled d;\r
+ integer f;\r
+\r
+ switch (cur_group)\r
+ {\r
+ case simple_group:\r
+ unsave();\r
+ break;\r
+\r
+ case bottom_level:\r
+ {\r
+ print_err("Too many }'s");\r
+ help2("You've closed more groups than you opened.",\r
+ "Such booboos are generally harmless, so keep going.");\r
+ error();\r
+ }\r
+ break;\r
+\r
+ case semi_simple_group:\r
+ case math_shift_group:\r
+ case math_left_group:\r
+ extra_right_brace();\r
+ break;\r
+\r
+ case hbox_group:\r
+ package(0);\r
+ break;\r
+\r
+ case adjust_hbox_group:\r
+ {\r
+ adjust_tail = adjust_head;\r
+ package(0);\r
+ }\r
+ break;\r
+\r
+ case vbox_group:\r
+ {\r
+ end_graf();\r
+ package(0);\r
+ }\r
+ break;\r
+\r
+ case vtop_group:\r
+ {\r
+ end_graf();\r
+ package(vtop_code);\r
+ }\r
+ break;\r
+\r
+ case insert_group:\r
+ {\r
+ end_graf();\r
+ q = split_top_skip;\r
+ add_glue_ref(q);\r
+ d = split_max_depth;\r
+ f = floating_penalty;\r
+ unsave();\r
+ decr(save_ptr);\r
+ p = vpackage(link(head), 0, 1, max_dimen);\r
+ pop_nest();\r
+\r
+ if (saved(0) < 255)\r
+ {\r
+ tail_append(get_node(ins_node_size));\r
+ type(tail) = ins_node;\r
+ subtype(tail) = saved(0);\r
+ height(tail) = height(p) + depth(p);\r
+ ins_ptr(tail) = list_ptr(p);\r
+ split_top_ptr(tail) = q;\r
+ depth(tail) = d;\r
+ float_cost(tail) = f;\r
+ }\r
+ else\r
+ {\r
+ tail_append(get_node(small_node_size));\r
+ type(tail) = adjust_node;\r
+ subtype(tail) = 0;\r
+ adjust_ptr(tail) = list_ptr(p);\r
+ delete_glue_ref(q);\r
+ }\r
+ free_node(p, box_node_size);\r
+\r
+ if (nest_ptr == 0)\r
+ build_page();\r
+ }\r
+ break;\r
+\r
+ case output_group:\r
+ {\r
+ if ((loc != 0) || ((token_type != output_text) && (token_type != backed_up)))\r
+ {\r
+ print_err("Unbalanced output routine");\r
+ help2("Your sneaky output routine has problematic {'s and/or }'s.",\r
+ "I can't handle that very well; good luck.");\r
+ error();\r
+\r
+ do\r
+ {\r
+ get_token();\r
+ }\r
+ while (!(loc == 0));\r
+ }\r
+\r
+ end_token_list();\r
+ end_graf();\r
+ unsave();\r
+ output_active = false;\r
+ insert_penalties = 0;\r
+\r
+ if (box(255) != 0)\r
+ {\r
+ print_err("Output routine didn't use all of ");\r
+ print_esc("box");\r
+ print_int(255);\r
+ help3("Your \\output commands should empty \\box255,",\r
+ "e.g., by saying `\\shipout\\box255'.",\r
+ "Proceed; I'll discard its present contents.");\r
+ box_error(255);\r
+ }\r
+\r
+ if (tail != head)\r
+ {\r
+ link(page_tail) = link(head);\r
+ page_tail = tail;\r
+ }\r
+\r
+ if (link(page_head) != 0)\r
+ {\r
+ if (link(contrib_head) == 0)\r
+ nest[0].tail_field = page_tail;\r
+\r
+ link(page_tail) = link(contrib_head);\r
+ link(contrib_head) = link(page_head);\r
+ link(page_head) = 0;\r
+ page_tail = page_head;\r
+ }\r
+\r
+ pop_nest();\r
+ build_page();\r
+ }\r
+ break;\r
+\r
+ case disc_group:\r
+ build_discretionary();\r
+ break;\r
+\r
+ case align_group:\r
+ {\r
+ back_input();\r
+ cur_tok = cs_token_flag + frozen_cr;\r
+ print_err("Missing ");\r
+ print_esc("cr");\r
+ prints("inserted");\r
+ help1("I'm guessing that you meant to end an alignment here.");\r
+ ins_error();\r
+ }\r
+ break;\r
+\r
+ case no_align_group:\r
+ {\r
+ end_graf();\r
+ unsave();\r
+ align_peek();\r
+ }\r
+ break;\r
+\r
+ case vcenter_group:\r
+ {\r
+ end_graf();\r
+ unsave();\r
+ save_ptr = save_ptr - 2;\r
+ p = vpackage(link(head), saved(1), saved(0), max_dimen);\r
+ pop_nest();\r
+ tail_append(new_noad());\r
+ type(tail) = vcenter_noad;\r
+ math_type(nucleus(tail)) = sub_box;\r
+ info(nucleus(tail)) = p;\r
+ }\r
+ break;\r
+\r
+ case math_choice_group:\r
+ build_choices();\r
+ break;\r
+\r
+ case math_group:\r
+ {\r
+ unsave();\r
+ decr(save_ptr);\r
+ math_type(saved(0)) = sub_mlist;\r
+ p = fin_mlist(0);\r
+ info(saved(0)) = p;\r
+\r
+ if (p != 0)\r
+ if (link(p) == 0)\r
+ if (type(p) == ord_noad)\r
+ {\r
+ if (math_type(subscr(p)) == 0)\r
+ if (math_type(supscr(p)) == 0)\r
+ {\r
+ mem[saved(0)].hh = mem[nucleus(p)].hh;\r
+ free_node(p, noad_size);\r
+ }\r
+ }\r
+ else if (type(p) == accent_noad)\r
+ if (saved(0) == nucleus(tail))\r
+ if (type(tail) == ord_noad)\r
+ {\r
+ q = head;\r
+\r
+ while (link(q) != tail)\r
+ q = link(q);\r
+\r
+ link(q) = p;\r
+ free_node(tail, noad_size);\r
+ tail = p;\r
+ }\r
+ }\r
+ break;\r
+\r
+ default:\r
+ {\r
+ confusion("rightbrace");\r
+ return;\r
+ }\r
+ break;\r
+ }\r
+}\r
+/* sec 1030 */\r
+void main_control (void) \r
+{\r
+ integer t;\r
+ boolean bSuppress;\r
+\r
+ if (every_job != 0)\r
+ begin_token_list(every_job, every_job_text);\r
+\r
+big_switch:\r
+ get_x_token();\r
+\r
+reswitch:\r
+ if (interrupt != 0)\r
+ if (OK_to_interrupt)\r
+ {\r
+ back_input();\r
+ check_interrupt();\r
+ goto big_switch;\r
+ }\r
+\r
+#ifdef DEBUG\r
+ if (panicking)\r
+ check_mem(false);\r
+#endif\r
+\r
+ if (tracing_commands > 0)\r
+ show_cur_cmd_chr();\r
+\r
+ switch (abs(mode) + cur_cmd)\r
+ {\r
+ case hmode + letter:\r
+ case hmode + other_char:\r
+ case hmode + char_given:\r
+ goto main_loop;\r
+ break;\r
+\r
+ case hmode + char_num:\r
+ {\r
+ scan_char_num();\r
+ cur_chr = cur_val;\r
+ goto main_loop;\r
+ }\r
+ break;\r
+\r
+ case hmode + no_boundary:\r
+ {\r
+ get_x_token();\r
+\r
+ if ((cur_cmd == letter) || (cur_cmd == other_char) ||\r
+ (cur_cmd == char_given) || (cur_cmd == char_num))\r
+ cancel_boundary = true;\r
+ goto reswitch;\r
+ }\r
+ break;\r
+\r
+ case hmode + spacer:\r
+ if (space_factor == 1000)\r
+ goto append_normal_space;\r
+ else\r
+ app_space();\r
+ break;\r
+\r
+ case hmode + ex_space:\r
+ case mmode + ex_space:\r
+ goto append_normal_space;\r
+ break;\r
+\r
+ case any_mode(relax):\r
+ case vmode + spacer:\r
+ case mmode + spacer:\r
+ case mmode + no_boundary:\r
+ do_nothing();\r
+ break;\r
+\r
+ case any_mode(ignore_spaces):\r
+ {\r
+ do\r
+ {\r
+ get_x_token();\r
+ }\r
+ while (!(cur_cmd != spacer));\r
+ goto reswitch;\r
+ }\r
+ break;\r
+\r
+ case vmode + stop:\r
+ if (its_all_over())\r
+ return;\r
+ break;\r
+\r
+ case vmode + vmove:\r
+ case hmode + hmove:\r
+ case mmode + hmove:\r
+ case any_mode(last_item):\r
+ case vmode + vadjust:\r
+ case vmode + ital_corr:\r
+ case non_math(eq_no):\r
+ case any_mode(mac_param):\r
+ report_illegal_case();\r
+ break;\r
+\r
+ case non_math(sup_mark):\r
+ case non_math(sub_mark):\r
+ case non_math(math_char_num):\r
+ case non_math(math_given):\r
+ case non_math(math_comp):\r
+ case non_math(delim_num):\r
+ case non_math(left_right):\r
+ case non_math(above):\r
+ case non_math(radical):\r
+ case non_math(math_style):\r
+ case non_math(math_choice):\r
+ case non_math(vcenter):\r
+ case non_math(non_script):\r
+ case non_math(mkern):\r
+ case non_math(limit_switch):\r
+ case non_math(mskip):\r
+ case non_math(math_accent):\r
+ case mmode + endv:\r
+ case mmode + par_end:\r
+ case mmode + stop:\r
+ case mmode + vskip:\r
+ case mmode + un_vbox:\r
+ case mmode + valign:\r
+ case mmode + hrule:\r
+ insert_dollar_sign();\r
+ break;\r
+\r
+ case vmode + hrule:\r
+ case hmode + vrule:\r
+ case mmode + vrule:\r
+ {\r
+ tail_append(scan_rule_spec());\r
+\r
+ if (abs(mode) == vmode)\r
+ prev_depth = ignore_depth;\r
+ else if (abs(mode) == hmode)\r
+ space_factor = 1000;\r
+ }\r
+ break;\r
+\r
+ case vmode + vskip:\r
+ case hmode + hskip:\r
+ case mmode + hskip:\r
+ case mmode + mskip:\r
+ append_glue();\r
+ break;\r
+\r
+ case any_mode(kern):\r
+ case mmode + mkern:\r
+ append_kern();\r
+ break;\r
+\r
+ case non_math(left_brace):\r
+ new_save_level(simple_group);\r
+ break;\r
+\r
+ case any_mode(begin_group):\r
+ new_save_level(semi_simple_group);\r
+ break;\r
+\r
+ case any_mode(end_group):\r
+ if (cur_group == semi_simple_group)\r
+ unsave();\r
+ else\r
+ off_save();\r
+ break;\r
+\r
+ case any_mode(right_brace):\r
+ handle_right_brace();\r
+ break;\r
+\r
+ case vmode + hmove:\r
+ case hmode + vmove:\r
+ case mmode + vmove:\r
+ {\r
+ t = cur_chr;\r
+ scan_dimen(false, false, false);\r
+\r
+ if (t == 0)\r
+ scan_box(cur_val);\r
+ else\r
+ scan_box(- (integer) cur_val);\r
+ }\r
+ break;\r
+\r
+ case any_mode(leader_ship):\r
+ scan_box(leader_flag - a_leaders + cur_chr);\r
+ break;\r
+\r
+ case any_mode(make_box):\r
+ begin_box(0);\r
+ break;\r
+\r
+ case vmode + start_par:\r
+ new_graf(cur_chr > 0);\r
+ break;\r
+\r
+ case vmode + letter:\r
+ case vmode + other_char:\r
+ case vmode + char_num:\r
+ case vmode + char_given:\r
+ case vmode + math_shift:\r
+ case vmode + un_hbox:\r
+ case vmode + vrule:\r
+ case vmode + accent:\r
+ case vmode + discretionary:\r
+ case vmode + hskip:\r
+ case vmode + valign:\r
+ case vmode + ex_space:\r
+ case vmode + no_boundary:\r
+ {\r
+ back_input();\r
+ new_graf(true);\r
+ }\r
+ break;\r
+\r
+ case hmode + start_par:\r
+ case mmode + start_par:\r
+ indent_in_hmode();\r
+ break;\r
+\r
+ case vmode + par_end:\r
+ {\r
+ normal_paragraph();\r
+\r
+ if (mode > 0)\r
+ build_page();\r
+ }\r
+ break;\r
+\r
+ case hmode + par_end:\r
+ {\r
+ if (align_state < 0)\r
+ off_save();\r
+\r
+ end_graf();\r
+\r
+ if (mode == 1)\r
+ build_page();\r
+ }\r
+ break;\r
+\r
+ case hmode + stop:\r
+ case hmode + vskip:\r
+ case hmode + hrule:\r
+ case hmode + un_vbox:\r
+ case hmode + halign:\r
+ head_for_vmode();\r
+ break;\r
+\r
+ case any_mode(insert):\r
+ case hmode + vadjust:\r
+ case mmode + vadjust:\r
+ begin_insert_or_adjust();\r
+ break;\r
+\r
+ case any_mode(mark):\r
+ make_mark();\r
+ break;\r
+\r
+ case any_mode(break_penalty):\r
+ append_penalty();\r
+ break;\r
+\r
+ case any_mode(remove_item):\r
+ delete_last();\r
+ break;\r
+\r
+ case vmode + un_vbox:\r
+ case hmode + un_hbox:\r
+ case mmode + un_hbox:\r
+ unpackage();\r
+ break;\r
+\r
+ case hmode + ital_corr:\r
+ append_italic_correction();\r
+ break;\r
+\r
+ case mmode + ital_corr:\r
+ tail_append(new_kern(0));\r
+ break;\r
+\r
+ case hmode + discretionary:\r
+ case mmode + discretionary:\r
+ append_discretionary();\r
+ break;\r
+\r
+ case hmode + accent:\r
+ make_accent();\r
+ break;\r
+\r
+ case any_mode(car_ret):\r
+ case any_mode(tab_mark):\r
+ align_error();\r
+ break;\r
+\r
+ case any_mode(no_align):\r
+ noalign_error();\r
+ break;\r
+\r
+ case any_mode(omit):\r
+ omit_error();\r
+ break;\r
+\r
+ case vmode + halign:\r
+ case hmode + valign:\r
+ init_align();\r
+ break;\r
+\r
+ case mmode + halign:\r
+ if (privileged ())\r
+ if (cur_group == math_shift_group)\r
+ init_align();\r
+ else\r
+ off_save();\r
+ break;\r
+\r
+ case vmode + endv:\r
+ case hmode + endv:\r
+ do_endv();\r
+ break;\r
+\r
+ case any_mode(end_cs_name):\r
+ cs_error();\r
+ break;\r
+\r
+ case hmode + math_shift:\r
+ init_math();\r
+ break;\r
+\r
+ case mmode + eq_no:\r
+ if (privileged ())\r
+ if (cur_group == math_shift_group)\r
+ start_eq_no();\r
+ else\r
+ off_save();\r
+ break;\r
+\r
+ case mmode + left_brace:\r
+ {\r
+ tail_append(new_noad());\r
+ back_input();\r
+ scan_math(nucleus(tail));\r
+ }\r
+ break;\r
+\r
+ case mmode + letter:\r
+ case mmode + other_char:\r
+ case mmode + char_given:\r
+ set_math_char(math_code(cur_chr));\r
+ break;\r
+\r
+ case mmode + char_num:\r
+ {\r
+ scan_char_num();\r
+ cur_chr = cur_val;\r
+ set_math_char(math_code(cur_chr));\r
+ }\r
+ break;\r
+\r
+ case mmode + math_char_num:\r
+ {\r
+ scan_fifteen_bit_int();\r
+ set_math_char(cur_val);\r
+ }\r
+ break;\r
+\r
+ case mmode + math_given:\r
+ set_math_char(cur_chr);\r
+ break;\r
+\r
+ case mmode + delim_num:\r
+ {\r
+ scan_twenty_seven_bit_int();\r
+ set_math_char(cur_val / 4096);\r
+ }\r
+ break;\r
+\r
+ case mmode + math_comp:\r
+ {\r
+ tail_append(new_noad());\r
+ type(tail) = cur_chr;\r
+ scan_math(nucleus(tail));\r
+ }\r
+ break;\r
+\r
+ case mmode + limit_switch:\r
+ math_limit_switch();\r
+ break;\r
+\r
+ case mmode + radical:\r
+ math_radical();\r
+ break;\r
+\r
+ case mmode + accent:\r
+ case mmode + math_accent:\r
+ math_ac();\r
+ break;\r
+\r
+ case mmode + vcenter:\r
+ {\r
+ scan_spec(vcenter_group, false);\r
+ normal_paragraph();\r
+ push_nest();\r
+ mode = -1;\r
+ prev_depth = ignore_depth;\r
+\r
+ if (every_vbox != 0)\r
+ begin_token_list(every_vbox, every_vbox_text);\r
+ }\r
+ break;\r
+\r
+ case mmode + math_style:\r
+ tail_append(new_style(cur_chr));\r
+ break;\r
+\r
+ case mmode + non_script:\r
+ {\r
+ tail_append(new_glue(zero_glue));\r
+ subtype(tail) = cond_math_glue;\r
+ }\r
+ break;\r
+\r
+ case mmode + math_choice:\r
+ append_choices();\r
+ break;\r
+\r
+ case mmode + sub_mark:\r
+ case mmode + sup_mark:\r
+ sub_sup();\r
+ break;\r
+\r
+ case mmode + above:\r
+ math_fraction();\r
+ break;\r
+\r
+ case mmode + left_right:\r
+ math_left_right();\r
+ break;\r
+\r
+ case mmode + math_shift:\r
+ if (cur_group == math_shift_group)\r
+ after_math();\r
+ else\r
+ off_save();\r
+ break;\r
+\r
+ case any_mode(toks_register):\r
+ case any_mode(assign_toks):\r
+ case any_mode(assign_int):\r
+ case any_mode(assign_dimen):\r
+ case any_mode(assign_glue):\r
+ case any_mode(assign_mu_glue):\r
+ case any_mode(assign_font_dimen):\r
+ case any_mode(assign_font_int):\r
+ case any_mode(set_aux):\r
+ case any_mode(set_prev_graf):\r
+ case any_mode(set_page_dimen):\r
+ case any_mode(set_page_int):\r
+ case any_mode(set_box_dimen):\r
+ case any_mode(set_shape):\r
+ case any_mode(def_code):\r
+ case any_mode(def_family):\r
+ case any_mode(set_font):\r
+ case any_mode(def_font):\r
+ case any_mode(tex_register):\r
+ case any_mode(advance):\r
+ case any_mode(multiply):\r
+ case any_mode(divide):\r
+ case any_mode(prefix):\r
+ case any_mode(let):\r
+ case any_mode(shorthand_def):\r
+ case any_mode(read_to_cs):\r
+ case any_mode(def):\r
+ case any_mode(set_box):\r
+ case any_mode(hyph_data):\r
+ case any_mode(set_interaction):\r
+ prefixed_command();\r
+ break;\r
+\r
+ case any_mode(after_assignment):\r
+ {\r
+ get_token();\r
+ after_token = cur_tok;\r
+ }\r
+ break;\r
+\r
+ case any_mode(after_group):\r
+ {\r
+ get_token();\r
+ save_for_after(cur_tok);\r
+ }\r
+ break;\r
+\r
+ case any_mode(in_stream):\r
+ open_or_close_in();\r
+ break;\r
+\r
+ case any_mode(message):\r
+ issue_message();\r
+ break;\r
+\r
+ case any_mode(case_shift):\r
+ shift_case();\r
+ break;\r
+\r
+ case any_mode(xray):\r
+ show_whatever();\r
+ break;\r
+\r
+ case any_mode(extension):\r
+ do_extension();\r
+ break;\r
+ }\r
+\r
+ goto big_switch;\r
+\r
+main_loop:\r
+ adjust_space_factor();\r
+ main_f = cur_font;\r
+ bchar = font_bchar[main_f];\r
+ false_bchar = font_false_bchar[main_f];\r
+\r
+ if (mode > 0)\r
+ if (language != clang)\r
+ fix_language();\r
+\r
+ fast_get_avail(lig_stack);\r
+ font(lig_stack) = main_f;\r
+ cur_l = cur_chr;\r
+ character(lig_stack) = cur_l;\r
+ cur_q = tail;\r
+\r
+ if (cancel_boundary)\r
+ {\r
+ cancel_boundary = false;\r
+ main_k = non_address;\r
+ }\r
+ else\r
+ main_k = bchar_label[main_f];\r
+\r
+ if (main_k == non_address)\r
+ goto main_loop_move_2;\r
+\r
+ cur_r = cur_l;\r
+ cur_l = non_char;\r
+ goto main_lig_loop_1;\r
+\r
+main_loop_wrapup: \r
+ wrapup(rt_hit);\r
+\r
+main_loop_move:\r
+ if (lig_stack == 0)\r
+ goto reswitch;\r
+\r
+ cur_q = tail;\r
+ cur_l = character(lig_stack);\r
+\r
+main_loop_move_1:\r
+ if (!is_char_node(lig_stack))\r
+ goto main_loop_move_lig;\r
+\r
+main_loop_move_2:\r
+ if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f]))\r
+ {\r
+ char_warning(main_f, cur_chr);\r
+ free_avail(lig_stack);\r
+ goto big_switch;\r
+ }\r
+\r
+ main_i = char_info(main_f, cur_l);\r
+\r
+ if (!char_exists(main_i))\r
+ {\r
+ char_warning(main_f, cur_chr);\r
+ free_avail(lig_stack);\r
+ goto big_switch; \r
+ }\r
+\r
+ link(tail) = lig_stack;\r
+ tail = lig_stack;\r
+\r
+main_loop_lookahead:\r
+ get_next();\r
+\r
+ if (cur_cmd == letter)\r
+ goto main_loop_lookahead_1;\r
+\r
+ if (cur_cmd == other_char)\r
+ goto main_loop_lookahead_1;\r
+\r
+ if (cur_cmd == char_given)\r
+ goto main_loop_lookahead_1;\r
+\r
+ x_token();\r
+\r
+ if (cur_cmd == letter)\r
+ goto main_loop_lookahead_1;\r
+\r
+ if (cur_cmd == other_char)\r
+ goto main_loop_lookahead_1;\r
+\r
+ if (cur_cmd == char_given)\r
+ goto main_loop_lookahead_1;\r
+\r
+ if (cur_cmd == char_num)\r
+ {\r
+ scan_char_num();\r
+ cur_chr = cur_val;\r
+ goto main_loop_lookahead_1;\r
+ }\r
+\r
+ if (cur_cmd == no_boundary)\r
+ bchar = non_char;\r
+\r
+ cur_r = bchar;\r
+ lig_stack = 0;\r
+ goto main_lig_loop;\r
+\r
+main_loop_lookahead_1:\r
+ adjust_space_factor();\r
+ fast_get_avail(lig_stack);\r
+ font(lig_stack) = main_f;\r
+ cur_r = cur_chr;\r
+ character(lig_stack) = cur_r;\r
+\r
+ if (cur_r == false_bchar)\r
+ cur_r = non_char;\r
+\r
+main_lig_loop:\r
+ if (char_tag(main_i) != lig_tag)\r
+ goto main_loop_wrapup;\r
+\r
+ if (cur_r == non_char)\r
+ goto main_loop_wrapup;\r
+\r
+ main_k = lig_kern_start(main_f, main_i);\r
+ main_j = font_info[main_k].qqqq;\r
+\r
+ if (skip_byte(main_j) <= stop_flag)\r
+ goto main_lig_loop_2;\r
+\r
+ main_k = lig_kern_restart(main_f, main_j);\r
+\r
+main_lig_loop_1:\r
+ main_j = font_info[main_k].qqqq;\r
+\r
+main_lig_loop_2:\r
+ bSuppress = false;\r
+\r
+ if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag)\r
+ {\r
+ if (cur_l == 'f')\r
+ bSuppress = true;\r
+ }\r
+\r
+ if (next_char(main_j) == cur_r && bSuppress == false)\r
+ if (skip_byte(main_j) <= stop_flag)\r
+ {\r
+ if (op_byte(main_j) >= kern_flag)\r
+ {\r
+ wrapup(rt_hit);\r
+ tail_append(new_kern(char_kern(main_f, main_j)));\r
+ goto main_loop_move;\r
+ }\r
+\r
+ if (cur_l == non_char)\r
+ lft_hit = true;\r
+ else if (lig_stack == 0)\r
+ rt_hit = true;\r
+\r
+ check_interrupt();\r
+\r
+ switch (op_byte(main_j))\r
+ {\r
+ case 1:\r
+ case 5:\r
+ {\r
+ cur_l = rem_byte(main_j);\r
+ main_i = char_info(main_f, cur_l);\r
+ ligature_present = true;\r
+ }\r
+ break;\r
+ case 2:\r
+ case 6:\r
+ {\r
+ cur_r = rem_byte(main_j);\r
+\r
+ if (lig_stack == 0)\r
+ {\r
+ lig_stack = new_lig_item(cur_r);\r
+ bchar = non_char;\r
+ }\r
+ else if (is_char_node(lig_stack))\r
+ {\r
+ main_p = lig_stack;\r
+ lig_stack = new_lig_item(cur_r);\r
+ lig_ptr(lig_stack) = main_p;\r
+ }\r
+ else\r
+ character(lig_stack) = cur_r;\r
+ }\r
+ break;\r
+ case 3:\r
+ {\r
+ cur_r = rem_byte(main_j);\r
+ main_p = lig_stack;\r
+ lig_stack = new_lig_item(cur_r);\r
+ link(lig_stack) = main_p;\r
+ }\r
+ break;\r
+ case 7:\r
+ case 11:\r
+ {\r
+ wrapup(false);\r
+ cur_q = tail;\r
+ cur_l = rem_byte(main_j);\r
+ main_i = char_info(main_f, cur_l);\r
+ ligature_present = true;\r
+ }\r
+ break;\r
+ default:\r
+ {\r
+ cur_l = rem_byte(main_j);\r
+ ligature_present = true;\r
+ \r
+ if (lig_stack == 0)\r
+ goto main_loop_wrapup;\r
+ else\r
+ goto main_loop_move_1;\r
+ }\r
+ break;\r
+ }\r
+\r
+ if (op_byte(main_j) > 4)\r
+ if (op_byte(main_j) != 7)\r
+ goto main_loop_wrapup;\r
+\r
+ if (cur_l < non_char)\r
+ goto main_lig_loop;\r
+\r
+ main_k = bchar_label[main_f];\r
+ goto main_lig_loop_1;\r
+ }\r
+\r
+ if (skip_byte(main_j) == 0)\r
+ incr(main_k);\r
+ else\r
+ {\r
+ if (skip_byte(main_j) >= stop_flag)\r
+ goto main_loop_wrapup;\r
+\r
+ main_k = main_k + skip_byte(main_j) + 1;\r
+ }\r
+\r
+ goto main_lig_loop_1;\r
+\r
+main_loop_move_lig:\r
+ main_p = lig_ptr(lig_stack);\r
+\r
+ if (main_p != 0)\r
+ tail_append(main_p);\r
+\r
+ temp_ptr = lig_stack;\r
+ lig_stack = link(temp_ptr);\r
+ free_node(temp_ptr, small_node_size);\r
+ main_i = char_info(main_f, cur_l);\r
+ ligature_present = true;\r
+\r
+ if (lig_stack == 0)\r
+ if (main_p != 0)\r
+ goto main_loop_lookahead;\r
+ else\r
+ cur_r = bchar;\r
+ else\r
+ cur_r = character(lig_stack);\r
+\r
+ goto main_lig_loop;\r
+\r
+append_normal_space:\r
+ if (space_skip == 0)\r
+ {\r
+ {\r
+ main_p = font_glue[cur_font];\r
+\r
+ if (main_p == 0)\r
+ {\r
+ main_p = new_spec(zero_glue);\r
+ main_k = param_base[cur_font] + space_code;\r
+ width(main_p) = font_info[main_k].cint;\r
+ stretch(main_p) = font_info[main_k + 1].cint;\r
+ shrink(main_p) = font_info[main_k + 2].cint;\r
+ font_glue[cur_font] = main_p;\r
+ }\r
+ }\r
+\r
+ temp_ptr = new_glue(main_p);\r
+ }\r
+ else\r
+ temp_ptr = new_param_glue(space_skip_code);\r
+\r
+ link(tail) = temp_ptr;\r
+ tail = temp_ptr;\r
+\r
+ goto big_switch;\r