6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
13 #pragma warning(disable:4996)
14 #pragma warning(disable:4131) // old style declarator
15 #pragma warning(disable:4135) // conversion between different integral types
16 #pragma warning(disable:4127) // conditional expression is constant
24 #pragma warning(disable:4244) /* 96/Jan/10 */
26 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
28 /* math_fraction etc used to be in tex7.c */
30 void math_fraction (void)
36 if (incompleat_noad != 0)
38 if (c >= delimited_code)
40 scan_delimiter(garbage, false);
41 scan_delimiter(garbage, false);
44 if (c % delimited_code == 0)
45 scan_dimen(false, false, false);
47 print_err("Ambiguous; you need another { and }");
48 help3("I'm ignoring this fraction specification, since I don't",
49 "know whether a construction like `x \\over y \\over z'",
50 "means `{x \\over y} \\over z' or `x \\over {y \\over z}'.");
55 incompleat_noad = get_node(fraction_noad_size);
56 type(incompleat_noad) = fraction_noad;
57 subtype(incompleat_noad) = normal;
58 math_type(numerator(incompleat_noad)) = sub_mlist;
59 info(numerator(incompleat_noad)) = link(head);
60 mem[denominator(incompleat_noad)].hh = empty_field;
61 mem[left_delimiter(incompleat_noad)].qqqq = null_delimiter;
62 mem[right_delimiter(incompleat_noad)].qqqq = null_delimiter;
66 if (c >= delimited_code)
68 scan_delimiter(left_delimiter(incompleat_noad), false);
69 scan_delimiter(right_delimiter(incompleat_noad), false);
72 switch(c % delimited_code)
75 scan_dimen(false, false, false);
76 thickness(incompleat_noad) = cur_val;
79 thickness(incompleat_noad) = default_code;
82 thickness(incompleat_noad) = 0;
88 void math_left_right (void)
95 if ((t == right_noad) && (cur_group != math_left_group))
97 if (cur_group == math_shift_group)
99 scan_delimiter(garbage, false);
102 help1("I'm ignoring a \\right that had no matching \\left.");
114 scan_delimiter(delimiter(p), false);
118 push_math(math_left_group);
126 tail_append(new_noad());
127 type(tail) = inner_noad;
128 math_type(nucleus(tail)) = sub_mlist;
129 info(nucleus(tail)) = p;
134 void after_math (void)
154 if ((font_params[fam_fnt(2 + text_size)] < 22) ||
155 (font_params[fam_fnt(2 + script_size)] < 22) ||
156 (font_params[fam_fnt(2 + script_script_size)] < 22))
158 print_err("Math formula deleted: Insufficient symbol fonts");
159 help3("Sorry, but I can't typeset math unless \\textfont 2",
160 "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
161 "the \\fontdimen values needed in math symbol fonts.");
166 else if ((font_params[fam_fnt(3 + text_size)] < 13) ||
167 (font_params[fam_fnt(3 + script_size)] < 13) ||
168 (font_params[fam_fnt(3 + script_script_size)] < 13))
170 print_err("Math formula deleted: Insufficient extension fonts");
171 help3("Sorry, but I can't typeset math unless \\textfont 3",
172 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
173 "the \\fontdimen values needed in math extension fonts.");
183 if (mode == - (integer) m)
188 if (cur_cmd != math_shift)
190 print_err("Display math should end with $$");
191 help2("The `$' that I just saw supposedly matches a previous `$$'.",
192 "So I shall assume that you typed `$$' both times.");
197 cur_style = text_style;
198 mlist_penalties = false;
200 a = hpack(link(temp_head), 0, 1);
204 if (save_stack[save_ptr + 0].cint == 1)
209 if ((font_params[fam_fnt(2 + text_size)] < 22) ||
210 (font_params[fam_fnt(2 + script_size)] < 22) ||
211 (font_params[fam_fnt(2 + script_script_size)] < 22))
213 print_err("Math formula deleted: Insufficient symbol fonts");
214 help3("Sorry, but I can't typeset math unless \\textfont 2",
215 "and \\scriptfont 2 and \\scriptscriptfont 2 have all",
216 "the \\fontdimen values needed in math symbol fonts.");
221 else if ((font_params[fam_fnt(3 + text_size)] < 13) ||
222 (font_params[fam_fnt(3 + script_size)] < 13) ||
223 (font_params[fam_fnt(3 + script_script_size)] < 13))
225 print_err("Math formula deleted: Insufficient extension fonts");
226 help3("Sorry, but I can't typeset math unless \\textfont 3",
227 "and \\scriptfont 3 and \\scriptscriptfont 3 have all",
228 "the \\fontdimen values needed in math extension fonts.");
242 tail_append(new_math(math_surround, 0));
244 cur_style = text_style;
245 mlist_penalties = (mode > 0);
247 link(tail) = link(temp_head);
249 while(link(tail) != 0)
252 tail_append(new_math(math_surround, 1));
262 if (cur_cmd != math_shift)
264 print_err("Display math should end with $$");
265 help2("The `$' that I just saw supposedly matches a previous `$$'.",
266 "So I shall assume that you typed `$$' both times.");
271 cur_style = display_style;
272 mlist_penalties = false;
275 adjust_tail = adjust_head;
284 if ((a == 0) || danger)
292 q = e + math_quad(text_size);
297 if ((e != 0) && ((w - total_shrink[normal] + q <= z) || (total_shrink[fil] != 0) || (total_shrink[fill] != 0) || (total_shrink[filll] != 0)))
299 free_node(b, box_node_size);
300 b = hpack(p, z - q, 0);
308 free_node(b, box_node_size);
317 if ((e > 0) && (d < 2 * e))
322 if (!(p >= hi_mem_min))
323 if (type(p) == glue_node)
327 tail_append(new_penalty(pre_display_penalty));
329 if ((d + s <= pre_display_size) || l)
331 g1 = above_display_skip_code;
332 g2 = below_display_skip_code;
336 g1 = above_display_short_skip_code;
337 g2 = below_display_short_skip_code;
343 tail_append(new_penalty(10000));
347 tail_append(new_param_glue(g1));
352 r = new_kern(z - w - e - d);
369 shift_amount(b) = s + d;
372 if ((a != 0) && (e == 0) && !l)
374 tail_append(new_penalty(10000));
375 shift_amount(a) = s + z - width(a);
380 if (t != adjust_head)
382 mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH;
386 tail_append(new_penalty(post_display_penalty));
390 tail_append(new_param_glue(g2));
393 resume_after_display();
397 void resume_after_display (void)
399 if (cur_group != math_shift_group)
401 confusion("display");
402 return; // abort_flag set
406 prev_graf = prev_graf + 3;
413 else if (language > 255)
419 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
424 if (cur_cmd != spacer)
434 void get_r_token (void)
441 while (!(cur_tok != 2592));
443 if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))
445 print_err("Missing control sequence inserted");
446 help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
447 "I've inserted an inaccessible control sequence so that your",
448 "definition will be completed without mixing me up too badly.",
449 "You can recover graciously from this error, if you're",
450 "careful; see exercise 27.2 in The TeXbook.");
455 cur_tok = cs_token_flag + frozen_protection;
461 void trap_zero_glue (void)
463 if ((width(cur_val) == 0) && (stretch(cur_val) == 0) && (shrink(cur_val) == 0))
465 add_glue_ref(zero_glue);
466 delete_glue_ref(cur_val);
471 void do_register_command_ (small_number a)
479 if (q != tex_register)
483 if ((cur_cmd >= assign_int) && (cur_cmd <= assign_mu_glue))
486 p = cur_cmd - assign_int;
490 if (cur_cmd != tex_register)
492 print_err("You can't use `");
493 print_cmd_chr(cur_cmd, cur_chr);
494 print_string("' after ");
496 help1("I'm forgetting what you said and not changing anything.");
503 scan_eight_bit_int();
508 l = cur_val + count_base;
511 l = cur_val + scaled_base;
514 l = cur_val + skip_base;
517 l = cur_val + mu_skip_base;
523 if (q == tex_register)
524 scan_optional_equals();
526 if (scan_keyword("by"));
536 scan_dimen(false, false, false);
539 cur_val = cur_val + eqtb[l].cint;
547 q = new_spec(cur_val);
549 delete_glue_ref(cur_val);
550 width(q) = width(q) + width(r);
553 stretch_order(q) = normal;
555 if (stretch_order(q) == stretch_order(r))
556 stretch(q) = stretch(q) + stretch(r);
557 else if ((stretch_order(q) < stretch_order(r)) && (stretch(r) != 0))
559 stretch(q) = stretch(r);
560 stretch_order(q) = stretch_order(r);
564 shrink_order(q) = normal;
566 if (shrink_order(q) == shrink_order(r))
567 shrink(q) = shrink(q) + shrink(r);
568 else if ((shrink_order(q) < shrink_order(r)) && (shrink(r) != 0))
570 shrink(q) = shrink(r);
571 shrink_order(q) = shrink_order(r);
583 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); /* 2^31 - 1 */
585 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); /* 2^30 - 1 */
587 cur_val = x_over_n(eqtb[l].cint, cur_val);
595 width(r) = mult_and_add(width(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
596 stretch(r) = mult_and_add(stretch(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
597 shrink(r) = mult_and_add(shrink(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
601 width(r) = x_over_n(width(s), cur_val);
602 stretch(r) = x_over_n(stretch(s), cur_val);
603 shrink(r) = x_over_n(shrink(s), cur_val);
611 print_err("Arithmetic overflow");
612 help2("I can't carry out that multiplication or division,",
613 "since the result is out of range.");
616 delete_glue_ref(cur_val);
625 geq_word_define(l, cur_val);
627 eq_word_define(l, cur_val);
634 geq_define(l, glue_ref, cur_val);
636 eq_define(l, glue_ref, cur_val);
639 /* called only from itex.c */
641 void alter_aux (void)
645 if (cur_chr != abs(mode))
647 report_illegal_case();
652 scan_optional_equals();
656 scan_dimen(false, false, false);
657 prev_depth = cur_val;
663 if ((cur_val <= 0) || (cur_val > 32767))
665 print_err("Bad space factor");
666 help1("I allow only values in the range 1..32767 here.");
670 space_factor = cur_val;
675 void alter_prev_graf (void)
679 nest[nest_ptr] = cur_list;
682 while(abs(nest[p].mode_field) != vmode)
685 scan_optional_equals();
691 print_esc("prevgraf");
692 help1("I allow only nonnegative values here.");
697 nest[p].pg_field = cur_val;
698 cur_list = nest[nest_ptr];
702 void alter_page_so_far (void)
707 scan_optional_equals();
708 scan_dimen(false, false, false);
709 page_so_far[c] = cur_val;
712 void alter_integer (void)
717 scan_optional_equals();
721 dead_cycles = cur_val;
723 insert_penalties = cur_val;
726 void alter_box_dimen (void)
732 scan_eight_bit_int();
734 scan_optional_equals();
735 scan_dimen(false, false, false);
738 mem[box(b) + c].cint = cur_val;
741 void new_font_(small_number a)
745 internal_font_number f;
748 str_number flushable_string;
758 else if (u >= single_base)
765 old_setting = selector;
767 print_string("FONT");
768 print(u - active_base);
769 selector = old_setting;
775 geq_define(u, set_font, 0);
777 eq_define(u, set_font, 0);
779 scan_optional_equals();
782 name_in_progress = true;
784 if (scan_keyword("at"))
786 scan_dimen(false, false, false);
789 if ((s <= 0) || (s >= 134217728L)) /* 2^27 */
791 print_err("Improper `at' size(");
793 print_string("pt), replaced by 10pt");
794 help2("I can only handle fonts at positive sizes that are",
795 "less than 2048pt, so I've changed what you said to 10pt.");
797 s = 10 * 65536L; /* 10pt */
800 else if (scan_keyword("scaled"))
803 s = - (integer) cur_val;
805 if ((cur_val <= 0) || (cur_val > 32768L))
807 print_err("Illegal magnification has been changed to 1000");
808 help1("The magnification ratio must be between 1 and 32768.");
816 name_in_progress = false;
818 flushable_string = str_ptr - 1;
820 if (trace_flag) /* debugging stuff only 98/Oct/5 */
822 int i, k1, k2, l1, l2;
823 char *sch = log_line;
824 k1 = str_start[cur_area];
825 k2 = str_start[cur_name];
826 l1 = length(cur_area);
827 l2 = length(cur_name);
829 show_line("FONT ", 0);
831 for (i = 0; i < l1; i++)
833 *sch++ = str_pool[i + k1];
836 for (i = 0; i < l2; i++)
838 *sch++ = str_pool[i + k2];
843 show_line(log_line, 0);
846 /* paragraph 1260 for f <- fontbase+1 to font_ptr do */
847 for (f = 1; f < font_ptr; f++)
849 if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))
851 if (cur_name == flushable_string)
854 cur_name = font_name[f];
859 if (s == font_size[f])
861 if (ignore_frozen == 0 || f > frozenfontptr)
865 sprintf(log_line, "SKIPPING %ld ", s);
866 show_line(log_line, 0);
872 else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))
874 if (ignore_frozen == 0 || f > frozenfontptr)
878 sprintf(log_line, "SKIPPING %ld ", s);
879 show_line(log_line, 0);
888 show_line("READING ", 0);
890 f = read_font_info(u, cur_name, cur_area, s);
895 sprintf(log_line, "NEW FONT %d ", f);
896 show_line(log_line, 0);
900 eqtb[font_id_base + f] = eqtb[u];
905 sprintf(log_line, "ERROR: %s too large %d\n", "hash_used", t);
906 show_line(log_line, 1);
912 void new_interaction (void)
915 interaction = cur_chr;
917 if (interaction == batch_mode)
920 selector = term_only;
923 selector = selector + 2;
926 void do_assignments (void)
934 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
936 if (cur_cmd <= max_non_prefixed_command)
939 set_box_allowed = false;
941 set_box_allowed = true;
945 void open_or_close_in (void)
954 if (read_open[n] != closed)
956 (void) a_close(read_file[n]);
957 read_open[n] = closed;
962 scan_optional_equals();
964 pack_file_name(cur_name, cur_area, cur_ext);
966 /* *** some changes in following in 3.14159 *** */
967 /* if current extension is *not* empty, try to open using name as is */
968 /* string 335 is "" the empty string */
969 if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
971 /* we get here if extension is "", or file with extension failed to open */
972 /* if current extension is not `tex,' and `tex' is not irrelevant, try it */
973 /* string 785 is .tex */
974 else if ((cur_ext != 785) && (name_length + 5 < PATHMAX) &&
975 /* *** some changes in above file name handling *** */
976 (!extensionirrelevantp(name_of_file, name_length, "tex")))
978 name_of_file[name_length + 1] = '.'; /* .tex */
979 name_of_file[name_length + 2] = 't';
980 name_of_file[name_length + 3] = 'e';
981 name_of_file[name_length + 4] = 'x';
982 name_of_file[name_length + 5] = ' ';
983 name_length = name_length + 4;
985 if (a_open_in(read_file[n], TEXINPUTPATH))
986 read_open[n] = just_open;
989 name_length = name_length - 4; /* remove ".tex" again */
990 name_of_file[name_length + 1] = ' ';
992 if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
994 else if (maketextex () && a_open_in(read_file[n], TEXINPUTPATH))
1001 void issue_message (void)
1008 link(garbage) = scan_toks(false, true);
1009 old_setting = selector;
1010 selector = new_string;
1011 token_show(def_ref);
1012 selector = old_setting;
1013 flush_list(def_ref);
1019 if (term_offset + length(s) > max_print_line - 2)
1021 else if ((term_offset > 0) || (file_offset > 0))
1036 use_err_help = true;
1037 else if (long_help_seen)
1038 help1("(That was another \\errmessage.)");
1041 if (interaction < error_stop_mode)
1042 long_help_seen = true;
1044 help4("This error message was generated by an \\errmessage",
1045 "command, so I can't give any explicit help.",
1046 "Pretend that you're Hercule Poirot: Examine all clues,",
1047 "and deduce the truth by order and method.");
1051 use_err_help = false;
1057 void shift_case (void)
1065 p = scan_toks(false, false);
1072 if (t < cs_token_flag + single_base) /* 4095 + 257 = cs_tokenflag + single_base */
1076 if (equiv(b + c) != 0)
1077 info(p) = t - c + equiv(b + c);
1082 begin_token_list(link(def_ref), 3);
1083 free_avail(def_ref);
1086 void show_whatever (void)
1100 scan_eight_bit_int();
1102 print_nl("> \\box");
1106 if (box(cur_val) == 0)
1107 print_string("void");
1109 show_box(box(cur_val));
1116 if (interaction == error_stop_mode)
1135 if (interaction == error_stop_mode)
1139 token_show(temp_head);
1140 flush_list(link(temp_head));
1146 end_diagnostic(true);
1149 if (selector == term_and_log)
1150 if (tracing_online <= 0)
1152 selector = term_only;
1153 print_string(" (see the transcript file)");
1154 selector = term_and_log;
1159 if (interaction < error_stop_mode)
1164 else if (tracing_online > 0)
1166 help3("This isn't an error message; I'm just \\showing something.",
1167 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1168 "\\showthe\\count10, \\showbox255, \\showlists).");
1172 help5("This isn't an error message; I'm just \\showing something.",
1173 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1174 "\\showthe\\count10, \\showbox255, \\showlists).",
1175 "And type `I\\tracingonline=1\\show...' to show boxes and",
1176 "lists on your terminal as well as in the transcript file.");
1181 void new_whatsit_(small_number s, small_number w)
1186 type(p) = whatsit_node;
1192 void new_write_whatsit_(small_number w)
1194 new_whatsit(cur_chr, w);
1196 if (w != write_node_size)
1198 scan_four_bit_int();
1206 else if (cur_val > 15)
1209 write_stream(tail) = cur_val;
1212 void do_extension (void)
1214 /* integer i, j, k; */
1216 /* halfword p, q, r; */
1223 new_write_whatsit(open_node_size);
1224 scan_optional_equals();
1226 open_name(tail) = cur_name;
1227 open_area(tail) = cur_area;
1228 open_ext(tail) = cur_ext;
1234 new_write_whatsit(write_node_size);
1236 p = scan_toks(false, false);
1237 write_tokens(tail) = def_ref;
1242 new_write_whatsit(write_node_size);
1243 write_tokens(tail) = 0;
1248 new_whatsit(special_node, write_node_size);
1249 write_stream(tail) = 0;
1250 p = scan_toks(false, true);
1251 write_tokens(tail) = def_ref;
1254 case immediate_code:
1258 if ((cur_cmd == extension) && (cur_chr <= close_node))
1263 flush_node_list(tail);
1271 case set_language_code:
1272 if (abs(mode) != hmode)
1274 report_illegal_case();
1278 new_whatsit(language_node, small_node_size);
1283 else if (cur_val > 255)
1288 what_lang(tail) = clang;
1289 what_lhm(tail) = norm_min(left_hyphen_min);
1290 what_rhm(tail) = norm_min(right_hyphen_min);
1295 confusion("display");
1296 return; // abort_flag set
1302 void fix_language (void)
1305 int l; /* 95/Jan/7 */
1309 else if (language > 255)
1316 new_whatsit(language_node, small_node_size);
1317 what_lang(tail) = l;
1319 what_lhm(tail) = norm_min(left_hyphen_min);
1320 what_rhm(tail) = norm_min(right_hyphen_min);
1324 void handle_right_brace (void)
1337 print_err("Too many }'s");
1338 help2("You've closed more groups than you opened.",
1339 "Such booboos are generally harmless, so keep going.");
1343 case semi_simple_group:
1344 case math_shift_group:
1345 case math_left_group:
1346 extra_right_brace();
1351 case adjust_hbox_group:
1353 adjust_tail = adjust_head;
1374 d = split_max_depth;
1375 f = floating_penalty;
1378 p = vpackage(mem[head].hh.v.RH, 0, 1, 1073741823L); /* 2^30 - 1 */
1381 if (save_stack[save_ptr + 0].cint < 255)
1383 tail_append(get_node(5));
1384 type(tail) = ins_node;
1385 subtype(tail) = save_stack[save_ptr + 0].cint;
1386 height(tail) = height(p) + depth(p);
1387 ins_ptr(tail) = list_ptr(p);
1388 split_top_ptr(tail) = q;
1390 float_cost(tail) = f;
1394 tail_append(get_node(2));
1395 type(tail) = adjust_node;
1397 adjust_ptr(tail) = list_ptr(p);
1400 free_node(p, box_node_size);
1410 if ((cur_input.loc_field != 0) || ((token_type != output_text) && (token_type != backed_up)))
1412 print_err("Unbalanced output routine");
1413 help2("Your sneaky output routine has problematic {'s and/or }'s.",
1414 "I can't handle that very well; good luck.");
1420 while (!(cur_input.loc_field == 0));
1425 output_active = false;
1426 insert_penalties = 0;
1430 print_err("Output routine didn't use all of ");
1433 help3("Your \\output commands should empty \\box255,",
1434 "e.g., by saying `\\ship_out\\box255'.",
1435 "Proceed; I'll discard its present contents.");
1441 link(page_tail) = link(head);
1445 if (link(page_head) != 0)
1447 if (link(contrib_head) == 0)
1448 nest[0].tail_field = page_tail;
1450 link(page_tail) = link(contrib_head);
1451 link(contrib_head) = link(page_head);
1452 link(page_head) = 0;
1453 page_tail = page_head;
1460 build_discretionary();
1465 cur_tok = cs_token_flag + frozen_cr;
1466 print_err("Missing ");
1468 print_string("inserted");
1469 help1("I'm guessing that you meant to end an alignment here.");
1473 case no_align_group:
1484 save_ptr = save_ptr - 2;
1485 p = vpackage(link(head), save_stack[save_ptr + 1].cint, save_stack[save_ptr + 0].cint, 1073741823L); /* 2^30 - 1 */
1487 tail_append(new_noad());
1488 type(tail) = vcenter_noad;
1489 math_type(nucleus(tail)) = sub_box;
1490 info(nucleus(tail)) = p;
1493 case math_choice_group:
1500 math_type(save_stack[save_ptr + 0].cint) = sub_mlist;
1502 info(save_stack[save_ptr + 0].cint) = p;
1505 if (type(p) == ord_noad)
1507 if (math_type(subscr(p)) == 0)
1508 if (math_type(supscr(p)) == 0)
1510 mem[save_stack[save_ptr + 0].cint].hh = mem[p + 1].hh;
1511 free_node(p, noad_size);
1514 else if (type(p) == accent_noad)
1515 if (save_stack[save_ptr + 0].cint == nucleus(tail))
1516 if (type(tail) == ord_noad)
1520 while(link(q) != tail)
1524 free_node(tail, noad_size);
1531 confusion("rightbrace");
1532 return; // abort_flag set
1538 void main_control (void)
1541 integer bSuppress; /* 199/Jan/5 */
1544 begin_token_list(every_job, every_job_text);
1547 get_x_token(); /* big_switch */
1551 if (OK_to_interrupt)
1557 pause_for_instructions();
1568 if (tracing_commands > 0)
1571 /* the big switch --- don't bother to test abort_flag ??? */
1572 switch(abs(mode) + cur_cmd)
1574 case hmode + letter:
1575 case hmode + other_char:
1576 case hmode + char_given:
1579 case hmode + char_num:
1586 case hmode + no_boundary:
1590 if ((cur_cmd == letter) || (cur_cmd == other_char) ||
1591 (cur_cmd == char_given) || (cur_cmd == char_num))
1592 cancel_boundary = true;
1596 case hmode + spacer:
1597 if (space_factor == 1000)
1602 case hmode + ex_space:
1603 case mmode + ex_space:
1606 case any_mode(relax):
1607 case vmode + spacer:
1608 case mmode + spacer:
1609 case mmode + no_boundary:
1612 case any_mode(ignore_spaces):
1618 while(!(cur_cmd != spacer));
1629 case any_mode(last_item):
1630 case vmode + vadjust:
1631 case vmode + ital_corr:
1632 case non_math(eq_no):
1633 case any_mode(mac_param):
1634 report_illegal_case();
1636 case non_math(sup_mark):
1637 case non_math(sub_mark):
1638 case non_math(math_char_num):
1639 case non_math(math_given):
1640 case non_math(math_comp):
1641 case non_math(delim_num):
1642 case non_math(left_right):
1643 case non_math(above):
1644 case non_math(radical):
1645 case non_math(math_style):
1646 case non_math(math_choice):
1647 case non_math(vcenter):
1648 case non_math(non_script):
1649 case non_math(mkern):
1650 case non_math(limit_switch):
1651 case non_math(mskip):
1652 case non_math(math_accent):
1654 case mmode + par_end:
1657 case mmode + un_vbox:
1658 case mmode + valign:
1660 insert_dollar_sign();
1666 tail_append(scan_rule_spec());
1668 if (abs(mode) == vmode)
1669 prev_depth = ignore_depth;
1670 else if (abs(mode) == hmode)
1671 space_factor = 1000;
1680 case any_mode(kern):
1684 case non_math(left_brace):
1685 new_save_level(simple_group);
1687 case any_mode(begin_group):
1688 new_save_level(semi_simple_group);
1690 case any_mode(end_group):
1691 if (cur_group == semi_simple_group)
1696 case any_mode(right_brace):
1697 handle_right_brace();
1704 scan_dimen(false, false, false);
1709 scan_box(- (integer) cur_val);
1712 case any_mode(leader_ship):
1713 scan_box(leader_flag - a_leaders + cur_chr);
1715 case any_mode(make_box):
1718 case vmode + start_par:
1719 new_graf(cur_chr > 0);
1721 case vmode + letter:
1722 case vmode + other_char:
1723 case vmode + char_num:
1724 case vmode + char_given:
1725 case vmode + math_shift:
1726 case vmode + un_hbox:
1728 case vmode + accent:
1729 case vmode + discretionary:
1731 case vmode + valign:
1732 case vmode + ex_space:
1733 case vmode + no_boundary:
1739 case hmode + start_par:
1740 case mmode + start_par:
1743 case vmode + par_end:
1751 case hmode + par_end:
1753 if (align_state < 0)
1765 case hmode + un_vbox:
1766 case hmode + halign:
1769 case any_mode(insert):
1770 case hmode + vadjust:
1771 case mmode + vadjust:
1772 begin_insert_or_adjust();
1774 case any_mode(mark):
1777 case any_mode(break_penalty):
1780 case any_mode(remove_item):
1783 case vmode + un_vbox:
1784 case hmode + un_hbox:
1785 case mmode + un_hbox:
1788 case hmode + ital_corr:
1789 append_italic_correction();
1791 case mmode + ital_corr:
1792 tail_append(new_kern(0));
1794 case hmode + discretionary:
1795 case mmode + discretionary:
1796 append_discretionary();
1798 case hmode + accent:
1801 case any_mode(car_ret):
1802 case any_mode(tab_mark):
1805 case any_mode(no_align):
1808 case any_mode(omit):
1811 case vmode + halign:
1812 case hmode + valign:
1815 case mmode + halign:
1817 if (cur_group == math_shift_group)
1826 case any_mode(end_cs_name):
1829 case hmode + math_shift:
1834 if (cur_group == math_shift_group)
1839 case mmode + left_brace:
1841 tail_append(new_noad());
1843 scan_math(nucleus(tail));
1846 case mmode + letter:
1847 case mmode + other_char:
1848 case mmode + char_given:
1849 set_math_char(math_code(cur_chr));
1851 case mmode + char_num:
1855 set_math_char(math_code(cur_chr));
1858 case mmode + math_char_num:
1860 scan_fifteen_bit_int();
1861 set_math_char(cur_val);
1864 case mmode + math_given:
1865 set_math_char(cur_chr);
1867 case mmode + delim_num:
1869 scan_twenty_seven_bit_int();
1870 set_math_char(cur_val / 4096);
1873 case mmode + math_comp:
1875 tail_append(new_noad());
1876 type(tail) = cur_chr;
1877 scan_math(nucleus(tail));
1880 case mmode + limit_switch:
1881 math_limit_switch();
1883 case mmode + radical:
1886 case mmode + accent:
1887 case mmode + math_accent:
1890 case mmode + vcenter:
1892 scan_spec(vcenter_group, false);
1896 prev_depth = ignore_depth;
1898 if (every_vbox != 0)
1899 begin_token_list(every_vbox, every_vbox_text);
1902 case mmode + math_style:
1903 tail_append(new_style(cur_chr));
1905 case mmode + non_script:
1907 tail_append(new_glue(0));
1908 subtype(tail) = cond_math_glue;
1911 case mmode + math_choice:
1914 case mmode + sub_mark:
1915 case mmode + sup_mark:
1921 case mmode + left_right:
1924 case mmode + math_shift:
1925 if (cur_group == math_shift_group)
1930 case any_mode(toks_register):
1931 case any_mode(assign_toks):
1932 case any_mode(assign_int):
1933 case any_mode(assign_dimen):
1934 case any_mode(assign_glue):
1935 case any_mode(assign_mu_glue):
1936 case any_mode(assign_font_dimen):
1937 case any_mode(assign_font_int):
1938 case any_mode(set_aux):
1939 case any_mode(set_prev_graf):
1940 case any_mode(set_page_dimen):
1941 case any_mode(set_page_int):
1942 case any_mode(set_box_dimen):
1943 case any_mode(set_shape):
1944 case any_mode(def_code):
1945 case any_mode(def_family):
1946 case any_mode(set_font):
1947 case any_mode(def_font):
1948 case any_mode(tex_register):
1949 case any_mode(advance):
1950 case any_mode(multiply):
1951 case any_mode(divide):
1952 case any_mode(prefix):
1954 case any_mode(shorthand_def):
1955 case any_mode(read_to_cs):
1957 case any_mode(set_box):
1958 case any_mode(hyph_data):
1959 case any_mode(set_interaction):
1962 case any_mode(after_assignment):
1965 after_token = cur_tok;
1968 case any_mode(after_group):
1971 save_for_after(cur_tok);
1974 case any_mode(in_stream):
1977 case any_mode(message):
1980 case any_mode(case_shift):
1983 case any_mode(xray):
1986 case any_mode(extension):
1989 } /* end of big switch */
1990 goto lab60; /* main_loop */
1993 adjust_space_factor();
1995 bchar = font_bchar[main_f];
1996 false_bchar = font_false_bchar[main_f];
1999 if (language != clang)
2005 lig_stack = get_avail();
2008 avail = mem[lig_stack].hh.v.RH;
2009 mem[lig_stack].hh.v.RH = 0;
2015 font(lig_stack) = main_f;
2017 character(lig_stack) = cur_l;
2020 if (cancel_boundary)
2022 cancel_boundary = false;
2023 main_k = non_address;
2026 main_k = bchar_label[main_f];
2028 if (main_k == non_address)
2038 /* main_loop_move */
2044 cur_l = character(lig_stack);
2047 if (!(lig_stack >= hi_mem_min))
2051 if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f]))
2053 char_warning(main_f, cur_chr);
2054 free_avail(lig_stack);
2058 main_i = char_info(main_f, cur_l);
2060 if (!(main_i.b0 > 0))
2062 char_warning(main_f, cur_chr);
2063 free_avail(lig_stack);
2067 link(tail) = lig_stack;
2071 /* main_loop_lookahead */
2075 if (cur_cmd == letter)
2077 if (cur_cmd == other_char)
2079 if (cur_cmd == char_given)
2084 if (cur_cmd == letter)
2086 if (cur_cmd == other_char)
2088 if (cur_cmd == char_given)
2091 if (cur_cmd == char_num)
2098 if (cur_cmd == no_boundary)
2106 adjust_space_factor();
2111 lig_stack = get_avail();
2114 avail = mem[lig_stack].hh.v.RH;
2115 mem[lig_stack].hh.v.RH = 0;
2121 font(lig_stack) = main_f;
2123 character(lig_stack) = cur_r;
2125 if (cur_r == false_bchar)
2128 // main_lig_loop:@<If there's a ligature/kern command relevant to |cur_l| and
2129 // |cur_r|, adjust the text appropriately; exit to |main_loop_wrapup|@>;
2132 if (char_tag(main_i) != lig_tag)
2135 if (cur_r == non_char)
2138 main_k = lig_kern_start(main_f, main_i);
2139 main_j = font_info[main_k].qqqq;
2141 if (skip_byte(main_j) <= stop_flag)
2144 main_k = lig_kern_restart(main_f, main_j);
2146 /* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */
2148 main_j = font_info[main_k].qqqq;
2151 /* provide for suppression of f-ligatures 99/Jan/5 */
2154 if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag)
2160 if (next_char(main_j) == cur_r && bSuppress == 0) /* 99/Jan/5 */
2161 if (skip_byte(main_j) <= stop_flag)
2163 if (op_byte(main_j) >= kern_flag)
2166 tail_append(new_kern(char_kern(main_f, main_j)));
2170 if (cur_l == non_char)
2172 else if (lig_stack == 0)
2178 pause_for_instructions();
2182 switch (op_byte(main_j))
2187 cur_l = rem_byte(main_j);
2188 main_i = char_info(main_f, cur_l);
2189 ligature_present = true;
2195 cur_r = rem_byte(main_j);
2199 lig_stack = new_lig_item(cur_r);
2202 else if ((lig_stack >= hi_mem_min))
2205 lig_stack = new_lig_item(cur_r);
2206 lig_ptr(lig_stack) = main_p;
2209 character(lig_stack) = cur_r;
2214 cur_r = rem_byte(main_j);
2216 lig_stack = new_lig_item(cur_r);
2217 link(lig_stack) = main_p;
2225 cur_l = rem_byte(main_j);
2226 main_i = char_info(main_f, cur_l);
2227 ligature_present = true;
2232 cur_l = rem_byte(main_j);
2233 ligature_present = true;
2243 if (op_byte(main_j) > 4)
2244 if (op_byte(main_j) != 7)
2247 if (cur_l < non_char)
2250 main_k = bchar_label[main_f];
2254 if (skip_byte(main_j) == 0)
2258 if (skip_byte(main_j) >= stop_flag)
2261 main_k = main_k + skip_byte(main_j) + 1;
2268 main_p = lig_ptr(lig_stack);
2270 if (main_p != 0) /* BUG FIX */
2271 tail_append(main_p);
2273 temp_ptr = lig_stack;
2274 lig_stack = link(temp_ptr);
2275 free_node(temp_ptr, small_node_size);
2276 main_i = char_info(main_f, cur_l);
2277 ligature_present = true;
2280 if (main_p != 0) /* BUG FIX */
2285 cur_r = character(lig_stack);
2289 /* append_normal_space */
2291 if (space_skip == 0)
2294 main_p = font_glue[cur_font];
2298 main_p = new_spec(zero_glue);
2299 main_k = param_base[cur_font] + space_code;
2300 width(main_p) = font_info[main_k].cint;
2301 stretch(main_p) = font_info[main_k + 1].cint;
2302 shrink(main_p) = font_info[main_k + 2].cint;
2303 font_glue[cur_font] = main_p;
2306 temp_ptr = new_glue(main_p);
2309 temp_ptr = new_param_glue(space_skip_code);
2311 link(tail) = temp_ptr;
2315 /* give_err_help etc followed here in the old tex8.c */