6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
11 #pragma warning(disable:4131) // old style declarator
12 #pragma warning(disable:4135) // conversion between different integral types
13 #pragma warning(disable:4127) // conditional expression is constant
21 #pragma warning(disable:4244) /* 96/Jan/10 */
23 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
25 void build_page (void)
31 /* unsigned char n; */
32 unsigned int n; /* 95/Jan/7 */
35 if ((link(contrib_head) == 0) || output_active)
41 p = link(contrib_head);
43 if (last_glue != max_halfword)
44 delete_glue_ref(last_glue);
49 if (type(p) == glue_node)
51 last_glue = glue_ptr(p);
52 add_glue_ref(last_glue);
56 last_glue = max_halfword;
58 if (type(p) == penalty_node)
59 last_penalty = penalty(p);
60 else if (type(p) == kern_node)
69 if (page_contents < box_there)
71 if (page_contents == 0)
72 freeze_page_specs(box_there);
74 page_contents = box_there;
76 q = new_skip_param(top_skip_code);
78 if (width(temp_ptr) > height(p))
79 width(temp_ptr) = width(temp_ptr) - height(p);
84 link(contrib_head) = q;
89 page_total = page_total + page_depth + height(p);
90 page_depth = depth(p);
100 if (page_contents < box_there)
102 else if (precedes_break(page_tail))
109 if (page_contents < box_there)
111 else if (link(p) == 0)
113 else if (type(link(p)) == glue_node)
120 if (page_contents < box_there)
132 if (page_contents == 0)
133 freeze_page_specs(inserts_only);
138 while (n >= subtype(link(r)))
145 q = get_node(page_ins_node_size);
156 height(r) = height(box(n)) + depth(box(n));
161 if (count(n) == 1000)
164 h = x_over_n(height(r), 1000) * count(n);
166 page_goal = page_goal - h - width(q);
167 page_so_far[2 + stretch_order(q)] = page_so_far[2 + stretch_order(q)] + stretch(q);
168 page_shrink = page_shrink + shrink(q);
170 if ((shrink_order(q) != normal) && (shrink(q) != 0))
172 print_err("Infinite glue shrinkage inserted from ");
175 help3("The correction glue for page breaking with insertions",
176 "must have finite shrinkability. But you may proceed,",
177 "since the offensive shrinkability has been made finite.");
182 if (type(r) == split_up)
183 insert_penalties = insert_penalties + float_cost(p);
187 delta = page_goal - page_total - page_depth + page_shrink;
189 if (count(n) == 1000)
192 h = x_over_n(height(p), 1000) * count(n);
194 if (((h <= 0) || (h <= delta)) && (height(p) + height(r) <= dimen(n)))
196 page_goal = page_goal - h;
197 height(r) = height(r) + height(p);
202 w = max_dimen; /* 2^30 - 1 */
205 w = page_goal - page_total - page_depth;
207 if (count(n) != 1000)
208 w = x_over_n(w, count(n)) * 1000;
211 if (w > dimen(n) - height(r))
212 w = dimen(n) - height(r);
214 q = vert_break(ins_ptr(p), w, depth(p));
215 height(r) = height(r) + best_height_plus_depth;
218 if (tracing_pages > 0)
226 print_scaled(best_height_plus_depth);
230 print_int(eject_penalty);
231 else if (type(q) == penalty_node)
232 print_int(penalty(q));
236 end_diagnostic(false);
239 if (count(n) != 1000)
240 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * count(n);
242 page_goal = page_goal - best_height_plus_depth;
248 insert_penalties = insert_penalties + (eject_penalty);
249 else if (type(q) == penalty_node)
250 insert_penalties = insert_penalties + penalty(q);
260 return; // abort_flag set
265 if (pi < inf_penalty)
267 if (page_total < page_goal)
268 if ((page_so_far[3] != 0) || (page_so_far[4] != 0) || (page_so_far[5] != 0))
271 b = badness(page_goal - page_total, page_so_far[2]);
272 else if (page_total - page_goal > page_shrink)
273 b = awful_bad; /* 2^30 - 1 */
275 b = badness(page_total - page_goal, page_shrink);
277 if (b < awful_bad) /* 2^30 - 1 */
278 if (pi <= eject_penalty)
280 else if (b < inf_bad)
281 c = b + pi + insert_penalties;
287 if (insert_penalties >= 10000)
288 c = awful_bad; /* 2^30 - 1 */
291 if (tracing_pages > 0)
298 print_scaled(page_goal);
301 if (b == awful_bad) /* 2^30 - 1 */
310 if (c == awful_bad) /* 2^30 - 1 */
315 if (c <= least_page_cost)
318 end_diagnostic(false);
322 if (c <= least_page_cost)
325 best_size = page_goal;
327 r = link(page_ins_head);
329 while (r != page_ins_head)
331 best_ins_ptr(r) = last_ins_ptr(r);
336 if ((c == awful_bad) || (pi <= eject_penalty)) /* 2^30 - 1 */
347 if ((type(p) < glue_node) || (type(p) > kern_node))
350 if (type(p) == kern_node)
355 page_so_far[2 + stretch_order(q)] = page_so_far[2 + stretch_order(q)] + stretch(q);
356 page_shrink = page_shrink + shrink(q);
358 if ((shrink_order(q) != normal) && (shrink(q) != 0))
360 print_err("Infinite glue shrinkage found on current page");
361 help4("The page about to be output contains some infinitely",
362 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
363 "Such glue doesn't belong there; but you can safely proceed,",
364 "since the offensive shrinkability has been made finite.");
367 shrink_order(r) = normal;
374 page_total = page_total + page_depth + width(q);
377 if (page_depth > page_max_depth)
379 page_total = page_total + page_depth - page_max_depth;
380 page_depth = page_max_depth;
385 link(contrib_head) = link(p);
389 link(contrib_head) = link(p);
394 while (!(link(contrib_head) == 0));
399 nest[0].tail_field = contrib_head;
402 void app_space (void)
406 if ((space_factor >= 2000) && (xspace_skip != zero_glue))
407 q = new_param_glue(xspace_skip_code);
410 if (space_skip != zero_glue)
414 main_p = font_glue[cur_font];
418 main_p = new_spec(zero_glue);
419 main_k = param_base[cur_font] + space_code;
420 width(main_p) = font_info[main_k].cint;
421 stretch(main_p) = font_info[main_k + 1].cint;
422 shrink(main_p) = font_info[main_k + 2].cint;
423 font_glue[cur_font] = main_p;
427 main_p = new_spec(main_p);
429 if (space_factor >= 2000)
430 width(main_p) = width(main_p) + extra_space(cur_font);
432 stretch(main_p) = xn_over_d(stretch(main_p), space_factor, 1000);
433 shrink(main_p) = xn_over_d(shrink(main_p), 1000, space_factor);
434 q = new_glue(main_p);
435 glue_ref_count(main_p) = 0;
441 /* called from tex8.c only */
443 void insert_dollar_sign (void)
446 cur_tok = math_shift_token + '$';
447 print_err("Missing $ inserted");
448 help2("I've inserted a begin-math/end-math symbol since I think",
449 "you left one out. Proceed, with fingers crossed.");
455 print_err("You can't use `");
456 print_cmd_chr(cur_cmd, cur_chr);
457 print_string("' in ");
461 void report_illegal_case (void)
464 help4("Sorry, but I'm not programmed to handle this case;",
465 "I'll just pretend that you didn't ask for it.",
466 "If you're in the wrong mode, you might be able to",
467 "return to the right one by typing `I}' or `I$' or `I\\par'.");
471 bool privileged (void)
477 report_illegal_case();
482 bool its_all_over (void)
486 if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
492 tail_append(new_null_box());
494 tail_append(new_glue(fill_glue));
495 tail_append(new_penalty(-1073741824L));
502 void append_glue (void)
523 cur_val = fil_neg_glue;
535 tail_append(new_glue(cur_val));
539 decr(glue_ref_count(cur_val));
542 subtype(tail) = mu_glue;
546 void append_kern (void)
552 scan_dimen(s == mu_glue, false, false);
553 tail_append(new_kern(cur_val));
561 if (cur_group == bottom_level)
564 print_cmd_chr(cur_cmd, cur_chr);
565 help1("Things are pretty mixed up, but I think the worst is over.");
573 print_err("Missing ");
577 case semi_simple_group:
579 info(p) = cs_token_flag + frozen_end_group;
580 print_esc("endgroup");
584 case math_shift_group:
586 info(p) = math_shift_token + '$';
591 case math_left_group:
593 info(p) = cs_token_flag + frozen_right;
594 link(p) = get_avail();
596 info(p) = other_token + '.';
603 info(p) = right_brace_token + '}';
609 print_string(" inserted");
610 ins_list(link(temp_head));
611 help5("I've inserted something that you may have forgotten.",
612 "(See the <inserted text> above.)",
613 "With luck, this will get me unwedged. But if you",
614 "really didn't forget anything, try typing `2' now; then",
615 "my insertion and my current dilemma will both disappear.");
619 /* only called from tex8.c */
621 void extra_right_brace (void)
623 print_err("Extra }, or forgotten ");
627 case semi_simple_group:
628 print_esc("endgroup");
631 case math_shift_group:
635 case math_left_group:
640 help5("I've deleted a group-closing symbol because it seems to be",
641 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
642 "you forgot something else, as in `\\hbox{$x}'. In such cases",
643 "the way to recover is to insert both the forgotten and the",
644 "deleted material, e.g., by typing `I$}'.");
649 void normal_paragraph (void)
652 eq_word_define(int_base + looseness_code, 0);
654 if (hang_indent != 0)
655 eq_word_define(dimen_base + hang_indent_code, 0);
658 eq_word_define(int_base + hang_after_code, 1);
660 if (par_shape_ptr != 0)
661 eq_define(par_shape_loc, shape_ref, 0);
664 void box_end_(integer box_context)
668 if (box_context < box_flag)
672 shift_amount(cur_box) = box_context;
674 if (abs(mode) == vmode)
676 append_to_vlist(cur_box);
678 if (adjust_tail != 0)
680 if (adjust_head != adjust_tail)
682 link(tail) = link(adjust_head);
694 if (abs(mode) == hmode)
699 math_type(nucleus(p)) = sub_box;
700 info(nucleus(p)) = cur_box;
704 link(tail) = cur_box;
709 else if (box_context < ship_out_flag)
710 if (box_context < (box_flag + 256))
711 eq_define((box_base - box_flag) + box_context, box_ref, cur_box);
713 geq_define((box_base - box_flag - 256) + box_context, box_ref, cur_box);
714 else if (cur_box != 0)
715 if (box_context > ship_out_flag)
721 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
723 if (((cur_cmd == hskip) && (abs(mode)!= vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode)))
726 subtype(tail) = box_context - (leader_flag - a_leaders);
727 leader_ptr(tail) = cur_box;
731 print_err("Leaders not followed by proper glue");
732 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
733 "I found the <box or rule>, but there's no suitable",
734 "<hskip or vskip>, so I'm ignoring these leaders.");
736 flush_node_list(cur_box);
742 /* called only from tex8.c */
744 void begin_box_(integer box_context)
755 scan_eight_bit_int();
756 cur_box = box(cur_val);
763 scan_eight_bit_int();
764 cur_box = copy_node_list(box(cur_val));
772 if (abs(mode) == mmode)
775 help1("Sorry; this \\lastbox will be void.");
778 else if ((mode == vmode) && (head == cur_list.tail_field))
781 help2("Sorry...I usually can't take things from the current page.",
782 "This \\lastbox will therefore be void.");
787 if (!(tail >= hi_mem_min))
788 if ((type(tail) == hlist_node) || (type(tail) == vlist_node))
796 if (!(q >= hi_mem_min))
797 if (type(q) == disc_node)
799 for (m = 1; m <= replace_count(q); m++)
808 while (!(q == tail));
811 shift_amount(cur_box) = 0;
823 scan_eight_bit_int();
826 if (!scan_keyword("to"))
828 print_err("Missing `to' inserted");
829 help2("I'm working on `\\vsplit<box number> to <dimen>';",
830 "will look for the <dimen> next.");
834 scan_dimen(false, false, false);
835 cur_box = vsplit(n, cur_val);
841 k = cur_chr - vtop_code;
842 saved(0) = box_context;
845 if ((box_context < box_flag) && (abs(mode) == vmode))
846 scan_spec(adjust_hbox_group, true);
848 scan_spec(hbox_group, true);
852 scan_spec(vbox_group, true);
855 scan_spec(vtop_group, true);
863 mode = - (integer) k;
867 prev_depth = ignore_depth;
870 begin_token_list(every_vbox, every_vbox_text);
877 begin_token_list(every_hbox, every_vbox_text);
884 box_end(box_context);
887 void scan_box_(integer box_context)
893 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
895 if (cur_cmd == make_box)
897 begin_box(box_context);
899 else if ((box_context >= leader_flag) && ((cur_cmd == hrule) || (cur_cmd == vrule)))
901 cur_box = scan_rule_spec();
902 box_end(box_context);
906 print_err("A <box> was supposed to be here");
907 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
908 "something like that. So you might find something missing in",
909 "your output. But keep trying; you can fix this later.");
913 /****************************************************************************/
914 void package_ (small_number);
915 /****************************************************************************/
917 small_number norm_min_ (integer h)
927 void new_graf_(bool indented)
931 if ((mode == vmode) || (head != tail))
932 tail_append(new_param_glue(par_skip_code));
939 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
943 tail = new_null_box();
945 width(tail) = par_indent;
949 begin_token_list(every_par, every_par_text);
954 /* procedure indent_in_hmode; l.21058 */
956 void indent_in_hmode (void)
963 width(p) = par_indent;
965 if (abs(mode) == hmode)
970 math_type(nucleus(q)) = sub_box;
971 info(nucleus(q)) = p;
978 /* only called from tex8.c */
980 void head_for_vmode (void)
984 if (cur_cmd != hrule)
988 print_err("You can't use `");
990 print_string("' here except with leaders");
991 help2("To put a horizontal rule in an hbox or an alignment,",
992 "you should use \\leaders or \\hrulefill (see The TeXbook).");
1001 cur_input.index_field = inserted;
1005 void end_graf (void)
1012 line_break(widow_penalty);
1018 /* only called form tex8.c */
1020 void begin_insert_or_adjust (void)
1022 if (cur_cmd == vadjust)
1026 scan_eight_bit_int();
1030 print_err("You can't ");
1031 print_esc("insert");
1033 help1("I'm changing to \\insert0; box 255 is special.");
1041 new_save_level(insert_group);
1046 prev_depth = ignore_depth;
1049 void make_mark (void)
1053 p = scan_toks(false, true);
1054 p = get_node(small_node_size);
1055 type(p) = mark_node;
1057 mark_ptr(p) = def_ref;
1062 void append_penalty (void)
1065 tail_append(new_penalty(cur_val));
1070 /* only called from tex8.c */
1072 void delete_last (void)
1077 if ((mode == vmode) && (tail == head))
1079 if ((cur_chr != glue_node) || (last_glue != max_halfword))
1082 help2("Sorry...I usually can't take things from the current page.",
1083 "Try `I\\vskip-\\lastskip' instead.");
1085 if (cur_chr == kern_node)
1086 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1087 else if (cur_chr != glue_node)
1088 help_line[0] = "Perhaps you can make the output routine do it.";
1094 if (!(tail >= hi_mem_min))
1095 if (type(tail) == cur_chr)
1103 if (!(q >= hi_mem_min))
1104 if (type(q) == disc_node)
1106 for (m = 1; m <= replace_count(q); m++)
1115 while (!(q == tail));
1118 flush_node_list(tail);
1123 /* only called from tex8.c */
1124 /* procedure unpackage; l.21256 */
1126 void unpackage (void)
1132 scan_eight_bit_int();
1138 if ((abs(mode) == mmode) || ((abs(mode) == vmode) && (type(p) != vlist_node)) ||
1139 ((abs(mode) == hmode) && (type(p) != hlist_node)))
1141 print_err("Incompatible list can't be unboxed");
1142 help3("Sorry, Pandora. (You sneaky devil.)",
1143 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1144 "And I can't open any boxes in math mode.");
1150 link(tail) = copy_node_list(list_ptr(p));
1153 link(tail) = list_ptr(p);
1155 free_node(p, box_node_size);
1158 while (link(tail) != 0)
1162 void append_italic_correction (void)
1165 internal_font_number f;
1169 if ((tail >= hi_mem_min))
1171 else if (type(tail) == ligature_node)
1177 tail_append(new_kern(char_italic(f, char_info(f, character(p)))));
1178 subtype(tail) = explicit;
1182 void append_discretionary (void)
1186 tail_append(new_disc());
1190 c = hyphen_char[cur_font];
1194 pre_break(tail) = new_character(cur_font, c);
1200 new_save_level(disc_group);
1204 space_factor = 1000;
1207 /* only called form tex8.c */
1209 void build_discretionary (void)
1221 if (!(p >= hi_mem_min))
1222 if (type(p) > rule_node)
1223 if (type(p) != kern_node)
1224 if (type(p) != ligature_node)
1226 print_err("Improper discretionary list");
1227 help1("Discretionary lists must contain only boxes and kerns.");
1230 print_nl("The following discretionary sublist has been deleted:");
1232 end_diagnostic(true);
1250 pre_break(tail) = p;
1254 post_break(tail) = p;
1259 if ((n > 0) && (abs(mode) == mmode))
1261 print_err("Illegal math ");
1262 print_esc("discretionary");
1263 help2("Sorry: The third part of a discretionary break must be",
1264 "empty, in math formulas. I had to delete your third part.");
1272 if (n <= max_quarterword)
1273 replace_count(tail) = n;
1276 print_err("Discretionary list is too long");
1277 help2("Wow---I never thought anybody would tweak me here.",
1278 "You can't seriously need such a huge discretionary list?");
1292 new_save_level(disc_group);
1296 space_factor = 1000;
1298 /* called only from tex8.c */
1300 void make_accent (void)
1304 internal_font_number f;
1305 scaled a, h, x, w, delta;
1310 p = new_character(f, cur_val);
1315 s = slant(f) / ((double) 65536.0);
1316 a = char_width(f, char_info(f, character(p)));
1321 if ((cur_cmd == letter) || (cur_cmd == other_char) || (cur_cmd == char_given))
1322 q = new_character(f, cur_chr);
1323 else if (cur_cmd == char_num)
1326 q = new_character(f, cur_val);
1333 t = slant(f) / ((double) 65536.0);
1334 i = char_info(f, character(q));
1335 w = char_width(f, i);
1336 h = char_height(f, height_depth(i));
1341 shift_amount(p) = x - h;
1344 delta = round((w - a) / ((double) 2.0)+ h * t - x * s);
1345 r = new_kern(delta);
1346 subtype(r) = acc_kern;
1349 tail = new_kern(- (integer) a - delta);
1350 subtype(tail) = acc_kern;
1357 space_factor = 1000;
1361 void align_error (void)
1363 if (abs(align_state) > 2)
1365 print_err("Misplaced ");
1366 print_cmd_chr(cur_cmd, cur_chr);
1368 if (cur_tok == tab_token + '&')
1370 help6("I can't figure out why you would want to use a tab mark",
1371 "here. If you just want an ampersand, the remedy is",
1372 "simple: Just type `I\\&' now. But if some right brace",
1373 "up above has ended a previous alignment prematurely,",
1374 "you're probably due for more error messages, and you",
1375 "might try typing `S' now just to see what is salvageable.");
1379 help5("I can't figure out why you would want to use a tab mark",
1380 "or \\cr or \\span just now. If something like a right brace",
1381 "up above has ended a previous alignment prematurely,",
1382 "you're probably due for more error messages, and you",
1383 "might try typing `S' now just to see what is salvageable.");
1392 if (align_state < 0)
1394 print_err("Missing { inserted");
1396 cur_tok = left_brace_token + '{';
1400 print_err("Missing } inserted");
1402 cur_tok = right_brace_token + '}';
1405 help3("I've put in what seems to be necessary to fix",
1406 "the current column of the current alignment.",
1407 "Try to go on, since this might almost work.");
1412 void noalign_error (void)
1414 print_err("Misplaced ");
1415 print_esc("noalign");
1416 help2("I expect to see \\noalign only after the \\cr of",
1417 "an alignment. Proceed, and I'll ignore this case.");
1420 /* only called from tex8.c */
1422 void omit_error (void)
1424 print_err("Misplaced ");
1426 help2("I expect to see \\omit only after tab marks or the \\cr of",
1427 "an alignment. Proceed, and I'll ignore this case.");
1433 base_ptr = input_ptr;
1434 input_stack[base_ptr] = cur_input;
1436 while ((input_stack[base_ptr].index_field != v_template) &&
1437 (input_stack[base_ptr].loc_field == 0) &&
1438 (input_stack[base_ptr].state_field == token_list))
1441 if ((input_stack[base_ptr].index_field != v_template) ||
1442 (input_stack[base_ptr].loc_field != 0) ||
1443 (input_stack[base_ptr].state_field != token_list))
1444 fatal_error("(interwoven alignment preambles are not allowed)");
1446 if (cur_group == align_group)
1456 /* only called form tex8.c */
1458 void cs_error (void)
1460 print_err("Extra ");
1461 print_esc("endcsname");
1462 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1466 void push_math_(group_code c)
1470 incompleat_noad = 0;
1474 void init_math (void)
1481 internal_font_number f;
1488 if ((cur_cmd == math_shift) && (mode > 0))
1493 w = -max_dimen; /* - (2^30 - 1) */
1497 line_break(display_widow_penalty);
1498 v = shift_amount(just_box) + 2 * quad(cur_font);
1499 w = -max_dimen; /* - (2^30 - 1) */
1500 p = list_ptr(just_box);
1505 if ((p >= hi_mem_min))
1508 d = char_width(f, char_info(f, character(p)));
1525 mem[lig_trick] = mem[lig_char(p)];
1526 link(lig_trick) = link(p);
1542 if (glue_sign(just_box) == stretching)
1544 if ((glue_order(just_box) == stretch_order(q)) && (stretch(q) != 0))
1545 v = max_dimen; /* - (2^30 - 1) */
1547 else if (glue_sign(just_box) == shrinking)
1549 if ((glue_order(just_box) == shrink_order(q)) && (shrink(q) != 0))
1550 v = max_dimen; /* - (2^30 - 1) */
1553 if (subtype(p) >= a_leaders)
1567 if (v < max_dimen) /* - (2^30 - 1) */
1572 if (v < max_dimen) /* - (2^30 - 1) */
1579 w = max_dimen; /* - (2^30 - 1) */
1588 if (par_shape_ptr == 0)
1589 if ((hang_indent != 0) && (((hang_after >= 0) &&
1590 (prev_graf + 2 > hang_after)) || (prev_graf + 1 < - (integer) hang_after)))
1592 l = hsize - abs(hang_indent);
1594 if (hang_indent > 0)
1606 n = info(par_shape_ptr);
1608 if (prev_graf + 2 >= n)
1609 p = par_shape_ptr + 2 * n;
1611 p = par_shape_ptr + 2 *(prev_graf + 2);
1613 s = mem[p - 1].cint;
1617 push_math(math_shift_group);
1619 eq_word_define(int_base + cur_fam_code, -1);
1620 eq_word_define(dimen_base + pre_display_size_code, w);
1621 eq_word_define(dimen_base + display_width_code, l);
1622 eq_word_define(dimen_base + display_indent_code, s);
1624 if (every_display != 0)
1625 begin_token_list(every_display, every_display_text);
1637 push_math(math_shift_group);
1638 eq_word_define(int_base + cur_fam_code, -1);
1640 if (every_math != 0)
1641 begin_token_list(every_math, every_math_text);
1646 void start_eq_no (void)
1652 push_math(math_shift_group);
1653 eq_word_define(int_base + cur_fam_code, -1);
1655 if (every_math != 0)
1656 begin_token_list(every_math, every_math_text);
1660 void scan_math_(halfword p)
1669 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1678 c = math_code(cur_chr);
1683 cur_cs = cur_chr + active_base;
1684 cur_cmd = eq_type(cur_cs);
1685 cur_chr = equiv(cur_cs);
1699 cur_cmd = char_given;
1706 scan_fifteen_bit_int();
1717 scan_twenty_seven_bit_int();
1728 push_math(math_group);
1734 math_type(p) = math_char;
1735 character(p) = c % 256;
1737 if ((c >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1740 fam(p) = (c / 256) % 16;
1743 void set_math_char_(integer c)
1749 cur_cs = cur_chr + active_base;
1750 cur_cmd = eq_type(cur_cs);
1751 cur_chr = equiv(cur_cs);
1758 math_type(nucleus(p)) = math_char;
1759 character(nucleus(p)) = c % 256;
1760 fam(nucleus(p)) = (c / 256) % 16;
1764 if (((cur_fam >= 0) && (cur_fam < 16)))
1765 fam(nucleus(p)) = cur_fam;
1770 type(p) = ord_noad + (c / 4096);
1777 void math_limit_switch (void)
1780 if (type(tail) == op_noad)
1782 subtype(tail) = cur_chr;
1786 print_err("Limit controls must follow a math operator");
1787 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1791 void scan_delimiter_(halfword p, bool r)
1795 scan_twenty_seven_bit_int();
1803 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1809 cur_val = del_code(cur_chr);
1813 scan_twenty_seven_bit_int();
1824 print_err("Missing delimiter (. inserted)");
1825 help6("I was expecting to see something like `(' or `\\{' or",
1826 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1827 "should probably delete the `{' by typing `1' now, so that",
1828 "braces don't get unbalanced. Otherwise just proceed.",
1829 "Acceptable delimiters are characters whose \\delcode is",
1830 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1835 small_fam(p) = (cur_val / 1048576L) % 16;
1836 small_char(p) = (cur_val / 4096) % 256;
1837 large_fam(p) = (cur_val / 256) % 16;
1838 large_char(p) = cur_val % 256;
1841 void math_radical (void)
1843 tail_append(get_node(radical_noad_size));
1844 type(tail) = radical_noad;
1845 subtype(tail) = normal;
1846 mem[nucleus(tail)].hh = empty_field;
1847 mem[subscr(tail)].hh = empty_field;
1848 mem[supscr(tail)].hh = empty_field;
1849 scan_delimiter(left_delimiter(tail), true);
1850 scan_math(nucleus(tail));
1855 if (cur_cmd == accent)
1857 print_err("Please use ");
1858 print_esc("mathaccent");
1859 print_string(" for accents in math mode");
1860 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1861 "(Accents are not the same in formulas as they are in text.)");
1865 tail_append(get_node(accent_noad_size));
1866 type(tail) = accent_noad;
1867 subtype(tail) = normal;
1868 mem[nucleus(tail)].hh = empty_field;
1869 mem[subscr(tail)].hh = empty_field;
1870 mem[supscr(tail)].hh = empty_field;
1871 math_type(accent_chr(tail)) = math_char;
1872 scan_fifteen_bit_int();
1873 character(accent_chr(tail)) = cur_val % 256;
1875 if ((cur_val >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1876 fam(accent_chr(tail)) = cur_fam;
1878 fam(accent_chr(tail)) = (cur_val / 256) % 16;
1880 scan_math(nucleus(tail));
1883 void append_choices (void)
1885 tail_append(new_choice());
1888 push_math(math_choice_group);
1892 halfword fin_mlist_(halfword p)
1896 if (incompleat_noad != 0)
1898 math_type(denominator(incompleat_noad)) = sub_mlist;
1899 info(denominator(incompleat_noad)) = link(head);
1902 q = incompleat_noad;
1905 q = info(numerator(incompleat_noad));
1907 if (type(q) != left_noad)
1910 return 0; // abort_flag set
1913 info(numerator(incompleat_noad)) = link(q);
1914 link(q) = incompleat_noad;
1915 link(incompleat_noad) = p;
1928 void build_choices (void)
1938 display_mlist(tail) = p;
1942 text_mlist(tail) = p;
1946 script_mlist(tail) = p;
1951 script_script_mlist(tail) = p;
1959 push_math(math_choice_group);
1965 /* small_number t; */
1966 int t; /* 95/Jan/7 */
1973 if (script_allowed(tail))
1975 p = supscr(tail) + cur_cmd - sup_mark;
1979 if ((p == 0) || (t != 0))
1981 tail_append(new_noad());
1982 p = supscr(tail) + cur_cmd - sup_mark;
1986 if (cur_cmd == sup_mark)
1988 print_err("Double superscript");
1989 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1993 print_err("Double subscript");
1994 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
2001 /* used to continue here with math_fraction etc in tex7.c */
2002 /*****************************************************************************/
2003 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
2005 void package_(small_number c)
2013 save_ptr = save_ptr - 3;
2016 cur_box = hpack(link(head), saved(2), saved(1));
2019 cur_box = vpackage(link(head), saved(2), saved(1), d);
2024 p = list_ptr(cur_box);
2027 if (type(p) <= rule_node)
2030 depth(cur_box) = depth(cur_box) - h + height(cur_box);
2031 height(cur_box) = h;
2037 //#pragma optimize ("", on) /* 96/Sep/12 */