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)
28 {/* 10 30 31 22 80 90 */
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)
41 lab22: p = mem[contrib_head].hh.v.RH;
42 /* if(last_glue != 262143L) */
43 if(last_glue != empty_flag)
44 delete_glue_ref(last_glue);
47 if(mem[p].hh.b0 == 10)
49 last_glue = mem[p + 1].hh.v.LH;
50 incr(mem[last_glue].hh.v.RH);
54 /* last_glue = 262143L; */
55 last_glue = empty_flag;
56 if(mem[p].hh.b0 == 12)
57 last_penalty = mem[p + 1].cint;
58 else if(mem[p].hh.b0 == 11)
59 last_kern = mem[p + 1].cint;
68 if(page_contents == 0)
72 q = new_skip_param(9);
73 if(mem[temp_ptr + 1].cint > mem[p + 3].cint)
74 mem[temp_ptr + 1].cint = mem[temp_ptr + 1].cint - mem[p + 3].cint;
76 mem[temp_ptr + 1].cint = 0;
78 mem[contrib_head].hh.v.RH = q;
82 page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[p + 3].cint;
83 page_so_far[7]= mem[p + 2].cint;
93 else if((mem[page_tail].hh.b0 < 9))
101 else if(mem[p].hh.v.RH == 0)
103 else if(mem[mem[p].hh.v.RH].hh.b0 == 10)
109 if(page_contents < 2)
112 pi = mem[p + 1].cint;
119 if(page_contents == 0)
120 freeze_page_specs(1);
123 while(n >= mem[mem[r].hh.v.RH].hh.b1)
126 if(mem[r].hh.b1 != n)
129 mem[q].hh.v.RH = mem[r].hh.v.RH;
135 if(eqtb[(hash_size + 1578) + n].hh.v.RH == 0)
138 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;
139 mem[r + 2].hh.v.LH = 0;
140 q = eqtb[(hash_size + 800) + n].hh.v.RH;
141 if(eqtb[(hash_size + 3218) + n].cint == 1000)
144 h = x_over_n(mem[r + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
145 page_so_far[0]= page_so_far[0]- h - mem[q + 1].cint;
146 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]+ mem[q + 2].cint;
147 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
148 if((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
150 print_err("Infinite glue shrinkage inserted from");
153 help3("The correction glue for page breaking with insertions",
154 "must have finite shrinkability. But you may proceed,",
155 "since the offensive shrinkability has been made finite.");
159 if(mem[r].hh.b0 == 1)
160 insert_penalties = insert_penalties + mem[p + 1].cint;
162 mem[r + 2].hh.v.RH = p;
163 delta = page_so_far[0]- page_so_far[1]- page_so_far[7] + page_so_far[6];
164 if(eqtb[(hash_size + 3218) + n].cint == 1000)
167 h = x_over_n(mem[p + 3].cint, 1000)* eqtb[(hash_size + 3218) + n].cint;
168 if(((h <= 0)||(h <= delta)) &&(mem[p + 3].cint + mem[r + 3].cint <= eqtb[(hash_size + 3751) + n].cint))
170 page_so_far[0]= page_so_far[0]- h;
171 mem[r + 3].cint = mem[r + 3].cint + mem[p + 3].cint;
174 if(eqtb[(hash_size + 3218) + n].cint <= 0)
175 w = 1073741823L; /* 2^30 - 1 */
177 w = page_so_far[0]- page_so_far[1]- page_so_far[7];
178 if(eqtb[(hash_size + 3218) + n].cint != 1000)
179 w = x_over_n(w, eqtb[(hash_size + 3218) + n].cint)* 1000;
181 if(w > eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint)
182 w = eqtb[(hash_size + 3751) + n].cint - mem[r + 3].cint;
183 q = vert_break(mem[p + 4].hh.v.LH, w, mem[p + 2].cint);
184 mem[r + 3].cint = mem[r + 3].cint + best_height_plus_depth;
187 if(eqtb[(hash_size + 3196)].cint > 0)
190 print_nl("% split"); /* */
194 print_char(44); /*, */
195 print_scaled(best_height_plus_depth);
197 if(q == 0) /* if q=null l.19614 */
199 else if(mem[q].hh.b0 == 12)
200 print_int(mem[q + 1].cint);
201 else print_char(48); /* 0 */
202 end_diagnostic(false);
205 if(eqtb[(hash_size + 3218) + n].cint != 1000)
206 best_height_plus_depth = x_over_n(best_height_plus_depth, 1000) * eqtb[(hash_size + 3218) + n].cint;
207 page_so_far[0]= page_so_far[0]- best_height_plus_depth;
209 mem[r + 1].hh.v.RH = q;
210 mem[r + 1].hh.v.LH = p;
212 insert_penalties = insert_penalties - 10000;
213 else if(mem[q].hh.b0 == 12)
214 insert_penalties = insert_penalties + mem[q + 1].cint;
222 confusion(987); /* page */
223 return; // abort_flag set
227 if(pi < 10000)/* pi may be used ... */
229 if(page_so_far[1]< page_so_far[0])
230 if((page_so_far[3]!= 0)||(page_so_far[4]!= 0)||(page_so_far[5]!= 0))
233 b = badness(page_so_far[0]- page_so_far[1], page_so_far[2]);
234 else if(page_so_far[1]- page_so_far[0]> page_so_far[6])
235 b = 1073741823L; /* 2^30 - 1 */
237 b = badness(page_so_far[1]- page_so_far[0], page_so_far[6]);
238 if(b < 1073741823L) /* 2^30 - 1 */
242 c = b + pi + insert_penalties;
247 if (insert_penalties >= 10000)
248 c = 1073741823L; /* 2^30 - 1 */
251 if(eqtb[(hash_size + 3196)].cint > 0)
254 print_nl("%"); /* % */
258 print_scaled(page_so_far[0]);
260 if(b == 1073741823L) /* 2^30 - 1 */
261 print_char(42); /* * */
267 if(c == 1073741823L) /* 2^30 - 1 */
268 print_char(42); /* * */
270 if(c <= least_page_cost)
271 print_char(35); /* # */
272 end_diagnostic(false);
275 if(c <= least_page_cost)
278 best_size = page_so_far[0];
280 r = mem[mem_top].hh.v.RH;
283 mem[r + 2].hh.v.LH = mem[r + 2].hh.v.RH;
287 if((c == 1073741823L)||(pi <= -10000)) /* 2^30 - 1 */
290 if(output_active)return;
294 if((mem[p].hh.b0 < 10)||(mem[p].hh.b0 > 11))
296 lab90: if(mem[p].hh.b0 == 11)
300 q = mem[p + 1].hh.v.LH;
301 page_so_far[2 + mem[q].hh.b0]= page_so_far[2 + mem[q].hh.b0]
303 page_so_far[6]= page_so_far[6]+ mem[q + 3].cint;
304 if((mem[q].hh.b1 != 0)&&(mem[q + 3].cint != 0))
306 print_err("Infinite glue shrinkage found on current page");
307 help4("The page about to be output contains some infinitely",
308 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
309 "Such glue doesn't belong there; but you can safely proceed,",
310 "since the offensive shrinkability has been made finite.");
315 mem[p + 1].hh.v.LH = r;
319 page_so_far[1]= page_so_far[1]+ page_so_far[7]+ mem[q + 1].cint
322 lab80: if(page_so_far[7]> page_max_depth)
324 page_so_far[1]= page_so_far[1]+ page_so_far[7]- page_max_depth;
325 page_so_far[7]= page_max_depth;
327 mem[page_tail].hh.v.RH = p;
329 mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
332 lab31: mem[contrib_head].hh.v.RH = mem[p].hh.v.RH;
336 } while(!(mem[contrib_head].hh.v.RH == 0));
339 else nest[0].tail_field = contrib_head;
342 void app_space (void)
345 if((space_factor >= 2000) && (eqtb[(hash_size + 795)].hh.v.RH != 0))
346 q = new_param_glue(13);
348 if(eqtb[(hash_size + 794)].hh.v.RH != 0)
349 main_p = eqtb[(hash_size + 794)].hh.v.RH;
351 main_p = font_glue[eqtb[(hash_size + 1834)].hh.v.RH];
354 main_p = new_spec(0);
355 main_k = param_base[eqtb[(hash_size + 1834)].hh.v.RH]+ 2;
356 mem[main_p + 1].cint = font_info[main_k].cint;
357 mem[main_p + 2].cint = font_info[main_k + 1].cint;
358 mem[main_p + 3].cint = font_info[main_k + 2].cint;
359 font_glue[eqtb[(hash_size + 1834)].hh.v.RH]= main_p;
362 main_p = new_spec(main_p);
363 if(space_factor >= 2000)
364 mem[main_p + 1].cint = mem[main_p + 1].cint + font_info[7 + param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
365 mem[main_p + 2].cint = xn_over_d(mem[main_p + 2].cint, cur_list.aux_field.hh.v.LH, 1000);
366 mem[main_p + 3].cint = xn_over_d(mem[main_p + 3].cint, 1000, space_factor);
367 q = new_glue(main_p);
368 mem[main_p].hh.v.RH = 0;
370 mem[tail].hh.v.RH = q;
373 /* called from tex8.c only */
375 void insert_dollar_sign (void)
379 print_err("Proceed; I'll discard its present contents.");
380 help2("I've inserted a begin-math/end-math symbol since I think",
381 "you left one out. Proceed, with fingers crossed.");
387 print_err("You can't use `");
388 print_cmd_chr(cur_cmd, cur_chr);
389 print_string("' in ");
393 void report_illegal_case (void)
396 help4("Sorry, but I'm not programmed to handle this case;",
397 "I'll just pretend that you didn't ask for it.",
398 "If you're in the wrong mode, you might be able to",
399 "return to the right one by typing `I}' or `I$' or `I\\par'.");
403 bool privileged (void)
405 register bool Result;
406 if(mode > 0)Result = true;
408 report_illegal_case ();
414 bool its_all_over (void)
416 register bool Result;
419 if((page_head == page_tail) && (head == cur_list.tail_field) && (dead_cycles == 0))
426 mem[tail].hh.v.RH = new_null_box ();
427 tail = mem[tail].hh.v.RH;
429 mem[tail + 1].cint = eqtb[(hash_size + 3733)].cint;
431 mem[tail].hh.v.RH = new_glue(8);
432 tail = mem[tail].hh.v.RH;
435 mem[tail].hh.v.RH = new_penalty(-1073741824L);
437 tail = mem[tail].hh.v.RH;
445 void append_glue (void)
470 mem[tail].hh.v.RH = new_glue(cur_val);
471 tail = mem[tail].hh.v.RH;
475 decr(mem[cur_val].hh.v.RH);
477 mem[tail].hh.b1 = 99;
481 void append_kern (void)
485 scan_dimen(s == 99, false, false);
487 mem[tail].hh.v.RH = new_kern(cur_val);
488 tail = mem[tail].hh.v.RH;
499 print_cmd_chr(cur_cmd, cur_chr);
500 help1("Things are pretty mixed up, but I think the worst is over.");
507 mem[temp_head].hh.v.RH = p;
508 print_err("Missing ");
512 /* mem[p].hh.v.LH = (hash_size + 4611); */
513 /* mem[p].hh.v.LH = (hash_size + 4095 + 516); */
514 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 516); /* 96/Jan/10 */
515 print_esc("endgroup");
520 mem[p].hh.v.LH = 804;
526 /* mem[p].hh.v.LH = (hash_size + 4612); */
527 /* mem[p].hh.v.LH = (hash_size + 4095 + 517); */
528 mem[p].hh.v.LH = (hash_size + hash_extra + 4095 + 517); /* 96/Jan/10 */
529 mem[p].hh.v.RH = get_avail ();
531 mem[p].hh.v.LH = 3118;
537 mem[p].hh.v.LH = 637;
538 print_char(125); /* } */
542 print_string(" inserted");
543 begin_token_list(mem[temp_head].hh.v.RH, 4);
544 help5("I've inserted something that you may have forgotten.",
545 "(See the <inserted text> above.)",
546 "With luck, this will get me unwedged. But if you",
547 "really didn't forget anything, try typing `2' now; then",
548 "my insertion and my current dilemma will both disappear.");
552 /* only called from tex8.c */
554 void extra_right_brace (void)
556 print_err("Extra }, or forgotten");
559 print_esc("endgroup");
562 print_char(36); /* $ */
568 help5("I've deleted a group-closing symbol because it seems to be",
569 "spurious, as in `$x}$'. But perhaps the } is legitimate and",
570 "you forgot something else, as in `\\hbox{$x}'. In such cases",
571 "the way to recover is to insert both the forgotten and the",
572 "deleted material, e.g., by typing `I$}'.");
577 void normal_paragraph (void)
579 /* if looseness<>0 then eq_word_define(int_base+looseness_code,0); */
580 if(eqtb[(hash_size + 3182)].cint != 0)
581 eq_word_define((hash_size + 3182), 0);
582 if(eqtb[(hash_size + 3747)].cint != 0)
583 eq_word_define((hash_size + 3747), 0);
584 if(eqtb[(hash_size + 3204)].cint != 1)
585 eq_word_define((hash_size + 3204), 1);
586 if(eqtb[(hash_size + 1312)].hh.v.RH != 0)
587 eq_define((hash_size + 1312), 118, 0);
590 void box_end_(integer boxcontext)
593 /* if box_context<box_flag then ... 1073741824 2^30 */
594 if(boxcontext < 1073741824L)
598 mem[cur_box + 4].cint = boxcontext;
601 append_to_vlist(cur_box);
604 if(adjust_head != adjust_tail)
606 mem[tail].hh.v.RH = mem[adjust_head].hh
622 mem[p + 1].hh.v.RH = 2;
623 mem[p + 1].hh.v.LH = cur_box;
626 mem[tail].hh.v.RH = cur_box;
632 /* following fixed 1994/Apr/5 1 day anno Yang --- moby sigh ... */
634 /* else if box_context<box_flag+512 then ... */
635 /* else if(boxcontext < 1073742336L)*/ /* 2^30 + 512 */
636 else if(boxcontext < (1073741824L + 512)) /* 2^30 + 512 */
637 /* else if box_context<box_flag+256 then ... */
638 /* if(boxcontext < 1073742080L)*/ /* 2^30 + 256 */
639 if(boxcontext < (1073741824L + 256))/* 2^30 + 256 */
640 /* eq_define(box_base-box_flag+box_context,box_ref,cur_box) */
641 /* eq_define((hash_size - 1073740246L) + boxcontext, 119, cur_box); */
642 eq_define((hash_size + 1578 - 1073741824L) + boxcontext, 119, cur_box);
643 /* else geq_define(box_base-box_flag-256+box_context,box_ref,cur_box) */
644 /* else geq_define((hash_size - 1073740502L) + boxcontext, 119, cur_box); */
645 else geq_define((hash_size + 1322 - 1073741824L) + boxcontext, 119, cur_box);
646 else if(cur_box != 0)
647 /* if(boxcontext > 1073742336L)*/ /* 2^30 + 512 */
648 if(boxcontext > (1073741824L + 512)) /* 2^30 + 512 */
652 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
653 /* 424 in tex82.bug */
654 if(((cur_cmd == 26) && (abs(mode)!= 1)) ||
655 ((cur_cmd == 27) && (abs(mode)== 1)))
657 /* begin append_glue; subtype(tail):=box_context-(leader_flag-a_leaders); */
659 /* -(2^30 + 513 - 100) */
660 mem[tail].hh.b1 = boxcontext -(1073742237L);
661 mem[tail + 1].hh.v.RH = cur_box;
664 print_err("Leaders not followed by proper glue");
665 help3("You should say `\\leaders <box or rule><hskip or vskip>'.",
666 "I found the <box or rule>, but there's no suitable",
667 "<hskip or vskip>, so I'm ignoring these leaders.");
669 flush_node_list(cur_box);
672 else ship_out(cur_box);
674 /* called only from tex8.c */
676 void begin_box_(integer boxcontext)
685 scan_eight_bit_int ();
686 cur_box = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
687 eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0;
692 scan_eight_bit_int ();
693 cur_box = copy_node_list(eqtb[(hash_size + 1578) + cur_val].hh.v.RH);
702 help1("Sorry; this \\lastbox will be void.");
705 else if((mode == 1)&&(head == cur_list
709 help2("Sorry...I usually can't take things from the current page.",
710 "This \\lastbox will therefore be void.");
714 if(!(tail >= hi_mem_min))
715 if((mem[tail].hh.b0 == 0)||(mem[cur_list
716 .tail_field].hh.b0 == 1))
721 if(!(q >= hi_mem_min))
722 if(mem[q].hh.b0 == 7)
725 register integer for_end;
727 for_end = mem[q].hh.b1;
730 while(m++ < for_end);
736 } while(!(q == tail));
738 mem[cur_box + 4].cint = 0;
748 scan_eight_bit_int ();
750 if(! scan_keyword(836)) /* to */
752 print_err("Missing `to' inserted");
753 help2("I'm working on `\\vsplit<box number> to <dimen>';",
754 "will look for the <dimen> next.");
757 scan_dimen(false, false, false);
758 cur_box = vsplit(n, cur_val);
764 save_stack[save_ptr + 0].cint = boxcontext;
766 if((boxcontext < 1073741824L)&& /* 2^30 */
770 else scan_spec(2, true);
783 mode = - (integer) k;
786 cur_list.aux_field.cint = ignore_depth;
787 if(eqtb[(hash_size + 1318)].hh.v.RH != 0)/* everyhbox */
788 begin_token_list(eqtb[(hash_size + 1318)].hh.v.RH, 11);
793 if(eqtb[(hash_size + 1317)].hh.v.RH != 0)/* everyhbox */
794 begin_token_list(eqtb[(hash_size + 1317)].hh.v.RH, 10);
803 void scan_box_(integer boxcontext)
807 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
809 begin_box(boxcontext);
811 else if((boxcontext >= 1073742337L)&& /* (2^30 + 512 + 1) */
812 ((cur_cmd == 36)||(cur_cmd == 35)))
814 cur_box = scan_rule_spec ();
818 print_err("A <box> was supposed to be here");
819 help3("I was expecting to see \\hbox or \\vbox or \\copy or \\box or",
820 "something like that. So you might find something missing in",
821 "your output. But keep trying; you can fix this later.");
825 /****************************************************************************/
826 void package_ (small_number);
827 /****************************************************************************/
829 small_number norm_min_ (integer h)
831 /* small_number Result; */
832 int Result; /* 95/Jan/7 */
841 void new_graf_(bool indented)
844 if((mode == 1)||(head != cur_list
847 mem[tail].hh.v.RH = new_param_glue(2);
848 tail = mem[tail].hh.v.RH;
850 /* used to be followingin 3.141 */
851 /* cur_list .lhmfield = norm_min(eqtb[(hash_size + 3214)].cint); */
852 /* cur_list .rhmfield = norm_min(eqtb[(hash_size + 3215)].cint); */
856 /* changes here since 3.141 */
857 if(eqtb[(hash_size + 3213)].cint <= 0)
859 else if(eqtb[(hash_size + 3213)].cint > 255)
861 else cur_lang = eqtb[(hash_size + 3213)].cint;
863 prev_graf =(norm_min(eqtb[(hash_size + 3214)].cint)* 64 +
864 norm_min(eqtb[(hash_size + 3215)].cint)) * 65536L + cur_lang;
865 /* eqtb ??? hash_size ? hash_size + hash_extra ? norm_min etc */
866 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
869 tail = new_null_box ();
870 mem[head].hh.v.RH = tail;
871 mem[tail + 1].cint = eqtb[(hash_size + 3730)].cint;
873 if(eqtb[(hash_size + 1314)].hh.v.RH != 0) /* everypar */
874 begin_token_list(eqtb[(hash_size + 1314)].hh.v.RH, 7);
879 /* procedure indent_in_hmode; l.21058 */
881 void indent_in_hmode (void)
887 mem[p + 1].cint = eqtb[(hash_size + 3730)].cint;
893 mem[q + 1].hh.v.RH = 2;
894 mem[q + 1].hh.v.LH = p;
898 mem[tail].hh.v.RH = p;
899 tail = mem[tail].hh.v.RH;
903 /* only called from tex8.c */
905 void head_for_vmode (void)
912 print_err("You can't use `");
914 print_string("' here except with leaders");
915 help2("To put a horizontal rule in an hbox or an alignment,",
916 "you should use \\leaders or \\hrulefill (see The TeXbook).");
924 cur_input.index_field = 4;
934 else line_break(eqtb[(hash_size + 3169)].cint);
939 /* only called form tex8.c */
941 void begin_insert_or_adjust (void)
947 scan_eight_bit_int ();
950 print_err("You can't ");
953 help1("I'm changing to \\insert0; box 255 is special.");
958 save_stack[save_ptr + 0].cint = cur_val;
965 cur_list.aux_field.cint = ignore_depth;
968 void make_mark (void)
971 p = scan_toks(false, true);
975 mem[p + 1].cint = def_ref;
976 mem[tail].hh.v.RH = p;
980 void append_penalty (void)
984 mem[tail].hh.v.RH = new_penalty(cur_val);
985 tail = mem[tail].hh.v.RH;
991 /* only called from tex8.c */
993 void delete_last (void)
997 if((mode == 1)&&(tail == cur_list
1000 /* if((cur_chr != 10)||(last_glue != 262143L)) */
1001 if((cur_chr != 10)||(last_glue != empty_flag))
1004 help2("Sorry...I usually can't take things from the current page.",
1005 "Try `I\\vskip-\\lastskip' instead.");
1007 help_line[0] = "Try `I\\kern-\\last_kern' instead.";
1008 else if(cur_chr != 10)
1009 help_line[0] = "Perhaps you can make the output routine do it.";
1015 if(!(tail >= hi_mem_min))
1016 if(mem[tail].hh.b0 == cur_chr)
1021 if(!(q >= hi_mem_min))
1022 if(mem[q].hh.b0 == 7)
1025 register integer for_end;
1027 for_end = mem[q].hh.b1;
1030 while(m++ < for_end);
1036 } while(!(q == tail));
1038 flush_node_list(tail);
1043 /* only called from tex8.c */
1044 /* procedure unpackage; l.21256 */
1046 void unpackage (void)
1051 scan_eight_bit_int ();
1052 p = eqtb[(hash_size + 1578) + cur_val].hh.v.RH;
1053 if(p == 0)/* if p=null then return; l.21261 */
1055 if((abs(mode)== 203)||((abs(mode)
1056 == 1)&&(mem[p].hh.b0 != 1)) ||((abs(mode)==
1057 102)&&(mem[p].hh.b0 != 0)))
1059 print_err("Incompatible list can't be unboxed");
1060 help3("Sorry, Pandora. (You sneaky devil.)",
1061 "I refuse to unbox an \\hbox in vertical mode or vice versa.",
1062 "And I can't open any boxes in math mode.");
1067 mem[tail].hh.v.RH = copy_node_list(mem[p + 5].hh
1071 mem[tail].hh.v.RH = mem[p + 5].hh.v.RH;
1072 eqtb[(hash_size + 1578) + cur_val].hh.v.RH = 0;
1075 while(mem[tail].hh.v.RH != 0)tail = mem
1079 void append_italic_correction (void)
1082 internal_font_number f;
1085 if((tail >= hi_mem_min))
1087 else if(mem[tail].hh.b0 == 6)
1092 mem[tail].hh.v.RH = new_kern(font_info[italic_base[
1093 f]+(font_info[char_base[f]+ mem[p].hh.b1].qqqq.b2)/ 4]
1095 tail = mem[tail].hh.v.RH;
1097 mem[tail].hh.b1 = 1;
1101 void append_discretionary (void)
1105 mem[tail].hh.v.RH = new_disc ();
1106 tail = mem[tail].hh.v.RH;
1110 c = hyphen_char[eqtb[(hash_size + 1834)].hh.v.RH];
1113 mem[tail + 1].hh.v.LH = new_character(eqtb[(hash_size + 1834)]
1119 save_stack[save_ptr - 1].cint = 0;
1124 space_factor = 1000;
1127 /* only called form tex8.c */
1129 void build_discretionary (void)
1139 if(!(p >= hi_mem_min))
1140 if(mem[p].hh.b0 > 2)
1141 if(mem[p].hh.b0 != 11)
1142 if(mem[p].hh.b0 != 6)
1144 print_err("Improper discretionary list");
1145 help1("Discretionary lists must contain only boxes and kerns.");
1147 begin_diagnostic ();
1148 print_nl("The following discretionary sublist has been deleted:"); /* */
1150 end_diagnostic(true);
1160 p = mem[head].hh.v.RH;
1162 switch(save_stack[save_ptr - 1].cint)
1164 mem[tail + 1].hh.v.LH = p;
1167 mem[tail + 1].hh.v.RH = p;
1171 if((n > 0)&&(abs(mode)== 203))
1173 print_err("Illegal math ");
1174 print_esc("discretionary");
1175 help2("Sorry: The third part of a discretionary break must be",
1176 "empty, in math formulas. I had to delete your third part.");
1181 else mem[tail].hh.v.RH = p;
1182 /* if n <= max_quarterword then replace_count(tail) <- n; p.1120 */
1183 /* if(n <= 255) */ /* 94/Apr/4 ? */
1184 if(n <= max_quarterword) /* 96/Oct/12 ??? */
1185 mem[tail].hh.b1 = n;
1187 print_err("Discretionary list is too long");
1188 help2("Wow---I never thought anybody would tweak me here.",
1189 "You can't seriously need such a huge discretionary list?");
1199 incr(save_stack[save_ptr - 1].cint);
1204 space_factor = 1000;
1206 /* called only from tex8.c */
1208 void make_accent (void)
1212 internal_font_number f;
1213 scaled a, h, x, w, delta;
1216 f = eqtb[(hash_size + 1834)].hh.v.RH;
1217 p = new_character(f, cur_val);
1220 x = font_info[5 + param_base[f]].cint;
1221 s = font_info[1 + param_base[f]].cint / ((double) 65536.0);
1222 a = font_info[width_base[f]+ font_info[char_base[f]+ mem[p]
1223 .hh.b1].qqqq.b0].cint;
1226 f = eqtb[(hash_size + 1834)].hh.v.RH;
1227 if((cur_cmd == 11)||(cur_cmd == 12)||(cur_cmd == 68))
1228 q = new_character(f, cur_chr);
1229 else if(cur_cmd == 16)
1232 q = new_character(f, cur_val);
1237 t = font_info[1 + param_base[f]].cint / ((double) 65536.0);
1238 i = font_info[char_base[f]+ mem[q].hh.b1].qqqq;
1239 w = font_info[width_base[f]+ i.b0].cint;
1240 h = font_info[height_base[f]+(i.b1)/ 16].cint;
1244 mem[p + 4].cint = x - h;
1246 delta = round((w - a)/ ((double) 2.0)+ h * t - x * s);
1247 r = new_kern(delta);
1249 mem[tail].hh.v.RH = r;
1251 tail = new_kern(- (integer) a - delta);
1252 mem[tail].hh.b1 = 2;
1253 mem[p].hh.v.RH = tail;
1256 mem[tail].hh.v.RH = p;
1258 space_factor = 1000;
1262 void align_error (void)
1264 if(abs(align_state)> 2){
1265 print_err("Misplaced ");
1266 print_cmd_chr(cur_cmd, cur_chr);
1267 if(cur_tok == 1062) {
1268 help6("I can't figure out why you would want to use a tab mark",
1269 "here. If you just want an ampersand, the remedy is",
1270 "simple: Just type `I\\&' now. But if some right brace",
1271 "up above has ended a previous alignment prematurely,",
1272 "you're probably due for more error messages, and you",
1273 "might try typing `S' now just to see what is salvageable.");
1276 help5("I can't figure out why you would want to use a tab mark",
1277 "or \\cr or \\span just now. If something like a right brace",
1278 "up above has ended a previous alignment prematurely,",
1279 "you're probably due for more error messages, and you",
1280 "might try typing `S' now just to see what is salvageable.");
1286 if(align_state < 0) {
1287 print_err("Missing { inserted");
1289 cur_tok = 379; /* belowdisplayshortskip ? */
1292 print_err("Missing } inserted");
1296 help3("I've put in what seems to be necessary to fix",
1297 "the current column of the current alignment.",
1298 "Try to go on, since this might almost work.");
1303 void noalign_error (void)
1305 print_err("Misplaced ");
1306 print_esc("noalign");
1307 help2("I expect to see \\noalign only after the \\cr of",
1308 "an alignment. Proceed, and I'll ignore this case.");
1311 /* only called from tex8.c */
1313 void omit_error (void)
1315 print_err("Misplaced ");
1317 help2("I expect to see \\omit only after tab marks or the \\cr of",
1318 "an alignment. Proceed, and I'll ignore this case.");
1324 if(cur_group == 6) {
1326 if(fin_col ())fin_row ();
1330 /* only called form tex8.c */
1332 void cs_error (void)
1334 print_err("Extra ");
1335 print_esc("endcsname");
1336 help1("I'm ignoring this, since I wasn't doing a \\csname.");
1340 void push_math_(group_code c)
1344 cur_list.aux_field.cint = 0;
1348 void init_math (void)
1355 internal_font_number f;
1360 if((cur_cmd == 3)&&(mode > 0))
1365 w = -1073741823L; /* - (2^30 - 1) */
1369 line_break(eqtb[(hash_size + 3170)].cint);
1370 v = mem[just_box + 4].cint + 2 * font_info[6 +
1371 param_base[eqtb[(hash_size + 1834)].hh.v.RH]].cint;
1372 w = -1073741823L; /* - (2^30 - 1) */
1373 p = mem[just_box + 5].hh.v.RH;
1376 lab21: if((p >= hi_mem_min))
1379 d = font_info[width_base[f]+ font_info[char_base[f]+ mem[p
1380 ].hh.b1].qqqq.b0].cint;
1383 switch(mem[p].hh.b0)
1388 d = mem[p + 1].cint;
1394 mem[lig_trick]= mem[p + 1];
1395 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1402 d = mem[p + 1].cint;
1406 q = mem[p + 1].hh.v.LH;
1407 d = mem[q + 1].cint;
1408 if(mem[just_box + 5].hh.b0 == 1)
1410 if((mem[just_box + 5].hh.b1 == mem[q].hh.b0)&&(mem
1412 v = 1073741823L; /* - (2^30 - 1) */
1414 else if(mem[just_box + 5].hh.b0 == 2)
1416 if((mem[just_box + 5].hh.b1 == mem[q].hh.b1)&&(mem
1418 v = 1073741823L; /* - (2^30 - 1) */
1420 if(mem[p].hh.b1 >= 100)
1431 if(v < 1073741823L) /* - (2^30 - 1) */
1434 lab40: if(v < 1073741823L) /* - (2^30 - 1) */
1441 w = 1073741823L; /* - (2^30 - 1) */
1444 lab45: p = mem[p].hh.v.RH;
1448 if(eqtb[(hash_size + 1312)].hh.v.RH == 0)
1449 if((eqtb[(hash_size + 3747)].cint != 0)&&(((eqtb[(hash_size + 3204)].cint >= 0)&&
1450 (prev_graf + 2 > eqtb[(hash_size + 3204)].cint)) ||(prev_graf +
1451 1 < - (integer) eqtb[(hash_size + 3204)].cint)))
1453 l = eqtb[(hash_size + 3733)].cint - abs(eqtb[(hash_size + 3747)].cint);
1454 if(eqtb[(hash_size + 3747)].cint > 0)
1455 s = eqtb[(hash_size + 3747)].cint;
1460 l = eqtb[(hash_size + 3733)].cint;
1465 n = mem[eqtb[(hash_size + 1312)].hh.v.RH].hh.v.LH;
1466 if(prev_graf + 2 >= n)
1467 p = eqtb[(hash_size + 1312)].hh.v.RH + 2 * n;
1468 else p = eqtb[(hash_size + 1312)].hh.v.RH + 2 *(prev_graf + 2);
1469 s = mem[p - 1].cint;
1474 eq_word_define((hash_size + 3207), -1);
1475 eq_word_define((hash_size + 3743), w);
1476 eq_word_define((hash_size + 3744), l);
1477 eq_word_define((hash_size + 3745), s);
1478 if(eqtb[(hash_size + 1316)].hh.v.RH != 0)/* everydisplay */
1479 begin_token_list(eqtb[(hash_size + 1316)].hh.v.RH, 9);
1489 eq_word_define((hash_size + 3207), -1);
1490 if(eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1491 begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8);
1496 void start_eq_no (void)
1498 save_stack[save_ptr + 0].cint = cur_chr;
1502 eq_word_define((hash_size + 3207), -1);
1503 if(eqtb[(hash_size + 1315)].hh.v.RH != 0)/* everymath */
1504 begin_token_list(eqtb[(hash_size + 1315)].hh.v.RH, 8);
1508 void scan_math_(halfword p)
1513 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1514 lab21: switch(cur_cmd)
1519 c = eqtb[(hash_size + 2907) + cur_chr].hh.v.RH;
1523 cur_cs = cur_chr + 1;
1524 cur_cmd = eqtb[cur_cs].hh.b0;
1525 cur_chr = eqtb[cur_cs].hh.v.RH;
1543 scan_fifteen_bit_int ();
1552 scan_twenty_seven_bit_int ();
1554 /* c = cur_val >> 12; */
1561 save_stack[save_ptr + 0].cint = p;
1569 mem[p].hh.b1 = c % 256;
1570 /* mem[p].hh.b1 = c & 255; */ /* last 8 bits */
1571 if((c >= 28672)&& /* 32768 - 4096 ??? if (c>=var_code) and ... */
1572 ((eqtb[(hash_size + 3207)].cint >= 0)&&
1573 (eqtb[(hash_size + 3207)].cint < 16)))
1574 mem[p].hh.b0 = eqtb[(hash_size + 3207)].cint;
1575 else mem[p].hh.b0 =(c / 256)% 16;
1576 /* else mem[p].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1579 void set_math_char_(integer c)
1584 cur_cs = cur_chr + 1; /* ??? */
1585 /* cur_cmd = eqtb[eqtbextra + cur_cs].hh.b0; */ /* was wrong ??? */
1586 cur_cmd = eqtb[cur_cs].hh.b0;
1587 /* cur_chr = eqtb[cur_cs].hh.v.RH; */ /* should have been eqtbextra ? */
1588 cur_chr = eqtb[cur_cs].hh.v.RH;
1595 mem[p + 1].hh.v.RH = 1;
1596 mem[p + 1].hh.b1 = c % 256;
1597 /* mem[p + 1].hh.b1 = c & 255; */ /* last 8 bits */
1598 mem[p + 1].hh.b0 =(c / 256)% 16;
1599 /* mem[p + 1].hh.b0 =(c >> 8)& 15; */ /* 4 bits to left */
1600 if(c >= 28672) /* 32768 - 4096 ? */
1602 if(((eqtb[(hash_size + 3207)].cint >= 0)&&(eqtb[(hash_size + 3207)].cint < 16))
1604 mem[p + 1].hh.b0 = eqtb[(hash_size + 3207)].cint;
1607 else mem[p].hh.b0 = 16 +(c / 4096);
1608 /* else mem[p].hh.b0 = 16 +(c >> 12); */
1609 mem[tail].hh.v.RH = p;
1614 void math_limit_switch (void)
1617 if(mem[tail].hh.b0 == 17)
1619 mem[tail].hh.b1 = cur_chr;
1622 print_err("Limit controls must follow a math operator");
1623 help1("I'm ignoring this misplaced \\limits or \\nolimits command.");
1627 void scan_delimiter_(halfword p, bool r)
1630 scan_twenty_seven_bit_int ();
1636 } while(!((cur_cmd != 10)&&(cur_cmd != 0)));
1640 cur_val = eqtb[(hash_size + 3474) + cur_chr].cint;
1643 scan_twenty_seven_bit_int ();
1652 print_err("Missing delimiter (. inserted)");
1653 help6("I was expecting to see something like `(' or `\\{' or",
1654 "`\\}' here. If you typed, e.g., `{' instead of `\\{', you",
1655 "should probably delete the `{' by typing `1' now, so that",
1656 "braces don't get unbalanced. Otherwise just proceed.",
1657 "Acceptable delimiters are characters whose \\delcode is",
1658 "nonnegative, or you can use `\\delimiter <delimiter code>'.");
1662 /* attempt to speed up - bkph */ /* is compiler smart enough already ? */
1663 mem[p].qqqq.b0 =(cur_val / 1048576L)% 16; /* 2^20 */
1664 /* mem[p].qqqq.b0 =(cur_val >> 20)& 15; */
1665 mem[p].qqqq.b1 =(cur_val / 4096)% 256;
1666 /* mem[p].qqqq.b1 =(cur_val >> 12)& 255; */
1667 mem[p].qqqq.b2 =(cur_val / 256)% 16;
1668 /* mem[p].qqqq.b2 =(cur_val >> 8)& 15; */
1669 mem[p].qqqq.b3 = cur_val % 256;
1670 /* mem[p].qqqq.b3 = cur_val & 255; */
1673 void math_radical (void)
1676 mem[tail].hh.v.RH = get_node(5);
1677 tail = mem[tail].hh.v.RH;
1679 mem[tail].hh.b0 = 24;
1680 mem[tail].hh.b1 = 0;
1681 mem[tail + 1].hh = empty_field;
1682 mem[tail + 3].hh = empty_field;
1683 mem[tail + 2].hh = empty_field;
1684 scan_delimiter(tail + 4, true);
1685 scan_math(tail + 1);
1692 print_err("Please use ");
1693 print_esc("mathaccent");
1694 print_string(" for accents in math mode");
1695 help2("I'm changing \\accent to \\mathaccent here; wish me luck.",
1696 "(Accents are not the same in formulas as they are in text.)");
1700 mem[tail].hh.v.RH = get_node(5);
1701 tail = mem[tail].hh.v.RH;
1703 mem[tail].hh.b0 = 28;
1704 mem[tail].hh.b1 = 0;
1705 mem[tail + 1].hh = empty_field;
1706 mem[tail + 3].hh = empty_field;
1707 mem[tail + 2].hh = empty_field;
1708 mem[tail + 4].hh.v.RH = 1;
1709 scan_fifteen_bit_int ();
1710 mem[tail + 4].hh.b1 = cur_val % 256;
1711 /* mem[tail + 4].hh.b1 = cur_val & 255; */
1712 if((cur_val >= 28672)&& /* 32768 - 4096 ? */
1713 ((eqtb[(hash_size + 3207)].cint >= 0)&&
1714 (eqtb[(hash_size + 3207)].cint < 16)))
1715 mem[tail + 4].hh.b0 = eqtb[(hash_size + 3207)].cint;
1716 else mem[tail + 4].hh.b0 =(cur_val / 256)% 16;
1717 /* else mem[tail + 4].hh.b0 =(cur_val >> 8)& 15; */
1718 scan_math(tail + 1);
1721 void append_choices (void)
1724 mem[tail].hh.v.RH = new_choice ();
1725 tail = mem[tail].hh.v.RH;
1728 save_stack[save_ptr - 1].cint = 0;
1733 halfword fin_mlist_(halfword p)
1734 {register halfword Result;
1736 if(cur_list.aux_field.cint != 0)
1738 mem[cur_list.aux_field.cint + 3].hh.v.RH = 3;
1739 mem[cur_list.aux_field.cint + 3].hh.v.LH = mem[head]
1742 q = cur_list.aux_field.cint;
1745 q = mem[cur_list.aux_field.cint + 2].hh.v.LH;
1746 if(mem[q].hh.b0 != 30){
1747 confusion(871); /* right */
1748 return 0; // abort_flag set
1750 mem[cur_list.aux_field.cint + 2].hh.v.LH = mem[q].hh.v.RH;
1751 mem[q].hh.v.RH = cur_list.aux_field.cint;
1752 mem[cur_list.aux_field.cint].hh.v.RH = p;
1757 mem[tail].hh.v.RH = p;
1758 q = mem[head].hh.v.RH;
1765 void build_choices (void)
1770 switch(save_stack[save_ptr - 1].cint)
1772 mem[tail + 1].hh.v.LH = p;
1775 mem[tail + 1].hh.v.RH = p;
1778 mem[tail + 2].hh.v.LH = p;
1782 mem[tail + 2].hh.v.RH = p;
1788 incr(save_stack[save_ptr - 1].cint);
1795 /* small_number t; */
1796 int t; /* 95/Jan/7 */
1801 if((mem[tail].hh.b0 >= 16)&&
1802 (mem[tail].hh.b0 < 30))
1804 p = tail + 2 + cur_cmd - 7;
1807 if((p == 0)||(t != 0))
1810 mem[tail].hh.v.RH = new_noad ();
1811 tail = mem[tail].hh.v.RH;
1813 p = tail + 2 + cur_cmd - 7;
1818 print_err("Double superscript");
1819 help1("I treat `x^1^2' essentially like `x^1{}^2'.");
1822 print_err("Double subscript");
1823 help1("I treat `x_1_2' essentially like `x_1{}_2'.");
1830 /* used to continue here with math_fraction etc in tex7.c */
1831 /*****************************************************************************/
1832 /* moved down here to avoid pragma optimize questions 96/Sep/12 */
1833 /* #pragma optimize("g", off) */ /* for MC VS compiler */
1834 /* #pragma optimize("a", off) */ /* for MC VS compiler */
1836 void package_(small_number c)
1841 d = eqtb[(hash_size + 3737)].cint;
1843 save_ptr = save_ptr - 3;
1845 cur_box = hpack(mem[head].hh.v.RH, save_stack[save_ptr
1846 + 2].cint, save_stack[save_ptr + 1].cint);
1849 cur_box = vpackage(mem[head].hh.v.RH, save_stack[
1850 save_ptr + 2].cint, save_stack[save_ptr + 1].cint, d);
1854 p = mem[cur_box + 5].hh.v.RH;
1856 if(mem[p].hh.b0 <= 2)
1857 h = mem[p + 3].cint;
1858 mem[cur_box + 2].cint = mem[cur_box + 2].cint - h + mem[cur_box +
1860 mem[cur_box + 3].cint = h;
1864 box_end(save_stack[save_ptr + 0].cint);
1866 /* #pragma optimize("g", on) */ /* for MC VS compiler */
1867 /* #pragma optimize("a", on) */ /* for MC VS compiler */
1868 /* #pragma optimize("a",) */ /* 94/Jan/25 */
1869 #pragma optimize ("", on) /* 96/Sep/12 */
1870 /****************************************************************************/