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;
425 if (cur_length < 256) /* can use xxx1 ? */
428 /* long to unsigned char ... */
432 { /* use xxx4 instead */
434 dvi_four(cur_length);
438 /* debugging code for \special{src: ... } 98/Nov/11 */
440 int k = str_start[str_ptr];
443 if (str_pool [k] == 's' &&
444 str_pool [k+1] == 'r' &&
445 str_pool [k+2] == 'c' &&
446 str_pool [k+3] == ':') { /* \special{src: ... } */
450 *s++ = str_pool[k++];
454 show_line(log_line, 0)
458 if (cur_input.name_field > 17) { /* redundant ? */
459 print(cur_input.name_field);
461 print_int(line); /* line number */
473 for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
474 dvi_out(str_pool[k]);
476 pool_ptr = str_start[str_ptr];
478 /* noew returns -1 if it fails */
480 void write_out_(halfword p)
483 /* integer oldmode; */
484 int oldmode; /* 1995/Jan/7 */
485 /* small_number j; */
486 int j; /* 1995/Jan/7 */
488 /* q:=get_avail; info(q):=right_brace_token+"}";@/ */
491 /* r:=get_avail; link(q):=r; info(r):=end_write_token; ins_list(q);@/ */
492 /* @d end_write_token==cs_token_flag+end_write */
495 /* mem[r].hh.v.LH = (hash_size + 4617); */
496 /* mem[r].hh.v.LH = (hash_size + 4095 + 522); */
497 info(r) = (hash_size + hash_extra + 4095 + 522);
498 begin_token_list(q, 4);
499 begin_token_list(mem[p + 1].hh.v.RH, 15);
501 mem[q].hh.v.LH = 379;
502 begin_token_list(q, 4);
506 q = scan_toks(false, true);
508 /* if (cur_tok != (hash_size + 4617)) */
509 /* if (cur_tok != (hash_size + 4095 + 522)) */
510 if (cur_tok != (hash_size + hash_extra + 4095 + 522))
512 print_err("Unbalanced write command");
513 help2("On this page there's a \\write with fewer real {'s than }'s.",
514 "I can't handle that very well; good luck.");
520 while(!(cur_tok == (hash_size + hash_extra + 4095 + 522))); /*1996/Jan/10*/
524 old_setting = selector;
525 j = mem[p + 1].hh.v.LH;
530 if ((j == 17) && (selector == 19))
537 selector = old_setting;
540 void out_what_(halfword p)
542 /* small_number j; */
543 int j; /* 1995/Jan/7 */
548 if (!doing_leaders) {
549 j = mem[p + 1].hh.v.LH;
550 if (mem[p].hh.b1 == 1){
554 (void) a_close(write_file[j]);
555 if (mem[p].hh.b1 == 2)
556 write_open[j]= false;
558 cur_name = mem[p + 1].hh.v.RH;
559 cur_area = mem[p + 2].hh.v.LH;
560 cur_ext = mem[p + 2].hh.v.RH;
561 if (cur_ext == 335) /* "" */
562 cur_ext = 785; /* => ".tex" */
563 pack_file_name(cur_name, cur_area, cur_ext);
564 while(! a_open_out(write_file[j])) {
565 prompt_file_name("output file name", ".tex");
581 return; // abort_flag set
586 /* following needs access to dvi_buf=zdvibuf see coerce.h */
588 void hlist_out (void)
594 /* glue_ord gorder; */
595 int gorder; /* 95/Jan/7 */
597 int gsign; /* 95/Jan/7 */
603 bool outerdoingleaders;
612 gorder = glue_order(thisbox);
613 gsign = glue_sign(thisbox);
614 p = list_ptr(thisbox);
618 if (cur_s > max_push)
620 saveloc = dvi_offset + dvi_ptr;
623 /* while p<>null do l.12314 */
630 movement(cur_h - dvi_h, 143); /* 143 == right1 */
635 movement(cur_v - dvi_v, 157); /* 157 == down1 */
650 dvi_out(f + 170); /* fnt_num_0 --- fnt_num_63 */
651 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
653 /* if we allow greater than 256 fonts */
656 dvi_out(235); /* fnt1 followed by f */
660 /* normal TeX 82 case */
663 dvi_out(235); /* fnt1 followed by f */
668 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
670 /* fnt2 followed by f / 256, f % 256 */
674 dvi_out(((f - 1) >> 8)); /* top byte */
675 dvi_out(((f - 1) & 255)); /* bottom byte */
678 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
684 cur_h = cur_h + font_info[width_base[f] + font_info[char_base[f] + c].qqqq.b0].cint;
686 } while(!(!(p >= hi_mem_min)));
695 if (list_ptr(p) == 0)
696 cur_h = cur_h + width(p);
701 cur_v = baseline + shift_amount(p);
704 if (type(p) == vlist_node)
710 cur_h = edge + width(p);
728 rule_wd = width(g) - cur_g;
731 if (gsign == stretching)
733 if (stretch_order(g) == gorder)
735 //gluetemp = glue_set(thisbox) * stretch(g);
736 cur_glue = cur_glue + stretch(g);
737 gluetemp = glue_set(thisbox) * cur_glue;
738 if (gluetemp > 1000000000.0)
739 gluetemp = 1000000000.0;
740 else if (gluetemp < -1000000000.0)
741 gluetemp = -1000000000.0;
742 cur_g = round(gluetemp);
743 //rule_wd = rule_wd + round(gluetemp);
746 else if (shrink_order(g) == gorder)
748 //gluetemp = glue_set(thisbox) * shrink(g);
749 cur_glue = cur_glue - shrink(g);
750 gluetemp = glue_set(thisbox) * cur_glue;
751 if (gluetemp > 1000000000.0)
752 gluetemp = 1000000000.0;
753 else if (gluetemp < -1000000000.0)
754 gluetemp = -1000000000.0;
755 cur_g = round(gluetemp);
756 //rule_wd = rule_wd - round(gluetemp);
759 rule_wd = rule_wd + cur_g;
760 if (subtype(p) >= a_leaders)
762 leaderbox = leader_ptr(p);
763 if (type(leaderbox) == rule_node)
765 rule_ht = height(leaderbox);
766 rule_dp = depth(leaderbox);
769 leaderwd = width(leaderbox);
770 if ((leaderwd > 0) && (rule_wd > 0))
772 rule_wd = rule_wd + 10;
773 edge = cur_h + rule_wd;
775 if (subtype(p) == a_leaders)
778 cur_h = leftedge + leaderwd * ((cur_h - leftedge) / leaderwd);
780 cur_h = cur_h + leaderwd;
784 lq = rule_wd / leaderwd;
785 lr = rule_wd % leaderwd;
786 if (subtype(p) == c_leaders)
787 cur_h = cur_h + (lr / 2);
790 lx =(2 * lr + lq + 1) / (2 * lq + 2);
791 cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
794 while (cur_h + leaderwd <= edge)
796 cur_v = baseline + shift_amount(leaderbox);
799 movement(cur_v - dvi_v, 157); /* 157 == down1 */
805 movement(cur_h - dvi_h, 143); /* 143 == right1 */
809 temp_ptr = leaderbox;
810 outerdoingleaders = doing_leaders;
811 doing_leaders = true;
812 if (type(leaderbox) == vlist_node)
816 doing_leaders = outerdoingleaders;
820 cur_h = saveh + leaderwd + lx;
831 cur_h = cur_h + width(p);
835 mem[lig_trick]= mem[p + 1];
836 mem[lig_trick].hh.v.RH = mem[p].hh.v.RH;
846 if ((rule_ht == -1073741824L)) /* - 2^30 */
847 rule_ht = height(thisbox);
848 if ((rule_dp == -1073741824L)) /* - 2^30 */
849 rule_dp = depth(thisbox);
850 rule_ht = rule_ht + rule_dp;
851 if ((rule_ht > 0)&&(rule_wd > 0))
855 movement(cur_h - dvi_h, 143); /* 143 == right1 */
858 cur_v = baseline + rule_dp;
861 movement(cur_v - dvi_v, 157); /* 157 == down1 */
868 dvi_h = dvi_h + rule_wd;
871 cur_h = cur_h + rule_wd;
875 prune_movements(saveloc);
880 /* following needs access to dvi_buf=zdvibuf see coerce.h */
882 void vlist_out (void)
888 /* glue_ord gorder; */
889 int gorder; /* 95/Jan/7 */
891 int gsign; /* 95/Jan/7 */
897 bool outerdoingleaders;
906 gorder = glue_order(thisbox);
907 gsign = glue_sign(thisbox);
908 p = list_ptr(thisbox);
912 if (cur_s > max_push)
914 saveloc = dvi_offset + dvi_ptr;
916 cur_v = cur_v - height(thisbox);
920 { /* while p<>null do l.12494 OK */
921 if ((p >= hi_mem_min))
923 confusion("vlistout");
924 return; // abort_flag set
928 switch (mem[p].hh.b0)
932 if (mem[p + 5].hh.v.RH == 0)
933 cur_v = cur_v + height(p) + depth(p);
936 cur_v = cur_v + height(p);
939 movement(cur_v - dvi_v, 157); /* 157 == down1 */
944 cur_h = leftedge + shift_amount(p);
946 if (type(p) == vlist_node)
952 cur_v = savev + depth(p);
970 rule_ht = width(g) - cur_g;
973 if (gsign == stretching)
975 if (stretch_order(g) == gorder)
977 //gluetemp = glue_set(thisbox) * mem[g + 2].cint;
978 cur_glue = cur_glue + stretch(g);
979 gluetemp = glue_set(thisbox) * cur_glue;
980 if (gluetemp > 1000000000.0)
981 gluetemp = 1000000000.0;
982 else if (gluetemp < -1000000000.0)
983 gluetemp = -1000000000.0;
984 //rule_ht = rule_ht + round(gluetemp);
985 cur_g = round(gluetemp);
988 else if (mem[g].hh.b1 == gorder) /* BUG FIX !!! */
990 //gluetemp = glue_set(thisbox) * mem[g + 3].cint;
991 cur_glue = cur_glue - shrink(g);
992 gluetemp = glue_set(thisbox) * cur_glue;
993 if (gluetemp > 1000000000.0)
994 gluetemp = 1000000000.0;
995 else if (gluetemp < -1000000000.0)
996 gluetemp = -1000000000.0;
997 //rule_ht = rule_ht - round(gluetemp);
998 cur_g = round(gluetemp);
1001 rule_ht = rule_ht + cur_g;
1002 if (subtype(p) >= a_leaders)
1004 leaderbox = leader_ptr(p);
1005 if (type(leaderbox) == rule_node)
1007 rule_wd = width(leaderbox);
1011 leaderht = height(leaderbox) + depth(leaderbox);
1012 if ((leaderht > 0) && (rule_ht > 0))
1014 rule_ht = rule_ht + 10;
1015 edge = cur_v + rule_ht;
1017 if (subtype(p) == a_leaders)
1020 cur_v = topedge + leaderht * ((cur_v - topedge) / leaderht);
1022 cur_v = cur_v + leaderht;
1026 lq = rule_ht / leaderht;
1027 lr = rule_ht % leaderht;
1028 if (subtype(p) == c_leaders)
1029 cur_v = cur_v + (lr / 2);
1032 lx =(2 * lr + lq + 1) / (2 * lq + 2);
1033 cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
1036 while (cur_v + leaderht <= edge)
1038 cur_h = leftedge + shift_amount(leaderbox);
1041 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1045 cur_v = cur_v + height(leaderbox);
1048 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1052 temp_ptr = leaderbox;
1053 outerdoingleaders = doing_leaders;
1054 doing_leaders = true;
1055 if (type(leaderbox) == vlist_node)
1059 doing_leaders = outerdoingleaders;
1063 cur_v = savev - height(leaderbox) + leaderht + lx;
1073 cur_v = cur_v + width(p);
1080 if ((rule_wd == -1073741824L)) /* -2^30 */
1081 rule_wd = width(thisbox);
1082 rule_ht = rule_ht + rule_dp;
1083 cur_v = cur_v + rule_ht;
1084 if ((rule_ht > 0) && (rule_wd > 0))
1088 movement(cur_h - dvi_h, 143); /* 143 == right1 */
1093 movement(cur_v - dvi_v, 157); /* 157 == down1 */
1102 cur_v = cur_v + rule_ht;
1107 prune_movements(saveloc);
1112 /****************HPDF******************/
1114 void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
1116 printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
1119 /****************HPDF******************/
1121 /* following needs access to dvi_buf=zdvibuf see coerce.h */
1123 void ship_out_(halfword p)
1130 if (tracing_output > 0)
1134 print_string("Completed box being shipped out");
1137 if (term_offset > max_print_line - 9)
1139 else if ((term_offset > 0) || (file_offset > 0))
1143 while((count(j) == 0) && (j > 0))
1145 for (k = 0; k <= j; k++)
1147 print_int(count(k));
1154 if (tracing_output > 0)
1159 end_diagnostic(true);
1161 if ((height(p) > 1073741823L) || /* 2^30 - 1 */
1162 (depth(p) > 1073741823L) ||
1163 (height(p) + depth(p) + v_offset > 1073741823L) ||
1164 (width(p) + h_offset > 1073741823L))
1166 print_err("Huge page cannot be shipped out");
1167 help2("The page just created is more than 18 feet tall or",
1168 "more than 18 feet wide, so I suspect something went wrong.");
1170 if (tracing_output <= 0)
1173 print_nl("The following box has been deleted:");
1175 end_diagnostic(true);
1179 if (height(p) + depth(p) + v_offset > max_v)
1180 max_v = height(p) + depth(p) + v_offset;
1181 if (width(p) + h_offset > max_h)
1182 max_h = height(p) + h_offset;
1188 if (output_file_name == 0)
1193 pack_job_name(".dvi");
1195 while(!b_open_out(dvi_file))
1197 prompt_file_name("file name for output", ".dvi");
1200 output_file_name = b_make_name_string(dvi_file);
1203 if (total_pages == 0)
1207 /********BINDING WITH LIBHARU*********/
1209 yandy_pdf = HPDF_New(error_handler, NULL);
1210 yandy_page = HPDF_AddPage(yandy_pdf);
1211 HPDF_SetInfoAttr(yandy_pdf, HPDF_INFO_PRODUCER, "Y&Y TeX with ApTeX");
1212 HPDF_SetCompressionMode (yandy_pdf, HPDF_COMP_ALL);
1213 HPDF_Page_SetSize (yandy_page, HPDF_PAGE_SIZE_A5, HPDF_PAGE_PORTRAIT);
1214 yandy_font = HPDF_GetFont (yandy_pdf, "Times-Roman", NULL);
1215 HPDF_Page_BeginText (yandy_page);
1216 HPDF_Page_SetFontAndSize (yandy_page, yandy_font, 16);
1217 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-90, "This is the \xAErst page.");
1218 HPDF_Page_TextOut (yandy_page, 60, HPDF_Page_GetHeight (yandy_page)-180, "Wait for ...");
1219 HPDF_Page_EndText (yandy_page);
1220 HPDF_SaveToFile (yandy_pdf, "NOTICE.pdf");
1221 HPDF_Free(yandy_pdf);
1223 /********BINDING WITH LIBHARU*********/
1224 dvi_four(25400000L); /* magic DVI scale factor */
1225 dvi_four(473628672L); /* 7227 * 65536 */
1228 old_setting = selector;
1229 selector = new_string;
1230 print_string(" TeX output ");
1237 print_two(tex_time / 60);
1238 print_two(tex_time % 60);
1239 selector = old_setting;
1240 dvi_out(cur_length);
1242 for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++)
1243 dvi_out(str_pool[s]);
1245 pool_ptr = str_start[str_ptr];
1246 } // end of if total_pages == 0
1248 pageloc = dvi_offset + dvi_ptr;
1250 for (k = 0; k <= 9; k++)
1254 cur_v = height(p) + v_offset;
1256 if (type(p) == vlist_node)
1264 if (tracing_output <= 0)
1272 if (tracing_stats > 1)
1274 print_nl("Memory usage before: ");
1275 print_int(var_used);
1277 print_int(dyn_used);
1283 if (tracing_stats > 1)
1285 print_string(" after: ");
1286 print_int(var_used);
1288 print_int(dyn_used);
1289 print_string("; still utouched: ");
1290 print_int(hi_mem_min - lo_mem_max - 1); /* somewhat inaccurate free mem */
1296 void scan_spec_(group_code c, bool threecodes)
1302 s = save_stack[save_ptr + 0].cint;
1303 if (scan_keyword("to"))
1305 else if (scan_keyword("spread"))
1313 scan_dimen(false, false, false);
1317 save_stack[save_ptr + 0].cint = s; /* s may be used without ... */
1320 save_stack[save_ptr + 0].cint = speccode;
1321 save_stack[save_ptr + 1].cint = cur_val;
1322 save_ptr = save_ptr + 2;
1327 halfword hpack_(halfword p, scaled w, small_number m)
1329 register halfword Result;
1336 int o; /* 95/Jan/7 */
1337 internal_font_number f;
1342 r = get_node(box_node_size);
1343 type(r) = hlist_node;
1345 shift_amount(r) = 0;
1346 q = r + list_offset;
1351 total_stretch[normal] = 0;
1352 total_shrink[normal] = 0;
1353 total_stretch[fil] = 0;
1354 total_shrink[fil] = 0;
1355 total_stretch[fill] = 0;
1356 total_shrink[fill] = 0;
1357 total_stretch[filll] = 0;
1358 total_shrink[filll] = 0;
1360 { /* while p<>null do l.12862 */
1362 while ((p >= hi_mem_min))
1365 i = font_info[char_base[f] + mem[p].hh.b1].qqqq;
1367 x = x + font_info[width_base[f] + i.b0].cint;
1368 s = font_info[height_base[f] + (hd) / 16].cint;
1371 s = font_info[depth_base[f] + (hd) % 16].cint;
1376 if (p != 0) /* if p<>null then l.12886 */
1378 switch (mem[p].hh.b0)
1386 if (type(p) >= rule_node)
1389 s = shift_amount(p);
1390 if (height(p) - s > h)
1392 if (depth(p) + s > d)
1399 if (adjust_tail != 0)
1401 while (link(q) != p)
1403 if (type(p) == adjust_node)
1405 link(adjust_tail) = adjust_ptr(p);
1406 while (link(adjust_tail)!= 0)
1407 adjust_tail = link(adjust_tail);
1409 free_node(link(q), small_node_size);
1413 link(adjust_tail) = p;
1427 o = stretch_order(g);
1428 total_stretch[o]= total_stretch[o] + stretch(g);
1429 o = shrink_order(g);
1430 total_shrink[o]= total_shrink[o] + shrink(g);
1431 if (subtype(p) >= a_leaders)
1447 mem[lig_trick] = mem[lig_char(p)];
1448 link(lig_trick) = link(p);
1459 if (adjust_tail != 0)
1460 link(adjust_tail) = 0;
1469 glue_sign(r) = normal;
1470 glue_order(r) = normal;
1476 if (total_stretch[filll] != 0)
1478 else if (total_stretch[fill] != 0)
1480 else if (total_stretch[fil] != 0)
1485 glue_sign(r) = stretching;
1486 if (total_stretch[o]!= 0)
1487 glue_set(r) = x / ((double) total_stretch[o]);
1490 glue_sign(r) = normal;
1494 if (list_ptr(r) != 0)
1496 last_badness = badness(x, total_stretch[0]);
1497 if (last_badness > hbadness)
1500 if (last_badness > 100)
1501 print_nl("Underfull");
1504 print_string(" \\hbox (badness ");
1505 print_int(last_badness);
1506 if (last_badness > 100) /* Y&Y TeX */
1507 underfull_hbox++; /* 1996/Feb/9 */
1515 if (total_shrink[filll] != 0)
1517 else if (total_shrink[fill] != 0)
1519 else if (total_shrink[fil] != 0)
1524 glue_sign(r) = shrinking;
1525 if (total_shrink[o] != 0)
1526 glue_set(r) =(- (integer) x) / ((double) total_shrink[o]);
1529 glue_sign(r) = normal;
1532 if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
1534 last_badness = 1000000L;
1536 if ((- (integer) x - total_shrink[0] > hfuzz) || (hbadness < 100))
1538 if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz))
1542 link(q) = new_rule();
1543 width(link(q)) = overfull_rule;
1546 print_nl("Overfull \\hbox (");
1547 print_scaled(- (integer) x - total_shrink[0]);
1548 print_string("pt too wide");
1549 overfull_hbox++; /* 1996/Feb/9 */
1553 else if (o == normal)
1554 if (list_ptr(r) != 0)
1556 last_badness = badness(- (integer) x, total_shrink[normal]);
1557 if (last_badness > hbadness)
1560 print_nl("Tight \\hbox (badness ");
1561 print_int(last_badness);
1569 print_string(") has occurred while \\output is active");
1572 if (pack_begin_line != 0)
1574 if (pack_begin_line > 0)
1575 print_string(") in paragraph at lines ");
1577 print_string(") in alignment at lines ");
1578 print_int(abs(pack_begin_line));
1582 print_string(") detected at line ");
1586 font_in_short_display = 0;
1587 short_display(list_ptr(r));
1591 end_diagnostic(true);
1597 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
1599 register halfword Result;
1605 int o; /* 95/Jan/7 */
1608 r = get_node(box_node_size);
1609 type(r) = vlist_node;
1611 shift_amount(r) = 0;
1616 total_stretch[normal] = 0;
1617 total_shrink[normal] = 0;
1618 total_stretch[fil] = 0;
1619 total_shrink[fil] = 0;
1620 total_stretch[fill] = 0;
1621 total_shrink[fill] = 0;
1622 total_stretch[filll] = 0;
1623 total_shrink[filll] = 0;
1627 if ((p >= hi_mem_min))
1630 return 0; // abort_flag set
1632 else switch (mem[p].hh.b0)
1639 x = x + d + height(p);
1641 if (type(p) >= rule_node)
1644 s = shift_amount(p);
1645 if (width(p) + s > w)
1657 o = stretch_order(g);
1658 total_stretch[o] = total_stretch[o] + stretch(g);
1659 o = shrink_order(g);
1660 total_shrink[o] = total_shrink[o] + shrink(g);
1662 if (subtype(p) >= a_leaders)
1672 x = x + d + width(p);
1697 glue_sign(r) = normal;
1698 glue_order(r) = normal;
1704 if (total_stretch[filll] != 0)
1706 else if (total_stretch[fill] != 0)
1708 else if (total_stretch[fil] != 0)
1713 glue_sign(r) = stretching;
1715 if (total_stretch[o] != 0)
1716 glue_set(r) = x / ((double) total_stretch[o]);
1719 glue_sign(r) = normal;
1724 if (list_ptr(r) != 0)
1726 last_badness = badness(x, total_stretch[normal]);
1727 if (last_badness > vbadness)
1730 if (last_badness > 100)
1731 print_nl("Underfull");
1734 print_string(" \\vbox (badness ");
1735 print_int(last_badness);
1736 if (last_badness > 100)
1737 underfull_vbox++; /* 1996/Feb/9 */
1745 if (total_shrink[filll] != 0)
1747 else if (total_shrink[fill] != 0)
1749 else if (total_shrink[fil] != 0)
1754 glue_sign(r) = shrinking;
1755 if (total_shrink[o]!= 0)
1756 glue_set(r) =(- (integer) x)/ ((double) total_shrink[o]);
1759 glue_sign(r) = normal;
1763 if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
1765 last_badness = 1000000L;
1767 if ((- (integer) x - total_shrink[0] > vfuzz) || (vbadness < 100))
1770 print_nl("Overfull \\vbox (");
1771 print_scaled(- (integer) x - total_shrink[0]);
1772 print_string("pt too high");
1773 overfull_vbox++; /* 1996/Feb/9 */
1778 if (list_ptr(r) != 0)
1780 last_badness = badness(- (integer) x, total_shrink[normal]);
1781 if (last_badness > vbadness)
1784 print_nl("Tight \\vbox (badness ");
1785 print_int(last_badness);
1793 print_string(") has occurred while \\output is active");
1795 if (pack_begin_line != 0)
1797 print_string(") in alignment at lines ");
1798 print_int(abs(pack_begin_line));
1802 print_string(") detected at line ");
1808 end_diagnostic(true);
1814 void append_to_vlist_(halfword b)
1819 if (cur_list.aux_field.cint > ignore_depth)
1821 d = width(baseline_skip) - cur_list.aux_field.cint - height(b);
1823 if (d < line_skip_limit)
1824 p = new_param_glue(line_skip_code);
1827 p = new_skip_param(baseline_skip_code);
1828 width(temp_ptr) = d;
1835 cur_list.aux_field.cint = depth(b);
1838 halfword new_noad (void)
1841 p = get_node(noad_size);
1843 subtype(p) = normal;
1844 mem[nucleus(p)].hh = empty_field;
1845 mem[subscr(p)].hh = empty_field;
1846 mem[supscr(p)].hh = empty_field;
1850 halfword new_style_(small_number s)
1853 p = get_node(style_node_size);
1854 type(p) = style_node;
1861 halfword new_choice (void)
1864 p = get_node(style_node_size);
1865 type(p) = choice_node;
1867 display_mlist(p) = 0;
1869 script_mlist(p) = 0;
1870 script_script_mlist(p) = 0;
1874 void show_info (void)
1876 show_node_list(info(temp_ptr));
1879 halfword fraction_rule_(scaled t)
1887 halfword overbar_(halfword b, scaled k, scaled t)
1889 register halfword Result;
1893 q = fraction_rule(t);
1897 Result = vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
1900 halfword char_box_(internal_font_number f, quarterword c)
1902 register halfword Result;
1906 q = font_info[char_base[f] + c].qqqq;
1909 mem[b + 1].cint = font_info[width_base[f] + q.b0].cint + font_info[italic_base[f] + (q.b2) / 4].cint;
1910 mem[b + 3].cint = font_info[height_base[f] + (hd) / 16].cint;
1911 mem[b + 2].cint = font_info[depth_base[f] + (hd) % 16].cint;
1912 /* long to unsigned short ... */
1916 mem[b + 5].hh.v.RH = p;
1920 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
1924 mem[p].hh.v.RH = mem[b + 5].hh.v.RH;
1925 mem[b + 5].hh.v.RH = p;
1926 mem[b + 3].cint = mem[p + 3].cint;
1928 scaled height_plus_depth_(internal_font_number f, fquarterword c)
1930 register scaled Result;
1933 q = font_info[char_base[f]+ c].qqqq;
1935 Result = font_info[height_base[f] + (hd) / 16].cint + font_info[depth_base[f] + (hd) % 16].cint;
1938 halfword var_delimiter_(halfword d, small_number s, scaled v)
1940 register halfword Result;
1942 internal_font_number f, g;
1943 quarterword c, x, y;
1950 /* small_number z; */
1951 int z; /* 95/Jan/7 */
1952 /* bool largeattempt; */
1953 int largeattempt; /* 95/Jan/7 */
1956 largeattempt = false;
1961 if ((z != 0) || (x != 0))
1967 g = eqtb[(hash_size + 1835) + z].hh.v.RH;
1970 if ((y >= font_bc[g]) && (y <= font_ec[g]))
1973 q = font_info[char_base[g]+ y].qqqq;
1976 if (((q.b2) % 4) == 3)
1983 u = font_info[height_base[g] + (hd) / 16].cint + font_info[depth_base[g] + (hd) % 16].cint;
1991 if (((q.b2)% 4)== 2) {
1998 } while (!(z < 16));
2002 largeattempt = true;
2008 if (((q.b2) % 4)== 3) /* q may be used without ... */
2012 r = font_info[exten_base[f]+ q.b3].qqqq;
2014 u = height_plus_depth(f, c);
2016 q = font_info[char_base[f]+ c].qqqq;
2017 mem[b + 1].cint = font_info[width_base[f]+ q.b0].cint + font_info[italic_base[f]+(q.b2) / 4].cint;
2020 w = w + height_plus_depth(f, c);
2023 w = w + height_plus_depth(f, c);
2026 w = w + height_plus_depth(f, c);
2037 stack_into_box(b, f, c);
2039 for (m = 1; m <= n; m++)
2041 stack_into_box(b, f, c);
2045 stack_into_box(b, f, c);
2047 for (m = 1; m <= n; m++)
2049 stack_into_box(b, f, c);
2054 stack_into_box(b, f, c);
2055 mem[b + 2].cint = w - mem[b + 3].cint;
2056 } else b = char_box(f, c);
2057 else { /* c may be used without ... */
2059 mem[b + 1].cint = null_delimiter_space;
2061 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;
2065 /* rebox_ etc used to follow here in tex4.c */