6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
13 #pragma warning(disable:4131) // old style declarator
14 #pragma warning(disable:4135) // conversion between different integral types
15 #pragma warning(disable:4127) // conditional expression is constant
23 #pragma warning(disable:4244) /* 96/Jan/10 */
25 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
27 void build_page (void)
33 /* unsigned char n; */
34 unsigned int n; /* 95/Jan/7 */
37 /* begin if (link(contrib_head)=null)or output_active then return; l.19351 */
38 if ((mem[contrib_head].hh.v.RH == 0) || output_active)
43 p = mem[contrib_head].hh.v.RH;
44 /* if (last_glue != 262143L) */
45 if (last_glue != empty_flag)
46 delete_glue_ref(last_glue);
49 if (mem[p].hh.b0 == 10)
51 last_glue = mem[p + 1].hh.v.LH;
52 incr(mem[last_glue].hh.v.RH);
56 /* last_glue = 262143L; */
57 last_glue = empty_flag;
58 if (mem[p].hh.b0 == 12)
59 last_penalty = mem[p + 1].cint;
60 else if (mem[p].hh.b0 == 11)
61 last_kern = mem[p + 1].cint;
68 if (page_contents < 2)
70 if (page_contents == 0)
74 q = new_skip_param(9);
75 if (mem[temp_ptr + 1].cint > mem[p + 3].cint)
76 mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3].cint;
78 mem[temp_ptr + 1].cint = 0;
80 mem[contrib_head].hh.v.RH = q;
85 page_so_far[1] = page_so_far[1] + page_so_far[7] + mem[p + 3].cint;
86 page_so_far[7] = mem[p + 2].cint;
94 if (page_contents < 2)
96 else if ((mem[page_tail].hh.b0 < 9))
102 if (page_contents < 2)
104 else if (mem[p].hh.v.RH == 0)
106 else if (mem[mem[p].hh.v.RH].hh.b0 == 10)
112 if (page_contents < 2)
115 pi = mem[p + 1].cint;
122 if (page_contents == 0)
123 freeze_page_specs(1);
126 while (n >= mem[mem[r].hh.v.RH].hh.b1)
129 if (mem[r].hh.b1 != n)
132 mem[q].hh.v.RH = mem[r].hh.v.RH;
138 if (eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
141 mem[r + 3].cint = mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 3].cint + mem[eqtb[(hash_size + 1578) + n].hh.v.RH + 2].cint;
142 mem[r + 2].hh.v.LH = 0;
143 q = eqtb[(hash_size + 800) + n].hh.v.RH;
144 if (eqtb[(hash_size + 3218) + n].cint == 1000)
147 h = x_over_n(mem[r + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
148 page_so_far[0]= page_so_far[0]- h - mem[q + 1].cint;
149 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]+ mem[q + 2].cint;
150 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
151 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
153 print_err("Infinite glue shrinkage inserted from");
156 help3("The correction glue for page breaking with insertions",
157 "must have finite shrinkability. But you may proceed,",
158 "since the offensive shrinkability has been made finite.");
162 if (mem[r].hh.b0 == 1)
163 insert_penalties = insert_penalties + mem[p + 1].cint;
166 mem[r + 2].hh.v.RH = p;
167 delta = page_so_far[0] - page_so_far[1] - page_so_far[7] + page_so_far[6];
168 if (eqtb[(hash_size + 3218) + n].cint == 1000)
171 h = x_over_n(mem[p + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
172 if (((h <= 0) || (h <= delta)) && (mem[p + 3].cint + mem[r + 3].cint <= eqtb[(hash_size + 3751) + n].cint))
174 page_so_far[0] = page_so_far[0]- h;
175 mem[r + 3].cint = mem[r + 3].cint + mem[p + 3].cint;
179 if (eqtb[(hash_size + 3218) + n].cint <= 0)
180 w = 1073741823L; /* 2^30 - 1 */
183 w = page_so_far[0] - page_so_far[1] - page_so_far[7];
184 if (eqtb[(hash_size + 3218) + n].cint != 1000)
185 w = x_over_n(w, eqtb[(hash_size + 3218) + n].cint)* 1000;
187 if (w > eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint)
188 w = eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint;
189 q = vert_break(mem[p + 4].hh.v.LH, w, mem[p + 2].cint);
190 mem[r + 3].cint = mem[r + 3].cint + best_height_plus_depth;
193 if (tracing_pages > 0)
196 print_nl("%% split");
201 print_scaled(best_height_plus_depth);
203 if (q == 0) /* if q=null l.19614 */
205 else if (mem[q].hh.b0 == 12)
206 print_int(mem[q + 1].cint);
209 end_diagnostic(false);
212 if (eqtb[(hash_size + 3218) + n].cint != 1000)
213 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * eqtb[(hash_size + 3218) + n].cint;
214 page_so_far[0]= page_so_far[0]- best_height_plus_depth;
216 mem[r + 1].hh.v.RH = q;
217 mem[r + 1].hh.v.LH = p;
219 insert_penalties = insert_penalties - 10000;
220 else if (mem[q].hh.b0 == 12)
221 insert_penalties = insert_penalties + mem[q + 1].cint;
230 return; // abort_flag set
234 if (pi < 10000)/* pi may be used ... */
236 if (page_so_far[1] < page_so_far[0])
237 if ((page_so_far[3] != 0) || (page_so_far[4] != 0) || (page_so_far[5] != 0))
240 b = badness(page_so_far[0] - page_so_far[1], page_so_far[2]);
241 else if (page_so_far[1]- page_so_far[0]> page_so_far[6])
242 b = 1073741823L; /* 2^30 - 1 */
244 b = badness(page_so_far[1]- page_so_far[0], page_so_far[6]);
245 if (b < 1073741823L) /* 2^30 - 1 */
249 c = b + pi + insert_penalties;
254 if (insert_penalties >= 10000)
255 c = 1073741823L; /* 2^30 - 1 */
258 if (tracing_pages > 0)
265 print_scaled(page_so_far[0]);
267 if (b == 1073741823L) /* 2^30 - 1 */
274 if (c == 1073741823L) /* 2^30 - 1 */
278 if (c <= least_page_cost)
280 end_diagnostic(false);
283 if (c <= least_page_cost)
286 best_size = page_so_far[0];
288 r = mem[mem_top].hh.v.RH;
291 mem[r + 2].hh.v.LH = mem[r + 2].hh.v.RH;
295 if ((c == 1073741823L) || (pi <= -10000)) /* 2^30 - 1 */
303 if ((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11))
306 if (mem[p].hh.b0 == 11)
310 q = mem[p + 1].hh.v.LH;
311 page_so_far[2 + mem[q].hh.b0] = page_so_far[2 + mem[q].hh.b0] + mem[q + 2].cint;
312 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
313 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
315 print_err("Infinite glue shrinkage found on current page");
316 help4("The page about to be output contains some infinitely",
317 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
318 "Such glue doesn't belong there; but you can safely proceed,",
319 "since the offensive shrinkability has been made finite.");
324 mem[p + 1].hh.v.LH = r;
328 page_so_far[1] = page_so_far[1] + page_so_far[7] + mem[q + 1].cint;
331 if (page_so_far[7]> page_max_depth)
333 page_so_far[1] = page_so_far[1] + page_so_far[7] - page_max_depth;
334 page_so_far[7] = page_max_depth;
336 mem[page_tail].hh.v.RH = p;
338 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
342 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
346 } while (!(mem[contrib_head].hh.v.RH == 0));
350 nest[0].tail_field = contrib_head;
353 void app_space (void)
357 if ((space_factor >= 2000) && (xspace_skip != zero_glue))
358 q = new_param_glue(xspace_skip_code);
361 if (space_skip != zero_glue)
365 main_p = font_glue[cur_font];
368 main_p = new_spec(zero_glue);
369 main_k = param_base[cur_font] + 2;
370 width(main_p) = font_info[main_k].cint;
371 stretch(main_p) = font_info[main_k + 1].cint;
372 shrink(main_p) = font_info[main_k + 2].cint;
373 font_glue[cur_font] = main_p;
376 main_p = new_spec(main_p);
378 if (space_factor >= 2000)
379 width(main_p) = width(main_p) + font_info[7 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
380 stretch(main_p) = xn_over_d(stretch(main_p), space_factor, 1000);
381 shrink(main_p) = xn_over_d(shrink(main_p), 1000, space_factor);
382 q = new_glue(main_p);
383 glue_ref_count(main_p) = 0;
388 /* called from tex8.c only */
390 void insert_dollar_sign (void)
394 print_err("Missing $ inserted");
395 help2("I've inserted a begin-math/end-math symbol since I think",
396 "you left one out. Proceed, with fingers crossed.");
402 print_err("You can't use `");
403 print_cmd_chr(cur_cmd, cur_chr);
404 print_string("' in ");
408 void report_illegal_case (void)
411 help4("Sorry, but I'm not programmed to handle this case;",
412 "I'll just pretend that you didn't ask for it.",
413 "If you're in the wrong mode, you might be able to",
414 "return to the right one by typing `I}' or `I$' or `I\\par'.");
418 bool privileged (void)
426 report_illegal_case();
431 bool its_all_over (void)
433 register bool Result;
437 if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
444 mem[tail].hh.v.RH = new_null_box();
445 tail = mem[tail].hh.v.RH;
449 mem[tail].hh.v.RH = new_glue(8);
450 tail = mem[tail].hh.v.RH;
453 mem[tail].hh.v.RH = new_penalty(-1073741824L); /* - 2^30 */
454 tail = mem[tail].hh.v.RH;
462 void append_glue (void)
490 mem[tail].hh.v.RH = new_glue(cur_val);
491 tail = mem[tail].hh.v.RH;
495 decr(mem[cur_val].hh.v.RH);
497 mem[tail].hh.b1 = 99;
501 void append_kern (void)
507 scan_dimen(s == mu_glue, false, false);
509 mem[tail].hh.v.RH = new_kern(cur_val);
510 tail = mem[tail].hh.v.RH;
522 print_cmd_chr(cur_cmd, cur_chr);
523 help1("Things are pretty mixed up, but I think the worst is over.");
530 mem[temp_head].hh.v.RH = p;
531 print_err("Missing ");
537 /* mem[p].hh.v.LH = (hash_size + 4611); */
538 /* mem[p].hh.v.LH = (hash_size + 4095 + 516); */
539 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 516); /* 96/Jan/10 */
540 print_esc("endgroup");
545 mem[p].hh.v.LH = 804;
551 /* mem[p].hh.v.LH = (hash_size + 4612); */
552 /* mem[p].hh.v.LH = (hash_size + 4095 + 517); */
553 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 517); /* 96/Jan/10 */
554 mem[p].hh.v.RH = get_avail();
556 mem[p].hh.v.LH = 3118;
562 mem[p].hh.v.LH = 637;
567 print_string(" inserted");
568 begin_token_list(mem[temp_head].hh.v.RH, 4);
569 help5("I've inserted something that you may have forgotten.",
570 "(See the <inserted text> above.)",
571 "With luck, this will get me unwedged. But if you",
572 "really didn't forget anything, try typing `2' now; then",
573 "my insertion and my current dilemma will both disappear.");
577 /* only called from tex8.c */
579 void extra_right_brace (void)
581 print_err("Extra }, or forgotten");
586 print_esc("endgroup");
595 help5("I've deleted a group-closing symbol because it seems to be",
596 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
597 "you forgot something else, as in `\\hbox{$x}'. In such cases",
598 "the way to recover is to insert both the forgotten and the",
599 "deleted material, e.g., by typing `I$}'.");
604 void normal_paragraph (void)
607 eq_word_define(int_base + looseness_code, 0);
609 if (hang_indent != 0)
610 eq_word_define(dimen_base + hang_indent_code, 0);
613 eq_word_define(int_base + hang_after_code, 1);
615 if (par_shape_ptr != 0)
616 eq_define(par_shape_loc, shape_ref, 0);
619 void box_end_(integer boxcontext)
623 if (boxcontext < box_flag)
627 shift_amount(cur_box) = boxcontext;
628 if (abs(mode) == vmode)
630 append_to_vlist(cur_box);
631 if (adjust_tail != 0)
633 if (adjust_head != adjust_tail)
635 link(tail) = link(adjust_head);
646 if (abs(mode) == hmode)
651 math_type(nucleus(p)) = sub_box;
652 info(nucleus(p)) = cur_box;
655 link(tail) = cur_box;
660 else if (boxcontext < ship_out_flag)
661 if (boxcontext < (box_flag + 256))
662 eq_define((box_base - box_flag) + boxcontext, box_ref, cur_box);
664 geq_define((box_base - box_flag - 256) + boxcontext, box_ref, cur_box);
665 else if (cur_box != 0)
666 if (boxcontext > (ship_out_flag))
672 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
674 if (((cur_cmd == hskip) && (abs(mode)!= vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode)))
677 subtype(tail) = boxcontext - (leader_flag - a_leaders);
678 leader_ptr(tail) = cur_box;
682 print_err("Leaders not followed by proper glue");
683 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
684 "I found the <box or rule>, but there's no suitable",
685 "<hskip or vskip>, so I'm ignoring these leaders.");
687 flush_node_list(cur_box);
693 /* called only from tex8.c */
695 void begin_box_(integer boxcontext)
706 scan_eight_bit_int();
707 cur_box = box(cur_val);
713 scan_eight_bit_int();
714 cur_box = copy_node_list(box(cur_val));
721 if (abs(mode) == mmode)
724 help1("Sorry; this \\lastbox will be void.");
727 else if ((mode == vmode) && (head == cur_list.tail_field))
730 help2("Sorry...I usually can't take things from the current page.",
731 "This \\lastbox will therefore be void.");
736 if (!(tail >= hi_mem_min))
737 if ((type(tail) == hlist_node) || (type(tail) == vlist_node))
743 if (!(q >= hi_mem_min))
744 if (type(q) == disc_node)
746 for (m = 1; m <= replace_count(q); m++)
754 while (!(q == tail));
756 shift_amount(cur_box) = 0;
767 scan_eight_bit_int();
769 if (!scan_keyword("to"))
771 print_err("Missing `to' inserted");
772 help2("I'm working on `\\vsplit<box number> to <dimen>';",
773 "will look for the <dimen> next.");
776 scan_dimen(false, false, false);
777 cur_box = vsplit(n, cur_val);
782 k = cur_chr - vtop_code;
783 save_stack[save_ptr + 0].cint = boxcontext;
786 if ((boxcontext < box_flag) && (abs(mode) == vmode))
787 scan_spec(adjust_hbox_group, true);
789 scan_spec(hbox_group, true);
793 scan_spec(vbox_group, true);
796 scan_spec(vtop_group, true);
802 mode = - (integer) k;
806 prev_depth = ignore_depth;
809 begin_token_list(every_vbox, every_vbox_text);
816 begin_token_list(every_hbox, every_vbox_text);
825 void scan_box_(integer boxcontext)
831 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
833 if (cur_cmd == make_box)
835 begin_box(boxcontext);
837 else if ((boxcontext >= leader_flag) && ((cur_cmd == hrule) || (cur_cmd == vrule)))
839 cur_box = scan_rule_spec();
844 print_err("A <box> was supposed to be here");
845 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
846 "something like that. So you might find something missing in",
847 "your output. But keep trying; you can fix this later.");
851 /****************************************************************************/
852 void package_ (small_number);
853 /****************************************************************************/
855 small_number norm_min_ (integer h)
865 void new_graf_(bool indented)
869 if ((mode == vmode) || (head != tail))
871 mem[tail].hh.v.RH = new_param_glue(2);
872 tail = mem[tail].hh.v.RH;
880 else if (language > 255)
886 prev_graf =(norm_min(left_hyphen_min) * 64 + norm_min(right_hyphen_min)) * 65536L + cur_lang;
890 tail = new_null_box();
892 width(tail) = par_indent;
896 begin_token_list(every_par, every_par_text);
901 /* procedure indent_in_hmode; l.21058 */
903 void indent_in_hmode (void)
910 width(p) = par_indent;
912 if (abs(mode) == hmode)
917 math_type(nucleus(q)) = sub_box;
918 info(nucleus(q)) = p;
922 mem[tail].hh.v.RH = p;
923 tail = mem[tail].hh.v.RH;
927 /* only called from tex8.c */
929 void head_for_vmode (void)
932 if (cur_cmd != hrule)
936 print_err("You can't use `");
938 print_string("' here except with leaders");
939 help2("To put a horizontal rule in an hbox or an alignment,",
940 "you should use \\leaders or \\hrulefill (see The TeXbook).");
948 cur_input.index_field = inserted;
959 line_break(widow_penalty);
965 /* only called form tex8.c */
967 void begin_insert_or_adjust (void)
969 if (cur_cmd == vadjust)
973 scan_eight_bit_int();
977 print_err("You can't ");
980 help1("I'm changing to \\insert0; box 255 is special.");
985 save_stack[save_ptr + 0].cint = cur_val;
987 new_save_level(insert_group);
992 prev_depth = ignore_depth;
995 void make_mark (void)
998 p = scan_toks(false, true);
999 p = get_node(small_node_size);
1000 type(p) = mark_node;
1002 mark_ptr(p) = def_ref;
1007 void append_penalty (void)
1011 mem[tail].hh.v.RH = new_penalty(cur_val);
1012 tail = mem[tail].hh.v.RH;
1018 /* only called from tex8.c */
1020 void delete_last (void)
1025 if ((mode == vmode) && (tail == head))
1027 if ((cur_chr != glue_node) || (last_glue != empty_flag))
1030 help2("Sorry...I usually can't take things from the current page.",
1031 "Try `I\\vskip-\\lastskip' instead.");
1033 if (cur_chr == kern_node)
1034 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1035 else if (cur_chr != glue_node)
1036 help_line[0] = "Perhaps you can make the output routine do it.";
1042 if (!(tail >= hi_mem_min))
1043 if (type(tail) == cur_chr)
1051 if (!(q >= hi_mem_min))
1052 if (type(q) == disc_node)
1054 for (m = 1; m <= replace_count(q); m++)
1062 while (!(q == tail));
1064 flush_node_list(tail);
1069 /* only called from tex8.c */
1070 /* procedure unpackage; l.21256 */
1072 void unpackage (void)
1078 scan_eight_bit_int();
1083 if ((abs(mode) == mmode) || ((abs(mode) == vmode) && (type(p) != vlist_node)) ||
1084 ((abs(mode) == hmode) && (type(p) != hlist_node)))
1086 print_err("Incompatible list can't be unboxed");
1087 help3("Sorry, Pandora. (You sneaky devil.)",
1088 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1089 "And I can't open any boxes in math mode.");
1095 link(tail) = copy_node_list(list_ptr(p));
1098 link(tail) = list_ptr(p);
1100 free_node(p, box_node_size);
1103 while (link(tail) != 0)
1107 void append_italic_correction (void)
1110 internal_font_number f;
1114 if ((tail >= hi_mem_min))
1116 else if (type(tail) == ligature_node)
1122 mem[tail].hh.v.RH = new_kern(font_info[italic_base[f] + (font_info[char_base[f] + mem[p].hh.b1].qqqq.b2) / 4].cint);
1123 tail = mem[tail].hh.v.RH;
1125 subtype(tail) = explicit;
1129 void append_discretionary (void)
1134 mem[tail].hh.v.RH = new_disc();
1135 tail = mem[tail].hh.v.RH;
1140 c = hyphen_char[cur_font];
1143 pre_break(tail) = new_character(cur_font, c);
1148 save_stack[save_ptr - 1].cint = 0;
1149 new_save_level(disc_group);
1153 space_factor = 1000;
1156 /* only called form tex8.c */
1158 void build_discretionary (void)
1170 if (!(p >= hi_mem_min))
1171 if (mem[p].hh.b0 > 2)
1172 if (mem[p].hh.b0 != 11)
1173 if (mem[p].hh.b0 != 6)
1175 print_err("Improper discretionary list");
1176 help1("Discretionary lists must contain only boxes and kerns.");
1179 print_nl("The following discretionary sublist has been deleted:");
1181 end_diagnostic(true);
1192 p = mem[head].hh.v.RH;
1195 switch (save_stack[save_ptr - 1].cint)
1198 mem[tail + 1].hh.v.LH = p;
1201 mem[tail + 1].hh.v.RH = p;
1205 if ((n > 0) && (abs(mode)== 203))
1207 print_err("Illegal math ");
1208 print_esc("discretionary");
1209 help2("Sorry: The third part of a discretionary break must be",
1210 "empty, in math formulas. I had to delete your third part.");
1216 mem[tail].hh.v.RH = p;
1217 /* if n <= max_quarterword then replace_count(tail) <- n; p.1120 */
1218 /* if (n <= 255) */ /* 94/Apr/4 ? */
1219 if (n <= max_quarterword) /* 96/Oct/12 ??? */
1220 mem[tail].hh.b1 = n;
1223 print_err("Discretionary list is too long");
1224 help2("Wow---I never thought anybody would tweak me here.",
1225 "You can't seriously need such a huge discretionary list?");
1235 incr(save_stack[save_ptr - 1].cint);
1240 space_factor = 1000;
1242 /* called only from tex8.c */
1244 void make_accent (void)
1248 internal_font_number f;
1249 scaled a, h, x, w, delta;
1254 p = new_character(f, cur_val);
1259 s = slant(f) / ((double) 65536.0);
1260 a = char_width(f, char_info(f, character(p)));
1265 if ((cur_cmd == letter) || (cur_cmd == other_char) || (cur_cmd == char_given))
1266 q = new_character(f, cur_chr);
1267 else if (cur_cmd == char_num)
1270 q = new_character(f, cur_val);
1277 t = slant(f) / ((double) 65536.0);
1278 i = char_info(f, character(q));
1279 w = char_width(f, i);
1280 h = char_height(f, height_depth(i));
1285 shift_amount(p) = x - h;
1287 delta = round((w - a) / ((double) 2.0)+ h * t - x * s);
1288 r = new_kern(delta);
1289 subtype(r) = acc_kern;
1292 tail = new_kern(- (integer) a - delta);
1293 subtype(tail) = acc_kern;
1299 space_factor = 1000;
1303 void align_error (void)
1305 if (abs(align_state) > 2)
1307 print_err("Misplaced ");
1308 print_cmd_chr(cur_cmd, cur_chr);
1309 if (cur_tok == 1062)
1311 help6("I can't figure out why you would want to use a tab mark",
1312 "here. If you just want an ampersand, the remedy is",
1313 "simple: Just type `I\\&' now. But if some right brace",
1314 "up above has ended a previous alignment prematurely,",
1315 "you're probably due for more error messages, and you",
1316 "might try typing `S' now just to see what is salvageable.");
1320 help5("I can't figure out why you would want to use a tab mark",
1321 "or \\cr or \\span just now. If something like a right brace",
1322 "up above has ended a previous alignment prematurely,",
1323 "you're probably due for more error messages, and you",
1324 "might try typing `S' now just to see what is salvageable.");
1332 if (align_state < 0)
1334 print_err("Missing { inserted");
1336 cur_tok = 379; /* belowdisplayshortskip ? */
1340 print_err("Missing } inserted");
1344 help3("I've put in what seems to be necessary to fix",
1345 "the current column of the current alignment.",
1346 "Try to go on, since this might almost work.");
1351 void noalign_error (void)
1353 print_err("Misplaced ");
1354 print_esc("noalign");
1355 help2("I expect to see \\noalign only after the \\cr of",
1356 "an alignment. Proceed, and I'll ignore this case.");
1359 /* only called from tex8.c */
1361 void omit_error (void)
1363 print_err("Misplaced ");
1365 help2("I expect to see \\omit only after tab marks or the \\cr of",
1366 "an alignment. Proceed, and I'll ignore this case.");
1382 /* only called form tex8.c */
1384 void cs_error (void)
1386 print_err("Extra ");
1387 print_esc("endcsname");
1388 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1392 void push_math_(group_code c)
1396 cur_list.aux_field.cint = 0;
1400 void init_math (void)
1407 internal_font_number f;
1414 if ((cur_cmd == 3) && (mode > 0))
1419 w = -1073741823L; /* - (2^30 - 1) */
1423 line_break(display_widow_penalty);
1424 v = mem[just_box + 4].cint + 2 * font_info[6 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
1425 w = -1073741823L; /* - (2^30 - 1) */
1426 p = mem[just_box + 5].hh.v.RH;
1430 if ((p >= hi_mem_min))
1433 d = font_info[width_base[f] + font_info[char_base[f] + mem[p].hh.b1].qqqq.b0].cint;
1436 switch (mem[p].hh.b0)
1442 d = mem[p + 1].cint;
1448 mem[lig_trick]= mem[p + 1];
1449 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1456 d = mem[p + 1].cint;
1460 q = mem[p + 1].hh.v.LH;
1461 d = mem[q + 1].cint;
1462 if (mem[just_box + 5].hh.b0 == 1)
1464 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b0) && (mem[q + 2].cint != 0))
1465 v = 1073741823L; /* - (2^30 - 1) */
1467 else if (mem[just_box + 5].hh.b0 == 2)
1469 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b1) && (mem[q + 3].cint != 0))
1470 v = 1073741823L; /* - (2^30 - 1) */
1472 if (mem[p].hh.b1 >= 100)
1483 if (v < 1073741823L) /* - (2^30 - 1) */
1487 if (v < 1073741823L) /* - (2^30 - 1) */
1494 w = 1073741823L; /* - (2^30 - 1) */
1503 if (par_shape_ptr == 0)
1504 if ((hang_indent != 0) && (((hang_after >= 0) && (prev_graf + 2 > hang_after)) || (prev_graf + 1 < - (integer) hang_after)))
1506 l = hsize - abs(hang_indent);
1507 if (hang_indent > 0)
1519 n = mem[par_shape_ptr].hh.v.LH;
1520 if (prev_graf + 2 >= n)
1521 p = par_shape_ptr + 2 * n;
1523 p = par_shape_ptr + 2 *(prev_graf + 2);
1524 s = mem[p - 1].cint;
1529 eq_word_define((hash_size + 3207), -1);
1530 eq_word_define((hash_size + 3743), w);
1531 eq_word_define((hash_size + 3744), l);
1532 eq_word_define((hash_size + 3745), s);
1534 if (every_display != 0)/* everydisplay */
1535 begin_token_list(every_display, 9);
1547 eq_word_define((hash_size + 3207), -1);
1548 if (every_math != 0)/* everymath */
1549 begin_token_list(every_math, 8);
1554 void start_eq_no (void)
1556 save_stack[save_ptr + 0].cint = cur_chr;
1559 push_math(math_shift_group);
1560 eq_word_define(int_base + cur_fam_code, -1);
1562 if (every_math != 0)
1563 begin_token_list(every_math, every_math_text);
1567 void scan_math_(halfword p)
1576 while(!((cur_cmd != spacer) && (cur_cmd != relax)));
1585 c = math_code(cur_chr);
1590 cur_cs = cur_chr + active_base;
1591 cur_cmd = eq_type(cur_cs);
1592 cur_chr = equiv(cur_cs);
1604 cur_cmd = char_given;
1610 scan_fifteen_bit_int();
1619 scan_twenty_seven_bit_int();
1627 save_stack[save_ptr + 0].cint = p;
1629 push_math(math_group);
1634 math_type(p) = math_char;
1635 character(p) = c % 256;
1637 if ((c >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1640 fam(p) = (c / 256) % 16;
1643 void set_math_char_(integer c)
1649 cur_cs = cur_chr + active_base;
1650 cur_cmd = eq_type(cur_cs);
1651 cur_chr = equiv(cur_cs);
1658 math_type(nucleus(p)) = math_char;
1659 character(nucleus(p)) = c % 256;
1660 fam(nucleus(p)) = (c / 256) % 16;
1664 if (((cur_fam >= 0) && (cur_fam < 16)))
1665 fam(nucleus(p)) = cur_fam;
1670 type(p) = ord_noad + (c / 4096);
1677 void math_limit_switch (void)
1680 if (mem[tail].hh.b0 == op_noad)
1682 subtype(tail) = cur_chr;
1686 print_err("Limit controls must follow a math operator");
1687 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1691 void scan_delimiter_(halfword p, bool r)
1695 scan_twenty_seven_bit_int();
1703 while (!((cur_cmd != spacer) && (cur_cmd != relax)));
1709 cur_val = del_code(cur_chr);
1712 scan_twenty_seven_bit_int();
1722 print_err("Missing delimiter (. inserted)");
1723 help6("I was expecting to see something like `(' or `\\{' or",
1724 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1725 "should probably delete the `{' by typing `1' now, so that",
1726 "braces don't get unbalanced. Otherwise just proceed.",
1727 "Acceptable delimiters are characters whose \\delcode is",
1728 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1733 small_fam(p) = (cur_val / 1048576L) % 16;
1734 small_char(p) = (cur_val / 4096) % 256;
1735 large_fam(p) = (cur_val / 256) % 16;
1736 large_char(p) = cur_val % 256;
1739 void math_radical (void)
1742 mem[tail].hh.v.RH = get_node(radical_noad_size);
1743 tail = mem[tail].hh.v.RH;
1745 type(tail) = radical_noad;
1746 subtype(tail) = normal;
1747 mem[nucleus(tail)].hh = empty_field;
1748 mem[subscr(tail)].hh = empty_field;
1749 mem[supscr(tail)].hh = empty_field;
1750 scan_delimiter(left_delimiter(tail), true);
1751 scan_math(nucleus(tail));
1756 if (cur_cmd == accent)
1758 print_err("Please use ");
1759 print_esc("mathaccent");
1760 print_string(" for accents in math mode");
1761 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1762 "(Accents are not the same in formulas as they are in text.)");
1767 mem[tail].hh.v.RH = get_node(5);
1768 tail = mem[tail].hh.v.RH;
1770 type(tail) = accent_noad;
1771 subtype(tail) = normal;
1772 mem[nucleus(tail)].hh = empty_field;
1773 mem[subscr(tail)].hh = empty_field;
1774 mem[supscr(tail)].hh = empty_field;
1775 math_type(accent_chr(tail)) = math_char;
1776 scan_fifteen_bit_int();
1777 character(accent_chr(tail)) = cur_val % 256;
1779 if ((cur_val >= var_code) && ((cur_fam >= 0) && (cur_fam < 16)))
1780 fam(accent_chr(tail)) = cur_fam;
1782 fam(accent_chr(tail)) = (cur_val / 256) % 16;
1784 scan_math(nucleus(tail));
1787 void append_choices (void)
1790 mem[tail].hh.v.RH = new_choice();
1791 tail = mem[tail].hh.v.RH;
1794 save_stack[save_ptr - 1].cint = 0;
1795 push_math(math_choice_group);
1799 halfword fin_mlist_(halfword p)
1801 register halfword Result;
1804 if (incompleat_noad != 0)
1806 math_type(denominator(incompleat_noad)) = sub_mlist;
1807 info(denominator(incompleat_noad)) = link(head);
1810 q = incompleat_noad;
1813 q = info(numerator(incompleat_noad));
1815 if (type(q) != left_noad)
1818 return 0; // abort_flag set
1821 info(numerator(incompleat_noad)) = link(q);
1822 link(q) = incompleat_noad;
1823 link(incompleat_noad) = p;
1836 void build_choices (void)
1843 switch (save_stack[save_ptr - 1].cint)
1846 display_mlist(tail) = p;
1849 text_mlist(tail) = p;
1852 script_mlist(tail) = p;
1856 script_script_mlist(tail) = p;
1862 incr(save_stack[save_ptr - 1].cint);
1863 push_math(math_choice_group);
1869 /* small_number t; */
1870 int t; /* 95/Jan/7 */
1877 if ((mem[tail].hh.b0 >= 16) && (mem[tail].hh.b0 < 30))
1879 p = supscr(tail) + cur_cmd - sup_mark;
1883 if ((p == 0) || (t != 0))
1886 mem[tail].hh.v.RH = new_noad();
1887 tail = mem[tail].hh.v.RH;
1889 p = supscr(tail) + cur_cmd - sup_mark;
1893 if (cur_cmd == sup_mark)
1895 print_err("Double superscript");
1896 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1900 print_err("Double subscript");
1901 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1908 /* used to continue here with math_fraction etc in tex7.c */
1909 /*****************************************************************************/
1910 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1912 void package_(small_number c)
1920 save_ptr = save_ptr - 3;
1923 cur_box = hpack(link(head), save_stack[save_ptr + 2].cint, save_stack[save_ptr + 1].cint);
1926 cur_box = vpackage(link(head), save_stack[save_ptr + 2].cint, save_stack[save_ptr + 1].cint, d);
1931 p = list_ptr(cur_box);
1934 if (type(p) <= rule_node)
1937 depth(cur_box) = depth(cur_box) - h + height(cur_box);
1938 height(cur_box) = h;
1942 box_end(save_stack[save_ptr + 0].cint);
1944 #pragma optimize ("", on) /* 96/Sep/12 */