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 bool node_r_stays_active;
95 halfword b; /* current badness */
97 bool 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);
150 if ((v >= hi_mem_min))
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);
174 return; // abort_flag set
182 if ((s >= hi_mem_min))
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)
222 if ((s >= hi_mem_min))
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 bool 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))
781 if ((q >= hi_mem_min))
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)
916 pause_for_instructions();
926 ligature_present = true;
936 character(lig_stack) = cur_r;
939 lig_stack = new_lig_item(cur_r);
946 list_ptr(lig_stack) = p;
947 character(p) = hu[j + 1];
958 lig_stack = new_lig_item(cur_r);
966 if (ligature_present)
968 p = new_ligature(hf, cur_l, mem[cur_q].hh.rh);
979 } */ /* removed 99/Jan/6 */
980 mem[cur_q].hh.rh = p;
982 ligature_present = false;
986 ligature_present = true;
993 ligature_present = true;
995 if (lig_stack != 0) /* BUG FIX */
997 if (mem[lig_stack + 1].hh.rh != 0) /* l.17828 ? */
999 mem[t].hh.rh = mem[lig_stack + 1].hh.rh;
1004 lig_stack = mem[p].hh.rh;
1006 if (lig_stack == 0) /* if lig_stack=null ? */
1018 cur_r = mem[lig_stack].hh.b1;
1024 append_charnode_to_t(cur_r);
1033 if (op_byte(q) != 7)
1039 w = char_kern(hf, q);
1043 if (q.b0 >= stop_flag)
1044 if (cur_rh == non_char)
1052 k = k + skip_byte(q) + 1;
1053 q = font_info[k].qqqq;
1060 link(t) = new_kern(w);
1065 if (lig_stack != 0) /* l.17841 */
1068 cur_l = character(lig_stack);
1069 ligature_present = true;
1077 void hyphenate (void)
1081 int l; /* 95/Jan/7 */
1084 halfword major_tail, minor_tail;
1086 int c; /* 95/Jan/7 */
1088 /* integer r_count; */
1089 int r_count; /* 95/Jan/7 */
1097 for (j = 0; j <= hn; j++)
1104 for (j = 2; j <= hn; j++)
1105 h = (h + h + hc[j]) % hyphen_prime;
1117 if (length(k) == hn)
1124 if (str_pool[u] < hc[j])
1127 if (str_pool[u] > hc[j])
1156 if (trie_trc[cur_lang + 1] != cur_lang)
1163 for (j = 0; j <= hn - rhyf + 1; j++)
1165 z = trie_trl[cur_lang + 1] + hc[j];
1168 while (hc[l] == trie_trc[z])
1170 if (trie_tro[z] != min_trie_op)
1176 v = v + op_start[cur_lang];
1177 i = l - hyf_distance[v];
1179 if (hyf_num[v] > hyf[i])
1184 while(!(v == min_trie_op));
1188 z = trie_trl[z] + hc[l];
1192 for (j = 0; j <= lhyf - 1; j++)
1195 for (j = 0; j <= rhyf - 1; j++)
1198 for (j = lhyf; j <= hn - rhyf; j++)
1210 if ((ha >= hi_mem_min))
1217 hu[0] = character(ha);
1219 else if (type(ha) == ligature_node)
1220 if (font(lig_char(ha)) != hf)
1224 init_list = lig_ptr(ha);
1226 init_lft = (subtype(ha) > 1);
1227 hu[0] = character(lig_char(ha));
1236 free_node(ha, small_node_size);
1240 if (!(r >= hi_mem_min))
1241 if (type(r) == ligature_node)
1253 while (link(s) != ha)
1270 j = reconstitute(j, hn, bchar, hyf_char) + 1;
1272 if (hyphen_passed == 0)
1274 link(s) = link(hold_head);
1276 while (link(s) != 0) /* l.17903 */
1279 if (odd(hyf[j - 1]))
1282 hyphen_passed = j - 1;
1283 link(hold_head) = 0;
1287 if (hyphen_passed > 0)
1290 r = get_node(small_node_size);
1291 link(r) = link(hold_head);
1292 type(r) = disc_node;
1296 while (mem[major_tail].hh.rh != 0)
1298 major_tail = link(major_tail);
1306 hyf_node = new_character(hf, hyf_char);
1313 free_avail(hyf_node);
1318 l = reconstitute(l, i, font_bchar[hf], non_char) + 1;
1320 if (link(hold_head) != 0) /* BUG FIX ??? */
1322 if (minor_tail == 0)
1323 pre_break(r) = link(hold_head);
1325 link(minor_tail) = link(hold_head);
1327 minor_tail = link(hold_head);
1329 while (link(minor_tail) != 0) /* BUG FIX */
1330 minor_tail = link(minor_tail);
1334 if (hyf_node != 0) /* if hyf_node<>null then l.17956 */
1345 if (bchar_label[hf] != non_address) /* i.e. 0 --- 96/Jan/15 */
1357 l = reconstitute(l, hn, bchar, 256) + 1;
1361 hu[c_loc] = c; /* c may be used ... */
1365 if (link(hold_head) != 0) /* BUG FIX */
1367 if (minor_tail == 0) /* begin if minor_tail=null then */
1368 post_break(r) = link(hold_head);
1370 link(minor_tail) = link(hold_head);
1372 minor_tail = link(hold_head);
1374 while (link(minor_tail) != 0) /* ??? */
1375 minor_tail = link(minor_tail);
1382 j = reconstitute(j, hn, bchar, non_char) + 1;
1383 link(major_tail) = link(hold_head);
1385 while (mem[major_tail].hh.rh != 0)
1387 major_tail = link(major_tail);
1402 replace_count(r) = r_count;
1406 hyphen_passed = j - 1;
1407 link(hold_head) = 0;
1409 while(!(! odd(hyf[j - 1])));
1414 flush_list(init_list);
1417 void new_hyph_exceptions (void)
1419 /* small_number n; */ /* in 3.141 */
1421 /* small_number j; */ /* in 3.141 */
1456 if (lc_code(cur_chr) == 0)
1458 print_err("Not a letter");
1459 help2("Letters in \\hyphenation words must have \\lccode>0.",
1460 "Proceed; I'll ignore the character I just read.");
1466 hc[n] = lc_code(cur_chr);
1475 cur_cmd = char_given;
1490 for (j = 1; j <= n; j++)
1492 h = (h + h + hc[j]) % hyphen_prime;
1498 if (hyph_count == hyphen_prime)
1500 overflow("exception dictionary", hyphen_prime); /* exception dictionary - NOT DYNAMIC */
1501 /* not dynamic ---- but can be set -e=... from command line in ini-TeX */
1502 return; // abort_flag set
1507 while (hyph_word[h] != 0)
1511 if (length(k) < length(s))
1514 if (length(k) > length(s))
1522 if (str_pool[u] < str_pool[v])
1525 if (str_pool[u] > str_pool[v])
1531 while(!(u == str_start[k + 1]));
1550 if (cur_cmd == right_brace)
1560 print_err("Improper ");
1561 print_esc("hyphenation");
1562 print_string(" will be flushed");
1563 help2("Hyphenation exceptions must contain only letters",
1564 "and hyphens. But continue; I'll forgive and forget.");
1568 } /* end of switch */
1572 halfword prune_page_top_(halfword p)
1578 link(temp_head) = p;
1587 q = new_skip_param(split_top_skip_code);
1591 if (width(temp_ptr) > height(p))
1592 width(temp_ptr) = width(temp_ptr) - height(p);
1594 width(temp_ptr) = 0;
1623 confusion("pruning");
1624 return 0; // abort_flag set
1629 return link(temp_head);
1632 halfword vert_break_(halfword p, scaled h, scaled d)
1639 halfword best_place;
1641 /* small_number t; */
1642 int t; /* 95/Jan/7 */
1645 least_cost = awful_bad;
1646 do_all_six(set_height_zero);
1653 else switch(type(p))
1659 cur_height = cur_height + prev_dp + height(p);
1670 if (precedes_break(prev_p))
1701 confusion("vertbreak");
1702 return 0; // abort_flag set
1707 if (pi < inf_penalty)
1710 if ((active_width[3] != 0) || (active_width[4] != 0) || (active_width[5]!= 0))
1713 b = badness(h - cur_height, active_width[2]);
1715 if (active_width[1] - h > active_width[6])
1718 b = badness(cur_height - h, active_width[6]);
1721 if (pi <= eject_penalty)
1729 if (b <= least_cost)
1733 best_height_plus_depth = cur_height + prev_dp;
1736 if ((b == awful_bad) || (pi <= eject_penalty))
1740 if ((type(p) < glue_node) || (type(p) > kern_node))
1743 if (type(p) == kern_node)
1748 active_width[2 + stretch_order(q)] = active_width[2 + stretch_order(q)] + stretch(q);
1749 active_width[6] = active_width[6] + shrink(q);
1751 if ((shrink_order(q) != normal) && (shrink(q) != 0))
1753 print_err("Infinite glue shrinkage found in box being split");
1754 help4("The box you are \\vsplitting contains some infinitely",
1755 "shrinkable glue, e.g., `\\vss' or `\\vskip 0pt minus 1fil'.",
1756 "Such glue doesn't belong there; but you can safely proceed,",
1757 "since the offensive shrinkability has been made finite.");
1760 shrink_order(r) = normal;
1767 cur_height = cur_height + prev_dp + width(q);
1772 cur_height = cur_height + prev_dp - d;
1784 halfword vsplit_(eight_bits n, scaled h)
1792 if (split_first_mark != 0)
1794 delete_token_ref(split_first_mark);
1795 split_first_mark = 0;
1796 delete_token_ref(split_bot_mark);
1805 if (type(v) != vlist_node)
1808 print_esc("vsplit");
1809 print_string(" needs a ");
1811 help2("The box you are trying to split is an \\hbox.",
1812 "I can't split such a box, so I'll leave it alone.");
1817 q = vert_break(list_ptr(v), h, split_max_depth);
1824 if (type(p) == mark_node)
1825 if (split_first_mark == 0)
1827 split_first_mark = mark_ptr(p);
1828 split_bot_mark = split_first_mark;
1829 token_ref_count(split_first_mark) = token_ref_count(split_first_mark) + 2;
1833 delete_token_ref(split_bot_mark);
1834 split_bot_mark = mark_ptr(p);
1835 add_token_ref(split_bot_mark);
1846 q = prune_page_top(q);
1848 free_node(v, box_node_size);
1853 box(n) = vpackage(q, 0, 1, 1073741823L); /* 2^30 - 1 */
1855 return vpackage(p, h, exactly, split_max_depth);
1858 void print_totals (void)
1860 print_scaled(page_so_far[1]);
1862 if (page_so_far[2] != 0)
1864 print_string(" plus ");
1865 print_scaled(page_so_far[2]);
1869 if (page_so_far[3] != 0)
1871 print_string(" plus ");
1872 print_scaled(page_so_far[3]);
1873 print_string("fil");
1876 if (page_so_far[4] != 0)
1878 print_string(" plus ");
1879 print_scaled(page_so_far[4]);
1880 print_string("fill");
1883 if (page_so_far[5] != 0)
1885 print_string(" plus ");
1886 print_scaled(page_so_far[5]);
1887 print_string("filll");
1890 if (page_so_far[6] != 0)
1892 print_string(" minus ");
1893 print_scaled(page_so_far[6]);
1897 void freeze_page_specs_(small_number s)
1901 page_max_depth = max_depth;
1903 do_all_six(set_page_so_far_zero);
1904 least_page_cost = awful_bad;
1907 if (tracing_pages > 0)
1910 print_nl("%% goal height=");
1911 print_scaled(page_goal);
1912 print_string(", max depth=");
1913 print_scaled(page_max_depth);
1914 end_diagnostic(false);
1919 void box_error_(eight_bits n)
1923 print_nl("The following box has been deleted:");
1925 end_diagnostic(true);
1926 flush_node_list(box(n));
1930 void ensure_vbox_(eight_bits n)
1937 if (type(p) == hlist_node)
1939 print_err("Insertions can only be added to a vbox");
1940 help3("Tut tut: You're trying to \\insert into a",
1941 "\\box register that now contains an \\hbox.",
1942 "Proceed, and I'll discard its present contents.");
1947 void fire_up_(halfword c)
1949 halfword p, q, r, s;
1951 /* unsigned char n; */
1952 unsigned int n; /* 95/Jan/7 */
1954 integer save_vbadness;
1956 halfword save_split_top_skip;
1958 if (type(best_page_break) == penalty_node)
1960 geq_word_define(int_base + output_penalty_code, penalty(best_page_break));
1961 penalty(best_page_break) = inf_penalty;
1964 geq_word_define(int_base + output_penalty_code, inf_penalty);
1969 delete_token_ref(top_mark);
1971 top_mark = bot_mark;
1972 add_token_ref(top_mark);
1973 delete_token_ref(first_mark);
1977 if (c == best_page_break)
1978 best_page_break = 0;
1984 print_string("255 is not void");
1985 help2("You shouldn't use \\box255 except in \\output routines.",
1986 "Proceed, and I'll discard its present contents.");
1990 insert_penalties = 0;
1991 save_split_top_skip = split_top_skip;
1993 if (holding_inserts <= 0)
1995 r = link(page_ins_head);
1997 while (r != page_ins_head)
1999 if (best_ins_ptr(r) != 0)
2005 box(n) = new_null_box();
2007 p = box(n) + list_offset;
2009 while (link(p) != 0)
2012 last_ins_ptr(r) = p;
2024 while (p != best_page_break)
2026 if (type(p) == ins_node)
2028 if (holding_inserts <= 0)
2030 r = link(page_ins_head);
2032 while (subtype(r) != subtype(p))
2035 if (best_ins_ptr(r) == 0)
2040 s = last_ins_ptr(r);
2041 link(s) = ins_ptr(p);
2043 if (best_ins_ptr(r) == p)
2045 if (type(r) == split_up)
2046 if ((broken_ins(r) == p) && (broken_ins(r) != 0))
2048 while (link(s) != broken_ptr(r))
2052 split_top_skip = split_top_ptr(p);
2053 ins_ptr(p) = prune_page_top(broken_ptr(r));
2055 if (ins_ptr(p) != 0)
2057 temp_ptr = vpackage(ins_ptr(p), 0, 1, 1073741823L); /* 2^30 - 1 */
2058 height(p) = height(temp_ptr) + depth(temp_ptr);
2059 free_node(temp_ptr, box_node_size);
2064 best_ins_ptr(r) = 0;
2066 temp_ptr = list_ptr(box(n));
2067 free_node(box(n), box_node_size);
2068 box(n) = vpackage(temp_ptr, 0, 1, 1073741823L); /* 2^30 - 1 */
2072 while (link(s) != 0)
2075 last_ins_ptr(r) = s;
2079 link(prev_p) = link(p);
2086 incr(insert_penalties);
2090 delete_glue_ref(split_top_ptr(p));
2091 free_node(p, ins_node_size);
2097 else if (type(p) == mark_node)
2099 if (first_mark == 0)
2101 first_mark = mark_ptr(p);
2102 add_token_ref(first_mark);
2106 delete_token_ref(bot_mark);
2108 bot_mark = mark_ptr(p);
2109 add_token_ref(bot_mark);
2115 split_top_skip = save_split_top_skip;
2117 if (p != 0) /* if p<>null then l.19730 */
2119 if (link(contrib_head) == 0)
2123 nest[0].tail_field = page_tail;
2125 link(page_tail) = link(contrib_head);
2126 link(contrib_head) = p;
2130 save_vbadness = vbadness;
2134 box(255) = vpackage(link(page_head), best_size, 0, page_max_depth);
2135 vbadness = save_vbadness;
2138 if (last_glue != empty_flag)
2139 delete_glue_ref(last_glue);
2142 page_tail = page_head;
2143 link(page_head) = 0;
2144 last_glue = empty_flag;
2152 link(page_head) = link(hold_head);
2156 r = link(page_ins_head);
2158 while (r != page_ins_head)
2161 free_node(r, page_ins_node_size);
2165 link(page_ins_head) = page_ins_head;
2167 if ((top_mark != 0) && (first_mark == 0))
2169 first_mark = top_mark;
2170 add_token_ref(top_mark);
2173 if (output_routine != 0)
2174 if (dead_cycles >= max_dead_cycles)
2176 print_err("Output loop---");
2177 print_int(dead_cycles);
2178 print_string(" consecutive dead cycles");
2179 help3("I've concluded that your \\output is awry; it never does",
2180 "\\ship_out, so I'm shipping \box255 out myself. Next ",
2181 "increase \\maxdeadcycles if you want me to be more patient!");
2186 output_active = true;
2190 cur_list.aux_field.cint = ignore_depth;
2191 mode_line = - (integer) line;
2192 begin_token_list(output_routine, output_text);
2193 new_save_level(output_group);
2200 if (link(page_head) != 0)
2202 if (link(contrib_head) == 0)
2206 nest[0].tail_field = page_tail;
2208 link(page_tail) = link(contrib_head);
2210 link(contrib_head) = link(page_head);
2211 link(page_head) = 0;
2212 page_tail = page_head;