1 /* Copyright 2014 Clerk Ma
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 void align_peek (void)
26 align_state = 1000000L;
32 while (!(cur_cmd != spacer));
34 if (cur_cmd == no_align)
38 new_save_level(no_align_group);
43 else if (cur_cmd == right_brace)
47 else if ((cur_cmd == car_ret) && (cur_chr == cr_cr_code))
56 halfword finite_shrink_(halfword p)
60 if (no_shrink_error_yet)
62 no_shrink_error_yet = false;
63 print_err("Infinite glue shrinkage found in a paragraph");
64 help5("The paragraph just ended includes some glue that has",
65 "infinite shrinkability, e.g., `\\hskip 0pt minus 1fil'.",
66 "Such glue doesn't belong there---it allows a paragraph",
67 "of any length to fit on one line. But it's safe to proceed,",
68 "since the offensive shrinkability has been made finite.");
73 shrink_order(q) = normal;
79 void try_break_ (integer pi, small_number break_type)
90 internal_font_number f;
92 boolean node_r_stays_active;
97 boolean artificial_demerits;
101 if (abs(pi)>= inf_penalty)
110 do_all_six(copy_to_cur_active);
117 if (type(r) == delta_node)
119 do_all_six(update_width);
120 prev_prev_r = prev_r;
130 if ((minimum_demerits < awful_bad) && ((old_l != easyline) || (r == active)))
134 no_break_yet = false;
135 do_all_six(set_break_width_to_background);
138 if (break_type > unhyphenated)
141 t = replace_count(cur_p);
143 s = post_break(cur_p);
153 break_width[1] = break_width[1] - char_width(f, char_info(f, character(v)));
155 else switch (type(v))
159 f = font(lig_char(v));
160 break_width[1] = break_width[1] - char_width(f, char_info(f, character(lig_char(v))));
168 break_width[1] = break_width[1] - width(v);
185 break_width[1] = break_width[1] + char_width(f, char_info(f, character(s)));
191 f = font(lig_char(s));
192 break_width[1] = break_width[1] + char_width(f, char_info(f, character(lig_char(s))));
200 break_width[1] = break_width[1] + width(s);
214 break_width[1] = break_width[1] + disc_width;
216 if (post_break(cur_p) == 0)
230 break_width[1] = break_width[1] - width(v);
231 break_width[2 + stretch_order(v)] = break_width[2 + stretch_order(v)] - stretch(v);
232 break_width[6] = break_width[6] - shrink(v);
241 break_width[1] = break_width[1] - width(s);
245 if (subtype(s) != explicit)
248 break_width[1] = break_width[1] - width(s);
261 if (type(prev_r) == delta_node)
263 do_all_six(convert_to_break_width);
265 else if (prev_r == active)
267 do_all_six(store_break_width);
271 q = get_node(delta_node_size);
273 type(q) = delta_node;
275 do_all_six(new_delta_to_break_width);
277 prev_prev_r = prev_r;
281 if (abs(adj_demerits) >= awful_bad - minimum_demerits)
282 minimum_demerits = awful_bad - 1;
284 minimum_demerits = minimum_demerits + abs(adj_demerits);
286 for (fit_class = very_loose_fit; fit_class <= tight_fit; fit_class++)
288 if (minimal_demerits[fit_class] <= minimum_demerits)
290 q = get_node(passive_node_size);
293 cur_break(q) = cur_p;
296 serial(q) = pass_number;
298 prev_break(q) = best_place[fit_class];
299 q = get_node(active_node_size);
300 break_node(q) = passive;
301 line_number(q) = best_pl_line[fit_class] + 1;
302 fitness(q) = fit_class;
303 type(q) = break_type;
304 total_demerits(q) = minimal_demerits[fit_class];
309 if (tracing_paragraphs > 0)
312 print_int(serial(passive));
314 print_int(line_number(q) - 1);
316 print_int(fit_class);
318 if (break_type == hyphenated)
322 print_int(total_demerits(q));
325 if (prev_break(passive) == 0)
328 print_int(serial(prev_break(passive)));
333 minimal_demerits[fit_class] = awful_bad;
336 minimum_demerits = awful_bad;
340 q = get_node(delta_node_size);
342 type(q) = delta_node;
344 do_all_six(new_delta_from_break_width);
346 prev_prev_r = prev_r;
356 line_width = second_width;
357 old_l = max_halfword - 1; /*262142L*/ /* 2^18 - 2 ? */
363 if (l > last_special_line)
364 line_width = second_width;
365 else if (par_shape_ptr == 0)
366 line_width = first_width;
368 line_width = mem[par_shape_ptr + 2 * l].cint;
374 artificial_demerits = false;
375 shortfall = line_width - cur_active_width[1];
378 if ((cur_active_width[3] != 0) || (cur_active_width[4] != 0) || (cur_active_width[5] != 0))
381 fit_class = decent_fit;
385 if (shortfall > 7230584L)
386 if (cur_active_width[2] < 1663497L)
389 fit_class = very_loose_fit;
393 b = badness(shortfall, cur_active_width[2]);
397 fit_class = very_loose_fit;
399 fit_class = loose_fit;
401 fit_class = decent_fit;
406 if (- (integer) shortfall > cur_active_width[6])
409 b = badness(- (integer) shortfall, cur_active_width[6]);
412 fit_class = tight_fit;
414 fit_class = decent_fit;
417 if ((b > inf_bad) || (pi == eject_penalty))
419 if (final_pass && (minimum_demerits == awful_bad) && (link(r) == active) && (prev_r == active))
420 artificial_demerits = true;
421 else if (b > threshold)
424 node_r_stays_active = false;
433 node_r_stays_active = true;
436 if (artificial_demerits)
440 d = line_penalty + b;
450 else if (pi > -10000)
453 if ((break_type == hyphenated) && (type(r) == hyphenated))
455 d = d + double_hyphen_demerits;
457 d = d + final_hyphen_demerits;
459 if (abs(toint(fit_class)- toint(fitness(r))) > 1)
460 d = d + adj_demerits;
464 if (tracing_paragraphs > 0)
466 if (printed_node != cur_p)
471 short_display(link(printed_node));
474 save_link = link(cur_p);
477 short_display(link(printed_node));
478 link(cur_p) = save_link;
481 printed_node = cur_p;
488 else if (type(cur_p) != glue_node)
490 if (type(cur_p) == penalty_node)
491 print_esc("penalty");
492 else if (type(cur_p) == disc_node)
493 print_esc("discretionary");
494 else if (type(cur_p) == kern_node)
502 if (break_node(r) == 0)
505 print_int(serial(break_node(r)));
518 if (artificial_demerits)
525 d = d + total_demerits(r);
527 if (d <= minimal_demerits[fit_class])
529 minimal_demerits[fit_class] = d;
530 best_place[fit_class] = break_node(r);
531 best_pl_line[fit_class] = l;
533 if (d < minimum_demerits)
534 minimum_demerits = d;
537 if (node_r_stays_active)
540 link(prev_r) = link(r);
541 free_node(r, active_node_size);
543 if (prev_r == active)
547 if (type(r) == delta_node)
549 do_all_six(update_active);
550 do_all_six(copy_to_cur_active);
551 link(active) = link(r);
552 free_node(r, delta_node_size);
555 else if (type(prev_r) == delta_node)
561 do_all_six(downdate_width);
562 link(prev_prev_r) = active;
563 free_node(prev_r, delta_node_size);
564 prev_r = prev_prev_r;
566 else if (type(r) == delta_node)
568 do_all_six(update_width);
569 do_all_six(combine_two_deltas);
570 link(prev_r) = link(r);
571 free_node(r, delta_node_size);
579 if (cur_p == printed_node)
581 if (type(cur_p) == disc_node)
583 t = replace_count(cur_p);
588 printed_node = link(printed_node);
593 /* end of the old tex5.c here */
595 void post_line_break_(integer final_widow_penalty)
599 boolean post_disc_break;
606 q = break_node(best_bet);
613 next_break(r) = cur_p;
618 cur_line = prev_graf + 1;
622 q = cur_break(cur_p);
624 post_disc_break = false;
627 if (type(q) == glue_node)
629 delete_glue_ref(glue_ptr(q));
630 glue_ptr(q) = right_skip;
631 subtype(q) = right_skip_code + 1;
632 add_glue_ref(right_skip);
637 if (type(q) == disc_node)
639 t = replace_count(q);
656 flush_node_list(link(q));
657 replace_count(q) = 0;
660 if (post_break(q) != 0)
670 post_disc_break = true;
673 if (pre_break(q) != 0)
688 else if ((type(q) == math_node) || (type(q) == kern_node))
699 r = new_param_glue(right_skip_code);
711 r = new_param_glue(left_skip_code);
716 if (cur_line > last_special_line)
718 cur_width = second_width;
719 cur_indent = second_indent;
721 else if (par_shape_ptr == 0)
723 cur_width = first_width;
724 cur_indent = first_indent;
728 cur_width = mem[par_shape_ptr + 2 * cur_line].cint;
729 cur_indent = mem[par_shape_ptr + 2 * cur_line - 1].cint;
732 adjust_tail = adjust_head;
733 just_box = hpack(q, cur_width, 0);
734 shift_amount(just_box) = cur_indent;
735 append_to_vlist(just_box);
737 if (adjust_head != adjust_tail)
739 link(tail) = link(adjust_head);
745 if (cur_line + 1 != best_line)
747 pen = inter_line_penalty;
749 if (cur_line == prev_graf + 1)
750 pen = pen + club_penalty;
752 if (cur_line + 2 == best_line)
753 pen = pen + final_widow_penalty;
756 pen = pen + broken_penalty;
760 r = new_penalty(pen);
767 cur_p = next_break(cur_p);
770 if (!post_disc_break)
778 if (q == cur_break(cur_p))
784 if (non_discardable(q))
787 if (type(q) == kern_node)
797 flush_node_list(link(temp_head));
802 while (!(cur_p == 0));
804 if ((cur_line != best_line) || (link(temp_head) != 0))
806 confusion("line breaking");
810 prev_graf = best_line - 1;
813 small_number reconstitute_(small_number j, small_number n, halfword bchar, halfword hchar)
832 ligature_present = init_lig;
835 if (ligature_present)
840 append_charnode_to_t(character(p));
844 else if (cur_l < 256)
846 append_charnode_to_t(cur_l);
853 if (cur_l == non_char)
857 if (k == non_address)
860 q = font_info[k].qqqq;
864 q = char_info(hf, cur_l);
866 if (char_tag(q) != lig_tag)
869 k = lig_kern_start(hf, q);
870 q = font_info[k].qqqq;
872 if (skip_byte(q) > stop_flag)
874 k = lig_kern_restart(hf, q);
875 q = font_info[k].qqqq;
879 if (cur_rh < non_char)
886 if (next_char(q) == test_char)
887 if (skip_byte(q) <= 128)
888 if (cur_rh < non_char)
897 if (hchar < non_char)
904 if (op_byte(q) < kern_flag)
906 if (cur_l == non_char)
921 ligature_present = true;
931 character(lig_stack) = cur_r;
934 lig_stack = new_lig_item(cur_r);
941 list_ptr(lig_stack) = p;
942 character(p) = hu[j + 1];
953 lig_stack = new_lig_item(cur_r);
961 if (ligature_present)
963 p = new_ligature(hf, cur_l, mem[cur_q].hh.rh);
971 mem[cur_q].hh.rh = p;
973 ligature_present = false;
977 ligature_present = true;
984 ligature_present = true;
988 if (lig_ptr(lig_stack) != 0)
990 link(t) = lig_ptr(lig_stack);
997 free_node(p, small_node_size);
1012 cur_r = character(lig_stack);
1018 append_charnode_to_t(cur_r);
1027 if (op_byte(q) != 7)
1033 w = char_kern(hf, q);
1037 if (q.b0 >= stop_flag)
1038 if (cur_rh == non_char)
1046 k = k + skip_byte(q) + 1;
1047 q = font_info[k].qqqq;
1054 link(t) = new_kern(w);
1059 if (lig_stack != 0) /* l.17841 */
1062 cur_l = character(lig_stack);
1063 ligature_present = true;
1071 void hyphenate (void)
1075 int l; /* 95/Jan/7 */
1078 halfword major_tail, minor_tail;
1080 int c; /* 95/Jan/7 */
1082 /* integer r_count; */
1083 int r_count; /* 95/Jan/7 */
1091 for (j = 0; j <= hn; j++)
1098 for (j = 2; j <= hn; j++)
1099 h = (h + h + hc[j]) % hyphen_prime;
1111 if (length(k) == hn)
1118 if (str_pool[u] < hc[j])
1121 if (str_pool[u] > hc[j])
1150 if (trie_trc[cur_lang + 1] != cur_lang)
1157 for (j = 0; j <= hn - rhyf + 1; j++)
1159 z = trie_trl[cur_lang + 1] + hc[j];
1162 while (hc[l] == trie_trc[z])
1164 if (trie_tro[z] != min_trie_op)
1170 v = v + op_start[cur_lang];
1171 i = l - hyf_distance[v];
1173 if (hyf_num[v] > hyf[i])
1178 while (!(v == min_trie_op));
1182 z = trie_trl[z] + hc[l];
1187 for (j = 0; j <= lhyf - 1; j++)
1190 for (j = 0; j <= rhyf - 1; j++)
1193 for (j = lhyf; j <= hn - rhyf; j++)
1206 if (is_char_node(ha))
1213 hu[0] = character(ha);
1215 else if (type(ha) == ligature_node)
1216 if (font(lig_char(ha)) != hf)
1220 init_list = lig_ptr(ha);
1222 init_lft = (subtype(ha) > 1);
1223 hu[0] = character(lig_char(ha));
1232 free_node(ha, small_node_size);
1236 if (!is_char_node(r))
1237 if (type(r) == ligature_node)
1249 while (link(s) != ha)
1266 j = reconstitute(j, hn, bchar, hyf_char) + 1;
1268 if (hyphen_passed == 0)
1270 link(s) = link(hold_head);
1272 while (link(s) != 0) /* l.17903 */
1275 if (odd(hyf[j - 1]))
1278 hyphen_passed = j - 1;
1279 link(hold_head) = 0;
1283 if (hyphen_passed > 0)
1286 r = get_node(small_node_size);
1287 link(r) = link(hold_head);
1288 type(r) = disc_node;
1292 while (mem[major_tail].hh.rh != 0)
1294 major_tail = link(major_tail);
1302 hyf_node = new_character(hf, hyf_char);
1309 free_avail(hyf_node);
1314 l = reconstitute(l, i, font_bchar[hf], non_char) + 1;
1316 if (link(hold_head) != 0) /* BUG FIX ??? */
1318 if (minor_tail == 0)
1319 pre_break(r) = link(hold_head);
1321 link(minor_tail) = link(hold_head);
1323 minor_tail = link(hold_head);
1325 while (link(minor_tail) != 0) /* BUG FIX */
1326 minor_tail = link(minor_tail);
1330 if (hyf_node != 0) /* if hyf_node<>null then l.17956 */
1341 if (bchar_label[hf] != non_address) /* i.e. 0 --- 96/Jan/15 */
1353 l = reconstitute(l, hn, bchar, 256) + 1;
1361 if (link(hold_head) != 0) /* BUG FIX */
1363 if (minor_tail == 0) /* begin if minor_tail=null then */
1364 post_break(r) = link(hold_head);
1366 link(minor_tail) = link(hold_head);
1368 minor_tail = link(hold_head);
1370 while (link(minor_tail) != 0) /* ??? */
1371 minor_tail = link(minor_tail);
1378 j = reconstitute(j, hn, bchar, non_char) + 1;
1379 link(major_tail) = link(hold_head);
1381 while (mem[major_tail].hh.rh != 0)
1383 major_tail = link(major_tail);
1398 replace_count(r) = r_count;
1402 hyphen_passed = j - 1;
1403 link(hold_head) = 0;
1405 while (!(! odd(hyf[j - 1])));
1410 flush_list(init_list);
1413 void new_hyph_exceptions (void)
1415 /* small_number n; */ /* in 3.141 */
1417 /* small_number j; */ /* in 3.141 */
1452 if (lc_code(cur_chr) == 0)
1454 print_err("Not a letter");
1455 help2("Letters in \\hyphenation words must have \\lccode>0.",
1456 "Proceed; I'll ignore the character I just read.");
1462 hc[n] = lc_code(cur_chr);
1471 cur_cmd = char_given;
1486 for (j = 1; j <= n; j++)
1488 h = (h + h + hc[j]) % hyphen_prime;
1494 if (hyph_count == hyphen_prime)
1496 overflow("exception dictionary", hyphen_prime); /* exception dictionary - NOT DYNAMIC */
1502 while (hyph_word[h] != 0)
1506 if (length(k) < length(s))
1509 if (length(k) > length(s))
1517 if (str_pool[u] < str_pool[v])
1520 if (str_pool[u] > str_pool[v])
1526 while (!(u == str_start[k + 1]));
1545 if (cur_cmd == right_brace)
1555 print_err("Improper ");
1556 print_esc("hyphenation");
1557 prints(" will be flushed");
1558 help2("Hyphenation exceptions must contain only letters",
1559 "and hyphens. But continue; I'll forgive and forget.");
1563 } /* end of switch */
1567 halfword prune_page_top_(halfword p)
1573 link(temp_head) = p;
1582 q = new_skip_param(split_top_skip_code);
1586 if (width(temp_ptr) > height(p))
1587 width(temp_ptr) = width(temp_ptr) - height(p);
1589 width(temp_ptr) = 0;
1618 confusion("pruning");
1624 return link(temp_head);
1627 halfword vert_break_(halfword p, scaled h, scaled d)
1634 halfword best_place;
1636 /* small_number t; */
1637 int t; /* 95/Jan/7 */
1640 least_cost = awful_bad;
1641 do_all_six(set_height_zero);
1648 else switch(type(p))
1654 cur_height = cur_height + prev_dp + height(p);
1665 if (precedes_break(prev_p))
1668 goto update_heights;
1681 goto update_heights;
1696 confusion("vertbreak");
1702 if (pi < inf_penalty)
1705 if ((active_width[3] != 0) || (active_width[4] != 0) || (active_width[5]!= 0))
1708 b = badness(h - cur_height, active_width[2]);
1710 if (act_width - h > active_width[6])
1713 b = badness(cur_height - h, active_width[6]);
1716 if (pi <= eject_penalty)
1724 if (b <= least_cost)
1728 best_height_plus_depth = cur_height + prev_dp;
1731 if ((b == awful_bad) || (pi <= eject_penalty))
1735 if ((type(p) < glue_node) || (type(p) > kern_node))
1739 if (type(p) == kern_node)
1744 active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
1745 active_width[6] = active_width[6] + shrink(q);
1747 if ((shrink_order(q) != normal) && (shrink(q) != 0))
1749 print_err("Infinite glue shrinkage found in box being split");
1750 help4("The box you are \\vsplitting contains some infinitely",
1751 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
1752 "Such glue doesn't belong there; but you can safely proceed,",
1753 "since the offensive shrinkability has been made finite.");
1756 shrink_order(r) = normal;
1763 cur_height = cur_height + prev_dp + width(q);
1768 cur_height = cur_height + prev_dp - d;
1780 halfword vsplit_(eight_bits n, scaled h)
1788 if (split_first_mark != 0)
1790 delete_token_ref(split_first_mark);
1791 split_first_mark = 0;
1792 delete_token_ref(split_bot_mark);
1801 if (type(v) != vlist_node)
1804 print_esc("vsplit");
1805 prints(" needs a ");
1807 help2("The box you are trying to split is an \\hbox.",
1808 "I can't split such a box, so I'll leave it alone.");
1813 q = vert_break(list_ptr(v), h, split_max_depth);
1820 if (type(p) == mark_node)
1821 if (split_first_mark == 0)
1823 split_first_mark = mark_ptr(p);
1824 split_bot_mark = split_first_mark;
1825 token_ref_count(split_first_mark) = token_ref_count(split_first_mark) + 2;
1829 delete_token_ref(split_bot_mark);
1830 split_bot_mark = mark_ptr(p);
1831 add_token_ref(split_bot_mark);
1842 q = prune_page_top(q);
1844 free_node(v, box_node_size);
1849 box(n) = vpackage(q, 0, 1, 1073741823L); /* 2^30 - 1 */
1851 return vpackage(p, h, exactly, split_max_depth);
1854 void print_totals (void)
1856 print_scaled(page_so_far[1]);
1858 if (page_so_far[2] != 0)
1861 print_scaled(page_so_far[2]);
1865 if (page_so_far[3] != 0)
1868 print_scaled(page_so_far[3]);
1872 if (page_so_far[4] != 0)
1875 print_scaled(page_so_far[4]);
1879 if (page_so_far[5] != 0)
1882 print_scaled(page_so_far[5]);
1886 if (page_so_far[6] != 0)
1889 print_scaled(page_so_far[6]);
1893 void freeze_page_specs_(small_number s)
1897 page_max_depth = max_depth;
1899 do_all_six(set_page_so_far_zero);
1900 least_page_cost = awful_bad;
1903 if (tracing_pages > 0)
1906 print_nl("%% goal height=");
1907 print_scaled(page_goal);
1908 prints(", max depth=");
1909 print_scaled(page_max_depth);
1910 end_diagnostic(false);
1915 void box_error_(eight_bits n)
1919 print_nl("The following box has been deleted:");
1921 end_diagnostic(true);
1922 flush_node_list(box(n));
1926 void ensure_vbox_(eight_bits n)
1933 if (type(p) == hlist_node)
1935 print_err("Insertions can only be added to a vbox");
1936 help3("Tut tut: You're trying to \\insert into a",
1937 "\\box register that now contains an \\hbox.",
1938 "Proceed, and I'll discard its present contents.");
1943 void fire_up_(halfword c)
1947 /* unsigned char n; */
1948 unsigned int n; /* 95/Jan/7 */
1950 integer save_vbadness;
1952 pointer save_split_top_skip;
1954 if (type(best_page_break) == penalty_node)
1956 geq_word_define(int_base + output_penalty_code, penalty(best_page_break));
1957 penalty(best_page_break) = inf_penalty;
1960 geq_word_define(int_base + output_penalty_code, inf_penalty);
1965 delete_token_ref(top_mark);
1967 top_mark = bot_mark;
1968 add_token_ref(top_mark);
1969 delete_token_ref(first_mark);
1973 if (c == best_page_break)
1974 best_page_break = 0;
1980 prints("255 is not void");
1981 help2("You shouldn't use \\box255 except in \\output routines.",
1982 "Proceed, and I'll discard its present contents.");
1986 insert_penalties = 0;
1987 save_split_top_skip = split_top_skip;
1989 if (holding_inserts <= 0)
1991 r = link(page_ins_head);
1993 while (r != page_ins_head)
1995 if (best_ins_ptr(r) != 0)
2001 box(n) = new_null_box();
2003 p = box(n) + list_offset;
2005 while (link(p) != 0)
2008 last_ins_ptr(r) = p;
2020 while (p != best_page_break)
2022 if (type(p) == ins_node)
2024 if (holding_inserts <= 0)
2026 r = link(page_ins_head);
2028 while (subtype(r) != subtype(p))
2031 if (best_ins_ptr(r) == 0)
2036 s = last_ins_ptr(r);
2037 link(s) = ins_ptr(p);
2039 if (best_ins_ptr(r) == p)
2041 if (type(r) == split_up)
2042 if ((broken_ins(r) == p) && (broken_ins(r) != 0))
2044 while (link(s) != broken_ptr(r))
2048 split_top_skip = split_top_ptr(p);
2049 ins_ptr(p) = prune_page_top(broken_ptr(r));
2051 if (ins_ptr(p) != 0)
2053 temp_ptr = vpackage(ins_ptr(p), 0, 1, 1073741823L); /* 2^30 - 1 */
2054 height(p) = height(temp_ptr) + depth(temp_ptr);
2055 free_node(temp_ptr, box_node_size);
2060 best_ins_ptr(r) = 0;
2062 temp_ptr = list_ptr(box(n));
2063 free_node(box(n), box_node_size);
2064 box(n) = vpackage(temp_ptr, 0, 1, 1073741823L); /* 2^30 - 1 */
2068 while (link(s) != 0)
2071 last_ins_ptr(r) = s;
2075 link(prev_p) = link(p);
2082 incr(insert_penalties);
2086 delete_glue_ref(split_top_ptr(p));
2087 free_node(p, ins_node_size);
2093 else if (type(p) == mark_node)
2095 if (first_mark == 0)
2097 first_mark = mark_ptr(p);
2098 add_token_ref(first_mark);
2102 delete_token_ref(bot_mark);
2104 bot_mark = mark_ptr(p);
2105 add_token_ref(bot_mark);
2111 split_top_skip = save_split_top_skip;
2115 if (link(contrib_head) == 0)
2119 nest[0].tail_field = page_tail;
2121 link(page_tail) = link(contrib_head);
2122 link(contrib_head) = p;
2126 save_vbadness = vbadness;
2130 box(255) = vpackage(link(page_head), best_size, 0, page_max_depth);
2131 vbadness = save_vbadness;
2134 if (last_glue != empty_flag)
2135 delete_glue_ref(last_glue);
2138 page_tail = page_head;
2139 link(page_head) = 0;
2140 last_glue = empty_flag;
2148 link(page_head) = link(hold_head);
2152 r = link(page_ins_head);
2154 while (r != page_ins_head)
2157 free_node(r, page_ins_node_size);
2161 link(page_ins_head) = page_ins_head;
2163 if ((top_mark != 0) && (first_mark == 0))
2165 first_mark = top_mark;
2166 add_token_ref(top_mark);
2169 if (output_routine != 0)
2170 if (dead_cycles >= max_dead_cycles)
2172 print_err("Output loop---");
2173 print_int(dead_cycles);
2174 prints(" consecutive dead cycles");
2175 help3("I've concluded that your \\output is awry; it never does",
2176 "\\ship_out, so I'm shipping \box255 out myself. Next ",
2177 "increase \\maxdeadcycles if you want me to be more patient!");
2182 output_active = true;
2186 prev_depth = ignore_depth;
2187 mode_line = - (integer) line;
2188 begin_token_list(output_routine, output_text);
2189 new_save_level(output_group);
2196 if (link(page_head) != 0)
2198 if (link(contrib_head) == 0)
2202 nest[0].tail_field = page_tail;
2204 link(page_tail) = link(contrib_head);
2206 link(contrib_head) = link(page_head);
2207 link(page_head) = 0;
2208 page_tail = page_head;