2 #pragma warning(disable:4131) // old style declarator
3 #pragma warning(disable:4135) // conversion between different integral types
4 #pragma warning(disable:4127) // conditional expression is constant
10 #pragma warning(disable:4244) /* 96/Jan/10 */
12 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
14 void build_page (void)
20 /* unsigned char n; */
21 unsigned int n; /* 95/Jan/7 */
24 if ((link(contrib_head) == 0) || output_active)
30 p = link(contrib_head);
32 if (last_glue != max_halfword)
33 delete_glue_ref(last_glue);
38 if (type(p) == glue_node)
40 last_glue = glue_ptr(p);
41 add_glue_ref(last_glue);
45 last_glue = max_halfword;
47 if (type(p) == penalty_node)
48 last_penalty = penalty(p);
49 else if (type(p) == kern_node)
58 if (page_contents < box_there)
60 if (page_contents == 0)
61 freeze_page_specs(box_there);
63 page_contents = box_there;
65 q = new_skip_param(top_skip_code);
67 if (width(temp_ptr) > height(p))
68 width(temp_ptr) = width(temp_ptr) - height(p);
73 link(contrib_head) = q;
78 page_total = page_total + page_depth + height(p);
79 page_depth = depth(p);
89 if (page_contents < box_there)
91 else if (precedes_break(page_tail))
98 if (page_contents < box_there)
100 else if (link(p) == 0)
102 else if (type(link(p)) == glue_node)
109 if (page_contents < box_there)
121 if (page_contents == 0)
122 freeze_page_specs(inserts_only);
127 while (n >= subtype(link(r)))
134 q = get_node(page_ins_node_size);
145 height(r) = height(box(n)) + depth(box(n));
150 if (count(n) == 1000)
153 h = x_over_n(height(r), 1000) * count(n);
155 page_goal = page_goal - h - width(q);
156 page_so_far[2 + stretch_order(q)] = page_so_far[2 + stretch_order(q)] + stretch(q);
157 page_shrink = page_shrink + shrink(q);
159 if ((shrink_order(q) != normal) && (shrink(q) != 0))
161 print_err("Infinite glue shrinkage inserted from ");
164 help3("The correction glue for page breaking with insertions",
165 "must have finite shrinkability. But you may proceed,",
166 "since the offensive shrinkability has been made finite.");
171 if (type(r) == split_up)
172 insert_penalties = insert_penalties + float_cost(p);
176 delta = page_goal - page_total - page_depth + page_shrink;
178 if (count(n) == 1000)
181 h = x_over_n(height(p), 1000) * count(n);
183 if (((h <= 0) || (h <= delta)) && (height(p) + height(r) <= dimen(n)))
185 page_goal = page_goal - h;
186 height(r) = height(r) + height(p);
191 w = max_dimen; /* 2^30 - 1 */
194 w = page_goal - page_total - page_depth;
196 if (count(n) != 1000)
197 w = x_over_n(w, count(n)) * 1000;
200 if (w > dimen(n) - height(r))
201 w = dimen(n) - height(r);
203 q = vert_break(ins_ptr(p), w, depth(p));
204 height(r) = height(r) + best_height_plus_depth;
207 if (tracing_pages > 0)
215 print_scaled(best_height_plus_depth);
219 print_int(eject_penalty);
220 else if (type(q) == penalty_node)
221 print_int(penalty(q));
225 end_diagnostic(false);
228 if (count(n) != 1000)
229 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * count(n);
231 page_goal = page_goal - best_height_plus_depth;
237 insert_penalties = insert_penalties + (eject_penalty);
238 else if (type(q) == penalty_node)
239 insert_penalties = insert_penalties + penalty(q);
249 return; // abort_flag set
254 if (pi < inf_penalty)
256 if (page_total < page_goal)
257 if ((page_so_far[3] != 0) || (page_so_far[4] != 0) || (page_so_far[5] != 0))
260 b = badness(page_goal - page_total, page_so_far[2]);
261 else if (page_total - page_goal > page_shrink)
262 b = awful_bad; /* 2^30 - 1 */
264 b = badness(page_total - page_goal, page_shrink);
266 if (b < awful_bad) /* 2^30 - 1 */
267 if (pi <= eject_penalty)
269 else if (b < inf_bad)
270 c = b + pi + insert_penalties;
276 if (insert_penalties >= 10000)
277 c = awful_bad; /* 2^30 - 1 */
280 if (tracing_pages > 0)
287 print_scaled(page_goal);
290 if (b == awful_bad) /* 2^30 - 1 */
299 if (c == awful_bad) /* 2^30 - 1 */
304 if (c <= least_page_cost)
307 end_diagnostic(false);
311 if (c <= least_page_cost)
314 best_size = page_goal;
316 r = link(page_ins_head);
318 while (r != page_ins_head)
320 best_ins_ptr(r) = last_ins_ptr(r);
325 if ((c == awful_bad) || (pi <= eject_penalty)) /* 2^30 - 1 */
336 if ((type(p) < glue_node) || (type(p) > kern_node))
339 if (type(p) == kern_node)
344 page_so_far[2 + stretch_order(q)] = page_so_far[2 + stretch_order(q)] + stretch(q);
345 page_shrink = page_shrink + shrink(q);
347 if ((shrink_order(q) != normal) && (shrink(q) != 0))
349 print_err("Infinite glue shrinkage found on current page");
350 help4("The page about to be output contains some infinitely",
351 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
352 "Such glue doesn't belong there; but you can safely proceed,",
353 "since the offensive shrinkability has been made finite.");
356 shrink_order(r) = normal;
363 page_total = page_total + page_depth + width(q);
366 if (page_depth > page_max_depth)
368 page_total = page_total + page_depth - page_max_depth;
369 page_depth = page_max_depth;
374 link(contrib_head) = link(p);
378 link(contrib_head) = link(p);
383 while (!(link(contrib_head) == 0));
388 nest[0].tail_field = contrib_head;
391 void app_space (void)
395 if ((space_factor >= 2000) && (xspace_skip != zero_glue))
396 q = new_param_glue(xspace_skip_code);
399 if (space_skip != zero_glue)
403 main_p = font_glue[cur_font];
407 main_p = new_spec(zero_glue);
408 main_k = param_base[cur_font] + space_code;
409 width(main_p) = font_info[main_k].cint;
410 stretch(main_p) = font_info[main_k + 1].cint;
411 shrink(main_p) = font_info[main_k + 2].cint;
412 font_glue[cur_font] = main_p;
416 main_p = new_spec(main_p);
418 if (space_factor >= 2000)
419 width(main_p) = width(main_p) + extra_space(cur_font);
421 stretch(main_p) = xn_over_d(stretch(main_p), space_factor, 1000);
422 shrink(main_p) = xn_over_d(shrink(main_p), 1000, space_factor);
423 q = new_glue(main_p);
424 glue_ref_count(main_p) = 0;
430 /* called from tex8.c only */
432 void insert_dollar_sign (void)
435 cur_tok = math_shift_token + '$';
436 print_err("Missing $ inserted");
437 help2("I've inserted a begin-math/end-math symbol since I think",
438 "you left one out. Proceed, with fingers crossed.");
444 print_err("You can't use `");
445 print_cmd_chr(cur_cmd, cur_chr);
446 print_string("' in ");
450 void report_illegal_case (void)
453 help4("Sorry, but I'm not programmed to handle this case;",
454 "I'll just pretend that you didn't ask for it.",
455 "If you're in the wrong mode, you might be able to",
456 "return to the right one by typing `I}' or `I$' or `I\\par'.");
460 bool privileged (void)
466 report_illegal_case();
471 bool its_all_over (void)
475 if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
481 tail_append(new_null_box());
483 tail_append(new_glue(fill_glue));
484 tail_append(new_penalty(-1073741824L));
491 void append_glue (void)
512 cur_val = fil_neg_glue;
524 tail_append(new_glue(cur_val));
528 decr(glue_ref_count(cur_val));
531 subtype(tail) = mu_glue;
535 void append_kern (void)
541 scan_dimen(s == mu_glue, false, false);
542 tail_append(new_kern(cur_val));
550 if (cur_group == bottom_level)
553 print_cmd_chr(cur_cmd, cur_chr);
554 help1("Things are pretty mixed up, but I think the worst is over.");
562 print_err("Missing ");
566 case semi_simple_group:
568 info(p) = cs_token_flag + frozen_end_group;
569 print_esc("endgroup");
573 case math_shift_group:
575 info(p) = math_shift_token + '$';
580 case math_left_group:
582 info(p) = cs_token_flag + frozen_right;
583 link(p) = get_avail();
585 info(p) = other_token + '.';
592 info(p) = right_brace_token + '}';
598 print_string(" inserted");
599 ins_list(link(temp_head));
600 help5("I've inserted something that you may have forgotten.",
601 "(See the <inserted text> above.)",
602 "With luck, this will get me unwedged. But if you",
603 "really didn't forget anything, try typing `2' now; then",
604 "my insertion and my current dilemma will both disappear.");
608 /* only called from tex8.c */
610 void extra_right_brace (void)
612 print_err("Extra }, or forgotten ");
616 case semi_simple_group:
617 print_esc("endgroup");
620 case math_shift_group:
624 case math_left_group:
629 help5("I've deleted a group-closing symbol because it seems to be",
630 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
631 "you forgot something else, as in `\\hbox{$x}'. In such cases",
632 "the way to recover is to insert both the forgotten and the",
633 "deleted material, e.g., by typing `I$}'.");
638 void normal_paragraph (void)
641 eq_word_define(int_base + looseness_code, 0);
643 if (hang_indent != 0)
644 eq_word_define(dimen_base + hang_indent_code, 0);
647 eq_word_define(int_base + hang_after_code, 1);
649 if (par_shape_ptr != 0)
650 eq_define(par_shape_loc, shape_ref, 0);
653 void box_end_(integer box_context)
657 if (box_context < box_flag)
661 shift_amount(cur_box) = box_context;
663 if (abs(mode) == vmode)
665 append_to_vlist(cur_box);
667 if (adjust_tail != 0)
669 if (adjust_head != adjust_tail)
671 link(tail) = link(adjust_head);
683 if (abs(mode) == hmode)
688 math_type(nucleus(p)) = sub_box;
689 info(nucleus(p)) = cur_box;
693 link(tail) = cur_box;
698 else if (box_context < ship_out_flag)
699 if (box_context < (box_flag + 256))
700 eq_define((box_base - box_flag) + box_context, box_ref, cur_box);
702 geq_define((box_base - box_flag - 256) + box_context, box_ref, cur_box);
703 else if (cur_box != 0)
704 if (box_context > ship_out_flag)
710 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
712 if (((cur_cmd == hskip) && (abs(mode)!= vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode)))
715 subtype(tail) = box_context - (leader_flag - a_leaders);
716 leader_ptr(tail) = cur_box;
720 print_err("Leaders not followed by proper glue");
721 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
722 "I found the <box or rule>, but there's no suitable",
723 "<hskip or vskip>, so I'm ignoring these leaders.");
725 flush_node_list(cur_box);
731 /* called only from tex8.c */
733 void begin_box_(integer box_context)
744 scan_eight_bit_int();
745 cur_box = box(cur_val);
752 scan_eight_bit_int();
753 cur_box = copy_node_list(box(cur_val));
761 if (abs(mode) == mmode)
764 help1("Sorry; this \\lastbox will be void.");
767 else if ((mode == vmode) && (head == cur_list.tail_field))
770 help2("Sorry...I usually can't take things from the current page.",
771 "This \\lastbox will therefore be void.");
776 if (!(tail >= hi_mem_min))
777 if ((type(tail) == hlist_node) || (type(tail) == vlist_node))
785 if (!(q >= hi_mem_min))
786 if (type(q) == disc_node)
788 for (m = 1; m <= replace_count(q); m++)
797 while (!(q == tail));
800 shift_amount(cur_box) = 0;
812 scan_eight_bit_int();
815 if (!scan_keyword("to"))
817 print_err("Missing `to' inserted");
818 help2("I'm working on `\\vsplit<box number> to <dimen>';",
819 "will look for the <dimen> next.");
823 scan_dimen(false, false, false);
824 cur_box = vsplit(n, cur_val);
830 k = cur_chr - vtop_code;
831 saved(0) = box_context;
834 if ((box_context < box_flag) && (abs(mode) == vmode))
835 scan_spec(adjust_hbox_group, true);
837 scan_spec(hbox_group, true);
841 scan_spec(vbox_group, true);
844 scan_spec(vtop_group, true);
852 mode = - (integer) k;
856 prev_depth = ignore_depth;
859 begin_token_list(every_vbox, every_vbox_text);
866 begin_token_list(every_hbox, every_vbox_text);
873 box_end(box_context);
876 void scan_box_(integer box_context)
882 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
884 if (cur_cmd == make_box)
886 begin_box(box_context);
888 else if ((box_context >= leader_flag) && ((cur_cmd == hrule) || (cur_cmd == vrule)))
890 cur_box = scan_rule_spec();
891 box_end(box_context);
895 print_err("A <box> was supposed to be here");
896 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
897 "something like that. So you might find something missing in",
898 "your output. But keep trying; you can fix this later.");
902 /****************************************************************************/
903 void package_ (small_number);
904 /****************************************************************************/
906 small_number norm_min_ (integer h)
916 void new_graf_(bool indented)
920 if ((mode == vmode) || (head != tail))
921 tail_append(new_param_glue(par_skip_code));
928 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
932 tail = new_null_box();
934 width(tail) = par_indent;
938 begin_token_list(every_par, every_par_text);
943 /* procedure indent_in_hmode; l.21058 */
945 void indent_in_hmode (void)
952 width(p) = par_indent;
954 if (abs(mode) == hmode)
959 math_type(nucleus(q)) = sub_box;
960 info(nucleus(q)) = p;
967 /* only called from tex8.c */
969 void head_for_vmode (void)
973 if (cur_cmd != hrule)
977 print_err("You can't use `");
979 print_string("' here except with leaders");
980 help2("To put a horizontal rule in an hbox or an alignment,",
981 "you should use \\leaders or \\hrulefill (see The TeXbook).");
990 cur_input.index_field = inserted;
1001 line_break(widow_penalty);
1007 /* only called form tex8.c */
1009 void begin_insert_or_adjust (void)
1011 if (cur_cmd == vadjust)
1015 scan_eight_bit_int();
1019 print_err("You can't ");
1020 print_esc("insert");
1022 help1("I'm changing to \\insert0; box 255 is special.");
1030 new_save_level(insert_group);
1035 prev_depth = ignore_depth;
1038 void make_mark (void)
1042 p = scan_toks(false, true);
1043 p = get_node(small_node_size);
1044 type(p) = mark_node;
1046 mark_ptr(p) = def_ref;
1051 void append_penalty (void)
1054 tail_append(new_penalty(cur_val));
1059 /* only called from tex8.c */
1061 void delete_last (void)
1066 if ((mode == vmode) && (tail == head))
1068 if ((cur_chr != glue_node) || (last_glue != max_halfword))
1071 help2("Sorry...I usually can't take things from the current page.",
1072 "Try `I\\vskip-\\lastskip' instead.");
1074 if (cur_chr == kern_node)
1075 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1076 else if (cur_chr != glue_node)
1077 help_line[0] = "Perhaps you can make the output routine do it.";
1083 if (!(tail >= hi_mem_min))
1084 if (type(tail) == cur_chr)
1092 if (!(q >= hi_mem_min))
1093 if (type(q) == disc_node)
1095 for (m = 1; m <= replace_count(q); m++)
1104 while (!(q == tail));
1107 flush_node_list(tail);
1112 /* only called from tex8.c */
1113 /* procedure unpackage; l.21256 */
1115 void unpackage (void)
1121 scan_eight_bit_int();
1127 if ((abs(mode) == mmode) || ((abs(mode) == vmode) && (type(p) != vlist_node)) ||
1128 ((abs(mode) == hmode) && (type(p) != hlist_node)))
1130 print_err("Incompatible list can't be unboxed");
1131 help3("Sorry, Pandora. (You sneaky devil.)",
1132 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1133 "And I can't open any boxes in math mode.");
1139 link(tail) = copy_node_list(list_ptr(p));
1142 link(tail) = list_ptr(p);
1144 free_node(p, box_node_size);
1147 while (link(tail) != 0)
1151 void append_italic_correction (void)
1154 internal_font_number f;
1158 if ((tail >= hi_mem_min))
1160 else if (type(tail) == ligature_node)
1166 tail_append(new_kern(char_italic(f, char_info(f, character(p)))));
1167 subtype(tail) = explicit;
1171 void append_discretionary (void)
1175 tail_append(new_disc());
1179 c = hyphen_char[cur_font];
1183 pre_break(tail) = new_character(cur_font, c);
1189 new_save_level(disc_group);
1193 space_factor = 1000;
1196 /* only called form tex8.c */
1198 void build_discretionary (void)
1210 if (!(p >= hi_mem_min))
1211 if (type(p) > rule_node)
1212 if (type(p) != kern_node)
1213 if (type(p) != ligature_node)
1215 print_err("Improper discretionary list");
1216 help1("Discretionary lists must contain only boxes and kerns.");
1219 print_nl("The following discretionary sublist has been deleted:");
1221 end_diagnostic(true);
1239 pre_break(tail) = p;
1243 post_break(tail) = p;
1248 if ((n > 0) && (abs(mode) == mmode))
1250 print_err("Illegal math ");
1251 print_esc("discretionary");
1252 help2("Sorry: The third part of a discretionary break must be",
1253 "empty, in math formulas. I had to delete your third part.");
1261 if (n <= max_quarterword)
1262 replace_count(tail) = n;
1265 print_err("Discretionary list is too long");
1266 help2("Wow---I never thought anybody would tweak me here.",
1267 "You can't seriously need such a huge discretionary list?");
1281 new_save_level(disc_group);
1285 space_factor = 1000;
1287 /* called only from tex8.c */
1289 void make_accent (void)
1293 internal_font_number f;
1294 scaled a, h, x, w, delta;
1299 p = new_character(f, cur_val);
1304 s = slant(f) / ((double) 65536.0);
1305 a = char_width(f, char_info(f, character(p)));
1310 if ((cur_cmd == letter) || (cur_cmd == other_char) || (cur_cmd == char_given))
1311 q = new_character(f, cur_chr);
1312 else if (cur_cmd == char_num)
1315 q = new_character(f, cur_val);
1322 t = slant(f) / ((double) 65536.0);
1323 i = char_info(f, character(q));
1324 w = char_width(f, i);
1325 h = char_height(f, height_depth(i));
1330 shift_amount(p) = x - h;
1333 delta = round((w - a) / ((double) 2.0)+ h * t - x * s);
1334 r = new_kern(delta);
1335 subtype(r) = acc_kern;
1338 tail = new_kern(- (integer) a - delta);
1339 subtype(tail) = acc_kern;
1346 space_factor = 1000;
1350 void align_error (void)
1352 if (abs(align_state) > 2)
1354 print_err("Misplaced ");
1355 print_cmd_chr(cur_cmd, cur_chr);
1357 if (cur_tok == tab_token + '&')
1359 help6("I can't figure out why you would want to use a tab mark",
1360 "here. If you just want an ampersand, the remedy is",
1361 "simple: Just type `I\\&' now. But if some right brace",
1362 "up above has ended a previous alignment prematurely,",
1363 "you're probably due for more error messages, and you",
1364 "might try typing `S' now just to see what is salvageable.");
1368 help5("I can't figure out why you would want to use a tab mark",
1369 "or \\cr or \\span just now. If something like a right brace",
1370 "up above has ended a previous alignment prematurely,",
1371 "you're probably due for more error messages, and you",
1372 "might try typing `S' now just to see what is salvageable.");
1381 if (align_state < 0)
1383 print_err("Missing { inserted");
1385 cur_tok = left_brace_token + '{';
1389 print_err("Missing } inserted");
1391 cur_tok = right_brace_token + '}';
1394 help3("I've put in what seems to be necessary to fix",
1395 "the current column of the current alignment.",
1396 "Try to go on, since this might almost work.");
1401 void noalign_error (void)
1403 print_err("Misplaced ");
1404 print_esc("noalign");
1405 help2("I expect to see \\noalign only after the \\cr of",
1406 "an alignment. Proceed, and I'll ignore this case.");
1409 /* only called from tex8.c */
1411 void omit_error (void)
1413 print_err("Misplaced ");
1415 help2("I expect to see \\omit only after tab marks or the \\cr of",
1416 "an alignment. Proceed, and I'll ignore this case.");
1422 base_ptr = input_ptr;
1423 input_stack[base_ptr] = cur_input;
1425 while ((input_stack[base_ptr].index_field != v_template) &&
1426 (input_stack[base_ptr].loc_field == 0) &&
1427 (input_stack[base_ptr].state_field == token_list))
1430 if ((input_stack[base_ptr].index_field != v_template) ||
1431 (input_stack[base_ptr].loc_field != 0) ||
1432 (input_stack[base_ptr].state_field != token_list))
1433 fatal_error("(interwoven alignment preambles are not allowed)");
1435 if (cur_group == align_group)
1445 /* only called form tex8.c */
1447 void cs_error (void)
1449 print_err("Extra ");
1450 print_esc("endcsname");
1451 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1455 void push_math_(group_code c)
1459 incompleat_noad = 0;
1463 void init_math (void)
1470 internal_font_number f;
1477 if ((cur_cmd == math_shift) && (mode > 0))
1482 w = -max_dimen; /* - (2^30 - 1) */
1486 line_break(display_widow_penalty);
1487 v = shift_amount(just_box) + 2 * quad(cur_font);
1488 w = -max_dimen; /* - (2^30 - 1) */
1489 p = list_ptr(just_box);
1494 if ((p >= hi_mem_min))
1497 d = char_width(f, char_info(f, character(p)));
1514 mem[lig_trick] = mem[lig_char(p)];
1515 link(lig_trick) = link(p);
1531 if (glue_sign(just_box) == stretching)
1533 if ((glue_order(just_box) == stretch_order(q)) && (stretch(q) != 0))
1534 v = max_dimen; /* - (2^30 - 1) */
1536 else if (glue_sign(just_box) == shrinking)
1538 if ((glue_order(just_box) == shrink_order(q)) && (shrink(q) != 0))
1539 v = max_dimen; /* - (2^30 - 1) */
1542 if (subtype(p) >= a_leaders)
1556 if (v < max_dimen) /* - (2^30 - 1) */
1561 if (v < max_dimen) /* - (2^30 - 1) */
1568 w = max_dimen; /* - (2^30 - 1) */
1577 if (par_shape_ptr == 0)
1578 if ((hang_indent != 0) && (((hang_after >= 0) &&
1579 (prev_graf + 2 > hang_after)) || (prev_graf + 1 < - (integer) hang_after)))
1581 l = hsize - abs(hang_indent);
1583 if (hang_indent > 0)
1595 n = info(par_shape_ptr);
1597 if (prev_graf + 2 >= n)
1598 p = par_shape_ptr + 2 * n;
1600 p = par_shape_ptr + 2 *(prev_graf + 2);
1602 s = mem[p - 1].cint;
1606 push_math(math_shift_group);
1608 eq_word_define(int_base + cur_fam_code, -1);
1609 eq_word_define(dimen_base + pre_display_size_code, w);
1610 eq_word_define(dimen_base + display_width_code, l);
1611 eq_word_define(dimen_base + display_indent_code, s);
1613 if (every_display != 0)
1614 begin_token_list(every_display, every_display_text);
1626 push_math(math_shift_group);
1627 eq_word_define(int_base + cur_fam_code, -1);
1629 if (every_math != 0)
1630 begin_token_list(every_math, every_math_text);
1635 void start_eq_no (void)
1641 push_math(math_shift_group);
1642 eq_word_define(int_base + cur_fam_code, -1);
1644 if (every_math != 0)
1645 begin_token_list(every_math, every_math_text);
1649 void scan_math_(halfword p)
1658 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1667 c = math_code(cur_chr);
1672 cur_cs = cur_chr + active_base;
1673 cur_cmd = eq_type(cur_cs);
1674 cur_chr = equiv(cur_cs);
1688 cur_cmd = char_given;
1695 scan_fifteen_bit_int();
1706 scan_twenty_seven_bit_int();
1717 push_math(math_group);
1723 math_type(p) = math_char;
1724 character(p) = c % 256;
1726 if ((c >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1729 fam(p) = (c / 256) % 16;
1732 void set_math_char_(integer c)
1738 cur_cs = cur_chr + active_base;
1739 cur_cmd = eq_type(cur_cs);
1740 cur_chr = equiv(cur_cs);
1747 math_type(nucleus(p)) = math_char;
1748 character(nucleus(p)) = c % 256;
1749 fam(nucleus(p)) = (c / 256) % 16;
1753 if (((cur_fam >= 0) && (cur_fam < 16)))
1754 fam(nucleus(p)) = cur_fam;
1759 type(p) = ord_noad + (c / 4096);
1766 void math_limit_switch (void)
1769 if (type(tail) == op_noad)
1771 subtype(tail) = cur_chr;
1775 print_err("Limit controls must follow a math operator");
1776 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1780 void scan_delimiter_(halfword p, bool r)
1784 scan_twenty_seven_bit_int();
1792 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1798 cur_val = del_code(cur_chr);
1802 scan_twenty_seven_bit_int();
1813 print_err("Missing delimiter (. inserted)");
1814 help6("I was expecting to see something like `(' or `\\{' or",
1815 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1816 "should probably delete the `{' by typing `1' now, so that",
1817 "braces don't get unbalanced. Otherwise just proceed.",
1818 "Acceptable delimiters are characters whose \\delcode is",
1819 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1824 small_fam(p) = (cur_val / 1048576L) % 16;
1825 small_char(p) = (cur_val / 4096) % 256;
1826 large_fam(p) = (cur_val / 256) % 16;
1827 large_char(p) = cur_val % 256;
1830 void math_radical (void)
1832 tail_append(get_node(radical_noad_size));
1833 type(tail) = radical_noad;
1834 subtype(tail) = normal;
1835 mem[nucleus(tail)].hh = empty_field;
1836 mem[subscr(tail)].hh = empty_field;
1837 mem[supscr(tail)].hh = empty_field;
1838 scan_delimiter(left_delimiter(tail), true);
1839 scan_math(nucleus(tail));
1844 if (cur_cmd == accent)
1846 print_err("Please use ");
1847 print_esc("mathaccent");
1848 print_string(" for accents in math mode");
1849 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1850 "(Accents are not the same in formulas as they are in text.)");
1854 tail_append(get_node(accent_noad_size));
1855 type(tail) = accent_noad;
1856 subtype(tail) = normal;
1857 mem[nucleus(tail)].hh = empty_field;
1858 mem[subscr(tail)].hh = empty_field;
1859 mem[supscr(tail)].hh = empty_field;
1860 math_type(accent_chr(tail)) = math_char;
1861 scan_fifteen_bit_int();
1862 character(accent_chr(tail)) = cur_val % 256;
1864 if ((cur_val >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1865 fam(accent_chr(tail)) = cur_fam;
1867 fam(accent_chr(tail)) = (cur_val / 256) % 16;
1869 scan_math(nucleus(tail));
1872 void append_choices (void)
1874 tail_append(new_choice());
1877 push_math(math_choice_group);
1881 halfword fin_mlist_(halfword p)
1885 if (incompleat_noad != 0)
1887 math_type(denominator(incompleat_noad)) = sub_mlist;
1888 info(denominator(incompleat_noad)) = link(head);
1891 q = incompleat_noad;
1894 q = info(numerator(incompleat_noad));
1896 if (type(q) != left_noad)
1899 return 0; // abort_flag set
1902 info(numerator(incompleat_noad)) = link(q);
1903 link(q) = incompleat_noad;
1904 link(incompleat_noad) = p;
1917 void build_choices (void)
1927 display_mlist(tail) = p;
1931 text_mlist(tail) = p;
1935 script_mlist(tail) = p;
1940 script_script_mlist(tail) = p;
1948 push_math(math_choice_group);
1954 /* small_number t; */
1955 int t; /* 95/Jan/7 */
1962 if (script_allowed(tail))
1964 p = supscr(tail) + cur_cmd - sup_mark;
1968 if ((p == 0) || (t != 0))
1970 tail_append(new_noad());
1971 p = supscr(tail) + cur_cmd - sup_mark;
1975 if (cur_cmd == sup_mark)
1977 print_err("Double superscript");
1978 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1982 print_err("Double subscript");
1983 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1990 /* used to continue here with math_fraction etc in tex7.c */
1991 /*****************************************************************************/
1992 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1994 void package_(small_number c)
2002 save_ptr = save_ptr - 3;
2005 cur_box = hpack(link(head), saved(2), saved(1));
2008 cur_box = vpackage(link(head), saved(2), saved(1), d);
2013 p = list_ptr(cur_box);
2016 if (type(p) <= rule_node)
2019 depth(cur_box) = depth(cur_box) - h + height(cur_box);
2020 height(cur_box) = h;
2026 //#pragma optimize ("", on) /* 96/Sep/12 */