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;
412 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
417 if (cur_cmd != spacer)
427 void get_r_token (void)
434 while (!(cur_tok != 2592));
436 if ((cur_cs == 0) || (cur_cs > frozen_control_sequence))
438 print_err("Missing control sequence inserted");
439 help5("Please don't say `\\def cs{...}', say `\\def\\cs{...}'.",
440 "I've inserted an inaccessible control sequence so that your",
441 "definition will be completed without mixing me up too badly.",
442 "You can recover graciously from this error, if you're",
443 "careful; see exercise 27.2 in The TeXbook.");
448 cur_tok = cs_token_flag + frozen_protection;
454 void trap_zero_glue (void)
456 if ((width(cur_val) == 0) && (stretch(cur_val) == 0) && (shrink(cur_val) == 0))
458 add_glue_ref(zero_glue);
459 delete_glue_ref(cur_val);
464 void do_register_command_ (small_number a)
472 if (q != tex_register)
476 if ((cur_cmd >= assign_int) && (cur_cmd <= assign_mu_glue))
479 p = cur_cmd - assign_int;
483 if (cur_cmd != tex_register)
485 print_err("You can't use `");
486 print_cmd_chr(cur_cmd, cur_chr);
487 print_string("' after ");
489 help1("I'm forgetting what you said and not changing anything.");
496 scan_eight_bit_int();
501 l = cur_val + count_base;
504 l = cur_val + scaled_base;
507 l = cur_val + skip_base;
510 l = cur_val + mu_skip_base;
516 if (q == tex_register)
517 scan_optional_equals();
519 if (scan_keyword("by"));
529 scan_dimen(false, false, false);
532 cur_val = cur_val + eqtb[l].cint;
540 q = new_spec(cur_val);
542 delete_glue_ref(cur_val);
543 width(q) = width(q) + width(r);
546 stretch_order(q) = normal;
548 if (stretch_order(q) == stretch_order(r))
549 stretch(q) = stretch(q) + stretch(r);
550 else if ((stretch_order(q) < stretch_order(r)) && (stretch(r) != 0))
552 stretch(q) = stretch(r);
553 stretch_order(q) = stretch_order(r);
557 shrink_order(q) = normal;
559 if (shrink_order(q) == shrink_order(r))
560 shrink(q) = shrink(q) + shrink(r);
561 else if ((shrink_order(q) < shrink_order(r)) && (shrink(r) != 0))
563 shrink(q) = shrink(r);
564 shrink_order(q) = shrink_order(r);
576 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 2147483647L); /* 2^31 - 1 */
578 cur_val = mult_and_add(eqtb[l].cint, cur_val, 0, 1073741823L); /* 2^30 - 1 */
580 cur_val = x_over_n(eqtb[l].cint, cur_val);
588 width(r) = mult_and_add(width(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
589 stretch(r) = mult_and_add(stretch(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
590 shrink(r) = mult_and_add(shrink(s), cur_val, 0, 1073741823L); /* 2^30 - 1 */
594 width(r) = x_over_n(width(s), cur_val);
595 stretch(r) = x_over_n(stretch(s), cur_val);
596 shrink(r) = x_over_n(shrink(s), cur_val);
604 print_err("Arithmetic overflow");
605 help2("I can't carry out that multiplication or division,",
606 "since the result is out of range.");
609 delete_glue_ref(cur_val);
618 geq_word_define(l, cur_val);
620 eq_word_define(l, cur_val);
627 geq_define(l, glue_ref, cur_val);
629 eq_define(l, glue_ref, cur_val);
632 /* called only from itex.c */
634 void alter_aux (void)
638 if (cur_chr != abs(mode))
640 report_illegal_case();
645 scan_optional_equals();
649 scan_dimen(false, false, false);
650 prev_depth = cur_val;
656 if ((cur_val <= 0) || (cur_val > 32767))
658 print_err("Bad space factor");
659 help1("I allow only values in the range 1..32767 here.");
663 space_factor = cur_val;
668 void alter_prev_graf (void)
672 nest[nest_ptr] = cur_list;
675 while(abs(nest[p].mode_field) != vmode)
678 scan_optional_equals();
684 print_esc("prevgraf");
685 help1("I allow only nonnegative values here.");
690 nest[p].pg_field = cur_val;
691 cur_list = nest[nest_ptr];
695 void alter_page_so_far (void)
700 scan_optional_equals();
701 scan_dimen(false, false, false);
702 page_so_far[c] = cur_val;
705 void alter_integer (void)
710 scan_optional_equals();
714 dead_cycles = cur_val;
716 insert_penalties = cur_val;
719 void alter_box_dimen (void)
725 scan_eight_bit_int();
727 scan_optional_equals();
728 scan_dimen(false, false, false);
731 mem[box(b) + c].cint = cur_val;
734 void new_font_(small_number a)
738 internal_font_number f;
741 str_number flushable_string;
751 else if (u >= single_base)
758 old_setting = selector;
760 print_string("FONT");
761 print(u - active_base);
762 selector = old_setting;
768 geq_define(u, set_font, 0);
770 eq_define(u, set_font, 0);
772 scan_optional_equals();
775 name_in_progress = true;
777 if (scan_keyword("at"))
779 scan_dimen(false, false, false);
782 if ((s <= 0) || (s >= 134217728L)) /* 2^27 */
784 print_err("Improper `at' size (");
786 print_string("pt), replaced by 10pt");
787 help2("I can only handle fonts at positive sizes that are",
788 "less than 2048pt, so I've changed what you said to 10pt.");
790 s = 10 * 65536L; /* 10pt */
793 else if (scan_keyword("scaled"))
796 s = - (integer) cur_val;
798 if ((cur_val <= 0) || (cur_val > 32768L))
800 print_err("Illegal magnification has been changed to 1000");
801 help1("The magnification ratio must be between 1 and 32768.");
809 name_in_progress = false;
811 flushable_string = str_ptr - 1;
813 if (trace_flag) /* debugging stuff only 98/Oct/5 */
815 int i, k1, k2, l1, l2;
816 char *sch = log_line;
817 k1 = str_start[cur_area];
818 k2 = str_start[cur_name];
819 l1 = length(cur_area);
820 l2 = length(cur_name);
822 show_line("FONT ", 0);
824 for (i = 0; i < l1; i++)
826 *sch++ = str_pool[i + k1];
829 for (i = 0; i < l2; i++)
831 *sch++ = str_pool[i + k2];
836 show_line(log_line, 0);
839 /* paragraph 1260 for f <- fontbase+1 to font_ptr do */
840 for (f = 1; f < font_ptr; f++)
842 if (str_eq_str(font_name[f], cur_name) && str_eq_str(font_area[f], cur_area))
844 if (cur_name == flushable_string)
847 cur_name = font_name[f];
852 if (s == font_size[f])
854 if (ignore_frozen == 0 || f > frozenfontptr)
858 sprintf(log_line, "SKIPPING %ld ", s);
859 show_line(log_line, 0);
865 else if (font_size[f] == xn_over_d(font_dsize[f], - (integer) s, 1000))
867 if (ignore_frozen == 0 || f > frozenfontptr)
871 sprintf(log_line, "SKIPPING %ld ", s);
872 show_line(log_line, 0);
881 show_line("READING ", 0);
883 f = read_font_info(u, cur_name, cur_area, s);
888 sprintf(log_line, "NEW FONT %d ", f);
889 show_line(log_line, 0);
893 eqtb[font_id_base + f] = eqtb[u];
898 sprintf(log_line, "ERROR: %s too large %d\n", "hash_used", t);
899 show_line(log_line, 1);
905 void new_interaction (void)
908 interaction = cur_chr;
910 if (interaction == batch_mode)
913 selector = term_only;
916 selector = selector + 2;
919 void do_assignments (void)
927 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
929 if (cur_cmd <= max_non_prefixed_command)
932 set_box_allowed = false;
934 set_box_allowed = true;
938 void open_or_close_in (void)
947 if (read_open[n] != closed)
949 (void) a_close(read_file[n]);
950 read_open[n] = closed;
955 scan_optional_equals();
957 pack_file_name(cur_name, cur_area, cur_ext);
959 /* *** some changes in following in 3.14159 *** */
960 /* if current extension is *not* empty, try to open using name as is */
961 /* string 335 is "" the empty string */
962 if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH))
964 /* we get here if extension is "", or file with extension failed to open */
965 /* if current extension is not `tex,' and `tex' is not irrelevant, try it */
966 /* string 785 is .tex */
967 else if ((cur_ext != 785) && (name_length + 5 < PATHMAX) &&
968 /* *** some changes in above file name handling *** */
969 (!extensionirrelevantp(name_of_file, name_length, "tex")))
971 name_of_file[name_length + 1] = '.'; /* .tex */
972 name_of_file[name_length + 2] = 't';
973 name_of_file[name_length + 3] = 'e';
974 name_of_file[name_length + 4] = 'x';
975 name_of_file[name_length + 5] = ' ';
976 name_length = name_length + 4;
978 if (a_open_in(read_file[n], TEXINPUTPATH))
979 read_open[n] = just_open;
982 name_length = name_length - 4; /* remove ".tex" again */
983 name_of_file[name_length + 1] = ' ';
985 if ((cur_ext == 335) && a_open_in(read_file[n], TEXINPUTPATH))
987 else if (maketextex () && a_open_in(read_file[n], TEXINPUTPATH))
994 void issue_message (void)
1001 link(garbage) = scan_toks(false, true);
1002 old_setting = selector;
1003 selector = new_string;
1004 token_show(def_ref);
1005 selector = old_setting;
1006 flush_list(def_ref);
1012 if (term_offset + length(s) > max_print_line - 2)
1014 else if ((term_offset > 0) || (file_offset > 0))
1029 use_err_help = true;
1030 else if (long_help_seen)
1031 help1("(That was another \\errmessage.)");
1034 if (interaction < error_stop_mode)
1035 long_help_seen = true;
1037 help4("This error message was generated by an \\errmessage",
1038 "command, so I can't give any explicit help.",
1039 "Pretend that you're Hercule Poirot: Examine all clues,",
1040 "and deduce the truth by order and method.");
1044 use_err_help = false;
1050 void shift_case (void)
1058 p = scan_toks(false, false);
1065 if (t < cs_token_flag + single_base) /* 4095 + 257 = cs_tokenflag + single_base */
1069 if (equiv(b + c) != 0)
1070 info(p) = t - c + equiv(b + c);
1075 begin_token_list(link(def_ref), 3);
1076 free_avail(def_ref);
1079 void show_whatever (void)
1093 scan_eight_bit_int();
1095 print_nl("> \\box");
1099 if (box(cur_val) == 0)
1100 print_string("void");
1102 show_box(box(cur_val));
1109 if (interaction == error_stop_mode)
1128 if (interaction == error_stop_mode)
1132 token_show(temp_head);
1133 flush_list(link(temp_head));
1139 end_diagnostic(true);
1142 if (selector == term_and_log)
1143 if (tracing_online <= 0)
1145 selector = term_only;
1146 print_string(" (see the transcript file)");
1147 selector = term_and_log;
1152 if (interaction < error_stop_mode)
1157 else if (tracing_online > 0)
1159 help3("This isn't an error message; I'm just \\showing something.",
1160 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1161 "\\showthe\\count10, \\showbox255, \\showlists).");
1165 help5("This isn't an error message; I'm just \\showing something.",
1166 "Type `I\\show...' to show more (e.g., \\show\\cs,",
1167 "\\showthe\\count10, \\showbox255, \\showlists).",
1168 "And type `I\\tracingonline=1\\show...' to show boxes and",
1169 "lists on your terminal as well as in the transcript file.");
1174 void new_whatsit_(small_number s, small_number w)
1179 type(p) = whatsit_node;
1185 void new_write_whatsit_(small_number w)
1187 new_whatsit(cur_chr, w);
1189 if (w != write_node_size)
1191 scan_four_bit_int();
1199 else if (cur_val > 15)
1202 write_stream(tail) = cur_val;
1205 void do_extension (void)
1207 /* integer i, j, k; */
1209 /* halfword p, q, r; */
1216 new_write_whatsit(open_node_size);
1217 scan_optional_equals();
1219 open_name(tail) = cur_name;
1220 open_area(tail) = cur_area;
1221 open_ext(tail) = cur_ext;
1227 new_write_whatsit(write_node_size);
1229 p = scan_toks(false, false);
1230 write_tokens(tail) = def_ref;
1235 new_write_whatsit(write_node_size);
1236 write_tokens(tail) = 0;
1241 new_whatsit(special_node, write_node_size);
1242 write_stream(tail) = 0;
1243 p = scan_toks(false, true);
1244 write_tokens(tail) = def_ref;
1247 case immediate_code:
1251 if ((cur_cmd == extension) && (cur_chr <= close_node))
1256 flush_node_list(tail);
1264 case set_language_code:
1265 if (abs(mode) != hmode)
1267 report_illegal_case();
1271 new_whatsit(language_node, small_node_size);
1276 else if (cur_val > 255)
1281 what_lang(tail) = clang;
1282 what_lhm(tail) = norm_min(left_hyphen_min);
1283 what_rhm(tail) = norm_min(right_hyphen_min);
1289 return; // abort_flag set
1295 void fix_language (void)
1298 int l; /* 95/Jan/7 */
1302 else if (language > 255)
1309 new_whatsit(language_node, small_node_size);
1310 what_lang(tail) = l;
1312 what_lhm(tail) = norm_min(left_hyphen_min);
1313 what_rhm(tail) = norm_min(right_hyphen_min);
1317 void handle_right_brace (void)
1330 print_err("Too many }'s");
1331 help2("You've closed more groups than you opened.",
1332 "Such booboos are generally harmless, so keep going.");
1336 case semi_simple_group:
1337 case math_shift_group:
1338 case math_left_group:
1339 extra_right_brace();
1344 case adjust_hbox_group:
1346 adjust_tail = adjust_head;
1367 d = split_max_depth;
1368 f = floating_penalty;
1371 p = vpackage(mem[head].hh.v.RH, 0, 1, 1073741823L); /* 2^30 - 1 */
1374 if (save_stack[save_ptr + 0].cint < 255)
1376 tail_append(get_node(5));
1377 type(tail) = ins_node;
1378 subtype(tail) = save_stack[save_ptr + 0].cint;
1379 height(tail) = height(p) + depth(p);
1380 ins_ptr(tail) = list_ptr(p);
1381 split_top_ptr(tail) = q;
1383 float_cost(tail) = f;
1387 tail_append(get_node(2));
1388 type(tail) = adjust_node;
1390 adjust_ptr(tail) = list_ptr(p);
1393 free_node(p, box_node_size);
1403 if ((cur_input.loc_field != 0) || ((token_type != output_text) && (token_type != backed_up)))
1405 print_err("Unbalanced output routine");
1406 help2("Your sneaky output routine has problematic {'s and/or }'s.",
1407 "I can't handle that very well; good luck.");
1413 while (!(cur_input.loc_field == 0));
1418 output_active = false;
1419 insert_penalties = 0;
1423 print_err("Output routine didn't use all of ");
1426 help3("Your \\output commands should empty \\box255,",
1427 "e.g., by saying `\\shipout\\box255'.",
1428 "Proceed; I'll discard its present contents.");
1434 link(page_tail) = link(head);
1438 if (link(page_head) != 0)
1440 if (link(contrib_head) == 0)
1441 nest[0].tail_field = page_tail;
1443 link(page_tail) = link(contrib_head);
1444 link(contrib_head) = link(page_head);
1445 link(page_head) = 0;
1446 page_tail = page_head;
1453 build_discretionary();
1458 cur_tok = cs_token_flag + frozen_cr;
1459 print_err("Missing ");
1461 print_string("inserted");
1462 help1("I'm guessing that you meant to end an alignment here.");
1466 case no_align_group:
1477 save_ptr = save_ptr - 2;
1478 p = vpackage(link(head), save_stack[save_ptr + 1].cint, save_stack[save_ptr + 0].cint, 1073741823L); /* 2^30 - 1 */
1480 tail_append(new_noad());
1481 type(tail) = vcenter_noad;
1482 math_type(nucleus(tail)) = sub_box;
1483 info(nucleus(tail)) = p;
1486 case math_choice_group:
1493 math_type(save_stack[save_ptr + 0].cint) = sub_mlist;
1495 info(save_stack[save_ptr + 0].cint) = p;
1498 if (type(p) == ord_noad)
1500 if (math_type(subscr(p)) == 0)
1501 if (math_type(supscr(p)) == 0)
1503 mem[save_stack[save_ptr + 0].cint].hh = mem[p + 1].hh;
1504 free_node(p, noad_size);
1507 else if (type(p) == accent_noad)
1508 if (save_stack[save_ptr + 0].cint == nucleus(tail))
1509 if (type(tail) == ord_noad)
1513 while(link(q) != tail)
1517 free_node(tail, noad_size);
1524 confusion("rightbrace");
1525 return; // abort_flag set
1531 void main_control (void)
1534 integer bSuppress; /* 199/Jan/5 */
1537 begin_token_list(every_job, every_job_text);
1540 get_x_token(); /* big_switch */
1544 if (OK_to_interrupt)
1550 pause_for_instructions();
1561 if (tracing_commands > 0)
1564 /* the big switch --- don't bother to test abort_flag ??? */
1565 switch(abs(mode) + cur_cmd)
1567 case hmode + letter:
1568 case hmode + other_char:
1569 case hmode + char_given:
1572 case hmode + char_num:
1579 case hmode + no_boundary:
1583 if ((cur_cmd == letter) || (cur_cmd == other_char) ||
1584 (cur_cmd == char_given) || (cur_cmd == char_num))
1585 cancel_boundary = true;
1589 case hmode + spacer:
1590 if (space_factor == 1000)
1595 case hmode + ex_space:
1596 case mmode + ex_space:
1599 case any_mode(relax):
1600 case vmode + spacer:
1601 case mmode + spacer:
1602 case mmode + no_boundary:
1605 case any_mode(ignore_spaces):
1611 while(!(cur_cmd != spacer));
1622 case any_mode(last_item):
1623 case vmode + vadjust:
1624 case vmode + ital_corr:
1625 case non_math(eq_no):
1626 case any_mode(mac_param):
1627 report_illegal_case();
1629 case non_math(sup_mark):
1630 case non_math(sub_mark):
1631 case non_math(math_char_num):
1632 case non_math(math_given):
1633 case non_math(math_comp):
1634 case non_math(delim_num):
1635 case non_math(left_right):
1636 case non_math(above):
1637 case non_math(radical):
1638 case non_math(math_style):
1639 case non_math(math_choice):
1640 case non_math(vcenter):
1641 case non_math(non_script):
1642 case non_math(mkern):
1643 case non_math(limit_switch):
1644 case non_math(mskip):
1645 case non_math(math_accent):
1647 case mmode + par_end:
1650 case mmode + un_vbox:
1651 case mmode + valign:
1653 insert_dollar_sign();
1659 tail_append(scan_rule_spec());
1661 if (abs(mode) == vmode)
1662 prev_depth = ignore_depth;
1663 else if (abs(mode) == hmode)
1664 space_factor = 1000;
1673 case any_mode(kern):
1677 case non_math(left_brace):
1678 new_save_level(simple_group);
1680 case any_mode(begin_group):
1681 new_save_level(semi_simple_group);
1683 case any_mode(end_group):
1684 if (cur_group == semi_simple_group)
1689 case any_mode(right_brace):
1690 handle_right_brace();
1697 scan_dimen(false, false, false);
1702 scan_box(- (integer) cur_val);
1705 case any_mode(leader_ship):
1706 scan_box(leader_flag - a_leaders + cur_chr);
1708 case any_mode(make_box):
1711 case vmode + start_par:
1712 new_graf(cur_chr > 0);
1714 case vmode + letter:
1715 case vmode + other_char:
1716 case vmode + char_num:
1717 case vmode + char_given:
1718 case vmode + math_shift:
1719 case vmode + un_hbox:
1721 case vmode + accent:
1722 case vmode + discretionary:
1724 case vmode + valign:
1725 case vmode + ex_space:
1726 case vmode + no_boundary:
1732 case hmode + start_par:
1733 case mmode + start_par:
1736 case vmode + par_end:
1744 case hmode + par_end:
1746 if (align_state < 0)
1758 case hmode + un_vbox:
1759 case hmode + halign:
1762 case any_mode(insert):
1763 case hmode + vadjust:
1764 case mmode + vadjust:
1765 begin_insert_or_adjust();
1767 case any_mode(mark):
1770 case any_mode(break_penalty):
1773 case any_mode(remove_item):
1776 case vmode + un_vbox:
1777 case hmode + un_hbox:
1778 case mmode + un_hbox:
1781 case hmode + ital_corr:
1782 append_italic_correction();
1784 case mmode + ital_corr:
1785 tail_append(new_kern(0));
1787 case hmode + discretionary:
1788 case mmode + discretionary:
1789 append_discretionary();
1791 case hmode + accent:
1794 case any_mode(car_ret):
1795 case any_mode(tab_mark):
1798 case any_mode(no_align):
1801 case any_mode(omit):
1804 case vmode + halign:
1805 case hmode + valign:
1808 case mmode + halign:
1810 if (cur_group == math_shift_group)
1819 case any_mode(end_cs_name):
1822 case hmode + math_shift:
1827 if (cur_group == math_shift_group)
1832 case mmode + left_brace:
1834 tail_append(new_noad());
1836 scan_math(nucleus(tail));
1839 case mmode + letter:
1840 case mmode + other_char:
1841 case mmode + char_given:
1842 set_math_char(math_code(cur_chr));
1844 case mmode + char_num:
1848 set_math_char(math_code(cur_chr));
1851 case mmode + math_char_num:
1853 scan_fifteen_bit_int();
1854 set_math_char(cur_val);
1857 case mmode + math_given:
1858 set_math_char(cur_chr);
1860 case mmode + delim_num:
1862 scan_twenty_seven_bit_int();
1863 set_math_char(cur_val / 4096);
1866 case mmode + math_comp:
1868 tail_append(new_noad());
1869 type(tail) = cur_chr;
1870 scan_math(nucleus(tail));
1873 case mmode + limit_switch:
1874 math_limit_switch();
1876 case mmode + radical:
1879 case mmode + accent:
1880 case mmode + math_accent:
1883 case mmode + vcenter:
1885 scan_spec(vcenter_group, false);
1889 prev_depth = ignore_depth;
1891 if (every_vbox != 0)
1892 begin_token_list(every_vbox, every_vbox_text);
1895 case mmode + math_style:
1896 tail_append(new_style(cur_chr));
1898 case mmode + non_script:
1900 tail_append(new_glue(0));
1901 subtype(tail) = cond_math_glue;
1904 case mmode + math_choice:
1907 case mmode + sub_mark:
1908 case mmode + sup_mark:
1914 case mmode + left_right:
1917 case mmode + math_shift:
1918 if (cur_group == math_shift_group)
1923 case any_mode(toks_register):
1924 case any_mode(assign_toks):
1925 case any_mode(assign_int):
1926 case any_mode(assign_dimen):
1927 case any_mode(assign_glue):
1928 case any_mode(assign_mu_glue):
1929 case any_mode(assign_font_dimen):
1930 case any_mode(assign_font_int):
1931 case any_mode(set_aux):
1932 case any_mode(set_prev_graf):
1933 case any_mode(set_page_dimen):
1934 case any_mode(set_page_int):
1935 case any_mode(set_box_dimen):
1936 case any_mode(set_shape):
1937 case any_mode(def_code):
1938 case any_mode(def_family):
1939 case any_mode(set_font):
1940 case any_mode(def_font):
1941 case any_mode(tex_register):
1942 case any_mode(advance):
1943 case any_mode(multiply):
1944 case any_mode(divide):
1945 case any_mode(prefix):
1947 case any_mode(shorthand_def):
1948 case any_mode(read_to_cs):
1950 case any_mode(set_box):
1951 case any_mode(hyph_data):
1952 case any_mode(set_interaction):
1955 case any_mode(after_assignment):
1958 after_token = cur_tok;
1961 case any_mode(after_group):
1964 save_for_after(cur_tok);
1967 case any_mode(in_stream):
1970 case any_mode(message):
1973 case any_mode(case_shift):
1976 case any_mode(xray):
1979 case any_mode(extension):
1982 } /* end of big switch */
1983 goto lab60; /* main_loop */
1986 adjust_space_factor();
1988 bchar = font_bchar[main_f];
1989 false_bchar = font_false_bchar[main_f];
1992 if (language != clang)
1998 lig_stack = get_avail();
2001 avail = mem[lig_stack].hh.v.RH;
2002 mem[lig_stack].hh.v.RH = 0;
2008 font(lig_stack) = main_f;
2010 character(lig_stack) = cur_l;
2013 if (cancel_boundary)
2015 cancel_boundary = false;
2016 main_k = non_address;
2019 main_k = bchar_label[main_f];
2021 if (main_k == non_address)
2031 /* main_loop_move */
2037 cur_l = character(lig_stack);
2040 if (!(lig_stack >= hi_mem_min))
2044 if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f]))
2046 char_warning(main_f, cur_chr);
2047 free_avail(lig_stack);
2051 main_i = char_info(main_f, cur_l);
2053 if (!(main_i.b0 > 0))
2055 char_warning(main_f, cur_chr);
2056 free_avail(lig_stack);
2060 link(tail) = lig_stack;
2064 /* main_loop_lookahead */
2068 if (cur_cmd == letter)
2070 if (cur_cmd == other_char)
2072 if (cur_cmd == char_given)
2077 if (cur_cmd == letter)
2079 if (cur_cmd == other_char)
2081 if (cur_cmd == char_given)
2084 if (cur_cmd == char_num)
2091 if (cur_cmd == no_boundary)
2099 adjust_space_factor();
2104 lig_stack = get_avail();
2107 avail = mem[lig_stack].hh.v.RH;
2108 mem[lig_stack].hh.v.RH = 0;
2114 font(lig_stack) = main_f;
2116 character(lig_stack) = cur_r;
2118 if (cur_r == false_bchar)
2121 // main_lig_loop:@<If there's a ligature/kern command relevant to |cur_l| and
2122 // |cur_r|, adjust the text appropriately; exit to |main_loop_wrapup|@>;
2125 if (char_tag(main_i) != lig_tag)
2128 if (cur_r == non_char)
2131 main_k = lig_kern_start(main_f, main_i);
2132 main_j = font_info[main_k].qqqq;
2134 if (skip_byte(main_j) <= stop_flag)
2137 main_k = lig_kern_restart(main_f, main_j);
2139 /* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */
2141 main_j = font_info[main_k].qqqq;
2144 /* provide for suppression of f-ligatures 99/Jan/5 */
2147 if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag)
2153 if (next_char(main_j) == cur_r && bSuppress == 0) /* 99/Jan/5 */
2154 if (skip_byte(main_j) <= stop_flag)
2156 if (op_byte(main_j) >= kern_flag)
2159 tail_append(new_kern(char_kern(main_f, main_j)));
2163 if (cur_l == non_char)
2165 else if (lig_stack == 0)
2171 pause_for_instructions();
2175 switch (op_byte(main_j))
2180 cur_l = rem_byte(main_j);
2181 main_i = char_info(main_f, cur_l);
2182 ligature_present = true;
2188 cur_r = rem_byte(main_j);
2192 lig_stack = new_lig_item(cur_r);
2195 else if ((lig_stack >= hi_mem_min))
2198 lig_stack = new_lig_item(cur_r);
2199 lig_ptr(lig_stack) = main_p;
2202 character(lig_stack) = cur_r;
2207 cur_r = rem_byte(main_j);
2209 lig_stack = new_lig_item(cur_r);
2210 link(lig_stack) = main_p;
2218 cur_l = rem_byte(main_j);
2219 main_i = char_info(main_f, cur_l);
2220 ligature_present = true;
2225 cur_l = rem_byte(main_j);
2226 ligature_present = true;
2236 if (op_byte(main_j) > 4)
2237 if (op_byte(main_j) != 7)
2240 if (cur_l < non_char)
2243 main_k = bchar_label[main_f];
2247 if (skip_byte(main_j) == 0)
2251 if (skip_byte(main_j) >= stop_flag)
2254 main_k = main_k + skip_byte(main_j) + 1;
2261 main_p = lig_ptr(lig_stack);
2263 if (main_p != 0) /* BUG FIX */
2264 tail_append(main_p);
2266 temp_ptr = lig_stack;
2267 lig_stack = link(temp_ptr);
2268 free_node(temp_ptr, small_node_size);
2269 main_i = char_info(main_f, cur_l);
2270 ligature_present = true;
2273 if (main_p != 0) /* BUG FIX */
2278 cur_r = character(lig_stack);
2282 /* append_normal_space */
2284 if (space_skip == 0)
2287 main_p = font_glue[cur_font];
2291 main_p = new_spec(zero_glue);
2292 main_k = param_base[cur_font] + space_code;
2293 width(main_p) = font_info[main_k].cint;
2294 stretch(main_p) = font_info[main_k + 1].cint;
2295 shrink(main_p) = font_info[main_k + 2].cint;
2296 font_glue[cur_font] = main_p;
2299 temp_ptr = new_glue(main_p);
2302 temp_ptr = new_param_glue(space_skip_code);
2304 link(tail) = temp_ptr;
2308 /* give_err_help etc followed here in the old tex8.c */