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 */
27 void char_warning_(internal_font_number f, eight_bits c)
29 if (tracing_lost_chars > 0)
31 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
32 if (show_missing == 0) /* show on screen 94/June/10 */
33 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
35 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
37 { /* add ! before 94/June/10 */
39 print_string("Missing character: there is no ");
42 print_nl("Missing character: there is no ");
44 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
46 { /* bkph 93/Dec/21 */
51 print_char(48 + c / 100);
53 c = c - (c / 100) * 100; /* ? */
54 print_char(48 + c / 10);
59 c = c - (c / 100) * 100; /* ? */
60 if (c / 10 > 0) print_char(48 + c / 10);
62 print_char(48 + c % 10);
66 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
67 print_string(" in font ");
68 slow_print(font_name[f]);
70 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
71 /* if (show_missing) show_context(); */ /* in tex2.c 94/June/10 */
74 if (f != 0) show_context(); /* not if its the nullfont */
76 if (show_missing == 0) /* show on screen 94/June/10 */
77 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
78 end_diagnostic(false);
79 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
80 missing_characters++; /* bkph 93/Dec/16 */
81 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
85 halfword new_character_(internal_font_number f, eight_bits c)
87 register halfword Result;
91 if ((font_info[char_base[f] + c].qqqq.b0 > 0))
99 char_warning(f, c); /* char_warning(f,c); l.11283 */
100 Result = 0; /* new_character:=null */
103 /* following needs access to dvi_buf=zdvibuf see coerce.h */
110 sprintf(log_line, "dvi_swap %d", dvi_gone);
111 show_line(log_line, 0);
114 if (dvi_limit == dvi_buf_size)
116 writedvi(0, half_buf - 1);
117 dvi_limit = half_buf;
118 dvi_offset = dvi_offset + dvi_buf_size;
123 writedvi(half_buf, dvi_buf_size - 1);
124 dvi_limit = dvi_buf_size;
126 dvi_gone = dvi_gone + half_buf;
128 /* following needs access to dvi_buf=zdvibuf see coerce.h */
129 /* attempt at speeding up bkph - is compiler smart ? */
131 void dvi_four_(integer x)
134 // dvi_out(x % 16777216L);
138 x = x + 1073741824L; /* 2^30 40000000 hex */
140 //dvi_out((x / 16777216L) + 128);
141 dvi_out((x >> 24) + 128);
143 /* x = x % 16777216L; */ /* % 2^24 */
145 //dvi_out(x / 65536L);
147 /* x = x % 65536L; */ /* % 2^16 */
154 /* following needs access to dvi_buf=zdvibuf see coerce.h */
156 void zdvipop(integer l)
158 if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
163 /* following needs access to dvi_buf=zdvibuf see coerce.h */
165 void dvi_font_def_(internal_font_number f)
168 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
178 dvi_out(((f - 1) >> 8));
179 dvi_out(((f - 1) & 255));
185 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
186 /* spit out the font checksum now */
187 dvi_out(font_check[f].b0);
188 dvi_out(font_check[f].b1);
189 dvi_out(font_check[f].b2);
190 dvi_out(font_check[f].b3);
191 dvi_four(font_size[f]);
192 dvi_four(font_dsize[f]);
193 dvi_out(length(font_area[f]));
194 dvi_out(length(font_name[f]));
196 for (k = str_start[font_area[f]]; k <= str_start[font_area[f]+ 1] - 1; k++)
197 dvi_out(str_pool[k]);
198 for (k = str_start[font_name[f]]; k <= str_start[font_name[f]+ 1] - 1; k++)
199 dvi_out(str_pool[k]);
201 /* following needs access to dvi_buf=zdvibuf see coerce.h */
203 void zmovement(scaled w, eight_bits o)
210 mem[q + 2].cint = dvi_offset + dvi_ptr;
211 if (o == 157) /* 157 == down1 */
213 mem[q].hh.v.RH = down_ptr;
217 { /* 143 == right1 */
218 mem[q].hh.v.RH = right_ptr;
223 while (p != 0) { /* while p<>null do l.12153 */
224 if (mem[p + 1].cint == w)
225 switch(mstate + mem[p].hh.v.LH)
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] + 5;
246 if (mem[p + 2].cint < dvi_gone)
250 k = mem[p + 2].cint - dvi_offset;
252 k = k + dvi_buf_size;
253 dvi_buf[k]= dvi_buf[k] + 10;
267 else switch (mstate + mem[p].hh.v.LH)
287 if (abs(w) >= 8388608L) /* 2^23 */
293 if (abs(w) >= 32768L)
297 w = w + 16777216L; /* 2^24 */
298 //dvi_out(w / 65536L);
300 /* w = w % 65536L; */
323 mem[q].hh.v.LH = mem[p].hh.v.LH;
324 if (mem[q].hh.v.LH == 1)
327 while (mem[q].hh.v.RH != p) {
329 switch (mem[q].hh.v.LH)
345 while (mem[q].hh.v.RH != p) {
347 switch (mem[q].hh.v.LH)
362 void prune_movements_(integer l)
365 while (down_ptr != 0)
367 if (mem[down_ptr + 2].cint < l)
370 down_ptr = mem[p].hh.v.RH;
374 while (right_ptr != 0)
376 if (mem[right_ptr + 2].cint < l)
379 right_ptr = mem[p].hh.v.RH;
383 /* following needs access to dvi_buf=zdvibuf see coerce.h */
385 void special_out_(halfword p)
392 movement(cur_h - dvi_h, 143); /* 143 == right1 */
398 movement(cur_v - dvi_v, 157); /* 157 == down1 */
401 old_setting = selector;
402 selector = new_string;
403 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
404 /* About output \special{...} make some space in string pool 97/Mar/9 */
405 #ifdef ALLOCATESTRING
406 if (pool_ptr + 32000 > current_pool_size)
407 str_pool = realloc_str_pool (increment_pool_size);
408 /* We don't bother to check whether this worked - will catch later */
410 /* Potential problem here if current_pool_size is not much more than pool_ptr! */
411 /* Fixed 97/Mar/9 in version 2.0.3 */
412 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
413 #ifdef ALLOCATESTRING
414 /* show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0,
415 current_pool_size - pool_ptr); */
416 show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0, 10000000L);
417 /* Above is safe, since print/print_char/print_esc will extend string space */
419 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
420 show_token_list(mem[mem[p + 1].hh.v.RH].hh.v.RH, 0, pool_size - pool_ptr);
422 selector = old_setting;
424 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
425 /* str_room(1) - is there space for one more character in string pool ? */
426 #ifdef ALLOCATESTRING
427 if (pool_ptr + 1 > current_pool_size)
428 str_pool = realloc_str_pool (increment_pool_size);
429 if (pool_ptr + 1 > current_pool_size)
430 { /* in case it failed 94/Jan/24 */
431 overflow("pool size", current_pool_size - init_pool_ptr); /* 97/Mar/7 */
432 return; // abort_flag set
435 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
436 if (pool_ptr + 1 > pool_size)
438 overflow("pool size", pool_size - init_pool_ptr); /* pool size */
439 return; // abort_flag set
443 if (cur_length < 256) /* can use xxx1 ? */
446 /* long to unsigned char ... */
448 } else { /* use xxx4 instead */
450 dvi_four(cur_length);
454 /* debugging code for \special{src: ... } 98/Nov/11 */
456 int k = str_start[str_ptr];
459 if (str_pool [k] == 's' &&
460 str_pool [k+1] == 'r' &&
461 str_pool [k+2] == 'c' &&
462 str_pool [k+3] == ':') { /* \special{src: ... } */
466 *s++ = str_pool[k++];
470 show_line(log_line, 0)
474 if (cur_input.name_field > 17) { /* redundant ? */
475 print(cur_input.name_field);
477 print_int(line); /* line number */
489 for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
490 dvi_out(str_pool[k]);
491 pool_ptr = str_start[str_ptr];
493 /* noew returns -1 if it fails */
495 void write_out_(halfword p)
498 /* integer oldmode; */
499 int oldmode; /* 1995/Jan/7 */
500 /* small_number j; */
501 int j; /* 1995/Jan/7 */
503 /* q:=get_avail; info(q):=right_brace_token+"}";@/ */
506 /* r:=get_avail; link(q):=r; info(r):=end_write_token; ins_list(q);@/ */
507 /* @d end_write_token==cs_token_flag+end_write */
510 /* mem[r].hh.v.LH = (hash_size + 4617); */
511 /* mem[r].hh.v.LH = (hash_size + 4095 + 522); */
512 info(r) = (hash_size + hash_extra + 4095 + 522);
513 begin_token_list(q, 4);
514 begin_token_list(mem[p + 1].hh.v.RH, 15);
516 mem[q].hh.v.LH = 379;
517 begin_token_list(q, 4);
521 q = scan_toks(false, true);
523 /* if (cur_tok != (hash_size + 4617)) */
524 /* if (cur_tok != (hash_size + 4095 + 522)) */
525 if (cur_tok != (hash_size + hash_extra + 4095 + 522))
527 print_err("Unbalanced write command");
528 help2("On this page there's a \\write with fewer real {'s than }'s.",
529 "I can't handle that very well; good luck.");
535 while(!(cur_tok == (hash_size + hash_extra + 4095 + 522))); /*1996/Jan/10*/
539 old_setting = selector;
540 j = mem[p + 1].hh.v.LH;
545 if ((j == 17) && (selector == 19))
552 selector = old_setting;
555 void out_what_(halfword p)
557 /* small_number j; */
558 int j; /* 1995/Jan/7 */
563 if (!doing_leaders) {
564 j = mem[p + 1].hh.v.LH;
565 if (mem[p].hh.b1 == 1){
569 (void) a_close(write_file[j]);
570 if (mem[p].hh.b1 == 2)
571 write_open[j]= false;
573 cur_name = mem[p + 1].hh.v.RH;
574 cur_area = mem[p + 2].hh.v.LH;
575 cur_ext = mem[p + 2].hh.v.RH;
576 if (cur_ext == 335) /* "" */
577 cur_ext = 785; /* => ".tex" */
578 pack_file_name(cur_name, cur_area, cur_ext);
579 while(! a_open_out(write_file[j])) {
580 prompt_file_name(1294, 785); /* output file name .tex */
596 return; // abort_flag set
601 /* following needs access to dvi_buf=zdvibuf see coerce.h */
603 void hlist_out (void)
609 /* glue_ord gorder; */
610 int gorder; /* 95/Jan/7 */
612 int gsign; /* 95/Jan/7 */
618 bool outerdoingleaders;
627 gorder = glue_order(thisbox);
628 gsign = glue_sign(thisbox);
629 p = list_ptr(thisbox);
633 if (cur_s > max_push)
635 saveloc = dvi_offset + dvi_ptr;
638 /* while p<>null do l.12314 */
645 movement(cur_h - dvi_h, 143); /* 143 == right1 */
650 movement(cur_v - dvi_v, 157); /* 157 == down1 */
665 dvi_out(f + 170); /* fnt_num_0 --- fnt_num_63 */
666 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
668 /* if we allow greater than 256 fonts */
671 dvi_out(235); /* fnt1 followed by f */
675 /* normal TeX 82 case */
678 dvi_out(235); /* fnt1 followed by f */
683 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
685 /* fnt2 followed by f / 256, f % 256 */
689 dvi_out(((f - 1) >> 8)); /* top byte */
690 dvi_out(((f - 1) & 255)); /* bottom byte */
693 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
699 cur_h = cur_h + font_info[width_base[f] + font_info[char_base[f] + c].qqqq.b0].cint;
701 } while(!(!(p >= hi_mem_min)));
710 if (list_ptr(p) == 0)
711 cur_h = cur_h + width(p);
716 cur_v = baseline + shift_amount(p);
719 if (type(p) == vlist_node)
725 cur_h = edge + width(p);
743 rule_wd = width(g) - cur_g;
746 if (gsign == stretching)
748 if (stretch_order(g) == gorder)
750 //gluetemp = glue_set(thisbox) * stretch(g);
751 cur_glue = cur_glue + stretch(g);
752 gluetemp = glue_set(thisbox) * cur_glue;
753 if (gluetemp > 1000000000.0)
754 gluetemp = 1000000000.0;
755 else if (gluetemp < -1000000000.0)
756 gluetemp = -1000000000.0;
757 cur_g = round(gluetemp);
758 //rule_wd = rule_wd + round(gluetemp);
761 else if (shrink_order(g) == gorder)
763 //gluetemp = glue_set(thisbox) * shrink(g);
764 cur_glue = cur_glue - shrink(g);
765 gluetemp = glue_set(thisbox) * cur_glue;
766 if (gluetemp > 1000000000.0)
767 gluetemp = 1000000000.0;
768 else if (gluetemp < -1000000000.0)
769 gluetemp = -1000000000.0;
770 cur_g = round(gluetemp);
771 //rule_wd = rule_wd - round(gluetemp);
774 rule_wd = rule_wd + cur_g;
775 if (subtype(p) >= a_leaders)
777 leaderbox = mem[p + 1].hh.v.RH;
778 if (mem[leaderbox].hh.b0 == 2)
780 rule_ht = mem[leaderbox + 3].cint;
781 rule_dp = mem[leaderbox + 2].cint;
784 leaderwd = mem[leaderbox + 1].cint;
785 if ((leaderwd > 0)&&(rule_wd > 0))
787 rule_wd = rule_wd + 10;
788 edge = cur_h + rule_wd;
790 if (mem[p].hh.b1 == 100)
793 cur_h = leftedge + leaderwd *((cur_h - leftedge)/ leaderwd)
796 cur_h = cur_h + leaderwd;
800 lq = rule_wd / leaderwd;
801 lr = rule_wd % leaderwd;
802 if (mem[p].hh.b1 == 101)
803 cur_h = cur_h +(lr / 2);
806 lx =(2 * lr + lq + 1)/(2 * lq + 2);
807 cur_h = cur_h +((lr -(lq - 1)* lx)/ 2);
810 while(cur_h + leaderwd <= edge){
812 cur_v = baseline + mem[leaderbox + 4].cint;
815 movement(cur_v - dvi_v, 157); /* 157 == down1 */
821 movement(cur_h - dvi_h, 143); /* 143 == right1 */
825 temp_ptr = leaderbox;
826 outerdoingleaders = doing_leaders;
827 doing_leaders = true;
828 if (mem[leaderbox].hh.b0 == 1)vlist_out();
830 doing_leaders = outerdoingleaders;
833 /* ****************************************************************** */
835 cur_v = baseline; /* changed in 3.1415 */
836 /* ****************************************************************** */
837 cur_h = saveh + leaderwd + lx;
848 cur_h = cur_h + mem[p + 1].cint;
852 mem[lig_trick]= mem[p + 1];
853 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
863 lab14: if ((rule_ht == -1073741824L)) /* - 2^30 */
864 rule_ht = mem[thisbox + 3].cint;
865 if ((rule_dp == -1073741824L)) /* - 2^30 */
866 rule_dp = mem[thisbox + 2].cint;
867 rule_ht = rule_ht + rule_dp;
868 if ((rule_ht > 0)&&(rule_wd > 0))
872 movement(cur_h - dvi_h, 143); /* 143 == right1 */
875 cur_v = baseline + rule_dp;
878 movement(cur_v - dvi_v, 157); /* 157 == down1 */
885 dvi_h = dvi_h + rule_wd;
887 lab13: cur_h = cur_h + rule_wd;
888 lab15: p = mem[p].hh.v.RH;
890 prune_movements(saveloc);
895 /* following needs access to dvi_buf=zdvibuf see coerce.h */
896 void vlist_out (void)
902 /* glue_ord gorder; */
903 int gorder; /* 95/Jan/7 */
905 int gsign; /* 95/Jan/7 */
911 bool outerdoingleaders;
913 /* ************************************************************************ */
914 real gluetemp; /* new in 3.14159 */
915 /* ************************************************************************ */
917 gorder = mem[thisbox + 5].hh.b1;
918 gsign = mem[thisbox + 5].hh.b0;
919 p = mem[thisbox + 5].hh.v.RH;
923 if (cur_s > max_push)
925 saveloc = dvi_offset + dvi_ptr;
927 cur_v = cur_v - mem[thisbox + 3].cint;
929 while(p != 0){ /* while p<>null do l.12494 OK */
930 if ((p >= hi_mem_min)) {
931 confusion("vlistout");
932 return; // abort_flag set
938 /* if list_ptr(p)=null then cur_v:=cur_v+height(p)+depth(p) l.12529 */
939 if (mem[p + 5].hh.v.RH == 0)
940 cur_v = cur_v + mem[p + 3].cint + mem[p + 2].cint;
943 cur_v = cur_v + mem[p + 3].cint;
946 movement(cur_v - dvi_v, 157); /* 157 == down1 */
951 cur_h = leftedge + mem[p + 4].cint;
953 if (mem[p].hh.b0 == 1)vlist_out();
957 cur_v = savev + mem[p + 2].cint;
963 rule_ht = mem[p + 3].cint;
964 rule_dp = mem[p + 2].cint;
965 rule_wd = mem[p + 1].cint;
974 g = mem[p + 1].hh.v.LH;
975 rule_ht = mem[g + 1].cint;
980 if (mem[g].hh.b0 == gorder)
981 /* ************************************************************************ */
982 /* rule_ht = rule_ht + round(mem[thisbox + 6].gr * mem[g + 2].cint); */
983 /* ************************ 3.14159 **************************************** */
985 gluetemp = mem[thisbox + 6].gr * mem[g + 2].cint;
986 if (gluetemp > 1000000000.0)
987 gluetemp = 1000000000.0;
988 else if (gluetemp < -1000000000.0)
989 gluetemp = -1000000000.0;
990 rule_ht = rule_ht + round(gluetemp);
992 /* ************************************************************************* */
994 /* ************************************************************************* */
996 /* if (mem[g].hh.b1 == gorder) */
997 /* rule_ht = rule_ht - round(mem[thisbox + 6].gr * mem[g + 3].cint); */
999 else if (mem[g].hh.b1 == gorder) /* BUG FIX !!! */
1001 gluetemp = mem[thisbox + 6].gr * mem[g + 3].cint;
1002 if (gluetemp > 1000000000.0)
1003 gluetemp = 1000000000.0;
1004 else if (gluetemp < -1000000000.0)
1005 gluetemp = -1000000000.0;
1006 rule_ht = rule_ht - round(gluetemp);
1008 /* ************************************************************************* */
1010 if (mem[p].hh.b1 >= 100)
1012 leaderbox = mem[p + 1].hh.v.RH;
1013 if (mem[leaderbox].hh.b0 == 2)
1015 rule_wd = mem[leaderbox + 1].cint;
1019 leaderht = mem[leaderbox + 3].cint + mem[leaderbox + 2]
1021 if ((leaderht > 0)&&(rule_ht > 0))
1023 rule_ht = rule_ht + 10;
1024 edge = cur_v + rule_ht;
1026 if (mem[p].hh.b1 == 100)
1029 cur_v = topedge + leaderht *((cur_v - topedge)/ leaderht)
1032 cur_v = cur_v + leaderht;
1036 lq = rule_ht / leaderht;
1037 lr = rule_ht % leaderht;
1038 if (mem[p].hh.b1 == 101)
1039 cur_v = cur_v +(lr / 2);
1042 lx =(2 * lr + lq + 1)/(2 * lq + 2);
1043 cur_v = cur_v +((lr -(lq - 1)* lx)/ 2);
1046 while(cur_v + leaderht <= edge){
1048 cur_h = leftedge + mem[leaderbox + 4].cint;
1051 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1055 cur_v = cur_v + mem[leaderbox + 3].cint;
1058 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1062 temp_ptr = leaderbox;
1063 outerdoingleaders = doing_leaders;
1064 doing_leaders = true;
1065 if (mem[leaderbox].hh.b0 == 1)vlist_out();
1067 doing_leaders = outerdoingleaders;
1070 /* ************************************************************************ */
1071 /* cur_h = saveh; */
1072 cur_h = leftedge; /* 3.1415 */
1073 /* ************************************************************************ */
1074 cur_v = savev - mem[leaderbox + 3].cint + leaderht + lx;
1084 cur_v = cur_v + mem[p + 1].cint;
1091 lab14: if ((rule_wd == -1073741824L)) /* -2^30 */
1092 rule_wd = mem[thisbox + 1].cint;
1093 rule_ht = rule_ht + rule_dp;
1094 cur_v = cur_v + rule_ht;
1095 if ((rule_ht > 0)&&(rule_wd > 0))
1099 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1104 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1112 lab13: cur_v = cur_v + rule_ht;
1114 lab15: p = mem[p].hh.v.RH;
1116 prune_movements(saveloc);
1121 /****************HPDF******************/
1123 void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
1125 printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
1128 /****************HPDF******************/
1130 /* following needs access to dvi_buf=zdvibuf see coerce.h */
1131 void ship_out_(halfword p)
1137 if (tracing_output > 0) {
1140 print_string("Completed box being shipped out");
1142 if (term_offset > max_print_line - 9)
1144 else if ((term_offset > 0)||(file_offset > 0))
1148 while((eqtb[(hash_size + 3218) + j].cint == 0) && (j > 0))
1151 register integer for_end;
1154 if (k <= for_end) do
1156 print_int(eqtb[(hash_size + 3218) + k].cint);
1159 } while(k++ < for_end);
1164 if (tracing_output > 0)
1169 end_diagnostic(true);
1171 if ((mem[p + 3].cint > 1073741823L) || /* 2^30 - 1 */
1172 (mem[p + 2].cint > 1073741823L) ||
1173 (mem[p + 3].cint + mem[p + 2].cint + v_offset > 1073741823L) ||
1174 (mem[p + 1].cint + h_offset > 1073741823L)) {
1175 print_err("Huge page cannot be shipped out");
1176 help2("The page just created is more than 18 feet tall or",
1177 "more than 18 feet wide, so I suspect something went wrong.");
1179 if (tracing_output <= 0) {
1181 print_nl("The following box has been deleted:");
1183 end_diagnostic(true);
1187 if (mem[p + 3].cint + mem[p + 2].cint + v_offset > max_v)
1188 max_v = mem[p + 3].cint + mem[p + 2].cint + v_offset;
1189 if (mem[p + 1].cint + h_offset > max_h)
1190 max_h = mem[p + 1].cint + h_offset;
1195 if (output_file_name == 0) {
1198 pack_job_name(788); /* .dvi */
1199 while(!b_open_out(dvi_file)) {
1200 prompt_file_name(789, 788); /* file name for output .dvi */
1202 output_file_name = b_make_name_string(dvi_file);
1205 if (total_pages == 0) {
1208 /********BINDING WITH LIBHARU*********/
1210 yandy_pdf = HPDF_New(error_handler, NULL);
1211 yandy_page = HPDF_AddPage(yandy_pdf);
1212 HPDF_SetInfoAttr(yandy_pdf, HPDF_INFO_PRODUCER, "Y&Y TeX with ApTeX");
1213 HPDF_SetCompressionMode (yandy_pdf, HPDF_COMP_ALL);
1214 HPDF_Page_SetSize (yandy_page, HPDF_PAGE_SIZE_A5, HPDF_PAGE_PORTRAIT);
1215 yandy_font = HPDF_GetFont (yandy_pdf, "Times-Roman", NULL);
1216 HPDF_Page_BeginText (yandy_page);
1217 HPDF_Page_SetFontAndSize (yandy_page, yandy_font, 16);
1218 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-90, "This is the \xAErst page.");
1219 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-180, "Wait for ...");
1220 HPDF_Page_EndText (yandy_page);
1221 HPDF_SaveToFile (yandy_pdf, "NOTICE.pdf");
1222 HPDF_Free(yandy_pdf);
1224 /********BINDING WITH LIBHARU*********/
1225 dvi_four(25400000L); /* magic DVI scale factor */
1226 dvi_four(473628672L); /* 7227 * 65536 */
1229 old_setting = selector;
1231 print_string(" TeX output ");
1238 print_two(tex_time / 60);
1239 print_two(tex_time % 60);
1240 selector = old_setting;
1241 /* long to unsigned char ... */
1242 dvi_out(cur_length);
1243 for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++) dvi_out(str_pool[s]);
1244 pool_ptr = str_start[str_ptr];
1245 } // end of if total_pages == 0
1247 pageloc = dvi_offset + dvi_ptr;
1249 for (k = 0; k <= 9; k++) dvi_four(eqtb[(hash_size + 3218) + k].cint);
1252 cur_v = mem[p + 3].cint + v_offset;
1254 if (mem[p].hh.b0 == 1)
1262 if (tracing_output <= 0)
1270 if (tracing_stats > 1) {
1271 print_nl("Memory usage before: ");
1272 print_int(var_used);
1274 print_int(dyn_used);
1281 if (tracing_stats > 1) {
1282 print_string("after");
1283 print_int(var_used);
1285 print_int(dyn_used);
1286 print_string("still utouched");
1287 print_int(hi_mem_min - lo_mem_max - 1); /* somewhat inaccurate free mem */
1292 void scan_spec_(group_code c, bool threecodes)
1297 s = save_stack[save_ptr + 0].cint;
1298 if (scan_keyword("to"))
1300 else if (scan_keyword("spread"))
1307 scan_dimen(false, false, false);
1310 save_stack[save_ptr + 0].cint = s; /* s may be used without ... */
1313 save_stack[save_ptr + 0].cint = speccode;
1314 save_stack[save_ptr + 1].cint = cur_val;
1315 save_ptr = save_ptr + 2;
1319 halfword hpack_(halfword p, scaled w, small_number m)
1321 register halfword Result;
1328 int o; /* 95/Jan/7 */
1329 internal_font_number f;
1336 mem[r + 4].cint = 0;
1342 total_stretch[0] = 0;
1343 total_shrink[0] = 0;
1344 total_stretch[1] = 0;
1345 total_shrink[1] = 0;
1346 total_stretch[2] = 0;
1347 total_shrink[2] = 0;
1348 total_stretch[3] = 0;
1349 total_shrink[3] = 0;
1350 while (p != 0) { /* while p<>null do l.12862 */
1352 while ((p >= hi_mem_min)) {
1354 i = font_info[char_base[f] + mem[p].hh.b1].qqqq;
1356 x = x + font_info[width_base[f] + i.b0].cint;
1357 s = font_info[height_base[f] + (hd) / 16].cint;
1360 s = font_info[depth_base[f]+(hd)% 16].cint;
1365 if (p != 0) /* if p<>null then l.12886 */
1367 switch (mem[p].hh.b0)
1374 x = x + mem[p + 1].cint;
1375 if (mem[p].hh.b0 >= 2)
1378 s = mem[p + 4].cint;
1379 if (mem[p + 3].cint - s > h)
1380 h = mem[p + 3].cint - s;
1381 if (mem[p + 2].cint + s > d)
1382 d = mem[p + 2].cint + s;
1388 /* if adjust_tail<>null then link(adjust_tail):=null; l.12865 / 12891 */
1389 if (adjust_tail != 0)
1391 while (mem[q].hh.v.RH != p)
1393 if (mem[p].hh.b0 == 5) {
1394 mem[adjust_tail].hh.v.RH = mem[p + 1].cint;
1395 while (mem[adjust_tail].hh.v.RH != 0)
1396 adjust_tail = mem[adjust_tail].hh.v.RH;
1398 free_node(mem[q].hh.v.RH, 2);
1400 mem[adjust_tail].hh.v.RH = p;
1413 g = mem[p + 1].hh.v.LH;
1414 x = x + mem[g + 1].cint;
1416 total_stretch[o]= total_stretch[o]+ mem[g + 2].cint;
1418 total_shrink[o]= total_shrink[o]+ mem[g + 3].cint;
1419 if (mem[p].hh.b1 >= 100) {
1420 g = mem[p + 1].hh.v.RH;
1421 if (mem[g + 3].cint > h)
1422 h = mem[g + 3].cint;
1423 if (mem[g + 2].cint > d)
1424 d = mem[g + 2].cint;
1430 x = x + mem[p + 1].cint;
1434 mem[lig_trick]= mem[p + 1];
1435 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
1447 if (adjust_tail != 0)
1448 mem[adjust_tail].hh.v.RH = 0;
1449 mem[r + 3].cint = h;
1450 mem[r + 2].cint = d;
1453 mem[r + 1].cint = w;
1456 mem[r + 5].hh.b0 = 0;
1457 mem[r + 5].hh.b1 = 0;
1458 mem[r + 6].gr = 0.0;
1461 if (total_stretch[3] != 0)
1463 else if (total_stretch[2] != 0)
1465 else if (total_stretch[1] != 0)
1469 mem[r + 5].hh.b1 = o;
1470 mem[r + 5].hh.b0 = 1;
1471 /* if total_stretch[o]<>0 then glue_set(r):=... l.12982 */
1472 if (total_stretch[o]!= 0)
1473 mem[r + 6].gr = x / ((double) total_stretch[o]);
1475 mem[r + 5].hh.b0 = 0;
1476 mem[r + 6].gr = 0.0;
1478 /* if o=normal then if list_ptr(r)<>null then l.12987 */
1480 if (mem[r + 5].hh.v.RH != 0)
1482 last_badness = badness(x, total_stretch[0]);
1483 if (last_badness > hbadness) {
1485 if (last_badness > 100)
1486 print_nl("Underfull");
1489 print_string(" \\hbox (badness ");
1490 print_int(last_badness);
1491 if (last_badness > 100)
1492 underfull_hbox++; /* 1996/Feb/9 */
1498 if (total_shrink[3] != 0)
1500 else if (total_shrink[2] != 0)
1502 else if (total_shrink[1] != 0)
1506 mem[r + 5].hh.b1 = o;
1507 mem[r + 5].hh.b0 = 2;
1508 if (total_shrink[o] != 0)
1509 mem[r + 6].gr =(- (integer) x) / ((double) total_shrink[o]);
1511 mem[r + 5].hh.b0 = 0;
1512 mem[r + 6].gr = 0.0;
1514 /* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13946 */
1515 if ((total_shrink[o]< - (integer) x) && (o == 0) && (mem[r + 5].hh.v.RH != 0)) {
1516 last_badness = 1000000L;
1517 /* set_glue_ratio_one(glue_set(r)); {use the maximum shrinkage} */
1518 mem[r + 6].gr = 1.0;
1519 /* if (-x-total_shrink[normal]>hfuzz)or(hbadness<100) then */
1520 if ((- (integer) x - total_shrink[0] > hfuzz) ||
1522 if ((overfull_rule > 0) &&
1523 (- (integer) x - total_shrink[0] > hfuzz)) {
1524 while(mem[q].hh.v.RH != 0)q = mem[q].hh.v.RH;
1525 mem[q].hh.v.RH = new_rule();
1526 mem[mem[q].hh.v.RH + 1].cint = overfull_rule;
1529 print_nl("Overfull \\hbox(");
1530 print_scaled(- (integer) x - total_shrink[0]);
1531 print_string("pt too wide");
1532 overfull_hbox++; /* 1996/Feb/9 */
1536 if (mem[r + 5].hh.v.RH != 0) {
1537 last_badness = badness(- (integer) x, total_shrink[0]);
1538 if (last_badness > hbadness) {
1540 print_nl("Tight \\hbox (badness ");
1541 print_int(last_badness);
1549 print_string(") has occurred while \\output is active");
1551 if (pack_begin_line != 0) {
1552 if (pack_begin_line > 0)
1553 print_string(") in paragraph at lines ");
1555 print_string(") in alignment at lines ");
1556 print_int(abs(pack_begin_line));
1558 } else print_string(")detected at line ");
1562 font_in_short_display = 0;
1563 short_display(mem[r + 5].hh.v.RH);
1567 end_diagnostic(true);
1572 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
1574 register halfword Result;
1580 int o; /* 95/Jan/7 */
1585 mem[r + 4].cint = 0;
1586 mem[r + 5].hh.v.RH = p;
1590 total_stretch[0] = 0;
1591 total_shrink[0] = 0;
1592 total_stretch[1] = 0;
1593 total_shrink[1] = 0;
1594 total_stretch[2] = 0;
1595 total_shrink[2] = 0;
1596 total_stretch[3] = 0;
1597 total_shrink[3] = 0;
1599 if ((p >= hi_mem_min)) {
1601 return 0; // abort_flag set
1602 } else switch (mem[p].hh.b0)
1609 x = x + d + mem[p + 3].cint;
1610 d = mem[p + 2].cint;
1611 if (mem[p].hh.b0 >= 2)
1613 else s = mem[p + 4].cint;
1614 if (mem[p + 1].cint + s > w)
1615 w = mem[p + 1].cint + s;
1625 g = mem[p + 1].hh.v.LH;
1626 x = x + mem[g + 1].cint;
1628 total_stretch[o] = total_stretch[o]+ mem[g + 2].cint;
1630 total_shrink[o]= total_shrink[o]+ mem[g + 3].cint;
1631 if (mem[p].hh.b1 >= 100) {
1632 g = mem[p + 1].hh.v.RH;
1633 if (mem[g + 1].cint > w)
1634 w = mem[g + 1].cint;
1640 x = x + d + mem[p + 1].cint;
1650 mem[r + 1].cint = w;
1653 mem[r + 2].cint = l;
1654 } else mem[r + 2].cint = d;
1657 mem[r + 3].cint = h;
1660 mem[r + 5].hh.b0 = 0;
1661 mem[r + 5].hh.b1 = 0;
1662 mem[r + 6].gr = 0.0;
1665 if (total_stretch[3] != 0)
1667 else if (total_stretch[2]!= 0)
1669 else if (total_stretch[1]!= 0)
1673 mem[r + 5].hh.b1 = o;
1674 mem[r + 5].hh.b0 = 1;
1675 if (total_stretch[o] != 0)
1676 mem[r + 6].gr = x / ((double) total_stretch[o]);
1678 mem[r + 5].hh.b0 = 0;
1679 mem[r + 6].gr = 0.0;
1682 if (mem[r + 5].hh.v.RH != 0) {
1683 last_badness = badness(x, total_stretch[0]);
1684 if (last_badness > vbadness) {
1686 if (last_badness > 100)
1687 print_nl("Underfull");
1690 print_string(" \\vbox (badness ");
1691 print_int(last_badness);
1692 if (last_badness > 100)
1693 underfull_vbox++; /* 1996/Feb/9 */
1699 if (total_shrink[3] != 0)
1701 else if (total_shrink[2] != 0)
1703 else if (total_shrink[1]!= 0)
1707 mem[r + 5].hh.b1 = o;
1708 mem[r + 5].hh.b0 = 2;
1709 if (total_shrink[o]!= 0)
1710 mem[r + 6].gr =(- (integer) x)/ ((double) total_shrink[o]);
1712 mem[r + 5].hh.b0 = 0;
1713 mem[r + 6].gr = 0.0;
1715 /* if (total_shrink[o]<-x)and(o=normal)and(list_ptr(r)<>null) then l.13046 */
1716 if ((total_shrink[o] < - (integer) x) && (o == 0) && (mem[r + 5].hh.v.RH != 0)) {
1717 last_badness = 1000000L;
1718 mem[r + 6].gr = 1.0;
1719 if ((- (integer) x - total_shrink[0] > eqtb[(hash_size + 3739)].cint) ||
1722 print_nl("Overfull \\vbox(");
1723 print_scaled(- (integer) x - total_shrink[0]);
1724 print_string("pt too high");
1725 overfull_vbox++; /* 1996/Feb/9 */
1729 /* else if o=normal then if list_ptr(r)<>null then l.13052 */
1731 if (mem[r + 5].hh.v.RH != 0) {
1732 last_badness = badness(- (integer) x, total_shrink[0]);
1733 if (last_badness > vbadness) {
1735 print_nl("Tight \\vbox (badness ");
1736 print_int(last_badness);
1744 print_string(") has occurred while \\output is active");
1746 if (pack_begin_line != 0) {
1747 print_string(") in alignment at lines ");
1748 print_int(abs(pack_begin_line));
1750 } else print_string(") detected at line ");
1756 end_diagnostic(true);
1761 void append_to_vlist_(halfword b)
1765 if (cur_list.aux_field.cint > ignore_depth) {
1766 d = mem[eqtb[(hash_size + 783)].hh.v.RH + 1].cint - cur_list.aux_field.cint - mem[b + 3].cint;
1767 if (d < line_skip_limit)
1768 p = new_param_glue(0);
1770 p = new_skip_param(1);
1771 mem[temp_ptr + 1].cint = d;
1773 mem[tail].hh.v.RH = p;
1776 mem[tail].hh.v.RH = b;
1778 cur_list.aux_field.cint = mem[b + 2].cint;
1780 halfword new_noad (void)
1782 register halfword Result;
1787 mem[p + 1].hh = empty_field;
1788 mem[p + 3].hh = empty_field;
1789 mem[p + 2].hh = empty_field;
1793 halfword new_style_(small_number s)
1795 register halfword Result;
1800 mem[p + 1].cint = 0;
1801 mem[p + 2].cint = 0;
1805 halfword new_choice (void)
1807 register halfword Result;
1812 mem[p + 1].hh.v.LH = 0;
1813 mem[p + 1].hh.v.RH = 0;
1814 mem[p + 2].hh.v.LH = 0;
1815 mem[p + 2].hh.v.RH = 0;
1819 void show_info (void)
1821 show_node_list(mem[temp_ptr].hh.v.LH);
1823 halfword fraction_rule_(scaled t)
1825 register halfword Result;
1828 mem[p + 3].cint = t;
1829 mem[p + 2].cint = 0;
1833 halfword overbar_(halfword b, scaled k, scaled t)
1835 register halfword Result;
1839 q = fraction_rule(t);
1843 Result = vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
1846 halfword char_box_(internal_font_number f, quarterword c)
1848 register halfword Result;
1852 q = font_info[char_base[f]+ c].qqqq;
1855 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
1856 mem[b + 3].cint = font_info[height_base[f]+(hd) / 16].cint;
1857 mem[b + 2].cint = font_info[depth_base[f]+(hd) % 16].cint;
1858 /* long to unsigned short ... */
1862 mem[b + 5].hh.v.RH = p;
1866 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
1870 mem[p].hh.v.RH = mem[b + 5].hh.v.RH;
1871 mem[b + 5].hh.v.RH = p;
1872 mem[b + 3].cint = mem[p + 3].cint;
1874 scaled height_plus_depth_(internal_font_number f, fquarterword c)
1876 register scaled Result;
1879 q = font_info[char_base[f]+ c].qqqq;
1881 Result = font_info[height_base[f]+(hd)/ 16].cint + font_info[depth_base[f]+(hd) % 16].cint;
1884 halfword var_delimiter_(halfword d, small_number s, scaled v)
1886 register halfword Result;
1888 internal_font_number f, g;
1889 quarterword c, x, y;
1896 /* small_number z; */
1897 int z; /* 95/Jan/7 */
1898 /* bool largeattempt; */
1899 int largeattempt; /* 95/Jan/7 */
1902 largeattempt = false;
1906 if ((z != 0) || (x != 0)) {
1910 g = eqtb[(hash_size + 1835) + z].hh.v.RH;
1913 if ((y >= font_bc[g]) && (y <= font_ec[g])) {
1915 q = font_info[char_base[g]+ y].qqqq;
1917 if (((q.b2) % 4) == 3) {
1923 u = font_info[height_base[g]+(hd)/ 16].cint + font_info[depth_base[g]+(hd)% 16].cint;
1931 if (((q.b2)% 4)== 2) {
1938 } while (!(z < 16));
1942 largeattempt = true;
1948 if (((q.b2) % 4)== 3) /* q may be used without ... */
1952 r = font_info[exten_base[f]+ q.b3].qqqq;
1954 u = height_plus_depth(f, c);
1956 q = font_info[char_base[f]+ c].qqqq;
1957 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
1960 w = w + height_plus_depth(f, c);
1963 w = w + height_plus_depth(f, c);
1966 w = w + height_plus_depth(f, c);
1977 stack_into_box(b, f, c);
1980 register integer for_end;
1983 if (m <= for_end) do
1984 stack_into_box(b, f, c);
1985 while (m++ < for_end);
1989 stack_into_box(b, f, c);
1992 register integer for_end;
1995 if (m <= for_end) do
1996 stack_into_box(b, f, c);
1997 while(m++ < for_end);
2002 stack_into_box(b, f, c);
2003 mem[b + 2].cint = w - mem[b + 3].cint;
2004 } else b = char_box(f, c);
2005 else { /* c may be used without ... */
2007 mem[b + 1].cint = null_delimiter_space;
2009 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;
2013 /* rebox_ etc used to follow here in tex4.c */