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 */
200 mem[q].hh.v.RH = down_ptr;
203 else { /* 143 == right1 */
204 mem[q].hh.v.RH = right_ptr;
209 while(p != 0){ /* while p<>null do l.12153 */
210 if (mem[p + 1].cint == w)
211 switch(mstate + mem[p].hh.v.LH)
216 if (mem[p + 2].cint < dvi_gone)
220 k = mem[p + 2].cint - dvi_offset;
222 k = k + dvi_buf_size;
223 dvi_buf[k]= dvi_buf[k]+ 5;
231 if (mem[p + 2].cint < dvi_gone)
235 k = mem[p + 2].cint - dvi_offset;
237 k = k + dvi_buf_size;
238 dvi_buf[k]= dvi_buf[k]+ 10;
253 else switch(mstate + mem[p].hh.v.LH)
272 if (abs(w)>= 8388608L) /* 2^23 */
282 w = w + 16777216L; /* 2^24 */
283 //dvi_out(w / 65536L);
285 /* w = w % 65536L; */
307 lab40: mem[q].hh.v.LH = mem[p].hh.v.LH;
308 if (mem[q].hh.v.LH == 1)
311 while (mem[q].hh.v.RH != p) {
313 switch(mem[q].hh.v.LH)
327 while (mem[q].hh.v.RH != p) {
329 switch(mem[q].hh.v.LH)
343 void prune_movements_(integer l)
346 while (down_ptr != 0) { /* while down_ptr<>null do l.12206 */
347 if (mem[down_ptr + 2].cint < l)
350 down_ptr = mem[p].hh.v.RH;
354 while (right_ptr != 0) { /* done: while right_ptr<>null do */
355 if (mem[right_ptr + 2].cint < l)
358 right_ptr = mem[p].hh.v.RH;
362 /* following needs access to dvi_buf=zdvibuf see coerce.h */
363 void special_out_(halfword p)
369 movement(cur_h - dvi_h, 143); /* 143 == right1 */
374 movement(cur_v - dvi_v, 157); /* 157 == down1 */
377 old_setting = selector;
379 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
380 /* About output \special{...} make some space in string pool 97/Mar/9 */
381 #ifdef ALLOCATESTRING
382 if (pool_ptr + 32000 > current_pool_size)
383 str_pool = realloc_str_pool (increment_pool_size);
384 /* We don't bother to check whether this worked - will catch later */
386 /* Potential problem here if current_pool_size is not much more than pool_ptr! */
387 /* Fixed 97/Mar/9 in version 2.0.3 */
388 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
389 #ifdef ALLOCATESTRING
390 /* show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
391 current_pool_size - pool_ptr); */
392 show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0, 10000000L);
393 /* Above is safe, since print/print_char/print_esc will extend string space */
395 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
396 show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
397 pool_size - pool_ptr);
400 selector = old_setting;
402 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
403 /* str_room(1) - is there space for one more character in string pool ? */
404 #ifdef ALLOCATESTRING
405 if (pool_ptr + 1 > current_pool_size)
406 str_pool = realloc_str_pool (increment_pool_size);
407 if (pool_ptr + 1 > current_pool_size) { /* in case it failed 94/Jan/24 */
408 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
409 return; // abort_flag set
412 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
413 if (pool_ptr + 1 > pool_size){
414 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
415 return; // abort_flag set
419 if (cur_length < 256) /* can use xxx1 ? */
422 /* long to unsigned char ... */
424 } else { /* use xxx4 instead */
426 dvi_four(cur_length);
430 /* debugging code for \special{src: ... } 98/Nov/11 */
432 int k = str_start[str_ptr];
435 if (str_pool [k] == 's' &&
436 str_pool [k+1] == 'r' &&
437 str_pool [k+2] == 'c' &&
438 str_pool [k+3] == ':') { /* \special{src: ... } */
442 *s++ = str_pool[k++];
446 show_line(log_line, 0)
450 if (cur_input.name_field > 17) { /* redundant ? */
451 print(cur_input.name_field);
453 print_int(line); /* line number */
466 register integer for_end;
467 k = str_start[str_ptr];
468 for_end = pool_ptr - 1;
470 dvi_out(str_pool[k]);
471 while(k++ < for_end);
473 pool_ptr = str_start[str_ptr];
475 /* noew returns -1 if it fails */
476 void write_out_(halfword p)
479 /* integer oldmode; */
480 int oldmode; /* 1995/Jan/7 */
481 /* small_number j; */
482 int j; /* 1995/Jan/7 */
484 /* q:=get_avail; info(q):=right_brace_token+"}";@/ */
487 /* r:=get_avail; link(q):=r; info(r):=end_write_token; ins_list(q);@/ */
488 /* @d end_write_token==cs_token_flag+end_write */
491 /* mem[r].hh.v.LH = (hash_size + 4617); */
492 /* mem[r].hh.v.LH = (hash_size + 4095 + 522); */
493 info(r) = (hash_size + hash_extra + 4095 + 522);
494 begin_token_list(q, 4);
495 begin_token_list(mem[p + 1].hh.v.RH, 15);
497 mem[q].hh.v.LH = 379;
498 begin_token_list(q, 4);
502 q = scan_toks(false, true);
504 /* if (cur_tok != (hash_size + 4617)) */
505 /* if (cur_tok != (hash_size + 4095 + 522)) */
506 if (cur_tok != (hash_size + hash_extra + 4095 + 522))
508 print_err("Unbalanced write command");
509 help2("On this page there's a \\write with fewer real {'s than }'s.",
510 "I can't handle that very well; good luck.");
514 /* } while(!(cur_tok == (hash_size + 4617))); */
515 /* } while(!(cur_tok == (hash_size + 4095 + 522))); */
516 } while(!(cur_tok == (hash_size + hash_extra + 4095 + 522))); /*1996/Jan/10*/
520 old_setting = selector;
521 j = mem[p + 1].hh.v.LH;
522 if (write_open[j])selector = j;
524 if ((j == 17)&&(selector == 19))
531 selector = old_setting;
533 void out_what_(halfword p)
535 /* small_number j; */
536 int j; /* 1995/Jan/7 */
541 if (!doing_leaders) {
542 j = mem[p + 1].hh.v.LH;
543 if (mem[p].hh.b1 == 1){
547 (void) a_close(write_file[j]);
548 if (mem[p].hh.b1 == 2)
549 write_open[j]= false;
551 cur_name = mem[p + 1].hh.v.RH;
552 cur_area = mem[p + 2].hh.v.LH;
553 cur_ext = mem[p + 2].hh.v.RH;
554 if (cur_ext == 335) /* "" */
555 cur_ext = 785; /* => ".tex" */
556 pack_file_name(cur_name, cur_area, cur_ext);
557 while(! a_open_out(write_file[j])) {
558 prompt_file_name(1294, 785); /* output file name .tex */
574 return; // abort_flag set
579 /* following needs access to dvi_buf=zdvibuf see coerce.h */
580 void hlist_out (void)
586 /* glue_ord gorder; */
587 int gorder; /* 95/Jan/7 */
589 int gsign; /* 95/Jan/7 */
595 bool outerdoingleaders;
597 /* ********************************************************************* */
598 real gluetemp; /* new in 3.14159 */
599 /* ********************************************************************* */
601 gorder = mem[thisbox + 5].hh.b1;
602 gsign = mem[thisbox + 5].hh.b0;
603 p = mem[thisbox + 5].hh.v.RH;
607 if (cur_s > max_push)
609 saveloc = dvi_offset + dvi_ptr;
612 /* while p<>null do l.12314 */
614 lab21: if ((p >= hi_mem_min))
618 movement(cur_h - dvi_h, 143); /* 143 == right1 */
623 movement(cur_v - dvi_v, 157); /* 157 == down1 */
637 dvi_out(f + 170); /* fnt_num_0 --- fnt_num_63 */
638 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
640 else if (f <= 256){ /* if we allow greater than 256 fonts */
642 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
643 else { /* normal TeX 82 case */
645 dvi_out(235); /* fnt1 followed by f */
648 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
650 else { /* fnt2 followed by f / 256, f % 256 */
652 dvi_out(((f - 1) >> 8)); /* top byte */
653 dvi_out(((f - 1) & 255)); /* bottom byte */
656 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
662 cur_h = cur_h + font_info[width_base[f] + font_info[char_base[f] + c].qqqq.b0].cint;
664 } while(!(!(p >= hi_mem_min)));
670 /* if list_ptr(p)=null then cur_h:=cur_h+width(p) l.12371 */
671 if (mem[p + 5].hh.v.RH == 0)
672 cur_h = cur_h + mem[p + 1].cint;
677 cur_v = baseline + mem[p + 4].cint;
680 if (mem[p].hh.b0 == 1)vlist_out();
684 cur_h = edge + mem[p + 1].cint;
690 rule_ht = mem[p + 3].cint;
691 rule_dp = mem[p + 2].cint;
692 rule_wd = mem[p + 1].cint;
701 g = mem[p + 1].hh.v.LH;
702 rule_wd = mem[g + 1].cint;
707 if (mem[g].hh.b0 == gorder)
708 /* *********************************************************************** */
709 /* rule_wd = rule_wd + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
710 /* ******************** 3.14159 ******************************************* */
712 gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
713 if (gluetemp > 1000000000.0)
714 gluetemp = 1000000000.0;
715 else if (gluetemp < -1000000000.0)
716 gluetemp = -1000000000.0;
717 rule_wd = rule_wd + round(gluetemp);
719 /* ************************************************************************* */
722 /* if (mem[g].hh.b1 == gorder)*/
723 /* rule_wd = rule_wd - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
725 /* ******************** 3.14159 ******************************************* */
726 else if (mem[g].hh.b1 == gorder)
728 gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
729 if (gluetemp > 1000000000.0)
730 gluetemp = 1000000000.0;
731 else if (gluetemp < -1000000000.0)
732 gluetemp = -1000000000.0;
733 rule_wd = rule_wd - round(gluetemp);
735 /* ************************************************************************* */
737 if (mem[p].hh.b1 >= 100)
739 leaderbox = mem[p + 1].hh.v.RH;
740 if (mem[leaderbox].hh.b0 == 2)
742 rule_ht = mem[leaderbox + 3].cint;
743 rule_dp = mem[leaderbox + 2].cint;
746 leaderwd = mem[leaderbox + 1].cint;
747 if ((leaderwd > 0)&&(rule_wd > 0))
749 rule_wd = rule_wd + 10;
750 edge = cur_h + rule_wd;
752 if (mem[p].hh.b1 == 100)
755 cur_h = leftedge + leaderwd *((cur_h - leftedge)/ leaderwd)
758 cur_h = cur_h + leaderwd;
762 lq = rule_wd / leaderwd;
763 lr = rule_wd % leaderwd;
764 if (mem[p].hh.b1 == 101)
765 cur_h = cur_h +(lr / 2);
768 lx =(2 * lr + lq + 1)/(2 * lq + 2);
769 cur_h = cur_h +((lr -(lq - 1)* lx)/ 2);
772 while(cur_h + leaderwd <= edge){
774 cur_v = baseline + mem[leaderbox + 4].cint;
777 movement(cur_v - dvi_v, 157); /* 157 == down1 */
783 movement(cur_h - dvi_h, 143); /* 143 == right1 */
787 temp_ptr = leaderbox;
788 outerdoingleaders = doing_leaders;
789 doing_leaders = true;
790 if (mem[leaderbox].hh.b0 == 1)vlist_out();
792 doing_leaders = outerdoingleaders;
795 /* ****************************************************************** */
797 cur_v = baseline; /* changed in 3.1415 */
798 /* ****************************************************************** */
799 cur_h = saveh + leaderwd + lx;
810 cur_h = cur_h + mem[p + 1].cint;
814 mem[lig_trick]= mem[p + 1];
815 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
825 lab14: if ((rule_ht == -1073741824L)) /* - 2^30 */
826 rule_ht = mem[thisbox + 3].cint;
827 if ((rule_dp == -1073741824L)) /* - 2^30 */
828 rule_dp = mem[thisbox + 2].cint;
829 rule_ht = rule_ht + rule_dp;
830 if ((rule_ht > 0)&&(rule_wd > 0))
834 movement(cur_h - dvi_h, 143); /* 143 == right1 */
837 cur_v = baseline + rule_dp;
840 movement(cur_v - dvi_v, 157); /* 157 == down1 */
847 dvi_h = dvi_h + rule_wd;
849 lab13: cur_h = cur_h + rule_wd;
850 lab15: p = mem[p].hh.v.RH;
852 prune_movements(saveloc);
857 /* following needs access to dvi_buf=zdvibuf see coerce.h */
858 void vlist_out (void)
864 /* glue_ord gorder; */
865 int gorder; /* 95/Jan/7 */
867 int gsign; /* 95/Jan/7 */
873 bool outerdoingleaders;
875 /* ************************************************************************ */
876 real gluetemp; /* new in 3.14159 */
877 /* ************************************************************************ */
879 gorder = mem[thisbox + 5].hh.b1;
880 gsign = mem[thisbox + 5].hh.b0;
881 p = mem[thisbox + 5].hh.v.RH;
885 if (cur_s > max_push)
887 saveloc = dvi_offset + dvi_ptr;
889 cur_v = cur_v - mem[thisbox + 3].cint;
891 while(p != 0){ /* while p<>null do l.12494 OK */
892 if ((p >= hi_mem_min)) {
893 confusion("vlistout");
894 return; // abort_flag set
900 /* if list_ptr(p)=null then cur_v:=cur_v+height(p)+depth(p) l.12529 */
901 if (mem[p + 5].hh.v.RH == 0)
902 cur_v = cur_v + mem[p + 3].cint + mem[p + 2].cint;
905 cur_v = cur_v + mem[p + 3].cint;
908 movement(cur_v - dvi_v, 157); /* 157 == down1 */
913 cur_h = leftedge + mem[p + 4].cint;
915 if (mem[p].hh.b0 == 1)vlist_out();
919 cur_v = savev + mem[p + 2].cint;
925 rule_ht = mem[p + 3].cint;
926 rule_dp = mem[p + 2].cint;
927 rule_wd = mem[p + 1].cint;
936 g = mem[p + 1].hh.v.LH;
937 rule_ht = mem[g + 1].cint;
942 if (mem[g].hh.b0 == gorder)
943 /* ************************************************************************ */
944 /* rule_ht = rule_ht + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
945 /* ************************ 3.14159 **************************************** */
947 gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
948 if (gluetemp > 1000000000.0)
949 gluetemp = 1000000000.0;
950 else if (gluetemp < -1000000000.0)
951 gluetemp = -1000000000.0;
952 rule_ht = rule_ht + round(gluetemp);
954 /* ************************************************************************* */
956 /* ************************************************************************* */
958 /* if (mem[g].hh.b1 == gorder) */
959 /* rule_ht = rule_ht - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
961 else if (mem[g].hh.b1 == gorder) /* BUG FIX !!! */
963 gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
964 if (gluetemp > 1000000000.0)
965 gluetemp = 1000000000.0;
966 else if (gluetemp < -1000000000.0)
967 gluetemp = -1000000000.0;
968 rule_ht = rule_ht - round(gluetemp);
970 /* ************************************************************************* */
972 if (mem[p].hh.b1 >= 100)
974 leaderbox = mem[p + 1].hh.v.RH;
975 if (mem[leaderbox].hh.b0 == 2)
977 rule_wd = mem[leaderbox + 1].cint;
981 leaderht = mem[leaderbox + 3].cint + mem[leaderbox + 2]
983 if ((leaderht > 0)&&(rule_ht > 0))
985 rule_ht = rule_ht + 10;
986 edge = cur_v + rule_ht;
988 if (mem[p].hh.b1 == 100)
991 cur_v = topedge + leaderht *((cur_v - topedge)/ leaderht)
994 cur_v = cur_v + leaderht;
998 lq = rule_ht / leaderht;
999 lr = rule_ht % leaderht;
1000 if (mem[p].hh.b1 == 101)
1001 cur_v = cur_v +(lr / 2);
1004 lx =(2 * lr + lq + 1)/(2 * lq + 2);
1005 cur_v = cur_v +((lr -(lq - 1)* lx)/ 2);
1008 while(cur_v + leaderht <= edge){
1010 cur_h = leftedge + mem[leaderbox + 4].cint;
1013 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1017 cur_v = cur_v + mem[leaderbox + 3].cint;
1020 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1024 temp_ptr = leaderbox;
1025 outerdoingleaders = doing_leaders;
1026 doing_leaders = true;
1027 if (mem[leaderbox].hh.b0 == 1)vlist_out();
1029 doing_leaders = outerdoingleaders;
1032 /* ************************************************************************ */
1033 /* cur_h = saveh; */
1034 cur_h = leftedge; /* 3.1415 */
1035 /* ************************************************************************ */
1036 cur_v = savev - mem[leaderbox + 3].cint + leaderht + lx;
1046 cur_v = cur_v + mem[p + 1].cint;
1053 lab14: if ((rule_wd == -1073741824L)) /* -2^30 */
1054 rule_wd = mem[thisbox + 1].cint;
1055 rule_ht = rule_ht + rule_dp;
1056 cur_v = cur_v + rule_ht;
1057 if ((rule_ht > 0)&&(rule_wd > 0))
1061 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1066 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1074 lab13: cur_v = cur_v + rule_ht;
1076 lab15: p = mem[p].hh.v.RH;
1078 prune_movements(saveloc);
1083 /****************HPDF******************/
1085 void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
1087 printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
1090 /****************HPDF******************/
1092 /* following needs access to dvi_buf=zdvibuf see coerce.h */
1093 void ship_out_(halfword p)
1099 if (tracing_output > 0) {
1102 print_string("Completed box being shipped out");
1104 if (term_offset > max_print_line - 9)
1106 else if ((term_offset > 0)||(file_offset > 0))
1110 while((eqtb[(hash_size + 3218) + j].cint == 0) && (j > 0))
1113 register integer for_end;
1116 if (k <= for_end) do
1118 print_int(eqtb[(hash_size + 3218) + k].cint);
1121 } while(k++ < for_end);
1126 if (tracing_output > 0)
1131 end_diagnostic(true);
1133 if ((mem[p + 3].cint > 1073741823L)|| /* 2^30 - 1 */
1134 (mem[p + 2].cint > 1073741823L)||
1135 (mem[p + 3].cint + mem[p + 2].cint +
1136 v_offset > 1073741823L)||
1137 (mem[p + 1].cint + h_offset > 1073741823L))
1139 print_err("Huge page cannot be shipped out");
1140 help2("The page just created is more than 18 feet tall or",
1141 "more than 18 feet wide, so I suspect something went wrong.");
1143 if (tracing_output <= 0)
1146 print_nl("The following box has been deleted:");
1148 end_diagnostic(true);
1152 if (mem[p + 3].cint + mem[p + 2].cint + v_offset > max_v
1154 max_v = mem[p + 3].cint + mem[p + 2].cint + v_offset;
1155 if (mem[p + 1].cint + h_offset > max_h)
1156 max_h = mem[p + 1].cint + h_offset;
1161 if (output_file_name == 0)
1163 if (job_name == 0)open_log_file();
1164 pack_job_name(788); /* .dvi */
1165 while(! b_open_out(dvi_file)) {
1166 prompt_file_name(789, 788); /* file name for output .dvi */
1168 output_file_name = b_make_name_string(dvi_file);
1171 if (total_pages == 0)
1175 /********BINDING WITH LIBHARU*********/
1177 yandy_pdf = HPDF_New(error_handler, NULL);
1178 yandy_page = HPDF_AddPage(yandy_pdf);
1179 HPDF_SetInfoAttr(yandy_pdf, HPDF_INFO_PRODUCER, "Y&Y TeX with ApTeX");
1180 HPDF_SetCompressionMode (yandy_pdf, HPDF_COMP_ALL);
1181 HPDF_Page_SetSize (yandy_page, HPDF_PAGE_SIZE_A5, HPDF_PAGE_PORTRAIT);
1182 yandy_font = HPDF_GetFont (yandy_pdf, "Times-Roman", NULL);
1183 HPDF_Page_BeginText (yandy_page);
1184 HPDF_Page_SetFontAndSize (yandy_page, yandy_font, 16);
1185 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-90, "This is the \xAErst page.");
1186 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-180, "Wait for ...");
1187 HPDF_Page_EndText (yandy_page);
1188 HPDF_SaveToFile (yandy_pdf, "NOTICE.pdf");
1189 HPDF_Free(yandy_pdf);
1191 /********BINDING WITH LIBHARU*********/
1192 dvi_four(25400000L); /* magic DVI scale factor */
1193 dvi_four(473628672L); /* 7227 * 65536 */
1196 old_setting = selector;
1198 print_string(" TeX output ");
1205 print_two(tex_time / 60);
1206 print_two(tex_time % 60);
1207 selector = old_setting;
1208 /* long to unsigned char ... */
1209 dvi_out(cur_length);
1211 register integer for_end;
1212 s = str_start[str_ptr];
1213 for_end = pool_ptr - 1;
1214 if (s <= for_end) do
1215 dvi_out(str_pool[s]);
1216 while(s++ < for_end);
1218 pool_ptr = str_start[str_ptr];
1219 } // end of if total_pages == 0
1221 pageloc = dvi_offset + dvi_ptr;
1224 register integer for_end;
1227 if (k <= for_end) do
1228 dvi_four(eqtb[(hash_size + 3218) + k].cint);
1229 while(k++ < for_end);
1233 cur_v = mem[p + 3].cint + v_offset;
1235 if (mem[p].hh.b0 == 1)vlist_out();
1241 if (tracing_output <= 0)
1249 if (tracing_stats > 1)
1251 print_nl("Memory usage before: ");
1252 print_int(var_used);
1254 print_int(dyn_used);
1261 if (tracing_stats > 1)
1263 print_string("after");
1264 print_int(var_used);
1266 print_int(dyn_used);
1267 print_string("still utouched");
1268 print_int(hi_mem_min - lo_mem_max - 1); /* somewhat inaccurate free mem */
1273 void scan_spec_(group_code c, bool threecodes)
1278 s = save_stack[save_ptr + 0].cint;
1279 if (scan_keyword("to")) /* to */
1281 else if (scan_keyword("spread")) /* spread */
1288 scan_dimen(false, false, false);
1289 lab40: if (threecodes)
1291 save_stack[save_ptr + 0].cint = s; /* s may be used without ... */
1294 save_stack[save_ptr + 0].cint = speccode;
1295 save_stack[save_ptr + 1].cint = cur_val;
1296 save_ptr = save_ptr + 2;
1300 halfword hpack_(halfword p, scaled w, small_number m)
1301 {/* 21 50 10 */ register halfword Result;
1308 int o; /* 95/Jan/7 */
1309 internal_font_number f;
1316 mem[r + 4].cint = 0;
1330 while (p != 0) { /* while p<>null do l.12862 */
1332 while ((p >= hi_mem_min)) {
1334 i = font_info[char_base[f]+ mem[p].hh.b1].qqqq;
1336 x = x + font_info[width_base[f]+ i.b0].cint;
1337 s = font_info[height_base[f]+(hd)/ 16].cint;
1340 s = font_info[depth_base[f]+(hd)% 16].cint;
1345 if (p != 0) /* if p<>null then l.12886 */
1347 switch (mem[p].hh.b0)
1354 x = x + mem[p + 1].cint;
1355 if (mem[p].hh.b0 >= 2)
1358 s = mem[p + 4].cint;
1359 if (mem[p + 3].cint - s > h)
1360 h = mem[p + 3].cint - s;
1361 if (mem[p + 2].cint + s > d)
1362 d = mem[p + 2].cint + s;
1368 /* if adjust_tail<>null then link(adjust_tail):=null; l.12865 / 12891 */
1369 if (adjust_tail != 0)
1371 while (mem[q].hh.v.RH != p)
1373 if (mem[p].hh.b0 == 5) {
1374 mem[adjust_tail].hh.v.RH = mem[p + 1].cint;
1375 while (mem[adjust_tail].hh.v.RH != 0)
1376 adjust_tail = mem[adjust_tail].hh.v.RH;
1378 free_node(mem[q].hh.v.RH, 2);
1380 mem[adjust_tail].hh.v.RH = p;
1393 g = mem[p + 1].hh.v.LH;
1394 x = x + mem[g + 1].cint;
1396 totalstretch[o]= totalstretch[o]+ mem[g + 2].cint;
1398 totalshrink[o]= totalshrink[o]+ mem[g + 3].cint;
1399 if (mem[p].hh.b1 >= 100) {
1400 g = mem[p + 1].hh.v.RH;
1401 if (mem[g + 3].cint > h)
1402 h = mem[g + 3].cint;
1403 if (mem[g + 2].cint > d)
1404 d = mem[g + 2].cint;
1410 x = x + mem[p + 1].cint;
1414 mem[lig_trick]= mem[p + 1];
1415 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1427 if (adjust_tail != 0)
1428 mem[adjust_tail].hh.v.RH = 0;
1429 mem[r + 3].cint = h;
1430 mem[r + 2].cint = d;
1433 mem[r + 1].cint = w;
1436 mem[r + 5].hh.b0 = 0;
1437 mem[r + 5].hh.b1 = 0;
1438 mem[r + 6].gr = 0.0;
1441 if (totalstretch[3] != 0)
1443 else if (totalstretch[2] != 0)
1445 else if (totalstretch[1] != 0)
1449 mem[r + 5].hh.b1 = o;
1450 mem[r + 5].hh.b0 = 1;
1451 /* if total_stretch[o]<>0 then glue_set(r):=... l.12982 */
1452 if (totalstretch[o]!= 0)
1453 mem[r + 6].gr = x / ((double) totalstretch[o]);
1455 mem[r + 5].hh.b0 = 0;
1456 mem[r + 6].gr = 0.0;
1458 /* if o=normal then if list_ptr(r)<>null then l.12987 */
1460 if (mem[r + 5].hh.v.RH != 0)
1462 last_badness = badness(x, totalstretch[0]);
1463 if (last_badness > hbadness) {
1465 if (last_badness > 100)
1466 print_nl("Underfull");
1469 print_string(" \\hbox (badness ");
1470 print_int(last_badness);
1471 if (last_badness > 100)
1472 underfull_hbox++; /* 1996/Feb/9 */
1478 if (totalshrink[3] != 0)
1480 else if (totalshrink[2] != 0)
1482 else if (totalshrink[1] != 0)
1486 mem[r + 5].hh.b1 = o;
1487 mem[r + 5].hh.b0 = 2;
1488 if (totalshrink[o] != 0)
1489 mem[r + 6].gr =(- (integer) x) / ((double) totalshrink[o]);
1491 mem[r + 5].hh.b0 = 0;
1492 mem[r + 6].gr = 0.0;
1494 /* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13946 */
1495 if ((totalshrink[o]< - (integer) x) && (o == 0) && (mem[r + 5].hh.v.RH != 0)) {
1496 last_badness = 1000000L;
1497 /* set_glue_ratio_one(glue_set(r)); {use the maximum shrinkage} */
1498 mem[r + 6].gr = 1.0;
1499 /* if (-x-total_shrink[normal]>hfuzz)or(hbadness<100) then */
1500 if ((- (integer) x - totalshrink[0] > hfuzz) ||
1502 if ((overfull_rule > 0) &&
1503 (- (integer) x - totalshrink[0] > hfuzz)) {
1504 while(mem[q].hh.v.RH != 0)q = mem[q].hh.v.RH;
1505 mem[q].hh.v.RH = new_rule();
1506 mem[mem[q].hh.v.RH + 1].cint = overfull_rule;
1509 print_nl("Overfull \\hbox(");
1510 print_scaled(- (integer) x - totalshrink[0]);
1511 print_string("pt too wide");
1512 overfull_hbox++; /* 1996/Feb/9 */
1516 if (mem[r + 5].hh.v.RH != 0) {
1517 last_badness = badness(- (integer) x, totalshrink[0]);
1518 if (last_badness > hbadness) {
1520 print_nl("Tight \\hbox (badness ");
1521 print_int(last_badness);
1529 print_string(") has occurred while \\output is active");
1531 if (pack_begin_line != 0) {
1532 if (pack_begin_line > 0)
1533 print_string(") in paragraph at lines ");
1535 print_string(") in alignment at lines ");
1536 print_int(abs(pack_begin_line));
1538 } else print_string(")detected at line ");
1542 font_in_short_display = 0;
1543 short_display(mem[r + 5].hh.v.RH);
1547 end_diagnostic(true);
1552 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
1554 register halfword Result;
1560 int o; /* 95/Jan/7 */
1565 mem[r + 4].cint = 0;
1566 mem[r + 5].hh.v.RH = p;
1570 totalstretch[0] = 0;
1572 totalstretch[1] = 0;
1574 totalstretch[2] = 0;
1576 totalstretch[3] = 0;
1579 if ((p >= hi_mem_min)) {
1581 return 0; // abort_flag set
1582 } else switch (mem[p].hh.b0)
1589 x = x + d + mem[p + 3].cint;
1590 d = mem[p + 2].cint;
1591 if (mem[p].hh.b0 >= 2)
1593 else s = mem[p + 4].cint;
1594 if (mem[p + 1].cint + s > w)
1595 w = mem[p + 1].cint + s;
1605 g = mem[p + 1].hh.v.LH;
1606 x = x + mem[g + 1].cint;
1608 totalstretch[o] = totalstretch[o]+ mem[g + 2].cint;
1610 totalshrink[o]= totalshrink[o]+ mem[g + 3].cint;
1611 if (mem[p].hh.b1 >= 100) {
1612 g = mem[p + 1].hh.v.RH;
1613 if (mem[g + 1].cint > w)
1614 w = mem[g + 1].cint;
1620 x = x + d + mem[p + 1].cint;
1630 mem[r + 1].cint = w;
1633 mem[r + 2].cint = l;
1634 } else mem[r + 2].cint = d;
1637 mem[r + 3].cint = h;
1640 mem[r + 5].hh.b0 = 0;
1641 mem[r + 5].hh.b1 = 0;
1642 mem[r + 6].gr = 0.0;
1645 if (totalstretch[3] != 0)
1647 else if (totalstretch[2]!= 0)
1649 else if (totalstretch[1]!= 0)
1653 mem[r + 5].hh.b1 = o;
1654 mem[r + 5].hh.b0 = 1;
1655 if (totalstretch[o] != 0)
1656 mem[r + 6].gr = x / ((double) totalstretch[o]);
1658 mem[r + 5].hh.b0 = 0;
1659 mem[r + 6].gr = 0.0;
1662 if (mem[r + 5].hh.v.RH != 0) {
1663 last_badness = badness(x, totalstretch[0]);
1664 if (last_badness > vbadness) {
1666 if (last_badness > 100)
1667 print_nl("Underfull");
1670 print_string(" \\vbox (badness ");
1671 print_int(last_badness);
1672 if (last_badness > 100)
1673 underfull_vbox++; /* 1996/Feb/9 */
1679 if (totalshrink[3] != 0)
1681 else if (totalshrink[2] != 0)
1683 else if (totalshrink[1]!= 0)
1687 mem[r + 5].hh.b1 = o;
1688 mem[r + 5].hh.b0 = 2;
1689 if (totalshrink[o]!= 0)
1690 mem[r + 6].gr =(- (integer) x)/ ((double) totalshrink[o]);
1692 mem[r + 5].hh.b0 = 0;
1693 mem[r + 6].gr = 0.0;
1695 /* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13046 */
1696 if ((totalshrink[o] < - (integer) x) && (o == 0) && (mem[r + 5].hh.v.RH != 0)) {
1697 last_badness = 1000000L;
1698 mem[r + 6].gr = 1.0;
1699 if ((- (integer) x - totalshrink[0] > eqtb[(hash_size + 3739)].cint) ||
1702 print_nl("Overfull \\vbox(");
1703 print_scaled(- (integer) x - totalshrink[0]);
1704 print_string("pt too high");
1705 overfull_vbox++; /* 1996/Feb/9 */
1709 /* else if o=normal then if list_ptr(r)<>null then l.13052 */
1711 if (mem[r + 5].hh.v.RH != 0) {
1712 last_badness = badness(- (integer) x, totalshrink[0]);
1713 if (last_badness > vbadness) {
1715 print_nl("Tight \\vbox (badness ");
1716 print_int(last_badness);
1724 print_string(") has occurred while \\output is active");
1726 if (pack_begin_line != 0) {
1727 print_string(") in alignment at lines ");
1728 print_int(abs(pack_begin_line));
1730 } else print_string(")detected at line ");
1736 end_diagnostic(true);
1741 void append_to_vlist_(halfword b)
1745 if (cur_list.aux_field.cint > ignore_depth) {
1746 d = mem[eqtb[(hash_size + 783)].hh.v.RH + 1].cint - cur_list.aux_field.cint - mem[b + 3].cint;
1747 if (d < line_skip_limit)
1748 p = new_param_glue(0);
1750 p = new_skip_param(1);
1751 mem[temp_ptr + 1].cint = d;
1753 mem[tail].hh.v.RH = p;
1756 mem[tail].hh.v.RH = b;
1758 cur_list.aux_field.cint = mem[b + 2].cint;
1760 halfword new_noad (void)
1762 register halfword Result;
1767 mem[p + 1].hh = empty_field;
1768 mem[p + 3].hh = empty_field;
1769 mem[p + 2].hh = empty_field;
1773 halfword new_style_(small_number s)
1775 register halfword Result;
1780 mem[p + 1].cint = 0;
1781 mem[p + 2].cint = 0;
1785 halfword new_choice (void)
1787 register halfword Result;
1792 mem[p + 1].hh.v.LH = 0;
1793 mem[p + 1].hh.v.RH = 0;
1794 mem[p + 2].hh.v.LH = 0;
1795 mem[p + 2].hh.v.RH = 0;
1799 void show_info (void)
1801 show_node_list(mem[temp_ptr].hh.v.LH);
1803 halfword fraction_rule_(scaled t)
1805 register halfword Result;
1808 mem[p + 3].cint = t;
1809 mem[p + 2].cint = 0;
1813 halfword overbar_(halfword b, scaled k, scaled t)
1815 register halfword Result;
1819 q = fraction_rule(t);
1823 Result = vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
1826 halfword char_box_(internal_font_number f, quarterword c)
1828 register halfword Result;
1832 q = font_info[char_base[f]+ c].qqqq;
1835 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
1836 mem[b + 3].cint = font_info[height_base[f]+(hd) / 16].cint;
1837 mem[b + 2].cint = font_info[depth_base[f]+(hd) % 16].cint;
1838 /* long to unsigned short ... */
1842 mem[b + 5].hh.v.RH = p;
1846 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
1850 mem[p].hh.v.RH = mem[b + 5].hh.v.RH;
1851 mem[b + 5].hh.v.RH = p;
1852 mem[b + 3].cint = mem[p + 3].cint;
1854 scaled height_plus_depth_(internal_font_number f, fquarterword c)
1856 register scaled Result;
1859 q = font_info[char_base[f]+ c].qqqq;
1861 Result = font_info[height_base[f]+(hd)/ 16].cint + font_info[depth_base[f]+(hd) % 16].cint;
1864 halfword var_delimiter_(halfword d, small_number s, scaled v)
1866 register halfword Result;
1868 internal_font_number f, g;
1869 quarterword c, x, y;
1876 /* small_number z; */
1877 int z; /* 95/Jan/7 */
1878 /* bool largeattempt; */
1879 int largeattempt; /* 95/Jan/7 */
1882 largeattempt = false;
1886 if ((z != 0) || (x != 0)) {
1890 g = eqtb[(hash_size + 1835) + z].hh.v.RH;
1893 if ((y >= font_bc[g]) && (y <= font_ec[g])) {
1895 q = font_info[char_base[g]+ y].qqqq;
1897 if (((q.b2) % 4) == 3) {
1903 u = font_info[height_base[g]+(hd)/ 16].cint + font_info[depth_base[g]+(hd)% 16].cint;
1911 if (((q.b2)% 4)== 2) {
1918 } while (!(z < 16));
1922 largeattempt = true;
1928 if (((q.b2) % 4)== 3) /* q may be used without ... */
1932 r = font_info[exten_base[f]+ q.b3].qqqq;
1934 u = height_plus_depth(f, c);
1936 q = font_info[char_base[f]+ c].qqqq;
1937 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
1940 w = w + height_plus_depth(f, c);
1943 w = w + height_plus_depth(f, c);
1946 w = w + height_plus_depth(f, c);
1957 stack_into_box(b, f, c);
1960 register integer for_end;
1963 if (m <= for_end) do
1964 stack_into_box(b, f, c);
1965 while (m++ < for_end);
1969 stack_into_box(b, f, c);
1972 register integer for_end;
1975 if (m <= for_end) do
1976 stack_into_box(b, f, c);
1977 while(m++ < for_end);
1982 stack_into_box(b, f, c);
1983 mem[b + 2].cint = w - mem[b + 3].cint;
1984 } else b = char_box(f, c);
1985 else { /* c may be used without ... */
1987 mem[b + 1].cint = null_delimiter_space;
1989 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;
1993 /* rebox_ etc used to follow here in tex4.c */