2 Copyright 2014 Clerk Ma
\r
4 This program is free software; you can redistribute it and/or modify
\r
5 it under the terms of the GNU General Public License as published by
\r
6 the Free Software Foundation; either version 2 of the License, or
\r
7 (at your option) any later version.
\r
9 This program is distributed in the hope that it will be useful, but
\r
10 WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
12 General Public License for more details.
\r
14 You should have received a copy of the GNU General Public License
\r
15 along with this program; if not, write to the Free Software
\r
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
20 #define EXTERN extern
\r
23 #include "yandytex.h"
\r
26 void char_warning_(internal_font_number f, eight_bits c)
\r
28 if (tracing_lost_chars > 0)
\r
30 if (show_missing == 0)
\r
36 prints("Missing character: there is no ");
\r
39 print_nl("Missing character: there is no ");
\r
50 print_char('0' + c / 100);
\r
51 c = c - (c / 100) * 100;
\r
52 print_char('0' + c / 10);
\r
56 c = c - (c / 100) * 100;
\r
59 print_char('0' + c / 10);
\r
62 print_char('0' + c % 10);
\r
66 prints(" in font ");
\r
67 slow_print(font_name[f]);
\r
76 if (show_missing == 0)
\r
77 end_diagnostic(false);
\r
79 missing_characters++;
\r
83 pointer new_character_(internal_font_number f, eight_bits c)
\r
87 if (font_bc[f] <= c)
\r
88 if (font_ec[f] >= c)
\r
89 if (char_exists(char_info(f, c)))
\r
101 void dvi_swap (void)
\r
106 printf("dvi_swap() %lld", dvi_gone);
\r
109 if (dvi_limit == dvi_buf_size)
\r
111 write_dvi(0, half_buf - 1);
\r
112 dvi_limit = half_buf;
\r
113 dvi_offset = dvi_offset + dvi_buf_size;
\r
118 write_dvi(half_buf, dvi_buf_size - 1);
\r
119 dvi_limit = dvi_buf_size;
\r
122 dvi_gone = dvi_gone + half_buf;
\r
125 void dvi_four_(integer x)
\r
128 dvi_out(x / 0100000000);
\r
131 x = x + 010000000000;
\r
132 x = x + 010000000000;
\r
133 dvi_out((x / 0100000000) + 128);
\r
136 x = x % 0100000000;
\r
137 dvi_out(x / 0200000);
\r
143 void dvi_pop_(integer l)
\r
145 if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0))
\r
151 void dvi_font_def (internal_font_number f)
\r
155 #ifdef INCREASEFONTS
\r
164 dvi_out(((f - 1) >> 8));
\r
165 dvi_out(((f - 1) & 255));
\r
172 dvi_out(font_check[f].b0);
\r
173 dvi_out(font_check[f].b1);
\r
174 dvi_out(font_check[f].b2);
\r
175 dvi_out(font_check[f].b3);
\r
176 dvi_four(font_size[f]);
\r
177 dvi_four(font_dsize[f]);
\r
178 dvi_out(length(font_area[f]));
\r
179 dvi_out(length(font_name[f]));
\r
181 for (k = str_start[font_area[f]]; k <= str_start[font_area[f] + 1] - 1; k++)
\r
182 dvi_out(str_pool[k]);
\r
184 for (k = str_start[font_name[f]]; k <= str_start[font_name[f] + 1] - 1; k++)
\r
185 dvi_out(str_pool[k]);
\r
188 void movement (scaled w, eight_bits o)
\r
190 small_number mstate;
\r
194 q = get_node(movement_node_size);
\r
196 location(q) = dvi_offset + dvi_ptr;
\r
200 link(q) = down_ptr;
\r
205 link(q) = right_ptr;
\r
210 mstate = none_seen;
\r
215 switch (mstate + info(p))
\r
217 case none_seen + yz_OK:
\r
218 case none_seen + y_OK:
\r
219 case z_seen + yz_OK:
\r
220 case z_seen + y_OK:
\r
221 if (location(p) < dvi_gone)
\r
225 k = location(p) - dvi_offset;
\r
228 k = k + dvi_buf_size;
\r
230 dvi_buf[k] = dvi_buf[k] + y1 - down1;
\r
236 case none_seen + z_OK:
\r
237 case y_seen + yz_OK:
\r
238 case y_seen + z_OK:
\r
239 if (location(p) < dvi_gone)
\r
243 k = location(p) - dvi_offset;
\r
246 k = k + dvi_buf_size;
\r
248 dvi_buf[k] = dvi_buf[k] + z1 - down1;
\r
254 case none_seen + y_here:
\r
255 case none_seen + z_here:
\r
256 case y_seen + z_here:
\r
257 case z_seen + y_here:
\r
265 switch (mstate + info(p))
\r
267 case none_seen + y_here:
\r
271 case none_seen + z_here:
\r
275 case y_seen + z_here:
\r
276 case z_seen + y_here:
\r
291 if (abs(w) >= 8388608L) /* 2^23 */
\r
298 if (abs(w) >= 32768L)
\r
303 w = w + 16777216L; /* 2^24 */
\r
304 //dvi_out(w / 65536L);
\r
305 dvi_out((w >> 16));
\r
338 if (info(q) == y_here)
\r
340 dvi_out(o + y0 - down1);
\r
342 while (link(q) != p)
\r
363 dvi_out(o + z0 - down1);
\r
365 while (link(q) != p)
\r
386 void prune_movements (integer l)
\r
390 while (down_ptr != 0)
\r
392 if (location(down_ptr) < l)
\r
396 down_ptr = link(p);
\r
397 free_node(p, movement_node_size);
\r
401 while (right_ptr != 0)
\r
403 if (location(right_ptr) < l)
\r
407 right_ptr = link(p);
\r
408 free_node(p, movement_node_size);
\r
412 void special_out (pointer p)
\r
417 pdf_synch_h();//synch_h();
\r
418 pdf_synch_h();//synch_v();
\r
419 old_setting = selector;
\r
420 selector = new_string;
\r
422 #ifdef ALLOCATESTRING
\r
423 if (pool_ptr + 32000 > current_pool_size)
\r
424 str_pool = realloc_str_pool (increment_pool_size);
\r
426 show_token_list(link(write_tokens(p)), 0, 10000000L);
\r
428 show_token_list(link(write_tokens(p)), 0, pool_size - pool_ptr);
\r
431 selector = old_setting;
\r
434 spc_exec_special((const char *)str_pool + str_start[str_ptr], cur_length, cur_h * 0.000015202, -cur_v * 0.000015202, 1.0);
\r
436 if (cur_length < 256)
\r
439 dvi_out(cur_length);
\r
444 dvi_four(cur_length);
\r
447 for (k = str_start[str_ptr]; k <= pool_ptr - 1; k++)
\r
448 dvi_out(str_pool[k]);
\r
450 pool_ptr = str_start[str_ptr];
\r
453 void write_out (pointer p)
\r
456 /* integer old_mode; */
\r
458 /* small_number j; */
\r
463 info(q) = right_brace_token + '}';
\r
466 info(r) = end_write_token;
\r
468 begin_token_list(write_tokens(p), write_text);
\r
470 info(q) = left_brace_token + '{';
\r
474 cur_cs = write_loc;
\r
475 q = scan_toks(false, true);
\r
478 if (cur_tok != end_write_token)
\r
480 print_err("Unbalanced write command");
\r
481 help2("On this page there's a \\write with fewer real {'s than }'s.",
\r
482 "I can't handle that very well; good luck.");
\r
489 while (!(cur_tok == end_write_token));
\r
494 old_setting = selector;
\r
495 j = write_stream(p);
\r
501 if ((j == 17) && (selector == term_and_log))
\r
502 selector = log_only;
\r
507 token_show(def_ref);
\r
509 flush_list(def_ref);
\r
510 selector = old_setting;
\r
513 void out_what (pointer p)
\r
515 /* small_number j; */
\r
518 switch (subtype(p))
\r
523 if (!doing_leaders)
\r
525 j = write_stream(p);
\r
527 if (subtype(p) == write_node)
\r
532 a_close(write_file[j]);
\r
534 if (subtype(p) == close_node)
\r
535 write_open[j]= false;
\r
538 cur_name = open_name(p);
\r
539 cur_area = open_area(p);
\r
540 cur_ext = open_ext(p);
\r
542 if (cur_ext == 335) /* "" */
\r
543 cur_ext = 785; /* ".tex" */
\r
545 pack_file_name(cur_name, cur_area, cur_ext);
\r
547 while (!a_open_out(write_file[j]))
\r
548 prompt_file_name("output file name", ".tex");
\r
550 write_open[j] = true;
\r
560 case language_node:
\r
573 void hlist_out (void)
\r
577 scaled save_h, save_v;
\r
579 /* glue_ord g_order; */
\r
585 pointer leader_box;
\r
588 boolean outer_doing_leaders;
\r
596 this_box = temp_ptr;
\r
597 g_order = glue_order(this_box);
\r
598 g_sign = glue_sign(this_box);
\r
599 p = list_ptr(this_box);
\r
605 if (cur_s > max_push)
\r
608 save_loc = dvi_offset + dvi_ptr;
\r
614 if (is_char_node(p))
\r
629 font_used[f] = true;
\r
632 if (f <= 64 + font_base)
\r
633 dvi_out(f - font_base - 1 + fnt_num_0);
\r
634 #ifdef INCREASEFONTS
\r
643 dvi_out(((f - 1) >> 8));
\r
644 dvi_out(((f - 1) & 255));
\r
661 cur_h = cur_h + char_width(f, char_info(f, c));
\r
664 while (!(!is_char_node(p)));
\r
674 if (list_ptr(p) == 0)
\r
675 cur_h = cur_h + width(p);
\r
680 cur_v = base_line + shift_amount(p);
\r
684 if (type(p) == vlist_node)
\r
691 cur_h = edge + width(p);
\r
698 rule_ht = height(p);
\r
699 rule_dp = depth(p);
\r
700 rule_wd = width(p);
\r
712 rule_wd = width(g) - cur_g;
\r
714 if (g_sign != normal)
\r
716 if (g_sign == stretching)
\r
718 if (stretch_order(g) == g_order)
\r
720 cur_glue = cur_glue + stretch(g);
\r
721 vet_glue(glue_set(this_box) * cur_glue);
\r
722 cur_g = round(glue_temp);
\r
725 else if (shrink_order(g) == g_order)
\r
727 cur_glue = cur_glue - shrink(g);
\r
728 vet_glue(glue_set(this_box) * cur_glue);
\r
729 cur_g = round(glue_temp);
\r
733 rule_wd = rule_wd + cur_g;
\r
735 if (subtype(p) >= a_leaders)
\r
737 leader_box = leader_ptr(p);
\r
739 if (type(leader_box) == rule_node)
\r
741 rule_ht = height(leader_box);
\r
742 rule_dp = depth(leader_box);
\r
746 leader_wd = width(leader_box);
\r
748 if ((leader_wd > 0) && (rule_wd > 0))
\r
750 rule_wd = rule_wd + 10;
\r
751 edge = cur_h + rule_wd;
\r
754 if (subtype(p) == a_leaders)
\r
757 cur_h = left_edge + leader_wd * ((cur_h - left_edge) / leader_wd);
\r
759 if (cur_h < save_h)
\r
760 cur_h = cur_h + leader_wd;
\r
764 lq = rule_wd / leader_wd;
\r
765 lr = rule_wd % leader_wd;
\r
767 if (subtype(p) == c_leaders)
\r
768 cur_h = cur_h + (lr / 2);
\r
771 lx = (2 * lr + lq + 1) / (2 * lq + 2);
\r
772 cur_h = cur_h + ((lr - (lq - 1)* lx) / 2);
\r
776 while (cur_h + leader_wd <= edge)
\r
778 cur_v = base_line + shift_amount(leader_box);
\r
783 temp_ptr = leader_box;
\r
784 outer_doing_leaders = doing_leaders;
\r
785 doing_leaders = true;
\r
787 if (type(leader_box) == vlist_node)
\r
792 doing_leaders = outer_doing_leaders;
\r
796 cur_h = save_h + leader_wd + lx;
\r
810 cur_h = cur_h + width(p);
\r
813 case ligature_node:
\r
815 mem[lig_trick] = mem[lig_char(p)];
\r
816 link(lig_trick) = link(p);
\r
829 if (is_running(rule_ht))
\r
830 rule_ht = height(this_box);
\r
832 if (is_running(rule_dp))
\r
833 rule_dp = depth(this_box);
\r
835 rule_ht = rule_ht + rule_dp;
\r
837 if ((rule_ht > 0) && (rule_wd > 0))
\r
840 cur_v = base_line + rule_dp;
\r
846 dvi_h = dvi_h + rule_wd;
\r
850 cur_h = cur_h + rule_wd;
\r
856 prune_movements(save_loc);
\r
864 void vlist_out (void)
\r
868 scaled save_h, save_v;
\r
870 /* glue_ord g_order; */
\r
876 pointer leader_box;
\r
879 boolean outer_doing_leaders;
\r
887 this_box = temp_ptr;
\r
888 g_order = glue_order(this_box);
\r
889 g_sign = glue_sign(this_box);
\r
890 p = list_ptr(this_box);
\r
896 if (cur_s > max_push)
\r
899 save_loc = dvi_offset + dvi_ptr;
\r
901 cur_v = cur_v - height(this_box);
\r
906 if (is_char_node(p))
\r
908 confusion("vlistout");
\r
917 if (list_ptr(p) == 0)
\r
918 cur_v = cur_v + height(p) + depth(p);
\r
921 cur_v = cur_v + height(p);
\r
925 cur_h = left_edge + shift_amount(p);
\r
928 if (type(p) == vlist_node)
\r
935 cur_v = save_v + depth(p);
\r
942 rule_ht = height(p);
\r
943 rule_dp = depth(p);
\r
944 rule_wd = width(p);
\r
956 rule_ht = width(g) - cur_g;
\r
958 if (g_sign != normal)
\r
960 if (g_sign == stretching)
\r
962 if (stretch_order(g) == g_order)
\r
964 cur_glue = cur_glue + stretch(g);
\r
965 vet_glue(glue_set(this_box) * cur_glue);
\r
966 cur_g = round(glue_temp);
\r
969 else if (shrink_order(g) == g_order) /* BUG FIX !!! */
\r
971 cur_glue = cur_glue - shrink(g);
\r
972 vet_glue(glue_set(this_box) * cur_glue);
\r
973 cur_g = round(glue_temp);
\r
977 rule_ht = rule_ht + cur_g;
\r
979 if (subtype(p) >= a_leaders)
\r
981 leader_box = leader_ptr(p);
\r
983 if (type(leader_box) == rule_node)
\r
985 rule_wd = width(leader_box);
\r
990 leader_ht = height(leader_box) + depth(leader_box);
\r
992 if ((leader_ht > 0) && (rule_ht > 0))
\r
994 rule_ht = rule_ht + 10;
\r
995 edge = cur_v + rule_ht;
\r
998 if (subtype(p) == a_leaders)
\r
1001 cur_v = top_edge + leader_ht * ((cur_v - top_edge) / leader_ht);
\r
1003 if (cur_v < save_v)
\r
1004 cur_v = cur_v + leader_ht;
\r
1008 lq = rule_ht / leader_ht;
\r
1009 lr = rule_ht % leader_ht;
\r
1011 if (subtype(p) == c_leaders)
\r
1012 cur_v = cur_v + (lr / 2);
\r
1015 lx = (2 * lr + lq + 1) / (2 * lq + 2);
\r
1016 cur_v = cur_v + ((lr - (lq - 1) * lx) / 2);
\r
1020 while (cur_v + leader_ht <= edge)
\r
1022 cur_h = left_edge + shift_amount(leader_box);
\r
1025 cur_v = cur_v + height(leader_box);
\r
1028 temp_ptr = leader_box;
\r
1029 outer_doing_leaders = doing_leaders;
\r
1030 doing_leaders = true;
\r
1032 if (type(leader_box) == vlist_node)
\r
1037 doing_leaders = outer_doing_leaders;
\r
1040 cur_h = left_edge;
\r
1041 cur_v = save_v - height(leader_box) + leader_ht + lx;
\r
1044 cur_v = edge - 10;
\r
1054 cur_v = cur_v + width(p);
\r
1064 if (is_running(rule_wd))
\r
1065 rule_wd = width(this_box);
\r
1067 rule_ht = rule_ht + rule_dp;
\r
1068 cur_v = cur_v + rule_ht;
\r
1070 if ((rule_ht > 0) && (rule_wd > 0))
\r
1074 dvi_out(put_rule);
\r
1075 dvi_four(rule_ht);
\r
1076 dvi_four(rule_wd);
\r
1082 cur_v = cur_v + rule_ht;
\r
1089 prune_movements(save_loc);
\r
1092 dvi_pop(save_loc);
\r
1097 void dvi_ship_out_(pointer p)
\r
1104 if (tracing_output > 0)
\r
1108 prints("Completed box being shipped out");
\r
1111 if (term_offset > max_print_line - 9)
\r
1113 else if ((term_offset > 0) || (file_offset > 0))
\r
1119 while ((count(j) == 0) && (j > 0))
\r
1122 for (k = 0; k <= j; k++)
\r
1124 print_int(count(k));
\r
1130 update_terminal();
\r
1132 if (tracing_output > 0)
\r
1135 begin_diagnostic();
\r
1137 end_diagnostic(true);
\r
1140 if ((height(p) > max_dimen) || (depth(p) > max_dimen) ||
\r
1141 (height(p) + depth(p) + v_offset > max_dimen) ||
\r
1142 (width(p) + h_offset > max_dimen))
\r
1144 print_err("Huge page cannot be shipped out");
\r
1145 help2("The page just created is more than 18 feet tall or",
\r
1146 "more than 18 feet wide, so I suspect something went wrong.");
\r
1149 if (tracing_output <= 0)
\r
1151 begin_diagnostic();
\r
1152 print_nl("The following box has been deleted:");
\r
1154 end_diagnostic(true);
\r
1160 if (height(p) + depth(p) + v_offset > max_v)
\r
1161 max_v = height(p) + depth(p) + v_offset;
\r
1163 if (width(p) + h_offset > max_h)
\r
1164 max_h = width(p) + h_offset;
\r
1169 dvi_f = null_font;
\r
1170 ensure_dvi_open();
\r
1172 if (total_pages == 0)
\r
1176 dvi_four(25400000L);
\r
1177 dvi_four(473628672L);
\r
1180 old_setting = selector;
\r
1181 selector = new_string;
\r
1182 prints(" TeX output ");
\r
1189 print_two(tex_time / 60);
\r
1190 print_two(tex_time % 60);
\r
1191 selector = old_setting;
\r
1192 dvi_out(cur_length);
\r
1194 for (s = str_start[str_ptr]; s <= pool_ptr - 1; s++)
\r
1195 dvi_out(str_pool[s]);
\r
1197 pool_ptr = str_start[str_ptr];
\r
1200 page_loc = dvi_offset + dvi_ptr;
\r
1203 for (k = 0; k <= 9; k++)
\r
1204 dvi_four(count(k));
\r
1206 dvi_four(last_bop);
\r
1207 last_bop = page_loc;
\r
1208 cur_v = height(p) + v_offset;
\r
1211 if (type(p) == vlist_node)
\r
1217 incr(total_pages);
\r
1221 if (tracing_output <= 0)
\r
1225 update_terminal();
\r
1228 if (tracing_stats > 1)
\r
1230 print_nl("Memory usage before: ");
\r
1231 print_int(var_used);
\r
1233 print_int(dyn_used);
\r
1238 flush_node_list(p);
\r
1241 if (tracing_stats > 1)
\r
1243 prints(" after: ");
\r
1244 print_int(var_used);
\r
1246 print_int(dyn_used);
\r
1247 prints("; still utouched: ");
\r
1248 print_int(hi_mem_min - lo_mem_max - 1);
\r
1253 void ship_out (pointer p)
\r
1257 switch (shipout_flag)
\r
1259 case out_dvi_flag:
\r
1260 case out_xdv_flag:
\r
1263 case out_pdf_flag:
\r
1264 //pdf_ship_out(p);
\r
1269 void scan_spec (group_code c, boolean three_codes)
\r
1277 if (scan_keyword("to"))
\r
1278 spec_code = exactly;
\r
1279 else if (scan_keyword("spread"))
\r
1280 spec_code = additional;
\r
1283 spec_code = additional;
\r
1288 scan_dimen(false, false, false);
\r
1297 saved(0) = spec_code;
\r
1298 saved(1) = cur_val;
\r
1299 save_ptr = save_ptr + 2;
\r
1300 new_save_level(c);
\r
1301 scan_left_brace();
\r
1304 pointer hpack_(pointer p, scaled w, small_number m)
\r
1313 internal_font_number f;
\r
1318 r = get_node(box_node_size);
\r
1319 type(r) = hlist_node;
\r
1321 shift_amount(r) = 0;
\r
1322 q = r + list_offset;
\r
1327 total_stretch[normal] = 0;
\r
1328 total_shrink[normal] = 0;
\r
1329 total_stretch[fil] = 0;
\r
1330 total_shrink[fil] = 0;
\r
1331 total_stretch[fill] = 0;
\r
1332 total_shrink[fill] = 0;
\r
1333 total_stretch[filll] = 0;
\r
1334 total_shrink[filll] = 0;
\r
1340 while (is_char_node(p))
\r
1343 i = char_info(f, character(p));
\r
1344 hd = height_depth(i);
\r
1345 x = x + char_width(f, i);
\r
1346 s = char_height(f, hd);
\r
1351 s = char_depth(f, hd);
\r
1370 if (type(p) >= rule_node)
\r
1373 s = shift_amount(p);
\r
1375 if (height(p) - s > h)
\r
1376 h = height(p) - s;
\r
1378 if (depth(p) + s > d)
\r
1386 if (adjust_tail != 0)
\r
1388 while (link(q) != p)
\r
1391 if (type(p) == adjust_node)
\r
1393 link(adjust_tail) = adjust_ptr(p);
\r
1395 while (link(adjust_tail) != 0)
\r
1396 adjust_tail = link(adjust_tail);
\r
1399 free_node(link(q), small_node_size);
\r
1403 link(adjust_tail) = p;
\r
1413 case whatsit_node:
\r
1420 o = stretch_order(g);
\r
1421 total_stretch[o] = total_stretch[o] + stretch(g);
\r
1422 o = shrink_order(g);
\r
1423 total_shrink[o] = total_shrink[o] + shrink(g);
\r
1425 if (subtype(p) >= a_leaders)
\r
1427 g = leader_ptr(p);
\r
1429 if (height(g) > h)
\r
1443 case ligature_node:
\r
1445 mem[lig_trick] = mem[lig_char(p)];
\r
1446 link(lig_trick) = link(p);
\r
1459 if (adjust_tail != 0)
\r
1460 link(adjust_tail) = 0;
\r
1465 if (m == additional)
\r
1473 glue_sign(r) = normal;
\r
1474 glue_order(r) = normal;
\r
1475 glue_set(r) = 0.0;
\r
1480 if (total_stretch[filll] != 0)
\r
1482 else if (total_stretch[fill] != 0)
\r
1484 else if (total_stretch[fil] != 0)
\r
1489 glue_order(r) = o;
\r
1490 glue_sign(r) = stretching;
\r
1492 if (total_stretch[o] != 0)
\r
1493 glue_set(r) = x / ((double) total_stretch[o]);
\r
1496 glue_sign(r) = normal;
\r
1497 glue_set(r) = 0.0;
\r
1501 if (list_ptr(r) != 0)
\r
1503 last_badness = badness(x, total_stretch[normal]);
\r
1505 if (last_badness > hbadness)
\r
1509 if (last_badness > 100)
\r
1510 print_nl("Underfull");
\r
1512 print_nl("Loose");
\r
1514 prints(" \\hbox (badness ");
\r
1515 print_int(last_badness);
\r
1517 if (last_badness > 100)
\r
1520 goto common_ending;
\r
1528 if (total_shrink[filll] != 0)
\r
1530 else if (total_shrink[fill] != 0)
\r
1532 else if (total_shrink[fil] != 0)
\r
1537 glue_order(r) = o;
\r
1538 glue_sign(r) = shrinking;
\r
1540 if (total_shrink[o] != 0)
\r
1541 glue_set(r) = ((- (integer) x) / ((double) total_shrink[o]));
\r
1544 glue_sign(r) = normal;
\r
1545 glue_set(r) = 0.0;
\r
1548 if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
\r
1550 last_badness = 1000000L;
\r
1551 glue_set(r) = 1.0;
\r
1553 if ((- (integer) x - total_shrink[normal] > hfuzz) || (hbadness < 100))
\r
1555 if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz))
\r
1557 while (link(q) != 0)
\r
1560 link(q) = new_rule();
\r
1561 width(link(q)) = overfull_rule;
\r
1565 print_nl("Overfull \\hbox (");
\r
1566 print_scaled(- (integer) x - total_shrink[normal]);
\r
1567 prints("pt too wide");
\r
1570 goto common_ending;
\r
1573 else if (o == normal)
\r
1574 if (list_ptr(r) != 0)
\r
1576 last_badness = badness(- (integer) x, total_shrink[normal]);
\r
1578 if (last_badness > hbadness)
\r
1581 print_nl("Tight \\hbox (badness ");
\r
1582 print_int(last_badness);
\r
1583 goto common_ending;
\r
1592 if (output_active)
\r
1593 prints(") has occurred while \\output is active");
\r
1596 if (pack_begin_line != 0)
\r
1598 if (pack_begin_line > 0)
\r
1599 prints(") in paragraph at lines ");
\r
1601 prints(") in alignment at lines ");
\r
1603 print_int(abs(pack_begin_line));
\r
1607 prints(") detected at line ");
\r
1613 font_in_short_display = null_font;
\r
1614 short_display(list_ptr(r));
\r
1616 begin_diagnostic();
\r
1618 end_diagnostic(true);
\r
1624 pointer vpackage_(pointer p, scaled h, small_number m, scaled l)
\r
1634 r = get_node(box_node_size);
\r
1635 type(r) = vlist_node;
\r
1636 subtype(r) = min_quarterword;
\r
1637 shift_amount(r) = 0;
\r
1642 total_stretch[normal] = 0;
\r
1643 total_shrink[normal] = 0;
\r
1644 total_stretch[fil] = 0;
\r
1645 total_shrink[fil] = 0;
\r
1646 total_stretch[fill] = 0;
\r
1647 total_shrink[fill] = 0;
\r
1648 total_stretch[filll] = 0;
\r
1649 total_shrink[filll] = 0;
\r
1653 if (is_char_node(p))
\r
1655 confusion("vpack");
\r
1658 else switch (type(p))
\r
1665 x = x + d + height(p);
\r
1668 if (type(p) >= rule_node)
\r
1671 s = shift_amount(p);
\r
1673 if (width(p) + s > w)
\r
1678 case whatsit_node:
\r
1687 o = stretch_order(g);
\r
1688 total_stretch[o] = total_stretch[o] + stretch(g);
\r
1689 o = shrink_order(g);
\r
1690 total_shrink[o] = total_shrink[o] + shrink(g);
\r
1692 if (subtype(p) >= a_leaders)
\r
1694 g = leader_ptr(p);
\r
1704 x = x + d + width(p);
\r
1726 if (m == additional)
\r
1734 glue_sign(r) = normal;
\r
1735 glue_order(r) = normal;
\r
1736 glue_set(r) = 0.0;
\r
1741 if (total_stretch[filll] != 0)
\r
1743 else if (total_stretch[fill] != 0)
\r
1745 else if (total_stretch[fil] != 0)
\r
1750 glue_order(r) = o;
\r
1751 glue_sign(r) = stretching;
\r
1753 if (total_stretch[o] != 0)
\r
1754 glue_set(r) = x / ((double) total_stretch[o]);
\r
1757 glue_sign(r) = normal;
\r
1758 glue_set(r) = 0.0;
\r
1762 if (list_ptr(r) != 0)
\r
1764 last_badness = badness(x, total_stretch[normal]);
\r
1766 if (last_badness > vbadness)
\r
1770 if (last_badness > 100)
\r
1771 print_nl("Underfull");
\r
1773 print_nl("Loose");
\r
1775 prints(" \\vbox (badness ");
\r
1776 print_int(last_badness);
\r
1778 if (last_badness > 100)
\r
1781 goto common_ending;
\r
1789 if (total_shrink[filll] != 0)
\r
1791 else if (total_shrink[fill] != 0)
\r
1793 else if (total_shrink[fil] != 0)
\r
1798 glue_order(r) = o;
\r
1799 glue_sign(r) = shrinking;
\r
1801 if (total_shrink[o] != 0)
\r
1802 glue_set(r) = (- (integer) x) / ((double) total_shrink[o]);
\r
1805 glue_sign(r) = normal;
\r
1806 glue_set(r) = 0.0;
\r
1809 if ((total_shrink[o] < - (integer) x) && (o == 0) && (list_ptr(r) != 0))
\r
1811 last_badness = 1000000L;
\r
1812 glue_set(r) = 1.0;
\r
1814 if ((- (integer) x - total_shrink[0] > vfuzz) || (vbadness < 100))
\r
1817 print_nl("Overfull \\vbox (");
\r
1818 print_scaled(- (integer) x - total_shrink[0]);
\r
1819 prints("pt too high");
\r
1823 goto common_ending;
\r
1827 if (list_ptr(r) != 0)
\r
1829 last_badness = badness(- (integer) x, total_shrink[normal]);
\r
1830 if (last_badness > vbadness)
\r
1833 print_nl("Tight \\vbox (badness ");
\r
1834 print_int(last_badness);
\r
1835 goto common_ending;
\r
1844 if (output_active)
\r
1845 prints(") has occurred while \\output is active");
\r
1848 if (pack_begin_line != 0)
\r
1850 prints(") in alignment at lines ");
\r
1851 print_int(abs(pack_begin_line));
\r
1855 prints(") detected at line ");
\r
1861 begin_diagnostic();
\r
1863 end_diagnostic(true);
\r
1869 void append_to_vlist (pointer b)
\r
1874 if (prev_depth > ignore_depth)
\r
1876 d = width(baseline_skip) - prev_depth - height(b);
\r
1878 if (d < line_skip_limit)
\r
1879 p = new_param_glue(line_skip_code);
\r
1882 p = new_skip_param(baseline_skip_code);
\r
1883 width(temp_ptr) = d;
\r
1892 prev_depth = depth(b);
\r
1895 pointer new_noad (void)
\r
1899 p = get_node(noad_size);
\r
1900 type(p) = ord_noad;
\r
1901 subtype(p) = normal;
\r
1902 mem[nucleus(p)].hh = empty_field;
\r
1903 mem[subscr(p)].hh = empty_field;
\r
1904 mem[supscr(p)].hh = empty_field;
\r
1909 pointer new_style (small_number s)
\r
1913 p = get_node(style_node_size);
\r
1914 type(p) = style_node;
\r
1922 pointer new_choice (void)
\r
1926 p = get_node(style_node_size);
\r
1927 type(p) = choice_node;
\r
1929 display_mlist(p) = 0;
\r
1930 text_mlist(p) = 0;
\r
1931 script_mlist(p) = 0;
\r
1932 script_script_mlist(p) = 0;
\r
1937 void show_info (void)
\r
1939 show_node_list(info(temp_ptr));
\r
1942 pointer fraction_rule (scaled t)
\r
1953 pointer overbar (pointer b, scaled k, scaled t)
\r
1959 q = fraction_rule(t);
\r
1964 return vpackage(p, 0, 1, max_dimen);
\r
1967 pointer char_box (internal_font_number f, quarterword c)
\r
1973 q = char_info(f, c);
\r
1974 hd = height_depth(q);
\r
1975 b = new_null_box();
\r
1976 width(b) = char_width(f, q) + char_italic(f, q);
\r
1977 height(b) = char_height(f, hd);
\r
1978 depth(b) = char_depth(f, hd);
\r
1987 void stack_into_box (pointer b, internal_font_number f, quarterword c)
\r
1991 p = char_box(f, c);
\r
1992 link(p) = list_ptr(b);
\r
1994 height(b) = height(p);
\r
1997 scaled height_plus_depth (internal_font_number f, quarterword c)
\r
2002 q = char_info(f, c);
\r
2003 hd = height_depth(q);
\r
2005 return char_height(f, hd) + char_depth(f, hd);
\r
2008 pointer var_delimiter (pointer d, small_number s, scaled v)
\r
2011 internal_font_number f, g;
\r
2012 quarterword c, x, y;
\r
2019 /* small_number z; */
\r
2021 boolean large_attempt;
\r
2025 large_attempt = false;
\r
2027 x = small_char(d);
\r
2031 if ((z != 0) || (x != 0))
\r
2040 if (g != null_font)
\r
2044 if ((y >= font_bc[g]) && (y <= font_ec[g]))
\r
2047 q = char_info(g, y);
\r
2049 if (char_exists(q))
\r
2051 if (char_tag(q) == ext_tag)
\r
2058 hd = height_depth(q);
\r
2059 u = char_height(g, hd) + char_depth(g, hd);
\r
2071 if (char_tag(q) == list_tag)
\r
2080 while (!(z < 16));
\r
2083 if (large_attempt)
\r
2086 large_attempt = true;
\r
2088 x = large_char(d);
\r
2092 if (f != null_font)
\r
2093 if (char_tag(q) == ext_tag)
\r
2095 b = new_null_box();
\r
2096 type(b) = vlist_node;
\r
2097 r = font_info[exten_base[f] + rem_byte(q)].qqqq;
\r
2099 u = height_plus_depth(f, c);
\r
2101 q = char_info(f, c);
\r
2102 width(b) = char_width(f, q) + char_italic(f, q);
\r
2105 if (c != min_quarterword)
\r
2106 w = w + height_plus_depth(f, c);
\r
2110 if (c != min_quarterword)
\r
2111 w = w + height_plus_depth(f, c);
\r
2115 if (c != min_quarterword)
\r
2116 w = w + height_plus_depth(f, c);
\r
2126 if (ext_mid(r) != min_quarterword)
\r
2132 if (c != min_quarterword)
\r
2133 stack_into_box(b, f, c);
\r
2137 for (m = 1; m <= n; m++)
\r
2138 stack_into_box(b, f, c);
\r
2142 if (c != min_quarterword)
\r
2144 stack_into_box(b, f, c);
\r
2147 for (m = 1; m <= n; m++)
\r
2148 stack_into_box(b, f, c);
\r
2154 stack_into_box(b, f, c);
\r
2156 depth(b) = w - height(b);
\r
2159 b = char_box(f, c);
\r
2162 b = new_null_box();
\r
2163 width(b) = null_delimiter_space;
\r
2166 shift_amount(b) = half(height(b) - depth(b)) - axis_height(s);
\r