6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
13 #pragma warning(disable:4996)
14 #pragma warning(disable:4131) // old style declarator
15 #pragma warning(disable:4135) // conversion between different integral types
16 #pragma warning(disable:4127) // conditional expression is constant
24 #pragma warning(disable:4244) /* 96/Jan/10 */
26 /* #pragma optimize("a", off) */ /* 98/Dec/10 experiment */
28 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
30 void char_warning_(internal_font_number f, eight_bits c)
32 if (tracing_lost_chars > 0)
34 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
35 if (show_missing == 0) /* show on screen 94/June/10 */
36 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
38 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
39 if (show_missing) { /* add ! before 94/June/10 */
41 print_string("Missing character: there is no ");
44 print_nl("Missing character: there is no ");
46 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
47 if (show_numeric) { /* bkph 93/Dec/21 */
51 print_char(48 + c / 100);
53 c = c - (c / 100) * 100; /* ? */
54 print_char(48 + c / 10);
58 c = c - (c / 100) * 100; /* ? */
59 if (c / 10 > 0) print_char(48 + c / 10);
61 print_char(48 + c % 10);
65 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
66 print_string(" in font ");
67 slow_print(font_name[f]);
69 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
70 /* if (show_missing) show_context(); */ /* in tex2.c 94/June/10 */
72 if (f != 0) show_context(); /* not if its the nullfont */
74 if (show_missing == 0) /* show on screen 94/June/10 */
75 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
76 end_diagnostic(false);
77 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
78 missing_characters++; /* bkph 93/Dec/16 */
79 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
82 halfword new_character_(internal_font_number f, eight_bits c)
84 register halfword Result;
88 if ((font_info[char_base[f]+ c].qqqq.b0 > 0))
96 char_warning(f, c); /* char_warning(f,c); l.11283 */
97 Result = 0; /* new_character:=null */
100 /* following needs access to dvi_buf=zdvibuf see coerce.h */
103 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
106 sprintf(log_line, "dvi_swap %d", dvi_gone);
107 show_line(log_line, 0);
109 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
110 if (dvi_limit == dvi_buf_size) {
111 writedvi(0, half_buf - 1);
112 dvi_limit = half_buf;
113 dvi_offset = dvi_offset + dvi_buf_size;
116 writedvi(half_buf, dvi_buf_size - 1);
117 dvi_limit = dvi_buf_size;
119 dvi_gone = dvi_gone + half_buf;
121 /* following needs access to dvi_buf=zdvibuf see coerce.h */
122 void dvi_four_(integer x) /* attempt at speeding up bkph - is compiler smart ? */
125 // dvi_out(x % 16777216L);
128 x = x + 1073741824L; /* 2^30 40000000 hex */
130 //dvi_out((x / 16777216L) + 128);
131 dvi_out((x >> 24) + 128);
133 /* x = x % 16777216L; */ /* % 2^24 */
135 //dvi_out(x / 65536L);
137 /* x = x % 65536L; */ /* % 2^16 */
144 /* following needs access to dvi_buf=zdvibuf see coerce.h */
145 void zdvipop(integer l)
147 if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
152 /* following needs access to dvi_buf=zdvibuf see coerce.h */
153 void dvi_font_def_(internal_font_number f)
156 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
164 dvi_out(((f - 1) >> 8));
165 dvi_out(((f - 1) & 255));
171 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
172 /* spit out the font checksum now */
173 dvi_out(font_check[f].b0);
174 dvi_out(font_check[f].b1);
175 dvi_out(font_check[f].b2);
176 dvi_out(font_check[f].b3);
177 dvi_four(font_size[f]);
178 dvi_four(font_dsize[f]);
179 /* long to unsigned char ... */
180 dvi_out(length(font_area[f]));
181 /* long to unsigned char ... */
182 dvi_out(length(font_name[f]));
184 for (k = str_start[font_area[f]]; k <= str_start[font_area[f]+ 1] - 1; k++)
185 dvi_out(str_pool[k]);
186 for (k = str_start[font_name[f]]; k <= str_start[font_name[f]+ 1] - 1; k++)
187 dvi_out(str_pool[k]);
189 /* following needs access to dvi_buf=zdvibuf see coerce.h */
190 void zmovement(scaled w, eight_bits o)
197 mem[q + 2].cint = dvi_offset + dvi_ptr;
198 if (o == 157) /* 157 == down1 */ {
199 mem[q].hh.v.RH = down_ptr;
201 } else { /* 143 == right1 */
202 mem[q].hh.v.RH = right_ptr;
207 while (p != 0) { /* while p<>null do l.12153 */
208 if (mem[p + 1].cint == w)
209 switch(mstate + mem[p].hh.v.LH)
214 if (mem[p + 2].cint < dvi_gone)
218 k = mem[p + 2].cint - dvi_offset;
220 k = k + dvi_buf_size;
221 dvi_buf[k]= dvi_buf[k]+ 5;
229 if (mem[p + 2].cint < dvi_gone)
233 k = mem[p + 2].cint - dvi_offset;
235 k = k + dvi_buf_size;
236 dvi_buf[k]= dvi_buf[k]+ 10;
251 else switch(mstate + mem[p].hh.v.LH)
270 if (abs(w)>= 8388608L) /* 2^23 */
280 w = w + 16777216L; /* 2^24 */
281 //dvi_out(w / 65536L);
283 /* w = w % 65536L; */
305 lab40: mem[q].hh.v.LH = mem[p].hh.v.LH;
306 if (mem[q].hh.v.LH == 1)
309 while (mem[q].hh.v.RH != p) {
311 switch(mem[q].hh.v.LH)
325 while (mem[q].hh.v.RH != p) {
327 switch(mem[q].hh.v.LH)
341 void prune_movements_(integer l)
344 while (down_ptr != 0) { /* while down_ptr<>null do l.12206 */
345 if (mem[down_ptr + 2].cint < l)
348 down_ptr = mem[p].hh.v.RH;
352 while (right_ptr != 0) { /* done: while right_ptr<>null do */
353 if (mem[right_ptr + 2].cint < l)
356 right_ptr = mem[p].hh.v.RH;
360 /* following needs access to dvi_buf=zdvibuf see coerce.h */
361 void special_out_(halfword p)
367 movement(cur_h - dvi_h, 143); /* 143 == right1 */
372 movement(cur_v - dvi_v, 157); /* 157 == down1 */
375 old_setting = selector;
377 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
378 /* About output \special{...} make some space in string pool 97/Mar/9 */
379 #ifdef ALLOCATESTRING
380 if (pool_ptr + 32000 > current_pool_size)
381 str_pool = realloc_str_pool (increment_pool_size);
382 /* We don't bother to check whether this worked - will catch later */
384 /* Potential problem here if current_pool_size is not much more than pool_ptr! */
385 /* Fixed 97/Mar/9 in version 2.0.3 */
386 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
387 #ifdef ALLOCATESTRING
388 /* show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
389 current_pool_size - pool_ptr); */
390 show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0, 10000000L);
391 /* Above is safe, since print/print_char/print_esc will extend string space */
393 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
394 show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
395 pool_size - pool_ptr);
398 selector = old_setting;
400 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
401 /* str_room(1) - is there space for one more character in string pool ? */
402 #ifdef ALLOCATESTRING
403 if (pool_ptr + 1 > current_pool_size)
404 str_pool = realloc_str_pool (increment_pool_size);
405 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
406 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
407 return; // abort_flag set
410 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
411 if (pool_ptr + 1 > pool_size){
412 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
413 return; // abort_flag set
417 if (cur_length < 256) /* can use xxx1 ? */
420 /* long to unsigned char ... */
422 } else { /* use xxx4 instead */
424 dvi_four(cur_length);
428 /* debugging code for \special{src: ... } 98/Nov/11 */
430 int k = str_start[str_ptr];
433 if (str_pool [k] == 's' &&
434 str_pool [k+1] == 'r' &&
435 str_pool [k+2] == 'c' &&
436 str_pool [k+3] == ':') { /* \special{src: ... } */
440 *s++ = str_pool[k++];
444 show_line(log_line, 0)
448 if (cur_input.name_field > 17) { /* redundant ? */
449 print(cur_input.name_field);
451 print_int(line); /* line number */
464 register integer for_end;
465 k = str_start[str_ptr];
466 for_end = pool_ptr - 1;
468 dvi_out(str_pool[k]);
469 while(k++ < for_end);
471 pool_ptr = str_start[str_ptr];
473 /* noew returns -1 if it fails */
474 void write_out_(halfword p)
477 /* integer oldmode; */
478 int oldmode; /* 1995/Jan/7 */
479 /* small_number j; */
480 int j; /* 1995/Jan/7 */
482 /* q:=get_avail; info(q):=right_brace_token+"}";@/ */
485 /* r:=get_avail; link(q):=r; info(r):=end_write_token; ins_list(q);@/ */
486 /* @d end_write_token==cs_token_flag+end_write */
489 /* mem[r].hh.v.LH = (hash_size + 4617); */
490 /* mem[r].hh.v.LH = (hash_size + 4095 + 522); */
491 info(r) = (hash_size + hash_extra + 4095 + 522);
492 begin_token_list(q, 4);
493 begin_token_list(mem[p + 1].hh.v.RH, 15);
495 mem[q].hh.v.LH = 379;
496 begin_token_list(q, 4);
500 q = scan_toks(false, true);
502 /* if (cur_tok != (hash_size + 4617)) */
503 /* if (cur_tok != (hash_size + 4095 + 522)) */
504 if (cur_tok != (hash_size + hash_extra + 4095 + 522))
506 print_err("Unbalanced write command");
507 help2("On this page there's a \\write with fewer real {'s than }'s.",
508 "I can't handle that very well; good luck.");
512 /* } while(!(cur_tok == (hash_size + 4617))); */
513 /* } while(!(cur_tok == (hash_size + 4095 + 522))); */
514 } while(!(cur_tok == (hash_size + hash_extra + 4095 + 522))); /*1996/Jan/10*/
518 old_setting = selector;
519 j = mem[p + 1].hh.v.LH;
520 if (write_open[j])selector = j;
522 if ((j == 17)&&(selector == 19))
529 selector = old_setting;
531 void out_what_(halfword p)
533 /* small_number j; */
534 int j; /* 1995/Jan/7 */
539 if (!doing_leaders) {
540 j = mem[p + 1].hh.v.LH;
541 if (mem[p].hh.b1 == 1){
545 (void) a_close(write_file[j]);
546 if (mem[p].hh.b1 == 2)
547 write_open[j]= false;
549 cur_name = mem[p + 1].hh.v.RH;
550 cur_area = mem[p + 2].hh.v.LH;
551 cur_ext = mem[p + 2].hh.v.RH;
552 if (cur_ext == 335) /* "" */
553 cur_ext = 785; /* => ".tex" */
554 pack_file_name(cur_name, cur_area, cur_ext);
555 while(! a_open_out(write_file[j])) {
556 prompt_file_name(1294, 785); /* output file name .tex */
572 return; // abort_flag set
577 /* following needs access to dvi_buf=zdvibuf see coerce.h */
578 void hlist_out (void)
584 /* glue_ord gorder; */
585 int gorder; /* 95/Jan/7 */
587 int gsign; /* 95/Jan/7 */
593 bool outerdoingleaders;
595 /* ********************************************************************* */
596 real gluetemp; /* new in 3.14159 */
597 /* ********************************************************************* */
599 gorder = mem[thisbox + 5].hh.b1;
600 gsign = mem[thisbox + 5].hh.b0;
601 p = mem[thisbox + 5].hh.v.RH;
605 if (cur_s > max_push)
607 saveloc = dvi_offset + dvi_ptr;
610 /* while p<>null do l.12314 */
613 if ((p >= hi_mem_min))
617 movement(cur_h - dvi_h, 143); /* 143 == right1 */
622 movement(cur_v - dvi_v, 157); /* 157 == down1 */
636 dvi_out(f + 170); /* fnt_num_0 --- fnt_num_63 */
637 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
639 else if (f <= 256){ /* if we allow greater than 256 fonts */
641 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
642 else { /* normal TeX 82 case */
644 dvi_out(235); /* fnt1 followed by f */
647 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
649 else { /* fnt2 followed by f / 256, f % 256 */
651 dvi_out(((f - 1) >> 8)); /* top byte */
652 dvi_out(((f - 1) & 255)); /* bottom byte */
655 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
661 cur_h = cur_h + font_info[width_base[f] + font_info[char_base[f] + c].qqqq.b0].cint;
663 } while(!(!(p >= hi_mem_min)));
669 /* if list_ptr(p)=null then cur_h:=cur_h+width(p) l.12371 */
670 if (mem[p + 5].hh.v.RH == 0)
671 cur_h = cur_h + mem[p + 1].cint;
676 cur_v = baseline + mem[p + 4].cint;
679 if (mem[p].hh.b0 == 1)vlist_out();
683 cur_h = edge + mem[p + 1].cint;
689 rule_ht = mem[p + 3].cint;
690 rule_dp = mem[p + 2].cint;
691 rule_wd = mem[p + 1].cint;
700 g = mem[p + 1].hh.v.LH;
701 rule_wd = mem[g + 1].cint;
706 if (mem[g].hh.b0 == gorder)
707 /* *********************************************************************** */
708 /* rule_wd = rule_wd + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
709 /* ******************** 3.14159 ******************************************* */
711 gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
712 if (gluetemp > 1000000000.0)
713 gluetemp = 1000000000.0;
714 else if (gluetemp < -1000000000.0)
715 gluetemp = -1000000000.0;
716 rule_wd = rule_wd + round(gluetemp);
718 /* ************************************************************************* */
721 /* if (mem[g].hh.b1 == gorder)*/
722 /* rule_wd = rule_wd - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
724 /* ******************** 3.14159 ******************************************* */
725 else if (mem[g].hh.b1 == gorder)
727 gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
728 if (gluetemp > 1000000000.0)
729 gluetemp = 1000000000.0;
730 else if (gluetemp < -1000000000.0)
731 gluetemp = -1000000000.0;
732 rule_wd = rule_wd - round(gluetemp);
734 /* ************************************************************************* */
736 if (mem[p].hh.b1 >= 100)
738 leaderbox = mem[p + 1].hh.v.RH;
739 if (mem[leaderbox].hh.b0 == 2)
741 rule_ht = mem[leaderbox + 3].cint;
742 rule_dp = mem[leaderbox + 2].cint;
745 leaderwd = mem[leaderbox + 1].cint;
746 if ((leaderwd > 0)&&(rule_wd > 0))
748 rule_wd = rule_wd + 10;
749 edge = cur_h + rule_wd;
751 if (mem[p].hh.b1 == 100)
754 cur_h = leftedge + leaderwd *((cur_h - leftedge)/ leaderwd)
757 cur_h = cur_h + leaderwd;
761 lq = rule_wd / leaderwd;
762 lr = rule_wd % leaderwd;
763 if (mem[p].hh.b1 == 101)
764 cur_h = cur_h +(lr / 2);
767 lx =(2 * lr + lq + 1)/(2 * lq + 2);
768 cur_h = cur_h +((lr -(lq - 1)* lx)/ 2);
771 while(cur_h + leaderwd <= edge){
773 cur_v = baseline + mem[leaderbox + 4].cint;
776 movement(cur_v - dvi_v, 157); /* 157 == down1 */
782 movement(cur_h - dvi_h, 143); /* 143 == right1 */
786 temp_ptr = leaderbox;
787 outerdoingleaders = doing_leaders;
788 doing_leaders = true;
789 if (mem[leaderbox].hh.b0 == 1)vlist_out();
791 doing_leaders = outerdoingleaders;
794 /* ****************************************************************** */
796 cur_v = baseline; /* changed in 3.1415 */
797 /* ****************************************************************** */
798 cur_h = saveh + leaderwd + lx;
809 cur_h = cur_h + mem[p + 1].cint;
813 mem[lig_trick]= mem[p + 1];
814 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
824 lab14: if ((rule_ht == -1073741824L)) /* - 2^30 */
825 rule_ht = mem[thisbox + 3].cint;
826 if ((rule_dp == -1073741824L)) /* - 2^30 */
827 rule_dp = mem[thisbox + 2].cint;
828 rule_ht = rule_ht + rule_dp;
829 if ((rule_ht > 0)&&(rule_wd > 0))
833 movement(cur_h - dvi_h, 143); /* 143 == right1 */
836 cur_v = baseline + rule_dp;
839 movement(cur_v - dvi_v, 157); /* 157 == down1 */
846 dvi_h = dvi_h + rule_wd;
848 lab13: cur_h = cur_h + rule_wd;
849 lab15: p = mem[p].hh.v.RH;
851 prune_movements(saveloc);
856 /* following needs access to dvi_buf=zdvibuf see coerce.h */
857 void vlist_out (void)
863 /* glue_ord gorder; */
864 int gorder; /* 95/Jan/7 */
866 int gsign; /* 95/Jan/7 */
872 bool outerdoingleaders;
874 /* ************************************************************************ */
875 real gluetemp; /* new in 3.14159 */
876 /* ************************************************************************ */
878 gorder = mem[thisbox + 5].hh.b1;
879 gsign = mem[thisbox + 5].hh.b0;
880 p = mem[thisbox + 5].hh.v.RH;
884 if (cur_s > max_push)
886 saveloc = dvi_offset + dvi_ptr;
888 cur_v = cur_v - mem[thisbox + 3].cint;
890 while(p != 0){ /* while p<>null do l.12494 OK */
891 if ((p >= hi_mem_min)) {
892 confusion("vlistout");
893 return; // abort_flag set
899 /* if list_ptr(p)=null then cur_v:=cur_v+height(p)+depth(p) l.12529 */
900 if (mem[p + 5].hh.v.RH == 0)
901 cur_v = cur_v + mem[p + 3].cint + mem[p + 2].cint;
904 cur_v = cur_v + mem[p + 3].cint;
907 movement(cur_v - dvi_v, 157); /* 157 == down1 */
912 cur_h = leftedge + mem[p + 4].cint;
914 if (mem[p].hh.b0 == 1)vlist_out();
918 cur_v = savev + mem[p + 2].cint;
924 rule_ht = mem[p + 3].cint;
925 rule_dp = mem[p + 2].cint;
926 rule_wd = mem[p + 1].cint;
935 g = mem[p + 1].hh.v.LH;
936 rule_ht = mem[g + 1].cint;
941 if (mem[g].hh.b0 == gorder)
942 /* ************************************************************************ */
943 /* rule_ht = rule_ht + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
944 /* ************************ 3.14159 **************************************** */
946 gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
947 if (gluetemp > 1000000000.0)
948 gluetemp = 1000000000.0;
949 else if (gluetemp < -1000000000.0)
950 gluetemp = -1000000000.0;
951 rule_ht = rule_ht + round(gluetemp);
953 /* ************************************************************************* */
955 /* ************************************************************************* */
957 /* if (mem[g].hh.b1 == gorder) */
958 /* rule_ht = rule_ht - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
960 else if (mem[g].hh.b1 == gorder) /* BUG FIX !!! */
962 gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
963 if (gluetemp > 1000000000.0)
964 gluetemp = 1000000000.0;
965 else if (gluetemp < -1000000000.0)
966 gluetemp = -1000000000.0;
967 rule_ht = rule_ht - round(gluetemp);
969 /* ************************************************************************* */
971 if (mem[p].hh.b1 >= 100)
973 leaderbox = mem[p + 1].hh.v.RH;
974 if (mem[leaderbox].hh.b0 == 2)
976 rule_wd = mem[leaderbox + 1].cint;
980 leaderht = mem[leaderbox + 3].cint + mem[leaderbox + 2]
982 if ((leaderht > 0)&&(rule_ht > 0))
984 rule_ht = rule_ht + 10;
985 edge = cur_v + rule_ht;
987 if (mem[p].hh.b1 == 100)
990 cur_v = topedge + leaderht *((cur_v - topedge)/ leaderht)
993 cur_v = cur_v + leaderht;
997 lq = rule_ht / leaderht;
998 lr = rule_ht % leaderht;
999 if (mem[p].hh.b1 == 101)
1000 cur_v = cur_v +(lr / 2);
1003 lx =(2 * lr + lq + 1)/(2 * lq + 2);
1004 cur_v = cur_v +((lr -(lq - 1)* lx)/ 2);
1007 while(cur_v + leaderht <= edge){
1009 cur_h = leftedge + mem[leaderbox + 4].cint;
1012 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1016 cur_v = cur_v + mem[leaderbox + 3].cint;
1019 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1023 temp_ptr = leaderbox;
1024 outerdoingleaders = doing_leaders;
1025 doing_leaders = true;
1026 if (mem[leaderbox].hh.b0 == 1)vlist_out();
1028 doing_leaders = outerdoingleaders;
1031 /* ************************************************************************ */
1032 /* cur_h = saveh; */
1033 cur_h = leftedge; /* 3.1415 */
1034 /* ************************************************************************ */
1035 cur_v = savev - mem[leaderbox + 3].cint + leaderht + lx;
1045 cur_v = cur_v + mem[p + 1].cint;
1052 lab14: if ((rule_wd == -1073741824L)) /* -2^30 */
1053 rule_wd = mem[thisbox + 1].cint;
1054 rule_ht = rule_ht + rule_dp;
1055 cur_v = cur_v + rule_ht;
1056 if ((rule_ht > 0)&&(rule_wd > 0))
1060 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1065 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1073 lab13: cur_v = cur_v + rule_ht;
1075 lab15: p = mem[p].hh.v.RH;
1077 prune_movements(saveloc);
1082 /****************HPDF******************/
1084 void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
1086 printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
1089 /****************HPDF******************/
1091 /* following needs access to dvi_buf=zdvibuf see coerce.h */
1092 void ship_out_(halfword p)
1098 if (tracing_output > 0) {
1101 print_string("Completed box being shipped out");
1103 if (term_offset > max_print_line - 9)
1105 else if ((term_offset > 0)||(file_offset > 0))
1109 while((eqtb[(hash_size + 3218) + j].cint == 0) && (j > 0))
1112 register integer for_end;
1115 if (k <= for_end) do
1117 print_int(eqtb[(hash_size + 3218) + k].cint);
1120 } while(k++ < for_end);
1125 if (tracing_output > 0)
1130 end_diagnostic(true);
1132 if ((mem[p + 3].cint > 1073741823L) || /* 2^30 - 1 */
1133 (mem[p + 2].cint > 1073741823L) ||
1134 (mem[p + 3].cint + mem[p + 2].cint + v_offset > 1073741823L) ||
1135 (mem[p + 1].cint + h_offset > 1073741823L)) {
1136 print_err("Huge page cannot be shipped out");
1137 help2("The page just created is more than 18 feet tall or",
1138 "more than 18 feet wide, so I suspect something went wrong.");
1140 if (tracing_output <= 0) {
1142 print_nl("The following box has been deleted:");
1144 end_diagnostic(true);
1148 if (mem[p + 3].cint + mem[p + 2].cint + v_offset > max_v)
1149 max_v = mem[p + 3].cint + mem[p + 2].cint + v_offset;
1150 if (mem[p + 1].cint + h_offset > max_h)
1151 max_h = mem[p + 1].cint + h_offset;
1156 if (output_file_name == 0) {
1159 pack_job_name(788); /* .dvi */
1160 while(!b_open_out(dvi_file)) {
1161 prompt_file_name(789, 788); /* file name for output .dvi */
1163 output_file_name = b_make_name_string(dvi_file);
1166 if (total_pages == 0) {
1169 /********BINDING WITH LIBHARU*********/
1171 yandy_pdf = HPDF_New(error_handler, NULL);
1172 yandy_page = HPDF_AddPage(yandy_pdf);
1173 HPDF_SetInfoAttr(yandy_pdf, HPDF_INFO_PRODUCER, "Y&Y TeX with ApTeX");
1174 HPDF_SetCompressionMode (yandy_pdf, HPDF_COMP_ALL);
1175 HPDF_Page_SetSize (yandy_page, HPDF_PAGE_SIZE_A5, HPDF_PAGE_PORTRAIT);
1176 yandy_font = HPDF_GetFont (yandy_pdf, "Times-Roman", NULL);
1177 HPDF_Page_BeginText (yandy_page);
1178 HPDF_Page_SetFontAndSize (yandy_page, yandy_font, 16);
1179 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-90, "This is the \xAErst page.");
1180 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-180, "Wait for ...");
1181 HPDF_Page_EndText (yandy_page);
1182 HPDF_SaveToFile (yandy_pdf, "NOTICE.pdf");
1183 HPDF_Free(yandy_pdf);
1185 /********BINDING WITH LIBHARU*********/
1186 dvi_four(25400000L); /* magic DVI scale factor */
1187 dvi_four(473628672L); /* 7227 * 65536 */
1190 old_setting = selector;
1192 print_string(" TeX output ");
1199 print_two(tex_time / 60);
1200 print_two(tex_time % 60);
1201 selector = old_setting;
1202 /* long to unsigned char ... */
1203 dvi_out(cur_length);
1204 for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++) dvi_out(str_pool[s]);
1205 pool_ptr = str_start[str_ptr];
1206 } // end of if total_pages == 0
1208 pageloc = dvi_offset + dvi_ptr;
1210 for (k = 0; k <= 9; k++) dvi_four(eqtb[(hash_size + 3218) + k].cint);
1213 cur_v = mem[p + 3].cint + v_offset;
1215 if (mem[p].hh.b0 == 1)
1223 if (tracing_output <= 0)
1231 if (tracing_stats > 1) {
1232 print_nl("Memory usage before: ");
1233 print_int(var_used);
1235 print_int(dyn_used);
1242 if (tracing_stats > 1) {
1243 print_string("after");
1244 print_int(var_used);
1246 print_int(dyn_used);
1247 print_string("still utouched");
1248 print_int(hi_mem_min - lo_mem_max - 1); /* somewhat inaccurate free mem */
1253 void scan_spec_(group_code c, bool threecodes)
1258 s = save_stack[save_ptr + 0].cint;
1259 if (scan_keyword("to"))
1261 else if (scan_keyword("spread"))
1268 scan_dimen(false, false, false);
1271 save_stack[save_ptr + 0].cint = s; /* s may be used without ... */
1274 save_stack[save_ptr + 0].cint = speccode;
1275 save_stack[save_ptr + 1].cint = cur_val;
1276 save_ptr = save_ptr + 2;
1280 halfword hpack_(halfword p, scaled w, small_number m)
1282 register halfword Result;
1289 int o; /* 95/Jan/7 */
1290 internal_font_number f;
1297 mem[r + 4].cint = 0;
1303 total_stretch[0] = 0;
1304 total_shrink[0] = 0;
1305 total_stretch[1] = 0;
1306 total_shrink[1] = 0;
1307 total_stretch[2] = 0;
1308 total_shrink[2] = 0;
1309 total_stretch[3] = 0;
1310 total_shrink[3] = 0;
1311 while (p != 0) { /* while p<>null do l.12862 */
1313 while ((p >= hi_mem_min)) {
1315 i = font_info[char_base[f] + mem[p].hh.b1].qqqq;
1317 x = x + font_info[width_base[f] + i.b0].cint;
1318 s = font_info[height_base[f] + (hd) / 16].cint;
1321 s = font_info[depth_base[f]+(hd)% 16].cint;
1326 if (p != 0) /* if p<>null then l.12886 */
1328 switch (mem[p].hh.b0)
1335 x = x + mem[p + 1].cint;
1336 if (mem[p].hh.b0 >= 2)
1339 s = mem[p + 4].cint;
1340 if (mem[p + 3].cint - s > h)
1341 h = mem[p + 3].cint - s;
1342 if (mem[p + 2].cint + s > d)
1343 d = mem[p + 2].cint + s;
1349 /* if adjust_tail<>null then link(adjust_tail):=null; l.12865 / 12891 */
1350 if (adjust_tail != 0)
1352 while (mem[q].hh.v.RH != p)
1354 if (mem[p].hh.b0 == 5) {
1355 mem[adjust_tail].hh.v.RH = mem[p + 1].cint;
1356 while (mem[adjust_tail].hh.v.RH != 0)
1357 adjust_tail = mem[adjust_tail].hh.v.RH;
1359 free_node(mem[q].hh.v.RH, 2);
1361 mem[adjust_tail].hh.v.RH = p;
1374 g = mem[p + 1].hh.v.LH;
1375 x = x + mem[g + 1].cint;
1377 total_stretch[o]= total_stretch[o]+ mem[g + 2].cint;
1379 total_shrink[o]= total_shrink[o]+ mem[g + 3].cint;
1380 if (mem[p].hh.b1 >= 100) {
1381 g = mem[p + 1].hh.v.RH;
1382 if (mem[g + 3].cint > h)
1383 h = mem[g + 3].cint;
1384 if (mem[g + 2].cint > d)
1385 d = mem[g + 2].cint;
1391 x = x + mem[p + 1].cint;
1395 mem[lig_trick]= mem[p + 1];
1396 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1408 if (adjust_tail != 0)
1409 mem[adjust_tail].hh.v.RH = 0;
1410 mem[r + 3].cint = h;
1411 mem[r + 2].cint = d;
1414 mem[r + 1].cint = w;
1417 mem[r + 5].hh.b0 = 0;
1418 mem[r + 5].hh.b1 = 0;
1419 mem[r + 6].gr = 0.0;
1422 if (total_stretch[3] != 0)
1424 else if (total_stretch[2] != 0)
1426 else if (total_stretch[1] != 0)
1430 mem[r + 5].hh.b1 = o;
1431 mem[r + 5].hh.b0 = 1;
1432 /* if total_stretch[o]<>0 then glue_set(r):=... l.12982 */
1433 if (total_stretch[o]!= 0)
1434 mem[r + 6].gr = x / ((double) total_stretch[o]);
1436 mem[r + 5].hh.b0 = 0;
1437 mem[r + 6].gr = 0.0;
1439 /* if o=normal then if list_ptr(r)<>null then l.12987 */
1441 if (mem[r + 5].hh.v.RH != 0)
1443 last_badness = badness(x, total_stretch[0]);
1444 if (last_badness > hbadness) {
1446 if (last_badness > 100)
1447 print_nl("Underfull");
1450 print_string(" \\hbox (badness ");
1451 print_int(last_badness);
1452 if (last_badness > 100)
1453 underfull_hbox++; /* 1996/Feb/9 */
1459 if (total_shrink[3] != 0)
1461 else if (total_shrink[2] != 0)
1463 else if (total_shrink[1] != 0)
1467 mem[r + 5].hh.b1 = o;
1468 mem[r + 5].hh.b0 = 2;
1469 if (total_shrink[o] != 0)
1470 mem[r + 6].gr =(- (integer) x) / ((double) total_shrink[o]);
1472 mem[r + 5].hh.b0 = 0;
1473 mem[r + 6].gr = 0.0;
1475 /* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13946 */
1476 if ((total_shrink[o]< - (integer) x) && (o == 0) && (mem[r + 5].hh.v.RH != 0)) {
1477 last_badness = 1000000L;
1478 /* set_glue_ratio_one(glue_set(r)); {use the maximum shrinkage} */
1479 mem[r + 6].gr = 1.0;
1480 /* if (-x-total_shrink[normal]>hfuzz)or(hbadness<100) then */
1481 if ((- (integer) x - total_shrink[0] > hfuzz) ||
1483 if ((overfull_rule > 0) &&
1484 (- (integer) x - total_shrink[0] > hfuzz)) {
1485 while(mem[q].hh.v.RH != 0)q = mem[q].hh.v.RH;
1486 mem[q].hh.v.RH = new_rule();
1487 mem[mem[q].hh.v.RH + 1].cint = overfull_rule;
1490 print_nl("Overfull \\hbox(");
1491 print_scaled(- (integer) x - total_shrink[0]);
1492 print_string("pt too wide");
1493 overfull_hbox++; /* 1996/Feb/9 */
1497 if (mem[r + 5].hh.v.RH != 0) {
1498 last_badness = badness(- (integer) x, total_shrink[0]);
1499 if (last_badness > hbadness) {
1501 print_nl("Tight \\hbox (badness ");
1502 print_int(last_badness);
1510 print_string(") has occurred while \\output is active");
1512 if (pack_begin_line != 0) {
1513 if (pack_begin_line > 0)
1514 print_string(") in paragraph at lines ");
1516 print_string(") in alignment at lines ");
1517 print_int(abs(pack_begin_line));
1519 } else print_string(")detected at line ");
1523 font_in_short_display = 0;
1524 short_display(mem[r + 5].hh.v.RH);
1528 end_diagnostic(true);
1533 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
1535 register halfword Result;
1541 int o; /* 95/Jan/7 */
1546 mem[r + 4].cint = 0;
1547 mem[r + 5].hh.v.RH = p;
1551 total_stretch[0] = 0;
1552 total_shrink[0] = 0;
1553 total_stretch[1] = 0;
1554 total_shrink[1] = 0;
1555 total_stretch[2] = 0;
1556 total_shrink[2] = 0;
1557 total_stretch[3] = 0;
1558 total_shrink[3] = 0;
1560 if ((p >= hi_mem_min)) {
1562 return 0; // abort_flag set
1563 } else switch (mem[p].hh.b0)
1570 x = x + d + mem[p + 3].cint;
1571 d = mem[p + 2].cint;
1572 if (mem[p].hh.b0 >= 2)
1574 else s = mem[p + 4].cint;
1575 if (mem[p + 1].cint + s > w)
1576 w = mem[p + 1].cint + s;
1586 g = mem[p + 1].hh.v.LH;
1587 x = x + mem[g + 1].cint;
1589 total_stretch[o] = total_stretch[o]+ mem[g + 2].cint;
1591 total_shrink[o]= total_shrink[o]+ mem[g + 3].cint;
1592 if (mem[p].hh.b1 >= 100) {
1593 g = mem[p + 1].hh.v.RH;
1594 if (mem[g + 1].cint > w)
1595 w = mem[g + 1].cint;
1601 x = x + d + mem[p + 1].cint;
1611 mem[r + 1].cint = w;
1614 mem[r + 2].cint = l;
1615 } else mem[r + 2].cint = d;
1618 mem[r + 3].cint = h;
1621 mem[r + 5].hh.b0 = 0;
1622 mem[r + 5].hh.b1 = 0;
1623 mem[r + 6].gr = 0.0;
1626 if (total_stretch[3] != 0)
1628 else if (total_stretch[2]!= 0)
1630 else if (total_stretch[1]!= 0)
1634 mem[r + 5].hh.b1 = o;
1635 mem[r + 5].hh.b0 = 1;
1636 if (total_stretch[o] != 0)
1637 mem[r + 6].gr = x / ((double) total_stretch[o]);
1639 mem[r + 5].hh.b0 = 0;
1640 mem[r + 6].gr = 0.0;
1643 if (mem[r + 5].hh.v.RH != 0) {
1644 last_badness = badness(x, total_stretch[0]);
1645 if (last_badness > vbadness) {
1647 if (last_badness > 100)
1648 print_nl("Underfull");
1651 print_string(" \\vbox (badness ");
1652 print_int(last_badness);
1653 if (last_badness > 100)
1654 underfull_vbox++; /* 1996/Feb/9 */
1660 if (total_shrink[3] != 0)
1662 else if (total_shrink[2] != 0)
1664 else if (total_shrink[1]!= 0)
1668 mem[r + 5].hh.b1 = o;
1669 mem[r + 5].hh.b0 = 2;
1670 if (total_shrink[o]!= 0)
1671 mem[r + 6].gr =(- (integer) x)/ ((double) total_shrink[o]);
1673 mem[r + 5].hh.b0 = 0;
1674 mem[r + 6].gr = 0.0;
1676 /* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13046 */
1677 if ((total_shrink[o] < - (integer) x) && (o == 0) && (mem[r + 5].hh.v.RH != 0)) {
1678 last_badness = 1000000L;
1679 mem[r + 6].gr = 1.0;
1680 if ((- (integer) x - total_shrink[0] > eqtb[(hash_size + 3739)].cint) ||
1683 print_nl("Overfull \\vbox(");
1684 print_scaled(- (integer) x - total_shrink[0]);
1685 print_string("pt too high");
1686 overfull_vbox++; /* 1996/Feb/9 */
1690 /* else if o=normal then if list_ptr(r)<>null then l.13052 */
1692 if (mem[r + 5].hh.v.RH != 0) {
1693 last_badness = badness(- (integer) x, total_shrink[0]);
1694 if (last_badness > vbadness) {
1696 print_nl("Tight \\vbox (badness ");
1697 print_int(last_badness);
1705 print_string(") has occurred while \\output is active");
1707 if (pack_begin_line != 0) {
1708 print_string(") in alignment at lines ");
1709 print_int(abs(pack_begin_line));
1711 } else print_string(") detected at line ");
1717 end_diagnostic(true);
1722 void append_to_vlist_(halfword b)
1726 if (cur_list.aux_field.cint > ignore_depth) {
1727 d = mem[eqtb[(hash_size + 783)].hh.v.RH + 1].cint - cur_list.aux_field.cint - mem[b + 3].cint;
1728 if (d < line_skip_limit)
1729 p = new_param_glue(0);
1731 p = new_skip_param(1);
1732 mem[temp_ptr + 1].cint = d;
1734 mem[tail].hh.v.RH = p;
1737 mem[tail].hh.v.RH = b;
1739 cur_list.aux_field.cint = mem[b + 2].cint;
1741 halfword new_noad (void)
1743 register halfword Result;
1748 mem[p + 1].hh = empty_field;
1749 mem[p + 3].hh = empty_field;
1750 mem[p + 2].hh = empty_field;
1754 halfword new_style_(small_number s)
1756 register halfword Result;
1761 mem[p + 1].cint = 0;
1762 mem[p + 2].cint = 0;
1766 halfword new_choice (void)
1768 register halfword Result;
1773 mem[p + 1].hh.v.LH = 0;
1774 mem[p + 1].hh.v.RH = 0;
1775 mem[p + 2].hh.v.LH = 0;
1776 mem[p + 2].hh.v.RH = 0;
1780 void show_info (void)
1782 show_node_list(mem[temp_ptr].hh.v.LH);
1784 halfword fraction_rule_(scaled t)
1786 register halfword Result;
1789 mem[p + 3].cint = t;
1790 mem[p + 2].cint = 0;
1794 halfword overbar_(halfword b, scaled k, scaled t)
1796 register halfword Result;
1800 q = fraction_rule(t);
1804 Result = vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
1807 halfword char_box_(internal_font_number f, quarterword c)
1809 register halfword Result;
1813 q = font_info[char_base[f]+ c].qqqq;
1816 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
1817 mem[b + 3].cint = font_info[height_base[f]+(hd) / 16].cint;
1818 mem[b + 2].cint = font_info[depth_base[f]+(hd) % 16].cint;
1819 /* long to unsigned short ... */
1823 mem[b + 5].hh.v.RH = p;
1827 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
1831 mem[p].hh.v.RH = mem[b + 5].hh.v.RH;
1832 mem[b + 5].hh.v.RH = p;
1833 mem[b + 3].cint = mem[p + 3].cint;
1835 scaled height_plus_depth_(internal_font_number f, fquarterword c)
1837 register scaled Result;
1840 q = font_info[char_base[f]+ c].qqqq;
1842 Result = font_info[height_base[f]+(hd)/ 16].cint + font_info[depth_base[f]+(hd) % 16].cint;
1845 halfword var_delimiter_(halfword d, small_number s, scaled v)
1847 register halfword Result;
1849 internal_font_number f, g;
1850 quarterword c, x, y;
1857 /* small_number z; */
1858 int z; /* 95/Jan/7 */
1859 /* bool largeattempt; */
1860 int largeattempt; /* 95/Jan/7 */
1863 largeattempt = false;
1867 if ((z != 0) || (x != 0)) {
1871 g = eqtb[(hash_size + 1835) + z].hh.v.RH;
1874 if ((y >= font_bc[g]) && (y <= font_ec[g])) {
1876 q = font_info[char_base[g]+ y].qqqq;
1878 if (((q.b2) % 4) == 3) {
1884 u = font_info[height_base[g]+(hd)/ 16].cint + font_info[depth_base[g]+(hd)% 16].cint;
1892 if (((q.b2)% 4)== 2) {
1899 } while (!(z < 16));
1903 largeattempt = true;
1909 if (((q.b2) % 4)== 3) /* q may be used without ... */
1913 r = font_info[exten_base[f]+ q.b3].qqqq;
1915 u = height_plus_depth(f, c);
1917 q = font_info[char_base[f]+ c].qqqq;
1918 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
1921 w = w + height_plus_depth(f, c);
1924 w = w + height_plus_depth(f, c);
1927 w = w + height_plus_depth(f, c);
1938 stack_into_box(b, f, c);
1941 register integer for_end;
1944 if (m <= for_end) do
1945 stack_into_box(b, f, c);
1946 while (m++ < for_end);
1950 stack_into_box(b, f, c);
1953 register integer for_end;
1956 if (m <= for_end) do
1957 stack_into_box(b, f, c);
1958 while(m++ < for_end);
1963 stack_into_box(b, f, c);
1964 mem[b + 2].cint = w - mem[b + 3].cint;
1965 } else b = char_box(f, c);
1966 else { /* c may be used without ... */
1968 mem[b + 1].cint = null_delimiter_space;
1970 mem[b + 4].cint = half(mem[b + 3].cint - mem[b + 2].cint) - font_info[22 + param_base[eqtb[(hash_size + 1837) + s].hh.v.RH]].cint;
1974 /* rebox_ etc used to follow here in tex4.c */