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)
42 p = mem[contrib_head].hh.v.RH;
43 /* if (last_glue != 262143L) */
44 if (last_glue != empty_flag)
45 delete_glue_ref(last_glue);
48 if (mem[p].hh.b0 == 10) {
49 last_glue = mem[p + 1].hh.v.LH;
50 incr(mem[last_glue].hh.v.RH);
52 /* last_glue = 262143L; */
53 last_glue = empty_flag;
54 if (mem[p].hh.b0 == 12)
55 last_penalty = mem[p + 1].cint;
56 else if (mem[p].hh.b0 == 11)
57 last_kern = mem[p + 1].cint;
64 if (page_contents < 2) {
65 if (page_contents == 0)
69 q = new_skip_param(9);
70 if (mem[temp_ptr + 1].cint > mem[p + 3].cint)
71 mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3].cint;
73 mem[temp_ptr + 1].cint = 0;
75 mem[contrib_head].hh.v.RH = q;
78 page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[p + 3].cint;
79 page_so_far[7]= mem[p + 2].cint;
87 if (page_contents < 2)
89 else if ((mem[page_tail].hh.b0 < 9))
95 if (page_contents < 2)
97 else if (mem[p].hh.v.RH == 0)
99 else if (mem[mem[p].hh.v.RH].hh.b0 == 10)
105 if (page_contents < 2)
108 pi = mem[p + 1].cint;
115 if (page_contents == 0)
116 freeze_page_specs(1);
119 while(n >= mem[mem[r].hh.v.RH].hh.b1)
122 if (mem[r].hh.b1 != n)
125 mem[q].hh.v.RH = mem[r].hh.v.RH;
131 if (eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
134 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;
135 mem[r + 2].hh.v.LH = 0;
136 q = eqtb[(hash_size + 800) + n].hh.v.RH;
137 if (eqtb[(hash_size + 3218) + n].cint == 1000)
140 h = x_over_n(mem[r + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
141 page_so_far[0]= page_so_far[0]- h - mem[q + 1].cint;
142 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]+ mem[q + 2].cint;
143 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
144 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0)) {
145 print_err("Infinite glue shrinkage inserted from");
148 help3("The correction glue for page breaking with insertions",
149 "must have finite shrinkability. But you may proceed,",
150 "since the offensive shrinkability has been made finite.");
154 if (mem[r].hh.b0 == 1)
155 insert_penalties = insert_penalties + mem[p + 1].cint;
157 mem[r + 2].hh.v.RH = p;
158 delta = page_so_far[0]- page_so_far[1]- page_so_far[7] + page_so_far[6];
159 if (eqtb[(hash_size + 3218) + n].cint == 1000)
162 h = x_over_n(mem[p + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
163 if (((h <= 0)||(h <= delta)) &&(mem[p + 3].cint + mem[r + 3].cint <= eqtb[(hash_size + 3751) + n].cint))
165 page_so_far[0]= page_so_far[0]- h;
166 mem[r + 3].cint = mem[r + 3].cint + mem[p + 3].cint;
168 if (eqtb[(hash_size + 3218) + n].cint <= 0)
169 w = 1073741823L; /* 2^30 - 1 */
171 w = page_so_far[0]- page_so_far[1]- page_so_far[7];
172 if (eqtb[(hash_size + 3218) + n].cint != 1000)
173 w = x_over_n(w, eqtb[(hash_size + 3218) + n].cint)* 1000;
175 if (w > eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint)
176 w = eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint;
177 q = vert_break(mem[p + 4].hh.v.LH, w, mem[p + 2].cint);
178 mem[r + 3].cint = mem[r + 3].cint + best_height_plus_depth;
181 if (tracing_pages > 0)
189 print_scaled(best_height_plus_depth);
191 if (q == 0) /* if q=null l.19614 */
193 else if (mem[q].hh.b0 == 12)
194 print_int(mem[q + 1].cint);
195 else print_char('0');
196 end_diagnostic(false);
199 if (eqtb[(hash_size + 3218) + n].cint != 1000)
200 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * eqtb[(hash_size + 3218) + n].cint;
201 page_so_far[0]= page_so_far[0]- best_height_plus_depth;
203 mem[r + 1].hh.v.RH = q;
204 mem[r + 1].hh.v.LH = p;
206 insert_penalties = insert_penalties - 10000;
207 else if (mem[q].hh.b0 == 12)
208 insert_penalties = insert_penalties + mem[q + 1].cint;
217 return; // abort_flag set
221 if (pi < 10000)/* pi may be used ... */
223 if (page_so_far[1]< page_so_far[0])
224 if ((page_so_far[3]!= 0)||(page_so_far[4]!= 0)||(page_so_far[5]!= 0))
227 b = badness(page_so_far[0]- page_so_far[1], page_so_far[2]);
228 else if (page_so_far[1]- page_so_far[0]> page_so_far[6])
229 b = 1073741823L; /* 2^30 - 1 */
231 b = badness(page_so_far[1]- page_so_far[0], page_so_far[6]);
232 if (b < 1073741823L) /* 2^30 - 1 */
236 c = b + pi + insert_penalties;
241 if (insert_penalties >= 10000)
242 c = 1073741823L; /* 2^30 - 1 */
245 if (tracing_pages > 0)
252 print_scaled(page_so_far[0]);
254 if (b == 1073741823L) /* 2^30 - 1 */
261 if (c == 1073741823L) /* 2^30 - 1 */
264 if (c <= least_page_cost)
266 end_diagnostic(false);
269 if (c <= least_page_cost)
272 best_size = page_so_far[0];
274 r = mem[mem_top].hh.v.RH;
275 while (r != mem_top) {
276 mem[r + 2].hh.v.LH = mem[r + 2].hh.v.RH;
280 if ((c == 1073741823L)||(pi <= -10000)) /* 2^30 - 1 */
288 if ((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11))
291 if (mem[p].hh.b0 == 11)
294 q = mem[p + 1].hh.v.LH;
295 page_so_far[2 + mem[q].hh.b0] = page_so_far[2 + mem[q].hh.b0] + mem[q + 2].cint;
296 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
297 if ((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0)) {
298 print_err("Infinite glue shrinkage found on current page");
299 help4("The page about to be output contains some infinitely",
300 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
301 "Such glue doesn't belong there; but you can safely proceed,",
302 "since the offensive shrinkability has been made finite.");
307 mem[p + 1].hh.v.LH = r;
311 page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[q + 1].cint;
314 if (page_so_far[7]> page_max_depth) {
315 page_so_far[1] = page_so_far[1] + page_so_far[7] - page_max_depth;
316 page_so_far[7] = page_max_depth;
318 mem[page_tail].hh.v.RH = p;
320 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
324 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
328 } while (!(mem[contrib_head].hh.v.RH == 0));
332 nest[0].tail_field = contrib_head;
335 void app_space (void)
338 if ((space_factor >= 2000) && (eqtb[(hash_size + 795)].hh.v.RH != 0))
339 q = new_param_glue(13);
341 if (eqtb[(hash_size + 794)].hh.v.RH != 0)
342 main_p = eqtb[(hash_size + 794)].hh.v.RH;
344 main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH];
346 main_p = new_spec(0);
347 main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2;
348 mem[main_p + 1].cint = font_info[main_k].cint;
349 mem[main_p + 2].cint = font_info[main_k + 1].cint;
350 mem[main_p + 3].cint = font_info[main_k + 2].cint;
351 font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p;
354 main_p = new_spec(main_p);
355 if (space_factor >= 2000)
356 mem[main_p + 1].cint = mem[main_p + 1].cint + font_info[7 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
357 mem[main_p + 2].cint = xn_over_d(mem[main_p + 2].cint, cur_list.aux_field.hh.v.LH, 1000);
358 mem[main_p + 3].cint = xn_over_d(mem[main_p + 3].cint, 1000, space_factor);
359 q = new_glue(main_p);
360 mem[main_p].hh.v.RH = 0;
362 mem[tail].hh.v.RH = q;
365 /* called from tex8.c only */
367 void insert_dollar_sign (void)
371 print_err("Proceed; I'll discard its present contents.");
372 help2("I've inserted a begin-math/end-math symbol since I think",
373 "you left one out. Proceed, with fingers crossed.");
379 print_err("You can't use `");
380 print_cmd_chr(cur_cmd, cur_chr);
381 print_string("' in ");
385 void report_illegal_case (void)
388 help4("Sorry, but I'm not programmed to handle this case;",
389 "I'll just pretend that you didn't ask for it.",
390 "If you're in the wrong mode, you might be able to",
391 "return to the right one by typing `I}' or `I$' or `I\\par'.");
395 bool privileged (void)
397 register bool Result;
401 report_illegal_case();
407 bool its_all_over (void)
409 register bool Result;
412 if ((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
419 mem[tail].hh.v.RH = new_null_box();
420 tail = mem[tail].hh.v.RH;
422 mem[tail + 1].cint = hsize;
424 mem[tail].hh.v.RH = new_glue(8);
425 tail = mem[tail].hh.v.RH;
428 mem[tail].hh.v.RH = new_penalty(-1073741824L);
430 tail = mem[tail].hh.v.RH;
438 void append_glue (void)
464 mem[tail].hh.v.RH = new_glue(cur_val);
465 tail = mem[tail].hh.v.RH;
468 decr(mem[cur_val].hh.v.RH);
470 mem[tail].hh.b1 = 99;
474 void append_kern (void)
478 scan_dimen(s == 99, false, false);
480 mem[tail].hh.v.RH = new_kern(cur_val);
481 tail = mem[tail].hh.v.RH;
489 if (cur_group == 0) {
491 print_cmd_chr(cur_cmd, cur_chr);
492 help1("Things are pretty mixed up, but I think the worst is over.");
497 mem[temp_head].hh.v.RH = p;
498 print_err("Missing ");
503 /* mem[p].hh.v.LH = (hash_size + 4611); */
504 /* mem[p].hh.v.LH = (hash_size + 4095 + 516); */
505 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 516); /* 96/Jan/10 */
506 print_esc("endgroup");
511 mem[p].hh.v.LH = 804;
517 /* mem[p].hh.v.LH = (hash_size + 4612); */
518 /* mem[p].hh.v.LH = (hash_size + 4095 + 517); */
519 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 517); /* 96/Jan/10 */
520 mem[p].hh.v.RH = get_avail();
522 mem[p].hh.v.LH = 3118;
528 mem[p].hh.v.LH = 637;
533 print_string(" inserted");
534 begin_token_list(mem[temp_head].hh.v.RH, 4);
535 help5("I've inserted something that you may have forgotten.",
536 "(See the <inserted text> above.)",
537 "With luck, this will get me unwedged. But if you",
538 "really didn't forget anything, try typing `2' now; then",
539 "my insertion and my current dilemma will both disappear.");
543 /* only called from tex8.c */
545 void extra_right_brace (void)
547 print_err("Extra }, or forgotten");
551 print_esc("endgroup");
560 help5("I've deleted a group-closing symbol because it seems to be",
561 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
562 "you forgot something else, as in `\\hbox{$x}'. In such cases",
563 "the way to recover is to insert both the forgotten and the",
564 "deleted material, e.g., by typing `I$}'.");
569 void normal_paragraph (void)
571 /* if looseness<>0 then eq_word_define(int_base+looseness_code,0); */
573 eq_word_define((hash_size + 3182), 0);
574 if (hang_indent != 0)
575 eq_word_define((hash_size + 3747), 0);
577 eq_word_define((hash_size + 3204), 1);
578 if (eqtb[(hash_size + 1312)].hh.v.RH != 0)
579 eq_define((hash_size + 1312), 118, 0);
582 void box_end_(integer boxcontext)
585 /* if box_context<box_flag then ... 1073741824 2^30 */
586 if (boxcontext < 1073741824L) {
588 mem[cur_box + 4].cint = boxcontext;
590 append_to_vlist(cur_box);
591 if (adjust_tail != 0) {
592 if (adjust_head != adjust_tail) {
593 mem[tail].hh.v.RH = mem[adjust_head].hh.v.RH;
606 mem[p + 1].hh.v.RH = 2;
607 mem[p + 1].hh.v.LH = cur_box;
610 mem[tail].hh.v.RH = cur_box;
616 /* following fixed 1994/Apr/5 1 day anno Yang --- moby sigh ... */
618 /* else if box_context<box_flag+512 then ... */
619 /* else if (boxcontext < 1073742336L)*/ /* 2^30 + 512 */
620 else if (boxcontext < (1073741824L + 512)) /* 2^30 + 512 */
621 /* else if box_context<box_flag+256 then ... */
622 /* if (boxcontext < 1073742080L)*/ /* 2^30 + 256 */
623 if (boxcontext < (1073741824L + 256))/* 2^30 + 256 */
624 /* eq_define(box_base-box_flag+box_context,box_ref,cur_box) */
625 /* eq_define((hash_size - 1073740246L) + boxcontext, 119, cur_box); */
626 eq_define((hash_size + 1578 - 1073741824L) + boxcontext, 119, cur_box);
627 /* else geq_define(box_base-box_flag-256+box_context,box_ref,cur_box) */
628 /* else geq_define((hash_size - 1073740502L) + boxcontext, 119, cur_box); */
629 else geq_define((hash_size + 1322 - 1073741824L) + boxcontext, 119, cur_box);
630 else if (cur_box != 0)
631 /* if (boxcontext > 1073742336L)*/ /* 2^30 + 512 */
632 if (boxcontext > (1073741824L + 512)) /* 2^30 + 512 */
636 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
637 /* 424 in tex82.bug */
638 if (((cur_cmd == 26) && (abs(mode)!= 1)) ||
639 ((cur_cmd == 27) && (abs(mode)== 1)))
641 /* begin append_glue; subtype(tail):=box_context-(leader_flag-a_leaders); */
643 /* -(2^30 + 513 - 100) */
644 mem[tail].hh.b1 = boxcontext -(1073742237L);
645 mem[tail + 1].hh.v.RH = cur_box;
648 print_err("Leaders not followed by proper glue");
649 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
650 "I found the <box or rule>, but there's no suitable",
651 "<hskip or vskip>, so I'm ignoring these leaders.");
653 flush_node_list(cur_box);
656 else ship_out(cur_box);
658 /* called only from tex8.c */
660 void begin_box_(integer boxcontext)
669 scan_eight_bit_int();
670 cur_box = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
671 eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0;
676 scan_eight_bit_int();
677 cur_box = copy_node_list(eqtb[(hash_size + 1578) + cur_val].hh.v.RH);
686 help1("Sorry; this \\lastbox will be void.");
688 } else if ((mode == 1)&&(head == cur_list.tail_field)) {
690 help2("Sorry...I usually can't take things from the current page.",
691 "This \\lastbox will therefore be void.");
694 if (!(tail >= hi_mem_min))
695 if ((mem[tail].hh.b0 == 0) || (mem[cur_list.tail_field].hh.b0 == 1)) {
699 if (!(q >= hi_mem_min))
700 if (mem[q].hh.b0 == 7)
703 register integer for_end;
705 for_end = mem[q].hh.b1;
708 while(m++ < for_end);
714 } while (!(q == tail));
716 mem[cur_box + 4].cint = 0;
726 scan_eight_bit_int();
728 if (!scan_keyword("to")) /* to */
730 print_err("Missing `to' inserted");
731 help2("I'm working on `\\vsplit<box number> to <dimen>';",
732 "will look for the <dimen> next.");
735 scan_dimen(false, false, false);
736 cur_box = vsplit(n, cur_val);
742 save_stack[save_ptr + 0].cint = boxcontext;
744 if ((boxcontext < 1073741824L) && /* 2^30 */
759 mode = - (integer) k;
762 cur_list.aux_field.cint = ignore_depth;
763 if (eqtb[(hash_size + 1318)].hh.v.RH != 0)/* everyhbox */
764 begin_token_list(eqtb[(hash_size + 1318)].hh.v.RH, 11);
767 if (eqtb[(hash_size + 1317)].hh.v.RH != 0)/* everyhbox */
768 begin_token_list(eqtb[(hash_size + 1317)].hh.v.RH, 10);
777 void scan_box_(integer boxcontext)
781 } while(!((cur_cmd != 10) && (cur_cmd != 0)));
783 begin_box(boxcontext);
785 else if ((boxcontext >= 1073742337L)&& /* (2^30 + 512 + 1) */
786 ((cur_cmd == 36)||(cur_cmd == 35)))
788 cur_box = scan_rule_spec();
792 print_err("A <box> was supposed to be here");
793 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
794 "something like that. So you might find something missing in",
795 "your output. But keep trying; you can fix this later.");
799 /****************************************************************************/
800 void package_ (small_number);
801 /****************************************************************************/
803 small_number norm_min_ (integer h)
805 /* small_number Result; */
806 int Result; /* 95/Jan/7 */
816 void new_graf_(bool indented)
819 if ((mode == 1)||(head != cur_list.tail_field))
821 mem[tail].hh.v.RH = new_param_glue(2);
822 tail = mem[tail].hh.v.RH;
824 /* used to be followingin 3.141 */
825 /* cur_list .lhmfield = norm_min(eqtb[(hash_size + 3214)].cint); */
826 /* cur_list .rhmfield = norm_min(eqtb[(hash_size + 3215)].cint); */
830 /* changes here since 3.141 */
833 else if (language > 255)
835 else cur_lang = language;
837 prev_graf =(norm_min(left_hyphen_min)* 64 +
838 norm_min(right_hyphen_min)) * 65536L + cur_lang;
839 /* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
840 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
843 tail = new_null_box();
844 mem[head].hh.v.RH = tail;
845 mem[tail + 1].cint = par_indent;
847 if (eqtb[(hash_size + 1314)].hh.v.RH != 0) /* everypar */
848 begin_token_list(eqtb[(hash_size + 1314)].hh.v.RH, 7);
853 /* procedure indent_in_hmode; l.21058 */
855 void indent_in_hmode (void)
861 mem[p + 1].cint = par_indent;
866 mem[q + 1].hh.v.RH = 2;
867 mem[q + 1].hh.v.LH = p;
871 mem[tail].hh.v.RH = p;
872 tail = mem[tail].hh.v.RH;
876 /* only called from tex8.c */
878 void head_for_vmode (void)
884 print_err("You can't use `");
886 print_string("' here except with leaders");
887 help2("To put a horizontal rule in an hbox or an alignment,",
888 "you should use \\leaders or \\hrulefill (see The TeXbook).");
894 cur_input.index_field = 4;
904 else line_break(widow_penalty);
909 /* only called form tex8.c */
911 void begin_insert_or_adjust (void)
916 scan_eight_bit_int();
919 print_err("You can't ");
922 help1("I'm changing to \\insert0; box 255 is special.");
927 save_stack[save_ptr + 0].cint = cur_val;
934 cur_list.aux_field.cint = ignore_depth;
937 void make_mark (void)
940 p = scan_toks(false, true);
944 mem[p + 1].cint = def_ref;
945 mem[tail].hh.v.RH = p;
949 void append_penalty (void)
953 mem[tail].hh.v.RH = new_penalty(cur_val);
954 tail = mem[tail].hh.v.RH;
960 /* only called from tex8.c */
962 void delete_last (void)
966 if ((mode == 1) && (tail == cur_list.head_field))
968 /* if ((cur_chr != 10)||(last_glue != 262143L)) */
969 if ((cur_chr != 10) || (last_glue != empty_flag)) {
971 help2("Sorry...I usually can't take things from the current page.",
972 "Try `I\\vskip-\\lastskip' instead.");
974 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
975 else if (cur_chr != 10)
976 help_line[0] = "Perhaps you can make the output routine do it.";
980 if (!(tail >= hi_mem_min))
981 if (mem[tail].hh.b0 == cur_chr)
986 if (!(q >= hi_mem_min))
987 if (mem[q].hh.b0 == 7)
990 register integer for_end;
992 for_end = mem[q].hh.b1;
995 while(m++ < for_end);
1001 } while (!(q == tail));
1003 flush_node_list(tail);
1008 /* only called from tex8.c */
1009 /* procedure unpackage; l.21256 */
1011 void unpackage (void)
1016 scan_eight_bit_int();
1017 p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
1018 if (p == 0)/* if p=null then return; l.21261 */
1020 if ((abs(mode)== 203) ||
1021 ((abs(mode) == 1) && (mem[p].hh.b0 != 1)) ||
1022 ((abs(mode) == 102) && (mem[p].hh.b0 != 0)))
1024 print_err("Incompatible list can't be unboxed");
1025 help3("Sorry, Pandora. (You sneaky devil.)",
1026 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1027 "And I can't open any boxes in math mode.");
1032 mem[tail].hh.v.RH = copy_node_list(mem[p + 5].hh.v.RH);
1034 mem[tail].hh.v.RH = mem[p + 5].hh.v.RH;
1035 eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0;
1038 while (mem[tail].hh.v.RH != 0)
1039 tail = mem[tail].hh.v.RH;
1042 void append_italic_correction (void)
1045 internal_font_number f;
1048 if ((tail >= hi_mem_min))
1050 else if (mem[tail].hh.b0 == 6)
1055 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);
1056 tail = mem[tail].hh.v.RH;
1058 mem[tail].hh.b1 = 1;
1062 void append_discretionary (void)
1066 mem[tail].hh.v.RH = new_disc();
1067 tail = mem[tail].hh.v.RH;
1070 c = hyphen_char[eqtb[(hash_size + 1834)].hh.v.RH];
1073 mem[tail + 1].hh.v.LH = new_character(eqtb[(hash_size + 1834)].hh.v.RH, c);
1076 save_stack[save_ptr - 1].cint = 0;
1081 space_factor = 1000;
1084 /* only called form tex8.c */
1086 void build_discretionary (void)
1095 if (!(p >= hi_mem_min))
1096 if (mem[p].hh.b0 > 2)
1097 if (mem[p].hh.b0 != 11)
1098 if (mem[p].hh.b0 != 6)
1100 print_err("Improper discretionary list");
1101 help1("Discretionary lists must contain only boxes and kerns.");
1104 print_nl("The following discretionary sublist has been deleted:");
1106 end_diagnostic(true);
1116 p = mem[head].hh.v.RH;
1118 switch (save_stack[save_ptr - 1].cint)
1121 mem[tail + 1].hh.v.LH = p;
1124 mem[tail + 1].hh.v.RH = p;
1128 if ((n > 0) && (abs(mode)== 203))
1130 print_err("Illegal math ");
1131 print_esc("discretionary");
1132 help2("Sorry: The third part of a discretionary break must be",
1133 "empty, in math formulas. I had to delete your third part.");
1137 } else mem[tail].hh.v.RH = p;
1138 /* if n <= max_quarterword then replace_count(tail) <- n; p.1120 */
1139 /* if (n <= 255) */ /* 94/Apr/4 ? */
1140 if (n <= max_quarterword) /* 96/Oct/12 ??? */
1141 mem[tail].hh.b1 = n;
1143 print_err("Discretionary list is too long");
1144 help2("Wow---I never thought anybody would tweak me here.",
1145 "You can't seriously need such a huge discretionary list?");
1155 incr(save_stack[save_ptr - 1].cint);
1160 space_factor = 1000;
1162 /* called only from tex8.c */
1164 void make_accent (void)
1168 internal_font_number f;
1169 scaled a, h, x, w, delta;
1172 f = eqtb[(hash_size + 1834)].hh.v.RH;
1173 p = new_character(f, cur_val);
1176 x = font_info[5 + param_base[f]].cint;
1177 s = font_info[1 + param_base[f]].cint / ((double) 65536.0);
1178 a = font_info[width_base[f]+ font_info[char_base[f]+ mem[p]
1179 .hh.b1].qqqq.b0].cint;
1182 f = eqtb[(hash_size + 1834)].hh.v.RH;
1183 if ((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68))
1184 q = new_character(f, cur_chr);
1185 else if (cur_cmd == 16)
1188 q = new_character(f, cur_val);
1193 t = font_info[1 + param_base[f]].cint / ((double) 65536.0);
1194 i = font_info[char_base[f]+ mem[q].hh.b1].qqqq;
1195 w = font_info[width_base[f]+ i.b0].cint;
1196 h = font_info[height_base[f]+(i.b1)/ 16].cint;
1200 mem[p + 4].cint = x - h;
1202 delta = round((w - a)/ ((double) 2.0)+ h * t - x * s);
1203 r = new_kern(delta);
1205 mem[tail].hh.v.RH = r;
1207 tail = new_kern(- (integer) a - delta);
1208 mem[tail].hh.b1 = 2;
1209 mem[p].hh.v.RH = tail;
1212 mem[tail].hh.v.RH = p;
1214 space_factor = 1000;
1218 void align_error (void)
1220 if (abs(align_state) > 2) {
1221 print_err("Misplaced ");
1222 print_cmd_chr(cur_cmd, cur_chr);
1223 if (cur_tok == 1062) {
1224 help6("I can't figure out why you would want to use a tab mark",
1225 "here. If you just want an ampersand, the remedy is",
1226 "simple: Just type `I\\&' now. But if some right brace",
1227 "up above has ended a previous alignment prematurely,",
1228 "you're probably due for more error messages, and you",
1229 "might try typing `S' now just to see what is salvageable.");
1231 help5("I can't figure out why you would want to use a tab mark",
1232 "or \\cr or \\span just now. If something like a right brace",
1233 "up above has ended a previous alignment prematurely,",
1234 "you're probably due for more error messages, and you",
1235 "might try typing `S' now just to see what is salvageable.");
1240 if (align_state < 0) {
1241 print_err("Missing { inserted");
1243 cur_tok = 379; /* belowdisplayshortskip ? */
1245 print_err("Missing } inserted");
1249 help3("I've put in what seems to be necessary to fix",
1250 "the current column of the current alignment.",
1251 "Try to go on, since this might almost work.");
1256 void noalign_error (void)
1258 print_err("Misplaced ");
1259 print_esc("noalign");
1260 help2("I expect to see \\noalign only after the \\cr of",
1261 "an alignment. Proceed, and I'll ignore this case.");
1264 /* only called from tex8.c */
1266 void omit_error (void)
1268 print_err("Misplaced ");
1270 help2("I expect to see \\omit only after tab marks or the \\cr of",
1271 "an alignment. Proceed, and I'll ignore this case.");
1277 if (cur_group == 6) {
1283 /* only called form tex8.c */
1285 void cs_error (void)
1287 print_err("Extra ");
1288 print_esc("endcsname");
1289 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1293 void push_math_(group_code c)
1297 cur_list.aux_field.cint = 0;
1301 void init_math (void)
1308 internal_font_number f;
1313 if ((cur_cmd == 3) && (mode > 0)) {
1316 w = -1073741823L; /* - (2^30 - 1) */
1318 line_break(display_widow_penalty);
1319 v = mem[just_box + 4].cint + 2 * font_info[6 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
1320 w = -1073741823L; /* - (2^30 - 1) */
1321 p = mem[just_box + 5].hh.v.RH;
1324 if ((p >= hi_mem_min)) {
1326 d = font_info[width_base[f]+ font_info[char_base[f]+ mem[p].hh.b1].qqqq.b0].cint;
1329 switch (mem[p].hh.b0)
1335 d = mem[p + 1].cint;
1341 mem[lig_trick]= mem[p + 1];
1342 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1349 d = mem[p + 1].cint;
1353 q = mem[p + 1].hh.v.LH;
1354 d = mem[q + 1].cint;
1355 if (mem[just_box + 5].hh.b0 == 1) {
1356 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b0) && (mem[q + 2].cint != 0))
1357 v = 1073741823L; /* - (2^30 - 1) */
1358 } else if (mem[just_box + 5].hh.b0 == 2) {
1359 if ((mem[just_box + 5].hh.b1 == mem[q].hh.b1) && (mem[q + 3].cint != 0))
1360 v = 1073741823L; /* - (2^30 - 1) */
1362 if (mem[p].hh.b1 >= 100)
1373 if (v < 1073741823L) /* - (2^30 - 1) */
1377 if (v < 1073741823L) /* - (2^30 - 1) */
1382 w = 1073741823L; /* - (2^30 - 1) */
1390 if (eqtb[(hash_size + 1312)].hh.v.RH == 0)
1391 if ((hang_indent != 0) &&
1392 (((hang_after >= 0) &&
1393 (prev_graf + 2 > hang_after)) ||(prev_graf + 1 < - (integer) hang_after))) {
1394 l = hsize - abs(hang_indent);
1395 if (hang_indent > 0)
1404 n = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH;
1405 if (prev_graf + 2 >= n)
1406 p = eqtb[(hash_size + 1312)].hh.v.RH + 2 * n;
1408 p = eqtb[(hash_size + 1312)].hh.v.RH + 2 *(prev_graf + 2);
1409 s = mem[p - 1].cint;
1414 eq_word_define((hash_size + 3207), -1);
1415 eq_word_define((hash_size + 3743), w);
1416 eq_word_define((hash_size + 3744), l);
1417 eq_word_define((hash_size + 3745), s);
1418 if (eqtb[(hash_size + 1316)].hh.v.RH != 0)/* everydisplay */
1419 begin_token_list(eqtb[(hash_size + 1316)].hh.v.RH, 9);
1420 if (nest_ptr == 1) {
1427 eq_word_define((hash_size + 3207), -1);
1428 if (eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1429 begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8);
1434 void start_eq_no (void)
1436 save_stack[save_ptr + 0].cint = cur_chr;
1440 eq_word_define((hash_size + 3207), -1);
1441 if (eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1442 begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8);
1446 void scan_math_(halfword p)
1452 } while(!((cur_cmd != 10) && (cur_cmd != 0)));
1460 c = eqtb[(hash_size + 2907) + cur_chr].hh.v.RH;
1463 cur_cs = cur_chr + 1;
1464 cur_cmd = eqtb[cur_cs].hh.b0;
1465 cur_chr = eqtb[cur_cs].hh.v.RH;
1483 scan_fifteen_bit_int();
1492 scan_twenty_seven_bit_int();
1494 /* c = cur_val >> 12; */
1501 save_stack[save_ptr + 0].cint = p;
1509 mem[p].hh.b1 = c % 256;
1510 /* mem[p].hh.b1 = c & 255; */ /* last 8 bits */
1511 if ((c >= 28672) && /* 32768 - 4096 ??? if (c>=var_code) and ... */
1512 ((cur_fam >= 0) && (cur_fam < 16)))
1513 mem[p].hh.b0 = cur_fam;
1515 mem[p].hh.b0 =(c / 256)% 16;
1516 /* else mem[p].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1519 void set_math_char_(integer c)
1523 cur_cs = cur_chr + 1; /* ??? */
1524 /* cur_cmd = eqtb[eqtbextra + cur_cs].hh.b0; */ /* was wrong ??? */
1525 cur_cmd = eqtb[cur_cs].hh.b0;
1526 /* cur_chr = eqtb[cur_cs].hh.v.RH; */ /* should have been eqtbextra ? */
1527 cur_chr = eqtb[cur_cs].hh.v.RH;
1532 mem[p + 1].hh.v.RH = 1;
1533 mem[p + 1].hh.b1 = c % 256;
1534 /* mem[p + 1].hh.b1 = c & 255; */ /* last 8 bits */
1535 mem[p + 1].hh.b0 =(c / 256)% 16;
1536 /* mem[p + 1].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1537 if (c >= 28672) /* 32768 - 4096 ? */
1539 if (((cur_fam >= 0) && (cur_fam < 16)))
1540 mem[p + 1].hh.b0 = cur_fam;
1543 mem[p].hh.b0 = 16 +(c / 4096);
1544 /* else mem[p].hh.b0 = 16 +(c >> 12); */
1545 mem[tail].hh.v.RH = p;
1550 void math_limit_switch (void)
1553 if (mem[tail].hh.b0 == 17) {
1554 mem[tail].hh.b1 = cur_chr;
1557 print_err("Limit controls must follow a math operator");
1558 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1562 void scan_delimiter_(halfword p, bool r)
1565 scan_twenty_seven_bit_int();
1569 } while (!((cur_cmd != 10) && (cur_cmd != 0)));
1574 cur_val = eqtb[(hash_size + 3474) + cur_chr].cint;
1577 scan_twenty_seven_bit_int();
1585 print_err("Missing delimiter (. inserted)");
1586 help6("I was expecting to see something like `(' or `\\{' or",
1587 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1588 "should probably delete the `{' by typing `1' now, so that",
1589 "braces don't get unbalanced. Otherwise just proceed.",
1590 "Acceptable delimiters are characters whose \\delcode is",
1591 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1595 /* attempt to speed up - bkph */ /* is compiler smart enough already ? */
1596 mem[p].qqqq.b0 =(cur_val / 1048576L) % 16; /* 2^20 */
1597 /* mem[p].qqqq.b0 =(cur_val >> 20)& 15; */
1598 mem[p].qqqq.b1 =(cur_val / 4096) % 256;
1599 /* mem[p].qqqq.b1 =(cur_val >> 12)& 255; */
1600 mem[p].qqqq.b2 =(cur_val / 256) % 16;
1601 /* mem[p].qqqq.b2 =(cur_val >> 8)& 15; */
1602 mem[p].qqqq.b3 = cur_val % 256;
1603 /* mem[p].qqqq.b3 = cur_val & 255; */
1606 void math_radical (void)
1609 mem[tail].hh.v.RH = get_node(5);
1610 tail = mem[tail].hh.v.RH;
1612 mem[tail].hh.b0 = 24;
1613 mem[tail].hh.b1 = 0;
1614 mem[tail + 1].hh = empty_field;
1615 mem[tail + 3].hh = empty_field;
1616 mem[tail + 2].hh = empty_field;
1617 scan_delimiter(tail + 4, true);
1618 scan_math(tail + 1);
1623 if (cur_cmd == 45) {
1624 print_err("Please use ");
1625 print_esc("mathaccent");
1626 print_string(" for accents in math mode");
1627 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1628 "(Accents are not the same in formulas as they are in text.)");
1632 mem[tail].hh.v.RH = get_node(5);
1633 tail = mem[tail].hh.v.RH;
1635 mem[tail].hh.b0 = 28;
1636 mem[tail].hh.b1 = 0;
1637 mem[tail + 1].hh = empty_field;
1638 mem[tail + 3].hh = empty_field;
1639 mem[tail + 2].hh = empty_field;
1640 mem[tail + 4].hh.v.RH = 1;
1641 scan_fifteen_bit_int();
1642 mem[tail + 4].hh.b1 = cur_val % 256;
1643 /* mem[tail + 4].hh.b1 = cur_val & 255; */
1644 if ((cur_val >= 28672) && /* 32768 - 4096 ? */
1647 mem[tail + 4].hh.b0 = cur_fam;
1649 mem[tail + 4].hh.b0 =(cur_val / 256) % 16;
1650 /* else mem[tail + 4].hh.b0 =(cur_val >> 8)& 15; */
1651 scan_math(tail + 1);
1654 void append_choices (void)
1657 mem[tail].hh.v.RH = new_choice();
1658 tail = mem[tail].hh.v.RH;
1661 save_stack[save_ptr - 1].cint = 0;
1666 halfword fin_mlist_(halfword p)
1668 register halfword Result;
1670 if (cur_list.aux_field.cint != 0) {
1671 mem[cur_list.aux_field.cint + 3].hh.v.RH = 3;
1672 mem[cur_list.aux_field.cint + 3].hh.v.LH = mem[head].hh.v.RH;
1674 q = cur_list.aux_field.cint;
1676 q = mem[cur_list.aux_field.cint + 2].hh.v.LH;
1677 if (mem[q].hh.b0 != 30) {
1679 return 0; // abort_flag set
1681 mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[q].hh.v.RH;
1682 mem[q].hh.v.RH = cur_list.aux_field.cint;
1683 mem[cur_list.aux_field.cint].hh.v.RH = p;
1686 mem[tail].hh.v.RH = p;
1687 q = mem[head].hh.v.RH;
1694 void build_choices (void)
1699 switch (save_stack[save_ptr - 1].cint)
1702 mem[tail + 1].hh.v.LH = p;
1705 mem[tail + 1].hh.v.RH = p;
1708 mem[tail + 2].hh.v.LH = p;
1712 mem[tail + 2].hh.v.RH = p;
1718 incr(save_stack[save_ptr - 1].cint);
1725 /* small_number t; */
1726 int t; /* 95/Jan/7 */
1731 if ((mem[tail].hh.b0 >= 16) && (mem[tail].hh.b0 < 30)) {
1732 p = tail + 2 + cur_cmd - 7;
1735 if ((p == 0)||(t != 0)) {
1737 mem[tail].hh.v.RH = new_noad();
1738 tail = mem[tail].hh.v.RH;
1740 p = tail + 2 + cur_cmd - 7;
1743 print_err("Double superscript");
1744 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1746 print_err("Double subscript");
1747 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1754 /* used to continue here with math_fraction etc in tex7.c */
1755 /*****************************************************************************/
1756 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1758 void package_(small_number c)
1765 save_ptr = save_ptr - 3;
1767 cur_box = hpack(mem[head].hh.v.RH, save_stack[save_ptr + 2].cint, save_stack[save_ptr + 1].cint);
1769 cur_box = vpackage(mem[head].hh.v.RH, save_stack[save_ptr + 2].cint, save_stack[save_ptr + 1].cint, d);
1772 p = mem[cur_box + 5].hh.v.RH;
1774 if (mem[p].hh.b0 <= 2)
1775 h = mem[p + 3].cint;
1776 mem[cur_box + 2].cint = mem[cur_box + 2].cint - h + mem[cur_box + 3].cint;
1777 mem[cur_box + 3].cint = h;
1781 box_end(save_stack[save_ptr + 0].cint);
1783 #pragma optimize ("", on) /* 96/Sep/12 */
1784 /****************************************************************************/