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 if (show_missing == 0)
34 if (show_missing) /* add ! before 94/June/10 */
37 print_string("Missing character: there is no ");
40 print_nl("Missing character: there is no ");
44 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);
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 */
75 show_context(); /* not if its the nullfont */
78 if (show_missing == 0) /* show on screen 94/June/10 */
79 end_diagnostic(false);
81 missing_characters++; /* bkph 93/Dec/16 */
82 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
86 halfword new_character_(internal_font_number f, eight_bits c)
92 if ((font_info[char_base[f] + c].qqqq.b0 > 0))
100 char_warning(f, c); /* char_warning(f,c); l.11283 */
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 write_dvi(0, half_buf - 1);
117 dvi_limit = half_buf;
118 dvi_offset = dvi_offset + dvi_buf_size;
123 write_dvi(half_buf, dvi_buf_size - 1);
124 dvi_limit = dvi_buf_size;
127 dvi_gone = dvi_gone + half_buf;
129 /* following needs access to dvi_buf=zdvibuf see coerce.h */
130 /* attempt at speeding up bkph - is compiler smart ? */
132 void dvi_four_(integer x)
135 // dvi_out(x % 16777216L);
139 x = x + 1073741824L; /* 2^30 40000000 hex */
141 //dvi_out((x / 16777216L) + 128);
142 dvi_out((x >> 24) + 128);
144 /* x = x % 16777216L; */ /* % 2^24 */
146 //dvi_out(x / 65536L);
148 /* x = x % 65536L; */ /* % 2^16 */
155 /* following needs access to dvi_buf=zdvibuf see coerce.h */
157 void zdvipop(integer l)
159 if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
164 /* following needs access to dvi_buf=zdvibuf see coerce.h */
166 void dvi_font_def_(internal_font_number f)
179 dvi_out(((f - 1) >> 8));
180 dvi_out(((f - 1) & 255));
186 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
187 /* spit out the font checksum now */
188 dvi_out(font_check[f].b0);
189 dvi_out(font_check[f].b1);
190 dvi_out(font_check[f].b2);
191 dvi_out(font_check[f].b3);
192 dvi_four(font_size[f]);
193 dvi_four(font_dsize[f]);
194 dvi_out(length(font_area[f]));
195 dvi_out(length(font_name[f]));
197 for (k = str_start[font_area[f]]; k <= str_start[font_area[f] + 1] - 1; k++)
198 dvi_out(str_pool[k]);
200 for (k = str_start[font_name[f]]; k <= str_start[font_name[f] + 1] - 1; k++)
201 dvi_out(str_pool[k]);
203 /* following needs access to dvi_buf=zdvibuf see coerce.h */
205 void zmovement(scaled w, eight_bits o)
211 q = get_node(movement_node_size);
213 location(q) = dvi_offset + dvi_ptr;
232 switch(mstate + info(p))
234 case none_seen + yz_OK:
235 case none_seen + y_OK:
238 if (location(p) < dvi_gone)
242 k = location(p) - dvi_offset;
245 k = k + dvi_buf_size;
247 dvi_buf[k] = dvi_buf[k] + y1 - down1;
253 case none_seen + z_OK:
256 if (location(p) < dvi_gone)
260 k = location(p) - dvi_offset;
263 k = k + dvi_buf_size;
265 dvi_buf[k] = dvi_buf[k] + z1 - down1;
271 case none_seen + y_here:
272 case none_seen + z_here:
273 case y_seen + z_here:
274 case z_seen + y_here:
281 else switch (mstate + info(p))
283 case none_seen + y_here:
287 case none_seen + z_here:
291 case y_seen + z_here:
292 case z_seen + y_here:
305 if (abs(w) >= 8388608L) /* 2^23 */
312 if (abs(w) >= 32768L)
317 w = w + 16777216L; /* 2^24 */
318 //dvi_out(w / 65536L);
320 /* w = w % 65536L; */
351 if (info(q) == y_here)
353 dvi_out(o + y0 - down1);
376 dvi_out(o + z0 - down1);
399 void prune_movements_(integer l)
403 while (down_ptr != 0)
405 if (location(down_ptr) < l)
410 free_node(p, movement_node_size);
413 while (right_ptr != 0)
415 if (location(right_ptr) < l)
420 free_node(p, movement_node_size);
423 /* following needs access to dvi_buf=zdvibuf see coerce.h */
425 void special_out_(halfword p)
432 movement(cur_h - dvi_h, right1);
438 movement(cur_v - dvi_v, down1);
442 old_setting = selector;
443 selector = new_string;
445 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
446 /* About output \special{...} make some space in string pool 97/Mar/9 */
447 #ifdef ALLOCATESTRING
448 if (pool_ptr + 32000 > current_pool_size)
449 str_pool = realloc_str_pool (increment_pool_size);
450 /* We don't bother to check whether this worked - will catch later */
452 /* Potential problem here if current_pool_size is not much more than pool_ptr! */
453 /* Fixed 97/Mar/9 in version 2.0.3 */
454 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
455 #ifdef ALLOCATESTRING
456 show_token_list(link(write_tokens(p)), 0, 10000000L);
457 /* Above is safe, since print/print_char/print_esc will extend string space */
459 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
460 show_token_list(link(write_tokens(p)), 0, pool_size - pool_ptr);
462 selector = old_setting;
465 if (cur_length < 256) /* can use xxx1 ? */
473 dvi_four(cur_length);
477 /* debugging code for \special{src: ... } 98/Nov/11 */
479 int k = str_start[str_ptr];
481 /* \special{src: ... } */
484 if (str_pool [k] == 's' && str_pool [k + 1] == 'r' && str_pool [k + 2] == 'c' && str_pool [k + 3] == ':')
491 *s++ = str_pool[k++];
496 show_line(log_line, 0)
500 if (cur_input.name_field > 17) /* redundant ? */
502 print(cur_input.name_field);
504 print_int(line); /* line number */
516 for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
517 dvi_out(str_pool[k]);
519 pool_ptr = str_start[str_ptr];
521 /* noew returns -1 if it fails */
523 void write_out_(halfword p)
526 /* integer oldmode; */
527 int oldmode; /* 1995/Jan/7 */
528 /* small_number j; */
529 int j; /* 1995/Jan/7 */
533 info(q) = right_brace_token + '}';
536 info(r) = end_write_token;
538 begin_token_list(write_tokens(p), write_text);
540 info(q) = left_brace_token + '{';
545 q = scan_toks(false, true);
548 if (cur_tok != end_write_token)
550 print_err("Unbalanced write command");
551 help2("On this page there's a \\write with fewer real {'s than }'s.",
552 "I can't handle that very well; good luck.");
559 while(!(cur_tok == end_write_token)); /*1996/Jan/10*/
564 old_setting = selector;
571 if ((j == 17) && (selector == term_and_log))
580 selector = old_setting;
583 void out_what_(halfword p)
585 /* small_number j; */
586 int j; /* 1995/Jan/7 */
597 if (subtype(p) == write_node)
604 (void) a_close(write_file[j]);
606 if (subtype(p) == close_node)
607 write_open[j]= false;
610 cur_name = open_name(p);
611 cur_area = open_area(p);
612 cur_ext = open_ext(p);
614 if (cur_ext == 335) /* "" */
615 cur_ext = 785; /* => ".tex" */
617 pack_file_name(cur_name, cur_area, cur_ext);
619 while(! a_open_out(write_file[j]))
621 prompt_file_name("output file name", ".tex");
624 write_open[j] = true;
641 return; // abort_flag set
646 /* following needs access to dvi_buf=zdvibuf see coerce.h */
648 void hlist_out (void)
652 scaled save_h, save_v;
654 /* glue_ord g_order; */
655 int g_order; /* 95/Jan/7 */
657 int g_sign; /* 95/Jan/7 */
663 bool outer_doing_leaders;
672 g_order = glue_order(this_box);
673 g_sign = glue_sign(this_box);
674 p = list_ptr(this_box);
680 if (cur_s > max_push)
683 save_loc = dvi_offset + dvi_ptr;
693 movement(cur_h - dvi_h, right1);
699 movement(cur_v - dvi_v, down1);
716 if (f <= 64 + font_base)
717 dvi_out(f - font_base - 1 + fnt_num_0); /* fnt_num_0 --- fnt_num_63 */
718 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
720 /* if we allow greater than 256 fonts */
727 /* normal TeX 82 case */
735 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
737 /* fnt2 followed by f / 256, f % 256 */
741 dvi_out(((f - 1) >> 8)); /* top byte */
742 dvi_out(((f - 1) & 255)); /* bottom byte */
745 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
753 cur_h = cur_h + char_width(f, char_info(f, c));
756 while(!(!(p >= hi_mem_min)));
765 if (list_ptr(p) == 0)
766 cur_h = cur_h + width(p);
771 cur_v = base_line + shift_amount(p);
775 if (type(p) == vlist_node)
782 cur_h = edge + width(p);
803 rule_wd = width(g) - cur_g;
805 if (g_sign != normal)
807 if (g_sign == stretching)
809 if (stretch_order(g) == g_order)
811 cur_glue = cur_glue + stretch(g);
812 glue_temp = glue_set(this_box) * cur_glue;
814 if (glue_temp > 1000000000.0)
815 glue_temp = 1000000000.0;
816 else if (glue_temp < -1000000000.0)
817 glue_temp = -1000000000.0;
819 cur_g = round(glue_temp);
822 else if (shrink_order(g) == g_order)
824 cur_glue = cur_glue - shrink(g);
825 glue_temp = glue_set(this_box) * cur_glue;
827 if (glue_temp > 1000000000.0)
828 glue_temp = 1000000000.0;
829 else if (glue_temp < -1000000000.0)
830 glue_temp = -1000000000.0;
832 cur_g = round(glue_temp);
836 rule_wd = rule_wd + cur_g;
838 if (subtype(p) >= a_leaders)
840 leader_box = leader_ptr(p);
842 if (type(leader_box) == rule_node)
844 rule_ht = height(leader_box);
845 rule_dp = depth(leader_box);
849 leader_wd = width(leader_box);
851 if ((leader_wd > 0) && (rule_wd > 0))
853 rule_wd = rule_wd + 10;
854 edge = cur_h + rule_wd;
857 if (subtype(p) == a_leaders)
860 cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);
863 cur_h = cur_h + leader_wd;
867 lq = rule_wd / leader_wd;
868 lr = rule_wd % leader_wd;
870 if (subtype(p) == c_leaders)
871 cur_h = cur_h + (lr / 2);
874 lx =(2 * lr + lq + 1) / (2 * lq + 2);
875 cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
879 while (cur_h + leader_wd <= edge)
881 cur_v = base_line + shift_amount(leader_box);
885 movement(cur_v - dvi_v, down1);
893 movement(cur_h - dvi_h, right1);
898 temp_ptr = leader_box;
899 outer_doing_leaders = doing_leaders;
900 doing_leaders = true;
902 if (type(leader_box) == vlist_node)
907 doing_leaders = outer_doing_leaders;
911 cur_h = save_h + leader_wd + lx;
925 cur_h = cur_h + width(p);
930 mem[lig_trick] = mem[lig_char(p)];
931 link(lig_trick) = link(p);
943 if ((rule_ht == -1073741824L)) /* - 2^30 */
944 rule_ht = height(this_box);
946 if ((rule_dp == -1073741824L)) /* - 2^30 */
947 rule_dp = depth(this_box);
949 rule_ht = rule_ht + rule_dp;
951 if ((rule_ht > 0) && (rule_wd > 0))
955 movement(cur_h - dvi_h, right1);
959 cur_v = base_line + rule_dp;
963 movement(cur_v - dvi_v, down1);
972 dvi_h = dvi_h + rule_wd;
975 cur_h = cur_h + rule_wd;
980 prune_movements(save_loc);
987 /* following needs access to dvi_buf=zdvibuf see coerce.h */
989 void vlist_out (void)
993 scaled save_h, save_v;
995 /* glue_ord g_order; */
996 int g_order; /* 95/Jan/7 */
998 int g_sign; /* 95/Jan/7 */
1001 halfword leader_box;
1004 bool outer_doing_leaders;
1012 this_box = temp_ptr;
1013 g_order = glue_order(this_box);
1014 g_sign = glue_sign(this_box);
1015 p = list_ptr(this_box);
1021 if (cur_s > max_push)
1024 save_loc = dvi_offset + dvi_ptr;
1026 cur_v = cur_v - height(this_box);
1031 if ((p >= hi_mem_min))
1033 confusion("vlistout");
1034 return; // abort_flag set
1042 if (list_ptr(p) == 0)
1043 cur_v = cur_v + height(p) + depth(p);
1046 cur_v = cur_v + height(p);
1050 movement(cur_v - dvi_v, down1);
1056 cur_h = left_edge + shift_amount(p);
1059 if (type(p) == vlist_node)
1066 cur_v = save_v + depth(p);
1073 rule_ht = height(p);
1087 rule_ht = width(g) - cur_g;
1089 if (g_sign != normal)
1091 if (g_sign == stretching)
1093 if (stretch_order(g) == g_order)
1095 cur_glue = cur_glue + stretch(g);
1096 glue_temp = glue_set(this_box) * cur_glue;
1098 if (glue_temp > 1000000000.0)
1099 glue_temp = 1000000000.0;
1100 else if (glue_temp < -1000000000.0)
1101 glue_temp = -1000000000.0;
1103 cur_g = round(glue_temp);
1106 else if (shrink_order(g) == g_order) /* BUG FIX !!! */
1108 cur_glue = cur_glue - shrink(g);
1109 glue_temp = glue_set(this_box) * cur_glue;
1111 if (glue_temp > 1000000000.0)
1112 glue_temp = 1000000000.0;
1113 else if (glue_temp < -1000000000.0)
1114 glue_temp = -1000000000.0;
1116 cur_g = round(glue_temp);
1120 rule_ht = rule_ht + cur_g;
1122 if (subtype(p) >= a_leaders)
1124 leader_box = leader_ptr(p);
1126 if (type(leader_box) == rule_node)
1128 rule_wd = width(leader_box);
1133 leader_ht = height(leader_box) + depth(leader_box);
1135 if ((leader_ht > 0) && (rule_ht > 0))
1137 rule_ht = rule_ht + 10;
1138 edge = cur_v + rule_ht;
1141 if (subtype(p) == a_leaders)
1144 cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht);
1147 cur_v = cur_v + leader_ht;
1151 lq = rule_ht / leader_ht;
1152 lr = rule_ht % leader_ht;
1154 if (subtype(p) == c_leaders)
1155 cur_v = cur_v + (lr / 2);
1158 lx =(2 * lr + lq + 1) / (2 * lq + 2);
1159 cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
1163 while (cur_v + leader_ht <= edge)
1165 cur_h = left_edge + shift_amount(leader_box);
1169 movement(cur_h - dvi_h, right1);
1174 cur_v = cur_v + height(leader_box);
1178 movement(cur_v - dvi_v, down1);
1183 temp_ptr = leader_box;
1184 outer_doing_leaders = doing_leaders;
1185 doing_leaders = true;
1187 if (type(leader_box) == vlist_node)
1192 doing_leaders = outer_doing_leaders;
1196 cur_v = save_v - height(leader_box) + leader_ht + lx;
1209 cur_v = cur_v + width(p);
1217 if ((rule_wd == -1073741824L)) /* -2^30 */
1218 rule_wd = width(this_box);
1220 rule_ht = rule_ht + rule_dp;
1221 cur_v = cur_v + rule_ht;
1223 if ((rule_ht > 0) && (rule_wd > 0))
1227 movement(cur_h - dvi_h, right1);
1233 movement(cur_v - dvi_v, down1);
1243 cur_v = cur_v + rule_ht;
1248 prune_movements(save_loc);
1255 /****************HPDF******************/
1257 void error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data)
1259 printf ("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
1262 /****************HPDF******************/
1264 /* following needs access to dvi_buf=zdvibuf see coerce.h */
1266 void ship_out_(halfword p)
1273 if (tracing_output > 0)
1277 print_string("Completed box being shipped out");
1280 if (term_offset > max_print_line - 9)
1282 else if ((term_offset > 0) || (file_offset > 0))
1288 while((count(j) == 0) && (j > 0))
1291 for (k = 0; k <= j; k++)
1293 print_int(count(k));
1303 if (tracing_output > 0)
1308 end_diagnostic(true);
1311 if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
1312 (height(p) + depth(p) + v_offset > max_dimen) ||
1313 (width(p) + h_offset > max_dimen))
1315 print_err("Huge page cannot be shipped out");
1316 help2("The page just created is more than 18 feet tall or",
1317 "more than 18 feet wide, so I suspect something went wrong.");
1320 if (tracing_output <= 0)
1323 print_nl("The following box has been deleted:");
1325 end_diagnostic(true);
1330 if (height(p) + depth(p) + v_offset > max_v)
1331 max_v = height(p) + depth(p) + v_offset;
1333 if (width(p) + h_offset > max_h)
1334 max_h = width(p) + h_offset;
1341 if (output_file_name == 0)
1346 pack_job_name(".dvi");
1348 while(!b_open_out(dvi_file))
1350 prompt_file_name("file name for output", ".dvi");
1353 output_file_name = b_make_name_string(dvi_file);
1356 if (total_pages == 0)
1360 dvi_four(25400000L); /* magic DVI scale factor */
1361 dvi_four(473628672L); /* 7227 * 65536 */
1364 old_setting = selector;
1365 selector = new_string;
1366 print_string(" TeX output ");
1373 print_two(tex_time / 60);
1374 print_two(tex_time % 60);
1375 selector = old_setting;
1376 dvi_out(cur_length);
1378 for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++)
1379 dvi_out(str_pool[s]);
1381 pool_ptr = str_start[str_ptr];
1384 page_loc = dvi_offset + dvi_ptr;
1387 for (k = 0; k <= 9; k++)
1391 last_bop = page_loc;
1392 cur_v = height(p) + v_offset;
1395 if (type(p) == vlist_node)
1404 if (tracing_output <= 0)
1414 if (tracing_stats > 1)
1416 print_nl("Memory usage before: ");
1417 print_int(var_used);
1419 print_int(dyn_used);
1427 if (tracing_stats > 1)
1429 print_string(" after: ");
1430 print_int(var_used);
1432 print_int(dyn_used);
1433 print_string("; still utouched: ");
1434 print_int(hi_mem_min - lo_mem_max - 1); /* somewhat inaccurate free mem */
1440 void scan_spec_(group_code c, bool three_codes)
1448 if (scan_keyword("to"))
1449 spec_code = exactly;
1450 else if (scan_keyword("spread"))
1451 spec_code = additional;
1454 spec_code = additional;
1459 scan_dimen(false, false, false);
1467 saved(0) = spec_code;
1469 save_ptr = save_ptr + 2;
1474 halfword hpack_(halfword p, scaled w, small_number m)
1482 int o; /* 95/Jan/7 */
1483 internal_font_number f;
1488 r = get_node(box_node_size);
1489 type(r) = hlist_node;
1491 shift_amount(r) = 0;
1492 q = r + list_offset;
1497 total_stretch[normal] = 0;
1498 total_shrink[normal] = 0;
1499 total_stretch[fil] = 0;
1500 total_shrink[fil] = 0;
1501 total_stretch[fill] = 0;
1502 total_shrink[fill] = 0;
1503 total_stretch[filll] = 0;
1504 total_shrink[filll] = 0;
1509 while ((p >= hi_mem_min))
1512 i = char_info(f, character(p));
1513 hd = height_depth(i);
1514 x = x + char_width(f, i);
1515 s = char_height(f, hd);
1520 s = char_depth(f, hd);
1539 if (type(p) >= rule_node)
1542 s = shift_amount(p);
1544 if (height(p) - s > h)
1547 if (depth(p) + s > d)
1555 if (adjust_tail != 0)
1557 while (link(q) != p)
1560 if (type(p) == adjust_node)
1562 link(adjust_tail) = adjust_ptr(p);
1564 while (link(adjust_tail)!= 0)
1565 adjust_tail = link(adjust_tail);
1568 free_node(link(q), small_node_size);
1572 link(adjust_tail) = p;
1588 o = stretch_order(g);
1589 total_stretch[o] = total_stretch[o] + stretch(g);
1590 o = shrink_order(g);
1591 total_shrink[o] = total_shrink[o] + shrink(g);
1593 if (subtype(p) >= a_leaders)
1613 mem[lig_trick] = mem[lig_char(p)];
1614 link(lig_trick) = link(p);
1627 if (adjust_tail != 0)
1628 link(adjust_tail) = 0;
1633 if (m == additional)
1641 glue_sign(r) = normal;
1642 glue_order(r) = normal;
1648 if (total_stretch[filll] != 0)
1650 else if (total_stretch[fill] != 0)
1652 else if (total_stretch[fil] != 0)
1658 glue_sign(r) = stretching;
1660 if (total_stretch[o] != 0)
1661 glue_set(r) = x / ((double) total_stretch[o]);
1664 glue_sign(r) = normal;
1669 if (list_ptr(r) != 0)
1671 last_badness = badness(x, total_stretch[normal]);
1673 if (last_badness > hbadness)
1677 if (last_badness > 100)
1678 print_nl("Underfull");
1682 print_string(" \\hbox (badness ");
1683 print_int(last_badness);
1685 if (last_badness > 100) /* Y&Y TeX */
1686 underfull_hbox++; /* 1996/Feb/9 */
1695 if (total_shrink[filll] != 0)
1697 else if (total_shrink[fill] != 0)
1699 else if (total_shrink[fil] != 0)
1705 glue_sign(r) = shrinking;
1707 if (total_shrink[o] != 0)
1708 glue_set(r) =(- (integer) x) / ((double) total_shrink[o]);
1711 glue_sign(r) = normal;
1715 if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
1717 last_badness = 1000000L;
1720 if ((- (integer) x - total_shrink[normal] > hfuzz) || (hbadness < 100))
1722 if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz))
1727 link(q) = new_rule();
1728 width(link(q)) = overfull_rule;
1732 print_nl("Overfull \\hbox (");
1733 print_scaled(- (integer) x - total_shrink[normal]);
1734 print_string("pt too wide");
1736 overfull_hbox++; /* 1996/Feb/9 */
1741 else if (o == normal)
1742 if (list_ptr(r) != 0)
1744 last_badness = badness(- (integer) x, total_shrink[normal]);
1746 if (last_badness > hbadness)
1749 print_nl("Tight \\hbox (badness ");
1750 print_int(last_badness);
1758 print_string(") has occurred while \\output is active");
1761 if (pack_begin_line != 0)
1763 if (pack_begin_line > 0)
1764 print_string(") in paragraph at lines ");
1766 print_string(") in alignment at lines ");
1768 print_int(abs(pack_begin_line));
1772 print_string(") detected at line ");
1778 font_in_short_display = null_font;
1779 short_display(list_ptr(r));
1783 end_diagnostic(true);
1788 halfword vpackage_(halfword p, scaled h, small_number m, scaled l)
1795 int o; /* 95/Jan/7 */
1798 r = get_node(box_node_size);
1799 type(r) = vlist_node;
1800 subtype(r) = min_quarterword;
1801 shift_amount(r) = 0;
1806 total_stretch[normal] = 0;
1807 total_shrink[normal] = 0;
1808 total_stretch[fil] = 0;
1809 total_shrink[fil] = 0;
1810 total_stretch[fill] = 0;
1811 total_shrink[fill] = 0;
1812 total_stretch[filll] = 0;
1813 total_shrink[filll] = 0;
1817 if ((p >= hi_mem_min))
1820 return 0; // abort_flag set
1822 else switch (type(p))
1829 x = x + d + height(p);
1832 if (type(p) >= rule_node)
1835 s = shift_amount(p);
1837 if (width(p) + s > w)
1851 o = stretch_order(g);
1852 total_stretch[o] = total_stretch[o] + stretch(g);
1853 o = shrink_order(g);
1854 total_shrink[o] = total_shrink[o] + shrink(g);
1856 if (subtype(p) >= a_leaders)
1868 x = x + d + width(p);
1889 if (m == additional)
1897 glue_sign(r) = normal;
1898 glue_order(r) = normal;
1904 if (total_stretch[filll] != 0)
1906 else if (total_stretch[fill] != 0)
1908 else if (total_stretch[fil] != 0)
1914 glue_sign(r) = stretching;
1916 if (total_stretch[o] != 0)
1917 glue_set(r) = x / ((double) total_stretch[o]);
1920 glue_sign(r) = normal;
1925 if (list_ptr(r) != 0)
1927 last_badness = badness(x, total_stretch[normal]);
1929 if (last_badness > vbadness)
1933 if (last_badness > 100)
1934 print_nl("Underfull");
1938 print_string(" \\vbox (badness ");
1939 print_int(last_badness);
1941 if (last_badness > 100)
1942 underfull_vbox++; /* 1996/Feb/9 */
1951 if (total_shrink[filll] != 0)
1953 else if (total_shrink[fill] != 0)
1955 else if (total_shrink[fil] != 0)
1961 glue_sign(r) = shrinking;
1963 if (total_shrink[o] != 0)
1964 glue_set(r) =(- (integer) x)/ ((double) total_shrink[o]);
1967 glue_sign(r) = normal;
1971 if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
1973 last_badness = 1000000L;
1976 if ((- (integer) x - total_shrink[0] > vfuzz) || (vbadness < 100))
1979 print_nl("Overfull \\vbox (");
1980 print_scaled(- (integer) x - total_shrink[0]);
1981 print_string("pt too high");
1983 overfull_vbox++; /* 1996/Feb/9 */
1989 if (list_ptr(r) != 0)
1991 last_badness = badness(- (integer) x, total_shrink[normal]);
1992 if (last_badness > vbadness)
1995 print_nl("Tight \\vbox (badness ");
1996 print_int(last_badness);
2004 print_string(") has occurred while \\output is active");
2007 if (pack_begin_line != 0)
2009 print_string(") in alignment at lines ");
2010 print_int(abs(pack_begin_line));
2014 print_string(") detected at line ");
2022 end_diagnostic(true);
2027 void append_to_vlist_(halfword b)
2032 if (cur_list.aux_field.cint > ignore_depth)
2034 d = width(baseline_skip) - prev_depth - height(b);
2036 if (d < line_skip_limit)
2037 p = new_param_glue(line_skip_code);
2040 p = new_skip_param(baseline_skip_code);
2041 width(temp_ptr) = d;
2049 prev_depth = depth(b);
2052 halfword new_noad (void)
2056 p = get_node(noad_size);
2058 subtype(p) = normal;
2059 mem[nucleus(p)].hh = empty_field;
2060 mem[subscr(p)].hh = empty_field;
2061 mem[supscr(p)].hh = empty_field;
2066 halfword new_style_(small_number s)
2070 p = get_node(style_node_size);
2071 type(p) = style_node;
2079 halfword new_choice (void)
2083 p = get_node(style_node_size);
2084 type(p) = choice_node;
2086 display_mlist(p) = 0;
2088 script_mlist(p) = 0;
2089 script_script_mlist(p) = 0;
2094 void show_info (void)
2096 show_node_list(info(temp_ptr));
2099 halfword fraction_rule_(scaled t)
2110 halfword overbar_(halfword b, scaled k, scaled t)
2116 q = fraction_rule(t);
2120 return vpackage(p, 0, 1, 1073741823L); /* 2^30 - 1 */
2123 halfword char_box_(internal_font_number f, quarterword c)
2129 q = char_info(f, c);
2130 hd = height_depth(q);
2132 width(b) = char_width(f, q) + char_italic(f, q);
2133 height(b) = char_height(f, hd);
2134 depth(b) = char_depth(f, hd);
2143 void stack_into_box_(halfword b, internal_font_number f, quarterword c)
2148 link(p) = list_ptr(b);
2150 height(b) = height(p);
2153 scaled height_plus_depth_(internal_font_number f, fquarterword c)
2158 q = char_info(f, c);
2159 hd = height_depth(q);
2160 return char_height(f, hd) + char_depth(f, hd);
2163 halfword var_delimiter_(halfword d, small_number s, scaled v)
2166 internal_font_number f, g;
2167 quarterword c, x, y;
2174 /* small_number z; */
2175 int z; /* 95/Jan/7 */
2176 /* bool large_attempt; */
2177 int large_attempt; /* 95/Jan/7 */
2181 large_attempt = false;
2187 if ((z != 0) || (x != 0))
2200 if ((y >= font_bc[g]) && (y <= font_ec[g]))
2203 q = char_info(g, y);
2207 if (char_tag(q) == ext_tag)
2214 hd = height_depth(q);
2215 u = char_height(g, hd) + char_depth(g, hd);
2227 if (char_tag(q) == list_tag)
2242 large_attempt = true;
2248 if (char_tag(q) == ext_tag)
2251 type(b) = vlist_node;
2252 r = font_info[exten_base[f] + rem_byte(q)].qqqq;
2254 u = height_plus_depth(f, c);
2256 q = char_info(f, c);
2257 width(b) = char_width(f, q) + char_italic(f, q);
2260 if (c != min_quarterword)
2261 w = w + height_plus_depth(f, c);
2265 if (c != min_quarterword)
2266 w = w + height_plus_depth(f, c);
2270 if (c != min_quarterword)
2271 w = w + height_plus_depth(f, c);
2281 if (ext_mid(r) != min_quarterword)
2287 if (c != min_quarterword)
2288 stack_into_box(b, f, c);
2292 for (m = 1; m <= n; m++)
2293 stack_into_box(b, f, c);
2297 if (c != min_quarterword)
2299 stack_into_box(b, f, c);
2302 for (m = 1; m <= n; m++)
2303 stack_into_box(b, f, c);
2309 stack_into_box(b, f, c);
2311 depth(b) = w - height(b);
2318 width(b) = null_delimiter_space;
2321 shift_amount(b) = half(height(b) - depth(b)) - axis_height(s);
2325 /* rebox_ etc used to follow here in tex4.c */