2 Copyright 2014 Clerk Ma
\r
4 This program is free software; you can redistribute it and/or modify
\r
5 it under the terms of the GNU General Public License as published by
\r
6 the Free Software Foundation; either version 2 of the License, or
\r
7 (at your option) any later version.
\r
9 This program is distributed in the hope that it will be useful, but
\r
10 WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
12 General Public License for more details.
\r
14 You should have received a copy of the GNU General Public License
\r
15 along with this program; if not, write to the Free Software
\r
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
20 #define EXTERN extern
\r
21 #include "yandytex.h"
\r
24 void print_ln (void)
\r
52 putc('\n', write_file[selector]);
\r
57 void print_char_ (ASCII_code s)
\r
59 if (s == new_line_char)
\r
60 if (selector < pseudo)
\r
74 if (term_offset == max_print_line)
\r
80 if (file_offset == max_print_line)
\r
92 if (file_offset == max_print_line)
\r
101 if (term_offset == max_print_line)
\r
111 if (tally < trick_count)
\r
112 trick_buf[tally % error_line] = s;
\r
117 #ifdef ALLOCATESTRING
\r
118 if (pool_ptr + 1 > current_pool_size)
\r
119 str_pool = realloc_str_pool(increment_pool_size);
\r
121 if (pool_ptr < current_pool_size)
\r
124 if (pool_ptr < pool_size)
\r
130 putc(xchr[s], write_file[selector]);
\r
137 void print_ (integer s)
\r
152 if (selector > pseudo)
\r
158 if (s == new_line_char)
\r
159 if (selector < pseudo)
\r
165 nl = new_line_char;
\r
166 new_line_char = -1;
\r
168 if (!show_in_hex && s < 256 && s >= 32)
\r
170 print_char(s); /* don't translate to hex */
\r
173 { /* not just a character */
\r
176 while (j < str_start[s + 1])
\r
178 print_char(str_pool[j]);
\r
183 new_line_char = nl;
\r
191 while (j < str_start[s + 1])
\r
193 print_char(str_pool[j]);
\r
197 /* string version print. */
\r
198 void prints_ (const char * s)
\r
204 void slow_print_ (integer s)
\r
208 if ((s >= str_ptr) || (s < 256))
\r
214 while (j < str_start[s + 1])
\r
216 print(str_pool[j]);
\r
222 void print_nl (const char * s)
\r
224 if (((term_offset > 0) && (odd(selector))) ||
\r
225 ((file_offset > 0) && (selector >= log_only)))
\r
231 void print_esc (const char * s)
\r
244 void print_the_digs (eight_bits k)
\r
251 print_char('0' + dig[k]);
\r
253 print_char('A' + dig[k]);
\r
257 void print_int_ (integer n)
\r
268 if (n > -100000000L)
\r
289 dig[k] = (char) (n % 10);
\r
298 void print_cs_ (integer p)
\r
301 if (p >= single_base)
\r
304 print_esc("csname");
\r
305 print_esc("endcsname");
\r
310 print_esc(""); print(p - single_base);
\r
312 if (cat_code(p - single_base) == letter)
\r
315 else if (p < active_base)
\r
316 print_esc("IMPOSSIBLE.");
\r
318 print(p - active_base);
\r
319 else if (p >= undefined_control_sequence)
\r
320 print_esc("IMPOSSIBLE.");
\r
321 else if ((text(p) >= str_ptr))
\r
322 print_esc("NONEXISTENT.");
\r
331 void sprint_cs (pointer p)
\r
334 if (p < single_base)
\r
335 print(p - active_base);
\r
336 else if (p < null_cs)
\r
339 print(p - single_base);
\r
343 print_esc("csname");
\r
344 print_esc("endcsname");
\r
348 print_esc(""); print(text(p));
\r
352 void print_file_name (integer n, integer a, integer e)
\r
359 void print_size (integer s)
\r
362 print_esc("textfont");
\r
364 print_esc("scriptfont");
\r
366 print_esc("scriptscriptfont");
\r
369 void print_write_whatsit_(const char * s, pointer p)
\r
373 if (write_stream(p) < 16)
\r
374 print_int(write_stream(p));
\r
375 else if (write_stream(p) == 16)
\r
381 void jump_out (void)
\r
383 close_files_and_terminate();
\r
392 puts("EXITING at JUMPOUT");
\r
394 if ((history != spotless) && (history != warning_issued))
\r
406 integer s1, s2, s3, s4;
\r
408 if (history < error_message_issued)
\r
409 history = error_message_issued;
\r
414 if (interaction == error_stop_mode)
\r
418 clear_for_error_prompt();
\r
419 prompt_input("? ");
\r
422 return; // no input
\r
427 c = (c + 'A' - 'a');
\r
441 if (deletions_allowed)
\r
447 align_state = 1000000L;
\r
448 OK_to_interrupt = false;
\r
450 if ((last > first + 1) && (buffer[first + 1] >= '0') && (buffer[first + 1] <= '9'))
\r
451 c = (c * 10 + buffer[first + 1] - '0' * 11);
\r
465 OK_to_interrupt = true;
\r
466 help2("I have just deleted some text, as you asked.",
\r
467 "You can now delete more, or insert, or whatever.");
\r
485 edit_name_start = str_start[input_stack[base_ptr].name_field];
\r
486 edit_name_length = length(input_stack[base_ptr].name_field);
\r
497 use_err_help = false;
\r
502 help2("Sorry, I don't know how to help in this situation.",
\r
503 "Maybe you should try asking a human?");
\r
507 prints(help_line[help_ptr]);
\r
510 while (!(help_ptr == 0));
\r
513 help4("Sorry, I already gave what help I could...",
\r
514 "Maybe you should try asking a human?",
\r
515 "An error might have occurred before I noticed any problems.",
\r
516 "``If all else fails, read the instructions.''");
\r
523 begin_file_reading();
\r
525 if (last > first + 1)
\r
528 buffer[first] = ' ';
\r
532 prompt_input("insert>");
\r
548 interaction = 0 + c - 'Q';
\r
549 prints("OK, entering ");
\r
554 print_esc("batchmode");
\r
559 print_esc("nonstopmode");
\r
563 print_esc("scrollmode");
\r
576 interaction = scroll_mode;
\r
586 prints("Type <return> to proceed, S to scroll future error messages,");
\r
587 print_nl("R to run without stopping, Q to run quietly,");
\r
588 print_nl("I to insert something, ");
\r
591 prints("E to edit your file,");
\r
593 if (deletions_allowed)
\r
594 print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
\r
596 print_nl("H for help, X to quit.");
\r
602 if (error_count == 100)
\r
604 print_nl("(That makes 100 errors; please try again.)");
\r
605 history = fatal_error_stop;
\r
609 if (interaction > batch_mode)
\r
617 else while (help_ptr > 0)
\r
620 print_nl(help_line[help_ptr]);
\r
625 if (interaction > batch_mode)
\r
631 void fatal_error (const char * s)
\r
633 normalize_selector();
\r
634 print_err("Emergency stop");
\r
639 void overflow_(const char * s, integer n)
\r
641 normalize_selector();
\r
642 print_err("TeX capacity exceeded, sorry [");
\r
647 help2("If you really absolutely need more capacity,",
\r
648 "you can ask a wizard to enlarge me.");
\r
652 if (!strcmp(s, "pattern memory") && (n == trie_size))
\r
653 printf("\n (Maybe use -h=... on command line in initex)\n");
\r
654 else if (!strcmp(s, "exception dictionary") && (n == hyphen_prime))
\r
655 printf("\n (Maybe use -e=... on command line in initex)\n");
\r
661 void confusion (const char * s)
\r
663 normalize_selector();
\r
665 if (history < error_message_issued)
\r
667 print_err("This can't happen (");
\r
670 help1("I'm broken. Please show this to someone who can fix can fix");
\r
674 print_err("I can't go on meeting you like this");
\r
675 help2("One of your faux pas seems to have wounded me deeply...",
\r
676 "in fact, I'm barely conscious. Please fix it and try again.");
\r
682 boolean init_terminal (void)
\r
692 while ((loc < last) && (buffer[loc]== ' '))
\r
699 // failed to find input file name
\r
702 wake_up_terminal();
\r
703 fputs("**", stdout);
\r
705 flag = input_ln(stdin, true);
\r
710 puts("! End of file on the terminal... why?\n");
\r
716 while ((loc < last) && (buffer[loc]== ' '))
\r
717 incr(loc); // step over intial white space
\r
722 printf("%s\n", "Please type the name of your input file.");
\r
726 str_number make_string (void)
\r
728 #ifdef ALLOCATESTRING
\r
729 if (str_ptr == current_max_strings)
\r
730 str_start = realloc_str_start(increment_max_strings);
\r
732 if (str_ptr == current_max_strings)
\r
734 overflow("number of strings", current_max_strings - init_str_ptr);
\r
738 if (str_ptr == max_strings)
\r
740 overflow("number of strings", max_strings - init_str_ptr);
\r
746 str_start[str_ptr] = pool_ptr;
\r
748 return (str_ptr - 1);
\r
751 boolean str_eq_buf_ (str_number s, integer k)
\r
758 while (j < str_start[s + 1])
\r
760 if (str_pool[j] != buffer[k])
\r
776 boolean str_eq_str_ (str_number s, str_number t)
\r
783 if (length(s) != length(t))
\r
789 while (j < str_start[s + 1])
\r
791 if (str_pool[j] != str_pool[k])
\r
804 void print_two_(integer n)
\r
807 print_char('0' + (n / 10));
\r
808 print_char('0' + (n % 10));
\r
811 void print_hex_(integer n)
\r
820 dig[k] = (unsigned char) (n % 16);
\r
829 void print_roman_int_(integer n)
\r
832 nonnegative_integer u, v;
\r
834 j = str_start[260]; /* m2d5c2l5x2v5i */
\r
841 print_char(str_pool[j]);
\r
849 u = v / (str_pool[k - 1] - '0');
\r
851 if (str_pool[k - 1] == 50)
\r
854 u = u / (str_pool[k - 1] - '0');
\r
859 print_char(str_pool[k]);
\r
865 v = v / (str_pool[j - 1] - '0');
\r
870 void print_current_string (void)
\r
874 j = str_start[str_ptr];
\r
876 while (j < pool_ptr)
\r
878 print_char(str_pool[j]);
\r
884 void term_input (void)
\r
889 show_line("\n", 0);
\r
893 if (!input_ln(stdin, true))
\r
895 fatal_error("End of file on the terminal!");
\r
903 for (k = first; k <= last - 1; k++)
\r
910 void int_error_ (integer n)
\r
918 void normalize_selector (void)
\r
921 selector = term_and_log;
\r
923 selector = term_only;
\r
928 if (interaction == batch_mode)
\r
932 void pause_for_instructions (void)
\r
934 if (OK_to_interrupt)
\r
936 interaction = error_stop_mode;
\r
938 if ((selector == log_only) || (selector == no_print))
\r
941 print_err("Interruption");
\r
943 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
\r
944 "unless you just want to quit by typing `X'.");
\r
945 deletions_allowed = false;
\r
947 deletions_allowed = true;
\r
952 integer half_(integer x)
\r
955 return ((x + 1) / 2);
\r
960 scaled round_decimals_(small_number k)
\r
969 a = (a + dig[k] * 131072L) / 10; /* 2^17 */
\r
972 return ((a + 1) / 2);
\r
975 void print_scaled_(scaled s)
\r
985 print_int(s / 65536L);
\r
987 s = 10 * (s % 65536L) + 5;
\r
992 if (delta > 65536L)
\r
993 s = s - 17232; /* 2^15 - 50000 - rounding */
\r
995 print_char('0' + (s / 65536L));
\r
996 s = 10 * (s % 65536L);
\r
997 delta = delta * 10;
\r
999 while (!(s <= delta));
\r
1002 scaled mult_and_add_(integer n, scaled x, scaled y, scaled max_answer)
\r
1006 x = - (integer) x;
\r
1007 n = - (integer) n;
\r
1012 else if (((x <= (max_answer - y) / n) && (- (integer) x <= (max_answer + y) / n)))
\r
1013 return (n * x + y);
\r
1016 arith_error = true;
\r
1021 scaled x_over_n_(scaled x, integer n)
\r
1023 register scaled Result;
\r
1030 arith_error = true;
\r
1032 tex_remainder = x;
\r
1038 x = - (integer) x;
\r
1039 n = - (integer) n;
\r
1046 tex_remainder = x % n;
\r
1050 Result = - (integer) ((- (integer) x) / n);
\r
1051 tex_remainder = - (integer) ((- (integer) x) % n);
\r
1056 tex_remainder = - (integer) tex_remainder;
\r
1061 scaled xn_over_d_(scaled x, integer n, integer d)
\r
1063 register scaled Result;
\r
1065 nonnegative_integer t, u, v;
\r
1071 x = - (integer) x;
\r
1075 t = (x % 32767L) * n;
\r
1076 u = (x / 32768L) * n + (t / 32768L);
\r
1077 v = (u % d) * 32768L + (t % 32768L);
\r
1079 if (u / d >= 32768L)
\r
1080 arith_error = true;
\r
1082 u = 32768L * (u / d) + (v / d);
\r
1087 tex_remainder = v % d;
\r
1091 Result = - (integer) u;
\r
1092 tex_remainder = - (integer)(v % d);
\r
1098 halfword badness_(scaled t, scaled s)
\r
1108 if (t <= 7230584L)
\r
1109 r = (t * 297) / s;
\r
1110 else if (s >= 1663497L)
\r
1111 r = t / (s / 297);
\r
1118 return (r * r * r + 131072L) / 262144L; /* 2^17 */
\r
1123 void print_word (memory_word w)
\r
1125 print_int(w.cint);
\r
1127 print_scaled(w.cint);
\r
1129 print_scaled(round(unity * w.gr));
\r
1131 print_int(w.hh.lh);
\r
1133 print_int(w.hh.b0);
\r
1135 print_int(w.hh.b1);
\r
1137 print_int(w.hh.rh);
\r
1139 print_int(w.qqqq.b0);
\r
1141 print_int(w.qqqq.b1);
\r
1143 print_int(w.qqqq.b2);
\r
1145 print_int(w.qqqq.b3);
\r
1149 void show_token_list_(integer p, integer q, integer l)
\r
1152 ASCII_code match_chr;
\r
1159 while ((p != 0) && (tally < l))
\r
1163 first_count = tally;
\r
1164 trick_count = tally + 1 + error_line - half_error_line;
\r
1166 if (trick_count < error_line)
\r
1167 trick_count = error_line;
\r
1170 if ((p < hi_mem_min) || (p > mem_end))
\r
1172 print_esc("CLOBBERED.");
\r
1176 if (info(p) >= cs_token_flag)
\r
1177 print_cs(info(p) - cs_token_flag);
\r
1180 m = info(p) / 256;
\r
1181 c = info(p) % 256;
\r
1184 print_esc("BAD.");
\r
1208 print_char(c + '0');
\r
1217 match_chr = (ASCII_code) c;
\r
1231 print_esc("BAD.");
\r
1240 print_esc("ETC.");
\r
1243 void runaway (void)
\r
1247 if (scanner_status > skipping)
\r
1249 print_nl("Runaway ");
\r
1251 switch (scanner_status)
\r
1254 prints("definition");
\r
1259 prints("argument");
\r
1264 prints("preamble");
\r
1276 show_token_list(link(p), 0, error_line - 10);
\r
1280 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
\r
1281 /* first try list of available nodes (avail != NULL) */
\r
1282 /* then see if can go upwards (mem_end < mem_max) */
\r
1283 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
\r
1284 /* if not, extend memory at the top and grab from there --- new */
\r
1285 /* else fail ! paragraph 120 */
\r
1286 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
\r
1287 pointer get_avail (void)
\r
1294 avail = link(avail);
\r
1295 else if (mem_end < mem_max)
\r
1305 if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
\r
1308 mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
\r
1313 if (mem_end >= mem_max)
\r
1316 overflow("main memory size", mem_max + 1 - mem_min);
\r
1320 incr(mem_end); /* then grab from new area */
\r
1321 p = mem_end; /* 1993/Dec/14 */
\r
1325 link(p) = 0; /* link(p) = null !!! */
\r
1334 void flush_list_(pointer p)
\r
1350 while (!(r == 0));
\r
1357 pointer get_node (integer s)
\r
1369 q = p + node_size(p);
\r
1371 while (is_empty(q))
\r
1378 llink(t) = llink(q);
\r
1379 rlink(llink(q)) = t;
\r
1380 q = q + node_size(q);
\r
1385 if (r > toint(p + 1))
\r
1387 node_size(p) = r - p;
\r
1393 if (rlink(p) != p)
\r
1402 node_size(p) = q - p;
\r
1405 while (!(p == rover));
\r
1407 if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
\r
1410 puts("Merged adjacent multi-word nodes");
\r
1412 return max_halfword;
\r
1415 /* maybe try downward epxansion first instead ? */
\r
1416 if (lo_mem_max + 2 < hi_mem_min)
\r
1417 if (lo_mem_max + 2 <= mem_bot + max_halfword) /* silly ? flush 93/Dec/16 */
\r
1419 if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
\r
1420 t = lo_mem_max + block_size;
\r
1422 t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
\r
1429 if (t > mem_bot + max_halfword)
\r
1430 t = mem_bot + max_halfword; /* silly ? flush 93/Dec/16 */
\r
1434 link(q) = empty_flag;
\r
1435 node_size(q) = t - lo_mem_max; /* block size */
\r
1437 link(lo_mem_max) = 0;
\r
1438 info(lo_mem_max) = 0;
\r
1443 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
\r
1444 /* we've run out of space in the middle for variable length blocks */
\r
1445 /* try and add new block from below mem_bot *//* first check if space ! */
\r
1446 if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
\r
1448 mem = realloc_main (mem_top / 2 + block_size, 0); /* zzzaa = zmem = mem */
\r
1456 if (mem_min - (block_size + 1) <= mem_start) /* check again */
\r
1459 printf("mem_min %lld, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
\r
1461 overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
\r
1465 add_variable_space(block_size);
\r
1466 goto restart; /* go try get_node again */
\r
1472 var_used = var_used + s;
\r
1478 void free_node (pointer p, halfword s)
\r
1483 link(p) = empty_flag;
\r
1491 var_used = var_used - s;
\r
1495 pointer new_null_box (void)
\r
1499 p = get_node(box_node_size);
\r
1500 type(p) = hlist_node;
\r
1501 subtype(p) = min_quarterword;
\r
1505 shift_amount(p) = 0;
\r
1507 glue_sign(p) = normal;
\r
1508 glue_order(p) = normal;
\r
1509 glue_set(p) = 0.0;
\r
1514 pointer new_rule (void)
\r
1518 p = get_node(rule_node_size);
\r
1519 type(p) = rule_node;
\r
1521 width(p) = null_flag;
\r
1522 depth(p) = null_flag;
\r
1523 height(p) = null_flag;
\r
1528 pointer new_ligature_(quarterword f, quarterword c, pointer q)
\r
1532 p = get_node(small_node_size);
\r
1533 type(p) = ligature_node;
\r
1534 font(lig_char(p)) = f;
\r
1535 character(lig_char(p)) = c;
\r
1542 pointer new_lig_item_(quarterword c)
\r
1546 p = get_node(small_node_size);
\r
1553 pointer new_disc (void)
\r
1557 p = get_node(small_node_size);
\r
1558 type(p) = disc_node;
\r
1559 replace_count(p) = 0;
\r
1561 post_break(p) = 0;
\r
1566 pointer new_math (scaled w, small_number s)
\r
1570 p = get_node(small_node_size);
\r
1571 type(p) = math_node;
\r
1578 pointer new_spec_(pointer p)
\r
1582 q = get_node(glue_spec_size);
\r
1584 glue_ref_count(q) = 0;
\r
1585 width(q) = width(p);
\r
1586 stretch(q) = stretch(p);
\r
1587 shrink(q) = shrink(p);
\r
1592 pointer new_param_glue (small_number n)
\r
1597 p = get_node(small_node_size);
\r
1598 type(p) = glue_node;
\r
1599 subtype(p) = n + 1;
\r
1600 leader_ptr(p) = 0;
\r
1603 incr(glue_ref_count(q));
\r
1608 pointer new_glue (pointer q)
\r
1612 p = get_node(small_node_size);
\r
1613 type(p) = glue_node;
\r
1614 subtype(p) = normal;
\r
1615 leader_ptr(p) = 0;
\r
1617 incr(glue_ref_count(q));
\r
1622 pointer new_skip_param (small_number n)
\r
1626 temp_ptr = new_spec(glue_par(n));
\r
1627 p = new_glue(temp_ptr);
\r
1628 glue_ref_count(temp_ptr) = 0;
\r
1629 subtype(p) = n + 1;
\r
1634 pointer new_kern(scaled w)
\r
1638 p = get_node(small_node_size);
\r
1639 type(p) = kern_node;
\r
1640 subtype(p) = normal;
\r
1646 pointer new_penalty(integer m)
\r
1650 p = get_node(small_node_size);
\r
1651 type(p) = penalty_node;
\r
1660 void check_mem (boolean print_locs)
\r
1663 boolean clobbered;
\r
1665 for (p = mem_min; p <= lo_mem_max; p++)
\r
1666 freearr[p] = false;
\r
1668 for (p = hi_mem_min; p <= mem_end; p++)
\r
1669 freearr[p] = false;
\r
1673 clobbered = false;
\r
1677 if ((p > mem_end) || (p < hi_mem_min))
\r
1679 else if (freearr[p])
\r
1684 print_nl("AVAIL list clobbered at ");
\r
1689 freearr[p] = true;
\r
1697 clobbered = false;
\r
1701 if ((p >= lo_mem_max) || (p < mem_min))
\r
1703 else if ((rlink(p) >= lo_mem_max) || (rlink(p) < mem_min))
\r
1705 else if (!(is_empty(p)) || (node_size(p) < 2) ||
\r
1706 (p + node_size(p) > lo_mem_max) || (llink(rlink(p)) != p))
\r
1711 print_nl("Double-AVAIL list clobbered at ");
\r
1716 for (q = p; q <= p + node_size(p) - 1; q++)
\r
1720 print_nl("Doubly free location at ");
\r
1725 freearr[q] = true;
\r
1731 while (!(p == rover));
\r
1736 while (p <= lo_mem_max)
\r
1740 print_nl("Bad flag at ");
\r
1744 while ((p <= lo_mem_max) && !freearr[p])
\r
1747 while ((p <= lo_mem_max) && freearr[p])
\r
1753 print_nl("New busy locs:");
\r
1755 for (p = mem_min; p <= lo_mem_max; p++)
\r
1756 if (!freearr[p] && ((p > was_lo_max) || wasfree[p]))
\r
1762 for (p = hi_mem_min; p <= mem_end; p++)
\r
1763 if (!freearr[p] && ((p < was_hi_min) || (p > was_mem_end) || wasfree[p]))
\r
1770 for (p = mem_min; p <= lo_mem_max; p++)
\r
1771 wasfree[p] = freearr[p];
\r
1773 for (p = hi_mem_min; p <= mem_end; p++)
\r
1774 wasfree[p] = freearr[p];
\r
1776 was_mem_end = mem_end;
\r
1777 was_lo_max = lo_mem_max;
\r
1778 was_hi_min = hi_mem_min;
\r
1781 void search_mem_(pointer p)
\r
1785 for (q = mem_min; q <= lo_mem_max; q++)
\r
1789 print_nl("LINK(");
\r
1796 print_nl("INFO(");
\r
1802 for (q = hi_mem_min; q <= mem_end; q++)
\r
1806 print_nl("LINK(");
\r
1813 print_nl("INFO(");
\r
1819 for (q = active_base; q <= box_base + 255; q++)
\r
1820 if (equiv(q) == p)
\r
1822 print_nl("EQUIV(");
\r
1828 for (q = 0; q <= save_ptr - 1; q++)
\r
1830 if (equiv_field(save_stack[q]) == p)
\r
1832 print_nl("SAVE(");
\r
1838 for (q = 0; q <= hyphen_prime; q++)
\r
1839 if (hyph_list[q] == p)
\r
1841 print_nl("HYPH(");
\r
1848 void short_display_(integer p)
\r
1852 while (p != 0) /* want p != null here ! */
\r
1854 if (is_char_node(p))
\r
1858 if (font(p) != font_in_short_display)
\r
1860 if ((font(p) > font_max))
\r
1865 print(font_id_text(font(p)));
\r
1869 font_in_short_display = font(p);
\r
1872 print(character(p));
\r
1875 else switch (type(p))
\r
1880 case whatsit_node:
\r
1892 if (glue_ptr(p) != 0)
\r
1900 case ligature_node:
\r
1901 short_display(lig_ptr(p));
\r
1905 short_display(pre_break(p));
\r
1906 short_display(post_break(p));
\r
1907 n = replace_count(p);
\r
1926 void print_font_and_char (integer p)
\r
1929 print_esc("CLOBBERED.");
\r
1932 if ((font(p) > font_max))
\r
1937 print(font_id_text(font(p)));
\r
1941 print(character(p));
\r
1945 void print_mark (integer p)
\r
1949 if ((p < hi_mem_min) || (p > mem_end))
\r
1950 print_esc("CLOBBERED.");
\r
1952 show_token_list(link(p), 0, max_print_line - 10);
\r
1957 void print_rule_dimen(scaled d)
\r
1959 if (is_running(d))
\r
1965 void print_glue_(scaled d, integer order, const char * s)
\r
1969 if ((order < normal) || (order > filll))
\r
1971 else if (order > normal)
\r
1975 while (order > fil)
\r
1981 else if (*s != '\0')
\r
1985 void print_spec_(integer p, const char * s)
\r
1987 if ((p < mem_min) || (p >= lo_mem_max))
\r
1991 print_scaled(width(p));
\r
1996 if (stretch(p) != 0)
\r
1999 print_glue(stretch(p), stretch_order(p), s);
\r
2002 if (shrink(p) != 0)
\r
2005 print_glue(shrink(p), shrink_order(p), s);
\r
2010 void print_fam_and_char_(pointer p)
\r
2013 print_int(fam(p));
\r
2015 print(character(p));
\r
2018 void print_delimiter_(pointer p)
\r
2022 a = small_fam(p) * 256 + small_char(p);
\r
2023 a = a * 0x1000 + large_fam(p) * 256 + large_char(p);
\r
2031 void print_subsidiary_data_(pointer p, ASCII_code c)
\r
2033 if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
\r
2035 if (math_type(p) != 0)
\r
2043 switch (math_type(p))
\r
2047 print_current_string();
\r
2048 print_fam_and_char(p);
\r
2059 print_current_string();
\r
2074 void print_style_(integer c)
\r
2079 print_esc("displaystyle");
\r
2082 print_esc("textstyle");
\r
2085 print_esc("scriptstyle");
\r
2088 print_esc("scriptscriptstyle");
\r
2091 prints("Unknown style!");
\r
2096 void print_skip_param_(integer n)
\r
2100 case line_skip_code:
\r
2101 print_esc("lineskip");
\r
2104 case baseline_skip_code:
\r
2105 print_esc("baselineskip");
\r
2108 case par_skip_code:
\r
2109 print_esc("parskip");
\r
2112 case above_display_skip_code:
\r
2113 print_esc("abovedisplayskip");
\r
2116 case below_display_skip_code:
\r
2117 print_esc("belowdisplayskip");
\r
2120 case above_display_short_skip_code:
\r
2121 print_esc("abovedisplayshortskip");
\r
2124 case below_display_short_skip_code:
\r
2125 print_esc("belowdisplayshortskip");
\r
2128 case left_skip_code:
\r
2129 print_esc("leftskip");
\r
2132 case right_skip_code:
\r
2133 print_esc("rightskip");
\r
2136 case top_skip_code:
\r
2137 print_esc("topskip");
\r
2140 case split_top_skip_code:
\r
2141 print_esc("splittopskip");
\r
2144 case tab_skip_code:
\r
2145 print_esc("tabskip");
\r
2148 case space_skip_code:
\r
2149 print_esc("spaceskip");
\r
2152 case xspace_skip_code:
\r
2153 print_esc("xspaceskip");
\r
2156 case par_fill_skip_code:
\r
2157 print_esc("parfillskip");
\r
2160 case thin_mu_skip_code:
\r
2161 print_esc("thinmuskip");
\r
2164 case med_mu_skip_code:
\r
2165 print_esc("medmuskip");
\r
2168 case thick_mu_skip_code:
\r
2169 print_esc("thickmuskip");
\r
2173 prints("[unknown glue parameter!]");
\r
2178 void show_node_list_(integer p)
\r
2183 if (cur_length > depth_threshold)
\r
2196 print_current_string();
\r
2200 prints("Bad link, display aborted.");
\r
2206 if (n > breadth_max)
\r
2212 if (is_char_node(p))
\r
2213 print_font_and_char(p);
\r
2214 else switch (type(p))
\r
2220 if (type(p) == hlist_node)
\r
2222 else if (type(p) == vlist_node)
\r
2225 print_esc("unset");
\r
2228 print_scaled(height(p));
\r
2230 print_scaled(depth(p));
\r
2232 print_scaled(width(p));
\r
2234 if (type(p) == unset_node)
\r
2236 if (span_count(p) != 0)
\r
2239 print_int(span_count(p) + 1);
\r
2240 prints(" columns)");
\r
2243 if (glue_stretch(p) != 0)
\r
2245 prints(", stretch ");
\r
2246 print_glue(glue_stretch(p), glue_order(p), "");
\r
2249 if (glue_shrink(p) != 0)
\r
2251 prints(", shrink ");
\r
2252 print_glue(glue_shrink(p), glue_sign(p), "");
\r
2259 if ((g != 0.0) && (glue_sign(p) != 0))
\r
2261 prints(", glue set ");
\r
2263 if (glue_sign(p) == shrinking)
\r
2266 if (fabs(g) > 20000.0)
\r
2273 print_glue(20000 * unity, glue_order(p), "");
\r
2276 print_glue(round(unity * g), glue_order(p), "");
\r
2279 if (shift_amount(p) != 0)
\r
2281 prints(", shifted ");
\r
2282 print_scaled(shift_amount(p));
\r
2286 node_list_display(list_ptr(p));
\r
2292 print_esc("rule(");
\r
2293 print_rule_dimen(height(p));
\r
2295 print_rule_dimen(depth(p));
\r
2297 print_rule_dimen(width(p));
\r
2303 print_esc("insert");
\r
2304 print_int(subtype(p));
\r
2305 prints(", natural size ");
\r
2306 print_scaled(height(p));
\r
2307 prints("; split(");
\r
2308 print_spec(split_top_ptr(p), "");
\r
2310 print_scaled(depth(p));
\r
2311 prints("); float cost ");
\r
2312 print_int(float_cost(p));
\r
2313 node_list_display(ins_ptr(p));
\r
2317 case whatsit_node:
\r
2318 switch (subtype(p))
\r
2322 print_write_whatsit("openout", p);
\r
2324 print_file_name(open_name(p), open_area(p), open_ext(p));
\r
2330 print_write_whatsit("write", p);
\r
2331 print_mark(write_tokens(p));
\r
2336 print_write_whatsit("closeout", p);
\r
2339 case special_node:
\r
2341 print_esc("special");
\r
2342 print_mark(write_tokens(p));
\r
2346 case language_node:
\r
2348 print_esc("setlanguage");
\r
2349 print_int(what_lang(p));
\r
2350 prints(" (hyphenmin ");
\r
2351 print_int(what_lhm(p));
\r
2353 print_int(what_rhm(p));
\r
2359 prints("whatsit?");
\r
2365 if (subtype(p) >= a_leaders)
\r
2369 if (subtype(p) == c_leaders)
\r
2371 else if (subtype(p) == x_leaders)
\r
2374 prints("leaders ");
\r
2375 print_spec(glue_ptr(p), "");
\r
2376 node_list_display(leader_ptr(p));
\r
2380 print_esc("glue");
\r
2382 if (subtype(p) != normal)
\r
2386 if (subtype(p) < cond_math_glue)
\r
2387 print_skip_param(subtype(p) - 1);
\r
2388 else if (subtype(p) == cond_math_glue)
\r
2389 print_esc("nonscript");
\r
2390 else print_esc("mskip");
\r
2395 if (subtype(p) != cond_math_glue)
\r
2399 if (subtype(p) < cond_math_glue)
\r
2400 print_spec(glue_ptr(p), "");
\r
2402 print_spec(glue_ptr(p), "mu");
\r
2408 if (subtype(p) != mu_glue)
\r
2410 print_esc("kern");
\r
2412 if (subtype(p) != normal)
\r
2415 print_scaled(width(p));
\r
2417 if (subtype(p) == acc_kern)
\r
2418 prints(" (for accent)");
\r
2422 print_esc("mkern");
\r
2423 print_scaled(width(p));
\r
2430 print_esc("math");
\r
2432 if (subtype(p) == before)
\r
2437 if (width(p) != 0)
\r
2439 prints(", surrounded ");
\r
2440 print_scaled(width(p));
\r
2445 case ligature_node:
\r
2447 print_font_and_char(lig_char(p));
\r
2448 prints("(ligature ");
\r
2450 if (subtype(p) > 1)
\r
2453 font_in_short_display = font(lig_char(p));
\r
2454 short_display(lig_ptr(p));
\r
2456 if (odd(subtype(p)))
\r
2463 case penalty_node:
\r
2465 print_esc("penalty ");
\r
2466 print_int(penalty(p));
\r
2472 print_esc("discretionary");
\r
2474 if (replace_count(p) > 0)
\r
2476 prints(" replacing ");
\r
2477 print_int(replace_count(p));
\r
2480 node_list_display(pre_break(p));
\r
2482 show_node_list(post_break(p));
\r
2489 print_esc("mark");
\r
2490 print_mark(mark_ptr(p));
\r
2496 print_esc("vadjust");
\r
2497 node_list_display(adjust_ptr(p));
\r
2502 print_style(subtype(p));
\r
2507 print_esc("mathchoice");
\r
2509 show_node_list(display_mlist(p));
\r
2512 show_node_list(text_mlist(p));
\r
2515 show_node_list(script_mlist(p));
\r
2518 show_node_list(script_script_mlist(p));
\r
2531 case radical_noad:
\r
2534 case vcenter_noad:
\r
2542 print_esc("mathord");
\r
2546 print_esc("mathop");
\r
2550 print_esc("mathbin");
\r
2554 print_esc("mathrel");
\r
2558 print_esc("mathopen");
\r
2562 print_esc("mathclose");
\r
2566 print_esc("mathpunct");
\r
2570 print_esc("mathinner");
\r
2574 print_esc("overline");
\r
2578 print_esc("underline");
\r
2581 case vcenter_noad:
\r
2582 print_esc("vcenter");
\r
2585 case radical_noad:
\r
2587 print_esc("radical");
\r
2588 print_delimiter(left_delimiter(p));
\r
2594 print_esc("accent");
\r
2595 print_fam_and_char(accent_chr(p));
\r
2601 print_esc("left");
\r
2602 print_delimiter(delimiter(p));
\r
2608 print_esc("right");
\r
2609 print_delimiter(delimiter(p));
\r
2614 if (subtype(p) != normal)
\r
2615 if (subtype(p) == limits)
\r
2616 print_esc("limits");
\r
2618 print_esc("nolimits");
\r
2620 if (type(p) < left_noad)
\r
2621 print_subsidiary_data(nucleus(p), '.');
\r
2623 print_subsidiary_data(supscr(p), '^');
\r
2624 print_subsidiary_data(subscr(p), '_');
\r
2628 case fraction_noad:
\r
2630 print_esc("fraction, thickness ");
\r
2632 if (thickness(p) == 1073741824L) /* 2^30 */
\r
2633 prints("= default");
\r
2635 print_scaled(thickness(p));
\r
2637 if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
\r
2638 (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
\r
2640 prints(", left-delimiter ");
\r
2641 print_delimiter(left_delimiter(p));
\r
2644 if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
\r
2645 (large_fam(right_delimiter(p)) != 0) || (large_char(right_delimiter(p)) != 0))
\r
2647 prints(", right-delimiter ");
\r
2648 print_delimiter(right_delimiter(p));
\r
2651 print_subsidiary_data(numerator(p), '\\');
\r
2652 print_subsidiary_data(denominator(p), '/');
\r
2657 prints("Unknown node type!");
\r