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);
206 return; // abort_flag set
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));
313 print_string(": line ");
314 print_int(line_number(q) - 1);
316 print_int(fit_class);
318 if (break_type == hyphenated)
322 print_int(total_demerits(q));
323 print_string(" -> @@");
325 if (prev_break(passive) == 0)
328 print_int(serial(prev_break(passive)));
333 minimal_demerits[fit_class] = awful_bad;
336 minimum_demerits = 1073741823L; /* 2^30 - 1 */
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)
500 print_string(" via @@");
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");
807 return; // abort_flag set
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)
838 while (p != 0) /* 94/Mar/22 BUG FIX */
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)
893 goto lab22; /* goto continue; */
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;
986 if (lig_stack != 0) /* BUG FIX */
988 if (mem[lig_stack + 1].hh.rh != 0) /* l.17828 ? */
990 mem[t].hh.rh = mem[lig_stack + 1].hh.rh;
995 lig_stack = mem[p].hh.rh;
997 if (lig_stack == 0) /* if lig_stack=null ? */
1009 cur_r = mem[lig_stack].hh.b1;
1015 append_charnode_to_t(cur_r);
1024 if (op_byte(q) != 7)
1030 w = char_kern(hf, q);
1034 if (q.b0 >= stop_flag)
1035 if (cur_rh == non_char)
1043 k = k + skip_byte(q) + 1;
1044 q = font_info[k].qqqq;
1051 link(t) = new_kern(w);
1056 if (lig_stack != 0) /* l.17841 */
1059 cur_l = character(lig_stack);
1060 ligature_present = true;
1068 void hyphenate (void)
1072 int l; /* 95/Jan/7 */
1075 halfword major_tail, minor_tail;
1077 int c; /* 95/Jan/7 */
1079 /* integer r_count; */
1080 int r_count; /* 95/Jan/7 */
1088 for (j = 0; j <= hn; j++)
1095 for (j = 2; j <= hn; j++)
1096 h = (h + h + hc[j]) % hyphen_prime;
1108 if (length(k) == hn)
1115 if (str_pool[u] < hc[j])
1118 if (str_pool[u] > hc[j])
1147 if (trie_trc[cur_lang + 1] != cur_lang)
1154 for (j = 0; j <= hn - rhyf + 1; j++)
1156 z = trie_trl[cur_lang + 1] + hc[j];
1159 while (hc[l] == trie_trc[z])
1161 if (trie_tro[z] != min_trie_op)
1167 v = v + op_start[cur_lang];
1168 i = l - hyf_distance[v];
1170 if (hyf_num[v] > hyf[i])
1175 while (!(v == min_trie_op));
1179 z = trie_trl[z] + hc[l];
1183 for (j = 0; j <= lhyf - 1; j++)
1186 for (j = 0; j <= rhyf - 1; j++)
1189 for (j = lhyf; j <= hn - rhyf; j++)
1201 if (is_char_node(ha))
1208 hu[0] = character(ha);
1210 else if (type(ha) == ligature_node)
1211 if (font(lig_char(ha)) != hf)
1215 init_list = lig_ptr(ha);
1217 init_lft = (subtype(ha) > 1);
1218 hu[0] = character(lig_char(ha));
1227 free_node(ha, small_node_size);
1231 if (!is_char_node(r))
1232 if (type(r) == ligature_node)
1244 while (link(s) != ha)
1261 j = reconstitute(j, hn, bchar, hyf_char) + 1;
1263 if (hyphen_passed == 0)
1265 link(s) = link(hold_head);
1267 while (link(s) != 0) /* l.17903 */
1270 if (odd(hyf[j - 1]))
1273 hyphen_passed = j - 1;
1274 link(hold_head) = 0;
1278 if (hyphen_passed > 0)
1281 r = get_node(small_node_size);
1282 link(r) = link(hold_head);
1283 type(r) = disc_node;
1287 while (mem[major_tail].hh.rh != 0)
1289 major_tail = link(major_tail);
1297 hyf_node = new_character(hf, hyf_char);
1304 free_avail(hyf_node);
1309 l = reconstitute(l, i, font_bchar[hf], non_char) + 1;
1311 if (link(hold_head) != 0) /* BUG FIX ??? */
1313 if (minor_tail == 0)
1314 pre_break(r) = link(hold_head);
1316 link(minor_tail) = link(hold_head);
1318 minor_tail = link(hold_head);
1320 while (link(minor_tail) != 0) /* BUG FIX */
1321 minor_tail = link(minor_tail);
1325 if (hyf_node != 0) /* if hyf_node<>null then l.17956 */
1336 if (bchar_label[hf] != non_address) /* i.e. 0 --- 96/Jan/15 */
1348 l = reconstitute(l, hn, bchar, 256) + 1;
1352 hu[c_loc] = c; /* c may be used ... */
1356 if (link(hold_head) != 0) /* BUG FIX */
1358 if (minor_tail == 0) /* begin if minor_tail=null then */
1359 post_break(r) = link(hold_head);
1361 link(minor_tail) = link(hold_head);
1363 minor_tail = link(hold_head);
1365 while (link(minor_tail) != 0) /* ??? */
1366 minor_tail = link(minor_tail);
1373 j = reconstitute(j, hn, bchar, non_char) + 1;
1374 link(major_tail) = link(hold_head);
1376 while (mem[major_tail].hh.rh != 0)
1378 major_tail = link(major_tail);
1393 replace_count(r) = r_count;
1397 hyphen_passed = j - 1;
1398 link(hold_head) = 0;
1400 while (!(! odd(hyf[j - 1])));
1405 flush_list(init_list);
1408 void new_hyph_exceptions (void)
1410 /* small_number n; */ /* in 3.141 */
1412 /* small_number j; */ /* in 3.141 */
1447 if (lc_code(cur_chr) == 0)
1449 print_err("Not a letter");
1450 help2("Letters in \\hyphenation words must have \\lccode>0.",
1451 "Proceed; I'll ignore the character I just read.");
1457 hc[n] = lc_code(cur_chr);
1466 cur_cmd = char_given;
1481 for (j = 1; j <= n; j++)
1483 h = (h + h + hc[j]) % hyphen_prime;
1489 if (hyph_count == hyphen_prime)
1491 overflow("exception dictionary", hyphen_prime); /* exception dictionary - NOT DYNAMIC */
1497 while (hyph_word[h] != 0)
1501 if (length(k) < length(s))
1504 if (length(k) > length(s))
1512 if (str_pool[u] < str_pool[v])
1515 if (str_pool[u] > str_pool[v])
1521 while (!(u == str_start[k + 1]));
1540 if (cur_cmd == right_brace)
1550 print_err("Improper ");
1551 print_esc("hyphenation");
1552 print_string(" will be flushed");
1553 help2("Hyphenation exceptions must contain only letters",
1554 "and hyphens. But continue; I'll forgive and forget.");
1558 } /* end of switch */
1562 halfword prune_page_top_(halfword p)
1568 link(temp_head) = p;
1577 q = new_skip_param(split_top_skip_code);
1581 if (width(temp_ptr) > height(p))
1582 width(temp_ptr) = width(temp_ptr) - height(p);
1584 width(temp_ptr) = 0;
1613 confusion("pruning");
1614 return 0; // abort_flag set
1619 return link(temp_head);
1622 halfword vert_break_(halfword p, scaled h, scaled d)
1629 halfword best_place;
1631 /* small_number t; */
1632 int t; /* 95/Jan/7 */
1635 least_cost = awful_bad;
1636 do_all_six(set_height_zero);
1643 else switch(type(p))
1649 cur_height = cur_height + prev_dp + height(p);
1660 if (precedes_break(prev_p))
1691 confusion("vertbreak");
1692 return 0; // abort_flag set
1697 if (pi < inf_penalty)
1700 if ((active_width[3] != 0) || (active_width[4] != 0) || (active_width[5]!= 0))
1703 b = badness(h - cur_height, active_width[2]);
1705 if (active_width[1] - h > active_width[6])
1708 b = badness(cur_height - h, active_width[6]);
1711 if (pi <= eject_penalty)
1719 if (b <= least_cost)
1723 best_height_plus_depth = cur_height + prev_dp;
1726 if ((b == awful_bad) || (pi <= eject_penalty))
1730 if ((type(p) < glue_node) || (type(p) > kern_node))
1733 if (type(p) == kern_node)
1738 active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
1739 active_width[6] = active_width[6] + shrink(q);
1741 if ((shrink_order(q) != normal) && (shrink(q) != 0))
1743 print_err("Infinite glue shrinkage found in box being split");
1744 help4("The box you are \\vsplitting contains some infinitely",
1745 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
1746 "Such glue doesn't belong there; but you can safely proceed,",
1747 "since the offensive shrinkability has been made finite.");
1750 shrink_order(r) = normal;
1757 cur_height = cur_height + prev_dp + width(q);
1762 cur_height = cur_height + prev_dp - d;
1774 halfword vsplit_(eight_bits n, scaled h)
1782 if (split_first_mark != 0)
1784 delete_token_ref(split_first_mark);
1785 split_first_mark = 0;
1786 delete_token_ref(split_bot_mark);
1795 if (type(v) != vlist_node)
1798 print_esc("vsplit");
1799 print_string(" needs a ");
1801 help2("The box you are trying to split is an \\hbox.",
1802 "I can't split such a box, so I'll leave it alone.");
1807 q = vert_break(list_ptr(v), h, split_max_depth);
1814 if (type(p) == mark_node)
1815 if (split_first_mark == 0)
1817 split_first_mark = mark_ptr(p);
1818 split_bot_mark = split_first_mark;
1819 token_ref_count(split_first_mark) = token_ref_count(split_first_mark) + 2;
1823 delete_token_ref(split_bot_mark);
1824 split_bot_mark = mark_ptr(p);
1825 add_token_ref(split_bot_mark);
1836 q = prune_page_top(q);
1838 free_node(v, box_node_size);
1843 box(n) = vpackage(q, 0, 1, 1073741823L); /* 2^30 - 1 */
1845 return vpackage(p, h, exactly, split_max_depth);
1848 void print_totals (void)
1850 print_scaled(page_so_far[1]);
1852 if (page_so_far[2] != 0)
1854 print_string(" plus ");
1855 print_scaled(page_so_far[2]);
1859 if (page_so_far[3] != 0)
1861 print_string(" plus ");
1862 print_scaled(page_so_far[3]);
1863 print_string("fil");
1866 if (page_so_far[4] != 0)
1868 print_string(" plus ");
1869 print_scaled(page_so_far[4]);
1870 print_string("fill");
1873 if (page_so_far[5] != 0)
1875 print_string(" plus ");
1876 print_scaled(page_so_far[5]);
1877 print_string("filll");
1880 if (page_so_far[6] != 0)
1882 print_string(" minus ");
1883 print_scaled(page_so_far[6]);
1887 void freeze_page_specs_(small_number s)
1891 page_max_depth = max_depth;
1893 do_all_six(set_page_so_far_zero);
1894 least_page_cost = awful_bad;
1897 if (tracing_pages > 0)
1900 print_nl("%% goal height=");
1901 print_scaled(page_goal);
1902 print_string(", max depth=");
1903 print_scaled(page_max_depth);
1904 end_diagnostic(false);
1909 void box_error_(eight_bits n)
1913 print_nl("The following box has been deleted:");
1915 end_diagnostic(true);
1916 flush_node_list(box(n));
1920 void ensure_vbox_(eight_bits n)
1927 if (type(p) == hlist_node)
1929 print_err("Insertions can only be added to a vbox");
1930 help3("Tut tut: You're trying to \\insert into a",
1931 "\\box register that now contains an \\hbox.",
1932 "Proceed, and I'll discard its present contents.");
1937 void fire_up_(halfword c)
1941 /* unsigned char n; */
1942 unsigned int n; /* 95/Jan/7 */
1944 integer save_vbadness;
1946 pointer save_split_top_skip;
1948 if (type(best_page_break) == penalty_node)
1950 geq_word_define(int_base + output_penalty_code, penalty(best_page_break));
1951 penalty(best_page_break) = inf_penalty;
1954 geq_word_define(int_base + output_penalty_code, inf_penalty);
1959 delete_token_ref(top_mark);
1961 top_mark = bot_mark;
1962 add_token_ref(top_mark);
1963 delete_token_ref(first_mark);
1967 if (c == best_page_break)
1968 best_page_break = 0;
1974 print_string("255 is not void");
1975 help2("You shouldn't use \\box255 except in \\output routines.",
1976 "Proceed, and I'll discard its present contents.");
1980 insert_penalties = 0;
1981 save_split_top_skip = split_top_skip;
1983 if (holding_inserts <= 0)
1985 r = link(page_ins_head);
1987 while (r != page_ins_head)
1989 if (best_ins_ptr(r) != 0)
1995 box(n) = new_null_box();
1997 p = box(n) + list_offset;
1999 while (link(p) != 0)
2002 last_ins_ptr(r) = p;
2014 while (p != best_page_break)
2016 if (type(p) == ins_node)
2018 if (holding_inserts <= 0)
2020 r = link(page_ins_head);
2022 while (subtype(r) != subtype(p))
2025 if (best_ins_ptr(r) == 0)
2030 s = last_ins_ptr(r);
2031 link(s) = ins_ptr(p);
2033 if (best_ins_ptr(r) == p)
2035 if (type(r) == split_up)
2036 if ((broken_ins(r) == p) && (broken_ins(r) != 0))
2038 while (link(s) != broken_ptr(r))
2042 split_top_skip = split_top_ptr(p);
2043 ins_ptr(p) = prune_page_top(broken_ptr(r));
2045 if (ins_ptr(p) != 0)
2047 temp_ptr = vpackage(ins_ptr(p), 0, 1, 1073741823L); /* 2^30 - 1 */
2048 height(p) = height(temp_ptr) + depth(temp_ptr);
2049 free_node(temp_ptr, box_node_size);
2054 best_ins_ptr(r) = 0;
2056 temp_ptr = list_ptr(box(n));
2057 free_node(box(n), box_node_size);
2058 box(n) = vpackage(temp_ptr, 0, 1, 1073741823L); /* 2^30 - 1 */
2062 while (link(s) != 0)
2065 last_ins_ptr(r) = s;
2069 link(prev_p) = link(p);
2076 incr(insert_penalties);
2080 delete_glue_ref(split_top_ptr(p));
2081 free_node(p, ins_node_size);
2087 else if (type(p) == mark_node)
2089 if (first_mark == 0)
2091 first_mark = mark_ptr(p);
2092 add_token_ref(first_mark);
2096 delete_token_ref(bot_mark);
2098 bot_mark = mark_ptr(p);
2099 add_token_ref(bot_mark);
2105 split_top_skip = save_split_top_skip;
2107 if (p != 0) /* if p<>null then l.19730 */
2109 if (link(contrib_head) == 0)
2113 nest[0].tail_field = page_tail;
2115 link(page_tail) = link(contrib_head);
2116 link(contrib_head) = p;
2120 save_vbadness = vbadness;
2124 box(255) = vpackage(link(page_head), best_size, 0, page_max_depth);
2125 vbadness = save_vbadness;
2128 if (last_glue != empty_flag)
2129 delete_glue_ref(last_glue);
2132 page_tail = page_head;
2133 link(page_head) = 0;
2134 last_glue = empty_flag;
2142 link(page_head) = link(hold_head);
2146 r = link(page_ins_head);
2148 while (r != page_ins_head)
2151 free_node(r, page_ins_node_size);
2155 link(page_ins_head) = page_ins_head;
2157 if ((top_mark != 0) && (first_mark == 0))
2159 first_mark = top_mark;
2160 add_token_ref(top_mark);
2163 if (output_routine != 0)
2164 if (dead_cycles >= max_dead_cycles)
2166 print_err("Output loop---");
2167 print_int(dead_cycles);
2168 print_string(" consecutive dead cycles");
2169 help3("I've concluded that your \\output is awry; it never does",
2170 "\\ship_out, so I'm shipping \box255 out myself. Next ",
2171 "increase \\maxdeadcycles if you want me to be more patient!");
2176 output_active = true;
2180 cur_list.aux_field.cint = ignore_depth;
2181 mode_line = - (integer) line;
2182 begin_token_list(output_routine, output_text);
2183 new_save_level(output_group);
2190 if (link(page_head) != 0)
2192 if (link(contrib_head) == 0)
2196 nest[0].tail_field = page_tail;
2198 link(page_tail) = link(contrib_head);
2200 link(contrib_head) = link(page_head);
2201 link(page_head) = 0;
2202 page_tail = page_head;