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
22 INLINE void prompt_input(const char * s)
27 INLINE void synch_h(void)
31 movement(cur_h - dvi_h, right1);
35 INLINE void synch_v(void)
39 movement(cur_v - dvi_v, down1);
43 INLINE void set_cur_lang(void)
47 else if (language > 255)
52 INLINE void free_avail_(halfword p)
60 INLINE void dvi_out_(ASCII_code op)
62 dvi_buf[dvi_ptr] = op;
65 if (dvi_ptr == dvi_limit)
68 INLINE void succumb (void)
70 if (interaction == error_stop_mode)
71 interaction = scroll_mode;
86 INLINE void flush_string (void)
89 pool_ptr = str_start[str_ptr];
91 INLINE void append_char (ASCII_code c)
93 str_pool[pool_ptr] = c;
96 INLINE void append_lc_hex (ASCII_code c)
101 append_char(c - 10 + 'a');
103 INLINE void print_err (const char * s)
105 if (interaction == error_stop_mode);
109 INLINE void tex_help (unsigned int n, ...)
118 va_start(help_arg, n);
120 for (i = n - 1; i > -1; --i)
121 help_line[i] = va_arg(help_arg, char *);
125 INLINE void str_room_ (int val)
127 #ifdef ALLOCATESTRING
128 if (pool_ptr + val > current_pool_size)
129 str_pool = realloc_str_pool(increment_pool_size);
131 if (pool_ptr + val > current_pool_size)
133 overflow("pool size", current_pool_size - init_pool_ptr);
136 if (pool_ptr + val > pool_size)
138 overflow("pool size", pool_size - init_pool_ptr);
142 INLINE void tail_append_ (pointer val)
147 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
149 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
158 (void) putc ('\n', log_file);
163 (void) putc ('\n', log_file);
178 (void) putc ('\n', write_file[selector]);
183 void print_char_ (ASCII_code s)
185 if (s == new_line_char)
187 if (selector < pseudo)
197 (void) show_char(xchr[s]);
199 (void) putc(xchr[s], log_file);
202 if (term_offset == max_print_line)
208 if (file_offset == max_print_line)
210 (void) putc ('\n', log_file);
217 (void) putc(xchr[s], log_file);
220 if (file_offset == max_print_line)
226 (void) show_char(xchr[s]);
229 if (term_offset == max_print_line)
238 if (tally < trick_count)
239 trick_buf[tally % error_line] = s;
244 #ifdef ALLOCATESTRING
245 if (pool_ptr + 1 > current_pool_size)
247 str_pool = realloc_str_pool (increment_pool_size);
250 if (pool_ptr < current_pool_size)
252 str_pool[pool_ptr]= s;
256 if (pool_ptr < pool_size)
258 str_pool[pool_ptr]= s;
265 (void) putc(xchr[s], write_file[selector]);
272 void print_ (integer s)
287 if (selector > pseudo)
293 if ((s == new_line_char))
294 if (selector < pseudo)
302 /* translate ansi to dos 850 */
303 if (!show_in_hex && s < 256 && s >= 32)
305 if (show_in_dos && s > 127)
307 if (wintodos[s - 128] > 0)
309 print_char (wintodos[s - 128]);
315 while (j < str_start[s + 1])
317 print_char(str_pool[j]);
324 print_char(s); /* don't translate to hex */
328 { /* not just a character */
331 while (j < str_start[s + 1])
333 print_char(str_pool[j]);
338 new_line_char = nl; /* restore eol */
343 /* we get here with s > 256 - i.e. not a single character */
346 while (j < str_start[s + 1])
348 print_char(str_pool[j]);
352 /* string version print. */
353 void print_string_ (unsigned char *s)
359 void slow_print_ (integer s)
363 if ((s >= str_ptr) || (s < 256))
371 while (j < str_start[s + 1])
379 void print_nl (const char * s)
381 if (((term_offset > 0) && (odd(selector))) ||
382 ((file_offset > 0) && (selector >= log_only)))
388 void print_esc (const char * s)
401 void print_the_digs_ (eight_bits k)
408 print_char('0' + dig[k]);
410 print_char('A' + dig[k]);
414 void print_int_ (integer n)
446 dig[k] = (char) (n % 10);
455 void print_cs_ (integer p)
458 if (p >= single_base)
462 print_esc("endcsname");
467 print_esc(""); print(p - single_base);
469 if (cat_code(p - single_base) == letter)
472 else if (p < active_base)
473 print_esc("IMPOSSIBLE.");
474 else print(p - active_base);
475 else if (p >= undefined_control_sequence)
476 print_esc("IMPOSSIBLE.");
477 else if ((text(p) >= str_ptr))
478 print_esc("NONEXISTENT.");
487 void sprint_cs_(halfword p)
491 print(p - active_base);
492 else if (p < null_cs)
495 print(p - single_base);
500 print_esc("endcsname");
504 print_esc(""); print(text(p));
508 void print_file_name_(integer n, integer a, integer e)
515 void print_size_ (integer s)
518 print_esc("textfont");
520 print_esc("scriptfont");
522 print_esc("scriptscriptfont");
525 void print_write_whatsit_(str_number s, pointer p)
530 if (write_stream(p) < 16)
531 print_int(write_stream(p));
532 else if (write_stream(p) == 16)
534 else print_char('-');
539 close_files_and_terminate();
551 puts("EXITING at JUMPOUT\n");
553 if ((history != 0) && (history != 1))
562 // deal with error by asking for user response 0-9, D, E, H, I, X, Q, R, S
563 // NOTE: this may JUMPOUT either via X, or because of too many errors
567 integer s1, s2, s3, s4;
569 if (history < error_message_issued)
570 history = error_message_issued;
575 if (interaction == error_stop_mode)
579 clear_for_error_prompt();
585 c = buffer[first]; // analyze first letter typed
587 if (c >= 'a') // uppercase letter first
588 c = (unsigned char) (c + 'A' - 'a');
602 if (deletions_allowed)
608 align_state = 1000000L;
609 OK_to_interrupt = false;
611 if ((last > first + 1) && (buffer[first + 1] >= '0') && (buffer[first + 1] <= '9'))
612 c = (unsigned char) (c * 10 + buffer[first + 1] - '0' * 11);
614 c = (unsigned char) (c - 48);
626 OK_to_interrupt = true;
627 help2("I have just deleted some text, as you asked.",
628 "You can now delete more, or insert, or whatever.");
630 goto lab22; /* loop again */
638 goto lab22; /* loop again */
645 edit_name_start = str_start[input_stack[base_ptr].name_field];
646 edit_name_length = length(input_stack[base_ptr].name_field);
657 use_err_help = false;
662 help2("Sorry, I don't know how to help in this situation.",
663 "Maybe you should try asking a human?");
666 print_string(help_line[help_ptr]);
668 } while (!(help_ptr == 0));
671 help4("Sorry, I already gave what help I could...",
672 "Maybe you should try asking a human?",
673 "An error might have occurred before I noticed any problems.",
674 "``If all else fails, read the instructions.''");
675 goto lab22; /* loop again */
681 begin_file_reading();
683 if (last > first + 1)
690 prompt_input("insert>");
704 interaction = 0 + c - 81; /* Q = 0, R = 1, S = 2, T = 3 */
705 print_string("OK, entering ");
710 print_esc("batchmode");
714 print_esc("nonstopmode");
717 print_esc("scrollmode");
739 } /* end of switch analysing response character */
742 print_string("Type <return> to proceed, S to scroll future error messages,");
743 print_nl("R to run without stopping, Q to run quietly,");
744 print_nl("I to insert something, ");
747 print_string("E to edit your file,");
749 if (deletions_allowed)
750 print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
752 print_nl("H for help, X to quit.");
754 } /* end of while (true) loop */
758 if (error_count == 100)
760 print_nl("(That makes 100 errors; please try again.)");
765 if (interaction > batch_mode)
773 else while (help_ptr > 0)
776 print_nl(help_line[help_ptr] == NULL ? "" : help_line[help_ptr]);
781 if (interaction > batch_mode)
787 void fatal_error(char * s)
789 normalize_selector();
790 print_err("Emergency stop");
795 void overflow_(char * s, integer n)
797 normalize_selector();
798 print_err("TeX capacity exceeded, sorry [");
803 help2("If you really absolutely need more capacity,",
804 "you can ask a wizard to enlarge me.");
808 if (!strcmp(s, "pattern memory") && (n == trie_size))
810 sprintf(log_line, "\n (Maybe use -h=... on command line in ini-TeX)\n");
811 show_line(log_line, 0);
813 else if (!strcmp(s, "exception dictionary") && (n == hyphen_prime))
815 sprintf(log_line, "\n (Maybe use -e=... on command line in ini-TeX)\n");
816 show_line(log_line, 0);
823 void confusion_(const char * s)
825 normalize_selector();
827 if (history < error_message_issued)
829 print_err("This can't happen (");
832 help1("I'm broken. Please show this to someone who can fix can fix");
836 print_err("I can't go on meeting you like this");
837 help2("One of your faux pas seems to have wounded me deeply...",
838 "in fact, I'm barely conscious. Please fix it and try again.");
844 boolean init_terminal (void)
854 while ((loc < last) && (buffer[loc]== ' '))
855 incr(loc); // step over initial white space
861 // failed to find input file name
866 flag = input_ln(stdin, true);
871 puts("! End of file on the terminal... why?\n");
877 while ((loc < last) && (buffer[loc]== ' '))
878 incr(loc); // step over intial white space
883 sprintf(log_line, "%s\n", "Please type the name of your input file.");
884 show_line(log_line, 1);
888 str_number make_string (void)
890 #ifdef ALLOCATESTRING
891 if (str_ptr == current_max_strings)
892 str_start = realloc_str_start(increment_max_strings);
894 if (str_ptr == current_max_strings)
896 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/9 */
897 return 0; // abort_flag set
900 if (str_ptr == max_strings)
902 overflow("number of strings", max_strings - init_str_ptr);
903 return 0; // abort_flag set
907 str_start[str_ptr] = pool_ptr;
909 return (str_ptr - 1);
912 boolean str_eq_buf_ (str_number s, integer k)
919 while (j < str_start[s + 1])
921 if (str_pool[j] != buffer[k])
936 boolean str_eq_str_ (str_number s, str_number t)
943 if (length(s) != length(t))
949 while (j < str_start[s + 1])
951 if (str_pool[j] != str_pool[k])
963 void print_two_(integer n)
966 print_char('0' + (n / 10));
967 print_char('0' + (n % 10));
970 void print_hex_(integer n)
979 dig[k] = (unsigned char) (n % 16);
988 void print_roman_int_(integer n)
991 nonnegative_integer u, v;
993 j = str_start[260]; /* m2d5c2l5x2v5i */
1000 print_char(str_pool[j]);
1008 u = v / (str_pool[k - 1] - '0');
1010 if (str_pool[k - 1] == 50)
1013 u = u / (str_pool[k - 1] - '0');
1018 print_char(str_pool[k]);
1024 v = v / (str_pool[j - 1] - '0');
1029 void print_current_string (void)
1033 j = str_start[str_ptr];
1035 while (j < pool_ptr)
1037 print_char(str_pool[j]);
1042 int stringlength (int str_ptr)
1044 return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2;
1047 char * add_string (char *s, char * str_string)
1051 n = strlen(str_string);
1052 memcpy(s, &str_string, n);
1060 int addextrahelp = 1;
1062 // make one long \r\n separated string out of help lines
1063 // str_pool is packed_ASCII_code *
1065 char * make_up_help_string (int nhelplines)
1067 char * helpstring, *s;
1070 // get length of help for this specific message
1071 for (k = nhelplines - 1; k >= 0; k--)
1073 nlen += strlen(help_line[k]);
1076 nlen += 2; // for blank line separator: "\r\n"
1080 nlen += stringlength(265);
1081 nlen += stringlength(266);
1082 nlen += stringlength(267);
1085 nlen += stringlength(268);
1087 if (deletions_allowed)
1088 nlen += stringlength(269);
1090 nlen += stringlength(270);
1093 helpstring = (char *) malloc(nlen + 1); // +1 = '\0'
1096 for (k = nhelplines-1; k >= 0; k--)
1098 s = add_string(s, help_line[k]);
1105 s = add_string(s, "Type <return> to proceed, S to scroll future error messages,");
1106 s = add_string(s, "R to run without stopping, Q to run quietly,");
1107 s = add_string(s, "I to insert something, ");
1110 s = add_string(s, "E to edit your file, ");
1112 if (deletions_allowed)
1113 s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
1115 s = add_string(s, "H for help, X to quit.");
1121 char * make_up_query_string (int promptstr)
1124 int nstart, nnext, n;
1127 nstart = str_start[ promptstr];
1128 nnext = str_start[ promptstr + 1];
1130 querystr = (char *) malloc(n + 1);
1132 memcpy(s, &str_pool[nstart], n);
1139 // abort_flag set if input_line / ConsoleInput returns non-zero
1140 // should set interrupt instead ???
1141 // called from tex0.c, tex2.c, tex3.c
1143 void term_input(void)
1152 flag = input_ln(stdin, true);
1156 fatal_error("End of file on the terminal!");
1157 return; // abort_flag set
1160 decr(selector); // shut off echo
1163 for (k = first; k <= last - 1; k++)
1167 incr(selector); // reset selector again
1170 void int_error_ (integer n)
1178 void normalize_selector (void)
1181 selector = term_and_log;
1183 selector = term_only;
1188 if (interaction == batch_mode)
1192 void pause_for_instructions (void)
1194 if (OK_to_interrupt)
1196 interaction = error_stop_mode;
1198 if ((selector == log_only) || (selector == no_print))
1201 print_err("Interruption");
1203 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
1204 "unless you just want to quit by typing `X'.");
1205 deletions_allowed = false;
1207 deletions_allowed = true;
1212 integer half_(integer x)
1215 return ((x + 1) / 2);
1220 scaled round_decimals_(small_number k)
1229 a = (a + dig[k] * 131072L) / 10; /* 2^17 */
1232 return ((a + 1) / 2);
1235 void print_scaled_(scaled s)
1245 print_int(s / 65536L);
1247 s = 10 * (s % 65536L) + 5;
1253 s = s - 17232; /* 2^15 - 50000 - rounding */
1254 print_char('0' + (s / 65536L));
1255 s = 10 * (s % 65536L);
1258 while (!(s <= delta));
1261 scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
1271 else if (((x <= (maxanswer - y) / n) && (- (integer) x <= (maxanswer + y) / n)))
1280 scaled x_over_n_(scaled x, integer n)
1282 register scaled Result;
1305 tex_remainder = x % n;
1309 Result = - (integer) ((- (integer) x)/ n);
1310 tex_remainder = - (integer) ((- (integer) x)% n);
1315 tex_remainder = - (integer) tex_remainder;
1320 scaled xn_over_d_(scaled x, integer n, integer d)
1322 register scaled Result;
1324 nonnegative_integer t, u, v;
1334 t = (x % 32767L) * n;
1335 u = (x / 32768L) * n + (t / 32768L);
1336 v = (u % d) * 32768L + (t % 32768L);
1338 if (u / d >= 32768L)
1341 u = 32768L * (u / d) + (v / d);
1346 tex_remainder = v % d;
1350 Result = - (integer) u;
1351 tex_remainder = - (integer)(v % d);
1357 halfword badness_(scaled t, scaled s)
1369 else if (s >= 1663497L)
1377 return (r * r * r + 131072L) / 262144L; /* 2^17 */
1382 void print_word_(memory_word w)
1386 print_scaled(w.cint);
1388 print_scaled(round(65536L * w.gr));
1398 print_int(w.qqqq.b0);
1400 print_int(w.qqqq.b1);
1402 print_int(w.qqqq.b2);
1404 print_int(w.qqqq.b3);
1406 /* need this version only if SHORTFONTINFO defined */
1407 void zprintfword(memory_word w)
1411 print_scaled(w.cint);
1413 print_scaled(round(65536L * w.gr));
1419 print_int(w .hh.b1);
1423 print_int(w.qqqq.b0);
1425 print_int(w.qqqq.b1);
1427 print_int(w.qqqq.b2);
1429 print_int(w.qqqq.b3);
1433 void show_token_list_(integer p, integer q, integer l)
1436 ASCII_code match_chr;
1443 while ((p != 0) && (tally < l))
1447 first_count = tally;
1448 trick_count = tally + 1 + error_line - half_error_line;
1450 if (trick_count < error_line)
1451 trick_count = error_line;
1454 if ((p < hi_mem_min) || (p > mem_end))
1456 print_esc("CLOBBERED.");
1460 if (info(p) >= cs_token_flag)
1461 print_cs(info(p) - cs_token_flag);
1493 print_char(c + '0');
1502 match_chr = (ASCII_code) c;
1531 if (scanner_status > 1)
1533 print_nl("Runaway ");
1535 switch (scanner_status)
1538 print_string("definition");
1543 print_string("argument");
1548 print_string("preamble");
1553 print_string("text");
1560 show_token_list(link(p), 0, error_line - 10);
1564 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1565 /* first try list of available nodes (avail != NULL) */
1566 /* then see if can go upwards (mem_end < mem_max) */
1567 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
1568 /* if not, extend memory at the top and grab from there --- new */
1569 /* else fail ! paragraph 120 */
1570 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1571 halfword get_avail (void)
1578 avail = link(avail);
1579 else if (mem_end < mem_max)
1589 if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
1592 mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
1597 if (mem_end >= mem_max)
1600 overflow("main memory size", mem_max + 1 - mem_min);
1601 return 0; // abort_flag set
1604 incr(mem_end); /* then grab from new area */
1605 p = mem_end; /* 1993/Dec/14 */
1609 link(p) = 0; /* link(p) = null !!! */
1618 void flush_list_(pointer p)
1622 if (p != 0) /* null !!! */
1634 while (!(r == 0)); /* r != null */
1641 pointer get_node_(integer s)
1653 q = p + node_size(p);
1655 while ((mem[q].hh.rh == empty_flag))
1662 llink(t) = llink(q);
1663 rlink(llink(q)) = t;
1664 q = q + node_size(q);
1669 if (r > toint(p + 1))
1671 node_size(p) = r - p;
1686 node_size(p) = q - p;
1689 while (!(p == rover));
1691 if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
1694 puts("Merged adjacent multi-word nodes\n");
1696 return max_halfword;
1699 /* maybe try downward epxansion first instead ? */
1700 if (lo_mem_max + 2 < hi_mem_min)
1701 if (lo_mem_max + 2 <= mem_bot + max_halfword) /* silly ? flush 93/Dec/16 */
1703 /* if (hi_mem_min - lo_mem_max >= 1998) */
1704 if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
1705 /* t = lo_mem_max + 1000; */
1706 t = lo_mem_max + block_size;
1708 t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
1715 if (t > mem_bot + max_halfword)
1716 t = mem_bot + max_halfword; /* silly ? flush 93/Dec/16 */
1720 link(q) = empty_flag;
1721 node_size(q) = t - lo_mem_max; /* block size */
1723 link(lo_mem_max) = 0;
1724 info(lo_mem_max) = 0;
1729 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1730 /* we've run out of space in the middle for variable length blocks */
1731 /* try and add new block from below mem_bot *//* first check if space ! */
1732 if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
1734 mem = realloc_main (mem_top/2 + block_size, 0); /* zzzaa = zmem = mem */
1742 if (mem_min - (block_size + 1) <= mem_start) /* check again */
1746 sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
1747 show_line(log_line, 0);
1750 overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
1751 return 0; // abort_flag set
1754 add_variable_space (block_size); /* now to be found in itex.c */
1755 goto lab20; /* go try get_node again */
1761 var_used = var_used + s;
1767 void free_node_(halfword p, halfword s)
1772 link(p) = empty_flag;
1780 var_used = var_used - s;
1784 pointer new_null_box (void)
1788 p = get_node(box_node_size);
1789 type(p) = hlist_node;
1790 subtype(p) = min_quarterword;
1794 shift_amount(p) = 0;
1796 glue_sign(p) = normal;
1797 glue_order(p) = normal;
1803 pointer new_rule (void)
1807 p = get_node(rule_node_size);
1808 type(p) = rule_node;
1810 width(p) = null_flag;
1811 depth(p) = null_flag;
1812 height(p) = null_flag;
1817 pointer new_ligature_(quarterword f, quarterword c, pointer q)
1821 p = get_node(small_node_size);
1822 type(p) = ligature_node;
1823 font(lig_char(p)) = f;
1824 character(lig_char(p)) = c;
1831 pointer new_lig_item_(quarterword c)
1835 p = get_node(small_node_size);
1842 pointer new_disc (void)
1846 p = get_node(small_node_size);
1847 type(p) = disc_node;
1848 replace_count(p) = 0;
1855 pointer new_math_(scaled w, small_number s)
1859 p = get_node(small_node_size);
1860 type(p) = math_node;
1867 pointer new_spec_(pointer p)
1871 q = get_node(glue_spec_size);
1873 glue_ref_count(q) = 0;
1874 width(q) = width(p);
1875 stretch(q) = stretch(p);
1876 shrink(q) = shrink(p);
1881 pointer new_param_glue_(small_number n)
1886 p = get_node(small_node_size);
1887 type(p) = glue_node;
1892 incr(glue_ref_count(q));
1897 pointer new_glue_(pointer q)
1901 p = get_node(small_node_size);
1902 type(p) = glue_node;
1903 subtype(p) = normal;
1906 incr(glue_ref_count(q));
1911 pointer new_skip_param_(small_number n)
1915 temp_ptr = new_spec(glue_par(n));
1916 p = new_glue(temp_ptr);
1917 glue_ref_count(temp_ptr) = 0;
1923 pointer new_kern(scaled w)
1927 p = get_node(small_node_size);
1928 type(p) = kern_node;
1929 subtype(p) = normal;
1935 pointer new_penalty(integer m)
1939 p = get_node(small_node_size);
1940 type(p) = penalty_node;
1949 void check_mem(boolean printlocs)
1954 for (p = mem_min; p <= lo_mem_max; p++) freearr[p] = false;
1955 for (p = hi_mem_min; p <= mem_end; p++) freearr[p] = false;
1960 if ((p > mem_end) || (p < hi_mem_min))
1962 else if (freearr[p])
1967 print_nl("AVAIL list clobbered at ");
1980 if ((p >= lo_mem_max) || (p < mem_min))
1982 else if ((rlink(p) >= lo_mem_max) || (rlink(p) < mem_min))
1984 else if (!(is_empty(p)) || (node_size(p) < 2) ||
1985 (p + node_size(p) > lo_mem_max) || (llink(rlink(p)) != p))
1990 print_nl("Double-AVAIL list clobbered at ");
1995 for (q = p; q <= p + node_size(p) - 1; q++)
1999 print_nl("Doubly free location at ");
2007 } while (!(p == rover));
2010 while (p <= lo_mem_max) {
2013 print_nl("Bad flag at ");
2016 while ((p <= lo_mem_max) && !freearr[p]) incr(p);
2017 while ((p <= lo_mem_max) && freearr[p]) incr(p);
2022 print_nl("New busy locs:");
2024 for (p = mem_min; p <= lo_mem_max; p++)
2025 if (!freearr[p] && ((p > was_lo_max) || wasfree[p]))
2031 for (p = hi_mem_min; p <= mem_end; p++)
2032 if (!freearr[p] && ((p < was_hi_min) || (p > was_mem_end) || wasfree[p]))
2039 for (p = mem_min; p <= lo_mem_max; p++) wasfree[p] = freearr[p];
2040 for (p = hi_mem_min; p <= mem_end; p++) wasfree[p] = freearr[p];
2042 was_mem_end = mem_end;
2043 was_lo_max = lo_mem_max;
2044 was_hi_min = hi_mem_min;
2050 void search_mem_(halfword p)
2054 for (q = mem_min; q <= lo_mem_max; q++)
2070 for (q = hi_mem_min; q <= mem_end; q++)
2086 for (q = active_base; q <= box_base + 255; q++)
2095 for (q = 0; q <= save_ptr - 1; q++)
2097 if (equiv_field(save_stack[q]) == p)
2105 for (q = 0; q <= hyphen_prime; q++)
2106 if (hyph_list[q] == p)
2115 void short_display_(integer p)
2119 while (p != 0) { /* want p != null here bkph 93/Dec/15 !!! NOTE: still not fixed in 3.14159 ! */
2120 if (is_char_node(p))
2124 if (font(p) != font_in_short_display)
2126 if ((font(p) > font_max))
2131 print(font_id_text(font(p)));
2134 font_in_short_display = font(p);
2136 print(character(p));
2139 else switch (mem[p].hh.b0)
2154 if (glue_ptr(p) != 0)
2161 short_display(lig_ptr(p));
2164 short_display(pre_break(p));
2165 short_display(post_break(p));
2166 n = replace_count(p);
2169 if (link(p) != 0) /* if link(p)<>null then */
2181 void print_font_and_char (integer p)
2184 print_esc("CLOBBERED.");
2187 if ((font(p) > font_max))
2192 print(font_id_text(font(p)));
2196 print(character(p));
2200 void print_mark_ (integer p)
2204 if ((p < hi_mem_min) || (p > mem_end))
2205 print_esc("CLOBBERED.");
2207 show_token_list(link(p), 0, max_print_line - 10);
2212 void print_rule_dimen(scaled d)
2214 if ((d == -1073741824L)) /* - 2^30 */
2220 void print_glue_(scaled d, integer order, char * s)
2224 if ((order < normal) || (order > filll))
2225 print_string("foul");
2228 print_string("fil");
2234 } else if (*s != '\0')
2238 void print_spec_(integer p, char * s)
2240 if ((p < mem_min) || (p >= lo_mem_max))
2244 print_scaled(width(p));
2249 if (stretch(p) != 0)
2251 print_string("plus");
2252 print_glue(stretch(p), stretch_order(p), s);
2257 print_string("minus");
2258 print_glue(shrink(p), shrink_order(p), s);
2263 void print_fam_and_char_(halfword p)
2268 print(character(p));
2271 void print_delimiter_(halfword p)
2275 a = small_fam(p) * 256 + small_char(p);
2276 a = a * 0x1000 + large_fam(p) * 256 + large_char(p);
2284 void print_subsidiary_data_(halfword p, ASCII_code c)
2286 if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
2288 if (math_type(p) != 0)
2289 print_string(" []");
2296 switch (math_type(p))
2300 print_current_string();
2301 print_fam_and_char(p);
2312 print_current_string();
2327 void print_style_(integer c)
2332 print_esc("displaystyle");
2335 print_esc("textstyle");
2338 print_esc("scriptstyle");
2341 print_esc("scriptscriptstyle");
2344 print_string("Unknown style!");
2349 void print_skip_param_(integer n)
2353 case line_skip_code:
2354 print_esc("lineskip");
2357 case baseline_skip_code:
2358 print_esc("baselineskip");
2362 print_esc("parskip");
2365 case above_display_skip_code:
2366 print_esc("abovedisplayskip");
2369 case below_display_skip_code:
2370 print_esc("belowdisplayskip");
2373 case above_display_short_skip_code:
2374 print_esc("abovedisplayshortskip");
2377 case below_display_short_skip_code:
2378 print_esc("belowdisplayshortskip");
2381 case left_skip_code:
2382 print_esc("leftskip");
2385 case right_skip_code:
2386 print_esc("rightskip");
2390 print_esc("topskip");
2393 case split_top_skip_code:
2394 print_esc("splittopskip");
2398 print_esc("tabskip");
2401 case space_skip_code:
2402 print_esc("spaceskip");
2405 case xspace_skip_code:
2406 print_esc("xspaceskip");
2409 case par_fill_skip_code:
2410 print_esc("parfillskip");
2413 case thin_mu_skip_code:
2414 print_esc("thinmuskip");
2417 case med_mu_skip_code:
2418 print_esc("medmuskip");
2421 case thick_mu_skip_code:
2422 print_esc("thickmuskip");
2426 print_string("[unknown glue parameter!]");
2431 void show_node_list_(integer p)
2436 if (cur_length > depth_threshold)
2438 if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
2439 print_string(" []");
2446 while (p != 0) { /* want p != null - bkph 93/Dec/15 NOTE: still not fixed in 3.14159 ! */
2448 print_current_string();
2452 print_string("Bad link, display aborted.");
2458 if (n > breadth_max)
2460 print_string("etc.");
2464 if (is_char_node(p))
2465 print_font_and_char(p);
2466 else switch (type(p))
2472 if (type(p) == hlist_node)
2474 else if (type(p) == vlist_node)
2476 else print_esc("unset");
2478 print_string("box(");
2479 print_scaled(height(p));
2481 print_scaled(depth(p));
2483 print_scaled(width(p));
2485 if (type(p) == unset_node)
2487 if (span_count(p) != 0)
2490 print_int(span_count(p) + 1);
2491 print_string(" columns)");
2494 if (glue_stretch(p) != 0)
2496 print_string(", stretch ");
2497 print_glue(glue_stretch(p), glue_order(p), "");
2500 if (glue_shrink(p) != 0)
2502 print_string(", shrink ");
2503 print_glue(glue_shrink(p), glue_sign(p), "");
2510 if ((g != 0.0) && (glue_sign(p) != 0))
2512 print_string(", glue set ");
2514 if (glue_sign(p) == shrinking)
2517 if (fabs(g)> 20000.0)
2522 print_string("< -");
2524 print_glue(20000 * 65536L, glue_order(p), "");
2527 print_glue(round(65536L * g), glue_order(p), "");
2530 if (shift_amount(p) != 0)
2532 print_string(", shifted ");
2533 print_scaled(shift_amount(p));
2539 str_pool[pool_ptr] = 46;
2542 show_node_list(mem[p + 5].hh.rh);
2551 print_rule_dimen(height(p));
2553 print_rule_dimen(depth(p));
2555 print_rule_dimen(width(p));
2561 print_esc("insert");
2562 print_int(subtype(p));
2563 print_string(", natural size ");
2564 print_scaled(height(p));
2565 print_string("; split(");
2566 print_spec(split_top_ptr(p), "");
2568 print_scaled(depth(p));
2569 print_string("); float cost ");
2570 print_int(float_cost(p));
2573 str_pool[pool_ptr] = 46;
2576 show_node_list(mem[p + 4].hh.lh);
2586 print_write_whatsit(1279, p); /* debug # (-1 to exit): */
2588 print_file_name(open_name(p), open_area(p), open_ext(p));
2594 print_write_whatsit(591, p); /* write */
2595 print_mark(write_tokens(p));
2600 print_write_whatsit(1280, p); /* closeout */
2605 print_esc("special");
2606 print_mark(write_tokens(p));
2612 print_esc("setlanguage");
2613 print_int(what_lang(p));
2614 print_string(" (hyphenmin ");
2615 print_int(what_lhm(p));
2617 print_int(what_rhm(p));
2623 print_string("whatsit?");
2629 if (subtype(p) >= a_leaders)
2633 if (subtype(p) == c_leaders)
2635 else if (subtype(p) == x_leaders)
2638 print_string("leaders ");
2640 print_spec(glue_ptr(p), "");
2643 str_pool[pool_ptr] = 46;
2646 show_node_list(mem[p + 1].hh.rh);
2654 if (subtype(p) != normal)
2658 if (subtype(p) < cond_math_glue)
2659 print_skip_param(subtype(p) - 1);
2660 else if (subtype(p) == cond_math_glue)
2661 print_esc("nonscript");
2662 else print_esc("mskip");
2667 if (subtype(p) != cond_math_glue)
2671 if (subtype(p) < cond_math_glue)
2672 print_spec(glue_ptr(p), "");
2674 print_spec(glue_ptr(p), "mu");
2680 if (subtype(p) != mu_glue)
2684 if (subtype(p) != normal)
2687 print_scaled(width(p));
2689 if (subtype(p) == acc_kern)
2690 print_string(" (for accent)");
2695 print_scaled(width(p));
2704 if (subtype(p) == before)
2707 print_string("off");
2711 print_string(", surrounded ");
2712 print_scaled(width(p));
2719 print_font_and_char(lig_char(p));
2720 print_string("(ligature ");
2725 font_in_short_display = font(lig_char(p));
2726 short_display(lig_ptr(p));
2728 if (odd(subtype(p)))
2737 print_esc("penalty ");
2738 print_int(penalty(p));
2744 print_esc("discretionary");
2746 if (replace_count(p) > 0)
2748 print_string(" replacing ");
2749 print_int(replace_count(p));
2754 str_pool[pool_ptr] = 46;
2757 show_node_list(mem[p + 1].hh.lh);
2761 str_pool[pool_ptr]= 124;
2764 show_node_list(mem[p + 1].hh.rh);
2772 print_mark(mark_ptr(p));
2778 print_esc("vadjust");
2781 str_pool[pool_ptr] = 46;
2784 show_node_list(mem[p + 1].cint);
2791 print_style(subtype(p));
2796 print_esc("mathchoice");
2798 show_node_list(display_mlist(p));
2801 show_node_list(text_mlist(p));
2804 show_node_list(script_mlist(p));
2807 show_node_list(script_script_mlist(p));
2831 print_esc("mathord");
2835 print_esc("mathop");
2839 print_esc("mathbin");
2843 print_esc("mathrel");
2847 print_esc("mathopen");
2851 print_esc("mathclose");
2855 print_esc("mathpunct");
2859 print_esc("mathinner");
2863 print_esc("overline");
2867 print_esc("underline");
2871 print_esc("vcenter");
2876 print_esc("radical");
2877 print_delimiter(left_delimiter(p));
2883 print_esc("accent");
2884 print_fam_and_char(accent_chr(p));
2891 print_delimiter(delimiter(p));
2898 print_delimiter(delimiter(p));
2903 if (subtype(p) != normal)
2904 if (subtype(p) == limits)
2905 print_esc("limits");
2907 print_esc("nolimits");
2909 if (type(p) < left_noad)
2910 print_subsidiary_data(nucleus(p), '.');
2912 print_subsidiary_data(supscr(p), '^');
2913 print_subsidiary_data(subscr(p), '_');
2919 print_esc("fraction, thickness ");
2921 if (thickness(p) == 1073741824L) /* 2^30 */
2922 print_string("= default");
2924 print_scaled(thickness(p));
2926 if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
2927 (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
2929 print_string(", left-delimiter ");
2930 print_delimiter(left_delimiter(p));
2933 if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
2934 (large_fam(right_delimiter(p)) != 0) || (large_char(right_delimiter(p)) != 0))
2936 print_string(", right-delimiter ");
2937 print_delimiter(right_delimiter(p));
2940 print_subsidiary_data(numerator(p), '\\');
2941 print_subsidiary_data(denominator(p), '/');
2946 print_string("Unknown node type!");