6 #pragma warning(disable:4115) // kill rpcasync.h complaint
8 #define MYLIBAPI __declspec(dllexport)
11 #pragma warning(disable:4996)
12 #pragma warning(disable:4131) // old style declarator
13 #pragma warning(disable:4135) // conversion between different integral types
14 #pragma warning(disable:4127) // conditional expression is constant
22 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
27 movement(cur_h - dvi_h, right1);
35 movement(cur_v - dvi_v, down1);
39 void set_cur_lang(void)
43 else if (language > 255)
48 INLINE void free_avail_(halfword p)
56 INLINE void dvi_out_(ASCII_code op)
58 dvi_buf[dvi_ptr] = op;
60 if (dvi_ptr == dvi_limit)
63 INLINE void succumb (void)
65 if (interaction == error_stop_mode)
66 interaction = scroll_mode;
79 INLINE void flush_string (void)
82 pool_ptr = str_start[str_ptr];
84 INLINE void append_char (ASCII_code c)
86 str_pool[pool_ptr] = c;
89 INLINE void append_lc_hex (ASCII_code c)
94 append_char(c - 10 + 'a');
96 INLINE void print_err (const char * s)
98 if (interaction == error_stop_mode);
102 INLINE void tex_help (unsigned int n, ...)
111 va_start(help_arg, n);
113 for (i = n - 1; i > -1; --i)
114 help_line[i] = va_arg(help_arg, char *);
118 INLINE void str_room_ (int val)
120 #ifdef ALLOCATESTRING
121 if (pool_ptr + val > current_pool_size)
122 str_pool = realloc_str_pool(increment_pool_size);
124 if (pool_ptr + val > current_pool_size)
126 overflow("pool size", current_pool_size - init_pool_ptr);
129 if (pool_ptr + val > pool_size)
131 overflow("pool size", pool_size - init_pool_ptr);
135 INLINE void tail_append_ (pointer val)
140 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
142 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
151 (void) putc ('\n', log_file);
156 (void) putc ('\n', log_file);
171 (void) putc ('\n', write_file[selector]);
176 void print_char_ (ASCII_code s)
178 if (s == new_line_char)
180 if (selector < pseudo)
190 (void) show_char(Xchr(s));
192 (void) putc(Xchr(s), log_file);
195 if (term_offset == max_print_line)
201 if (file_offset == max_print_line)
203 (void) putc ('\n', log_file);
210 (void) putc(Xchr(s), log_file);
213 if (file_offset == max_print_line)
219 (void) show_char(Xchr(s));
222 if (term_offset == max_print_line)
231 if (tally < trick_count)
232 trick_buf[tally % error_line] = s;
237 #ifdef ALLOCATESTRING
238 if (pool_ptr + 1 > current_pool_size)
240 str_pool = realloc_str_pool (increment_pool_size);
243 if (pool_ptr < current_pool_size)
245 str_pool[pool_ptr]= s;
249 if (pool_ptr < pool_size)
251 str_pool[pool_ptr]= s;
258 (void) putc(Xchr(s), write_file[selector]);
265 void print_ (integer s)
280 if (selector > pseudo)
286 if ((s == new_line_char))
287 if (selector < pseudo)
295 /* translate ansi to dos 850 */
296 if (!show_in_hex && s < 256 && s >= 32)
298 if (show_in_dos && s > 127)
300 if (wintodos[s - 128] > 0)
302 print_char (wintodos[s - 128]);
308 while (j < str_start[s + 1])
310 print_char(str_pool[j]);
317 print_char(s); /* don't translate to hex */
321 { /* not just a character */
324 while (j < str_start[s + 1])
326 print_char(str_pool[j]);
330 new_line_char = nl; /* restore eol */
335 /* we get here with s > 256 - i.e. not a single character */
338 while (j < str_start[s + 1])
340 print_char(str_pool[j]);
344 /* string version print. */
345 void print_string_ (unsigned char *s)
351 // print string number s from string pool by calling print_
352 void slow_print_ (integer s)
356 if ((s >= str_ptr) || (s < 256))
364 while (j < str_start[s + 1])
372 // print newline followed by string number s (unless at start of line)
373 void print_nl_ (const char * s)
375 if (((term_offset > 0) && (odd(selector))) ||
376 ((file_offset > 0) && (selector >= log_only)))
382 // print string number s preceded by escape character
383 void print_esc_ (const char * s)
396 void print_the_digs_ (eight_bits k)
403 print_char('0' + dig[k]);
405 print_char('A' + dig[k]);
409 void print_int_ (integer n)
441 dig[k] = (char) (n % 10);
450 void print_cs_ (integer p)
453 if (p >= single_base)
457 print_esc("endcsname");
462 print_esc(""); print(p - single_base);
464 if (cat_code(p - single_base) == letter)
467 else if (p < active_base)
468 print_esc("IMPOSSIBLE.");
469 else print(p - active_base);
470 else if (p >= undefined_control_sequence)
471 print_esc("IMPOSSIBLE.");
472 else if ((text(p) >= str_ptr))
473 print_esc("NONEXISTENT.");
476 print_esc(""); print(text(p));
481 void sprint_cs_(halfword p)
485 print(p - active_base);
486 else if (p < null_cs)
488 print_esc(""); print(p - single_base);
493 print_esc("endcsname");
497 print_esc(""); print(text(p));
501 /* ! I can't find file ` c:/foo/ accents .tex '. */
502 void print_file_name_(integer n, integer a, integer e)
509 void print_size_ (integer s)
512 print_esc("textfont");
514 print_esc("scriptfont");
516 print_esc("scriptscriptfont");
519 void print_write_whatsit_(str_number s, halfword p)
521 print_esc(""); print(s);
522 if (write_stream(p) < 16)
523 print_int(write_stream(p));
524 else if (write_stream(p) == 16)
526 else print_char('-');
529 // called from itex.c and tex0.c only NASTY NASTY!
530 // now uses uses non-local goto (longjmp) 1999/Nov/7
533 close_files_and_terminate();
545 show_line("EXITING at JUMPOUT\n", 0);
547 if ((history != 0) && (history != 1))
556 // deal with error by asking for user response 0-9, D, E, H, I, X, Q, R, S
557 // NOTE: this may JUMPOUT either via X, or because of too many errors
561 integer s1, s2, s3, s4;
563 if (history < error_message_issued)
564 history = error_message_issued;
569 if (interaction == error_stop_mode)
573 clear_for_error_prompt();
577 term_input("? ", help_ptr);
583 c = buffer[first]; // analyze first letter typed
585 if (c >= 'a') // uppercase letter first
586 c = (unsigned char) (c + 'A' - 'a');
600 if (deletions_allowed)
606 align_state = 1000000L;
607 OK_to_interrupt = false;
609 if ((last > first + 1) && (buffer[first + 1] >= '0') && (buffer[first + 1] <= '9'))
610 c = (unsigned char) (c * 10 + buffer[first + 1] - '0' * 11);
612 c = (unsigned char) (c - 48);
624 OK_to_interrupt = true;
625 help2("I have just deleted some text, as you asked.",
626 "You can now delete more, or insert, or whatever.");
628 goto lab22; /* loop again */
636 goto lab22; /* loop again */
643 edit_name_start = str_start[input_stack[base_ptr].name_field];
644 edit_name_length = length(input_stack[base_ptr].name_field);
655 use_err_help = false;
660 help2("Sorry, I don't know how to help in this situation.",
661 "Maybe you should try asking a human?");
664 print_string(help_line[help_ptr]);
666 } while (!(help_ptr == 0));
669 help4("Sorry, I already gave what help I could...",
670 "Maybe you should try asking a human?",
671 "An error might have occurred before I noticed any problems.",
672 "``If all else fails, read the instructions.''");
673 goto lab22; /* loop again */
679 begin_file_reading();
681 if (last > first + 1)
683 cur_input.loc_field = first + 1;
689 print_string("insert>");
690 term_input("insert>", 0);
692 cur_input.loc_field = first;
695 cur_input.limit_field = last - 1;
705 interaction = 0 + c - 81; /* Q = 0, R = 1, S = 2, T = 3 */
706 print_string("OK, entering ");
711 print_esc("batchmode");
715 print_esc("nonstopmode");
718 print_esc("scrollmode");
740 } /* end of switch analysing response character */
743 print_string("Type <return> to proceed, S to scroll future error messages,");
744 print_nl("R to run without stopping, Q to run quietly,");
745 print_nl("I to insert something, ");
748 print_string("E to edit your file,");
750 if (deletions_allowed)
751 print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
753 print_nl("H for help, X to quit.");
755 } /* end of while(true) loop */
759 if (error_count == 100)
761 print_nl("(That makes 100 errors; please try again.)");
766 if (interaction > batch_mode)
774 else while(help_ptr > 0)
777 print_nl(help_line[help_ptr] == NULL ? "" : help_line[help_ptr]);
782 if (interaction > batch_mode)
788 void fatal_error_(char * s)
790 normalize_selector();
791 print_err("Emergency stop");
796 void overflow_(char * s, integer n)
798 normalize_selector();
799 print_err("TeX capacity exceeded, sorry [");
804 help2("If you really absolutely need more capacity,",
805 "you can ask a wizard to enlarge me.");
809 if (!strcmp(s, "pattern memory") && n == trie_size)
811 sprintf(log_line, "\n (Maybe use -h=... on command line in ini-TeX)\n");
812 show_line(log_line, 0);
814 else if (!strcmp(s, "exception dictionary") && n == hyphen_prime)
816 sprintf(log_line, "\n (Maybe use -e=... on command line in ini-TeX)\n");
817 show_line(log_line, 0);
824 void confusion_(char * s)
826 normalize_selector();
828 if (history < error_message_issued)
830 print_err("This can't happen (");
833 help1("I'm broken. Please show this to someone who can fix can fix");
837 print_err("I can't go on meeting you like this");
838 help2("One of your faux pas seems to have wounded me deeply...",
839 "in fact, I'm barely conscious. Please fix it and try again.");
845 bool init_terminal (void)
853 cur_input.loc_field = first;
855 while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
856 incr(cur_input.loc_field); // step over initial white space
858 if (cur_input.loc_field < last)
862 // failed to find input file name
866 flag = ConsoleInput("**", "Please type a file name or a control sequence\r\n(or ^z to exit)", (char *) &buffer[first]);
867 last = first + strlen((char *) &buffer[first]); /* -1 ? */
868 // may need to be more elaborate see input_line in texmf.c
870 (void) fputs("**", stdout);
872 flag = input_ln(stdin, true);
878 show_line("! End of file on the terminal... why?\n", 1);
882 cur_input.loc_field = first;
884 while ((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
885 incr(cur_input.loc_field); // step over intial white space
887 if (cur_input.loc_field < last)
890 sprintf(log_line, "%s\n", "Please type the name of your input file.");
891 show_line(log_line, 1);
895 // Make string from str_start[str_ptr] to pool_ptr
896 str_number make_string (void)
898 #ifdef ALLOCATESTRING
899 if (str_ptr == current_max_strings)
900 str_start = realloc_str_start(increment_max_strings);
902 if (str_ptr == current_max_strings)
904 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/9 */
905 return 0; // abort_flag set
908 if (str_ptr == max_strings)
910 overflow("number of strings", max_strings - init_str_ptr);
911 return 0; // abort_flag set
915 str_start[str_ptr] = pool_ptr;
917 return (str_ptr - 1);
920 bool str_eq_buf_ (str_number s, integer k)
922 register bool Result;
928 while (j < str_start[s + 1])
930 if (str_pool[j] != buffer[k])
945 bool str_eq_str_ (str_number s, str_number t)
947 register bool Result;
953 if (length(s) != length(t))
959 while (j < str_start[s + 1])
961 if (str_pool[j] != str_pool[k])
973 void print_two_(integer n)
976 print_char('0' + (n / 10));
977 print_char('0' + (n % 10));
980 void print_hex_(integer n)
989 dig[k] = (unsigned char) (n % 16);
998 void print_roman_int_(integer n)
1001 nonnegative_integer u, v;
1003 j = str_start[260]; /* m2d5c2l5x2v5i */
1010 print_char(str_pool[j]);
1018 u = v / (str_pool[k - 1] - '0');
1020 if (str_pool[k - 1] == 50)
1023 u = u / (str_pool[k - 1] - '0');
1028 print_char(str_pool[k]);
1034 v = v / (str_pool[j - 1] - '0');
1039 void print_current_string (void)
1043 j = str_start[str_ptr];
1045 while (j < pool_ptr)
1047 print_char(str_pool[j]);
1052 int stringlength (int str_ptr)
1054 return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2;
1057 char * add_string (char *s, char * str_string)
1061 n = strlen(str_string);
1062 memcpy(s, &str_string, n);
1069 int addextrahelp = 1;
1071 // make one long \r\n separated string out of help lines
1072 // str_pool is packed_ASCII_code *
1074 char * make_up_help_string (int nhelplines)
1076 char * helpstring, *s;
1079 // get length of help for this specific message
1080 for (k = nhelplines - 1; k >= 0; k--)
1082 nlen += strlen(help_line[k]);
1085 nlen += 2; // for blank line separator: "\r\n"
1089 nlen += stringlength(265);
1090 nlen += stringlength(266);
1091 nlen += stringlength(267);
1094 nlen += stringlength(268);
1096 if (deletions_allowed)
1097 nlen += stringlength(269);
1099 nlen += stringlength(270);
1102 helpstring = (char *) malloc(nlen + 1); // +1 = '\0'
1105 for (k = nhelplines-1; k >= 0; k--)
1107 s = add_string(s, help_line[k]);
1114 s = add_string(s, "Type <return> to proceed, S to scroll future error messages,");
1115 s = add_string(s, "R to run without stopping, Q to run quietly,");
1116 s = add_string(s, "I to insert something, ");
1119 s = add_string(s, "E to edit your file, ");
1121 if (deletions_allowed)
1122 s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
1124 s = add_string(s, "H for help, X to quit.");
1130 char * make_up_query_string (int promptstr)
1133 int nstart, nnext, n;
1136 nstart = str_start[ promptstr];
1137 nnext = str_start[ promptstr + 1];
1139 querystr = (char *) malloc(n + 1);
1141 memcpy(s, &str_pool[nstart], n);
1148 // abort_flag set if input_line / ConsoleInput returns non-zero
1149 // should set interrupt instead ???
1150 // called from tex0.c, tex2.c, tex3.c
1152 // void term_input(void)
1153 void term_input (char * term_str, int term_help_lines)
1157 char * helpstring = NULL;
1159 char * querystring = NULL;
1161 // if (nhelplines != 0) {
1162 // helpstring = make_up_help_string (nhelplines);
1163 // printf(helpstring);
1164 // free(helpstring);
1166 show_line("\n", 0); // force it to show what may be buffered up ???
1170 if (term_str != NULL)
1171 querystring = term_str;
1173 if (term_help_lines != NULL)
1174 helpstring = make_up_help_string(term_help_lines);
1176 if (helpstring == NULL && querystring != NULL)
1178 if (strcmp(querystring, ": ") == 0)
1179 helpstring = xstrdup("Please type another file name (or ^z to exit):");
1180 else if (strcmp(querystring, "=>") == 0) // from firm_up_the_line
1181 helpstring = xstrdup("Please type <enter> to accept this line\r\nor type a replacement line");
1182 else if (strcmp(querystring, "insert>") == 0) // from error() after "I"
1183 helpstring = xstrdup("Please type something to insert here");
1184 else if (strcmp(querystring, "") == 0) // from read_toks
1185 helpstring = xstrdup("Please type a control sequence");
1186 else if (strcmp(querystring, "= ") == 0) // from read_toks
1187 helpstring = xstrdup("Please type a token");
1188 else if (strcmp(querystring, "*") == 0) // get_next
1189 helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)");
1192 flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]); // ???
1193 // flag == 0 means trouble --- EOF on terminal
1194 if (querystring != NULL)
1197 if (helpstring != NULL)
1200 helpstring = querystring = NULL;
1202 last = first + strlen((char *) &buffer[first]); /* -1 ? */
1203 // flag = (last > first);
1204 // may need to be more elaborate see input_line in texmf.c ???
1205 // sprintf(log_line, "first %d last %d flag %d - %s",
1206 // first, last, flag, (char *) &buffer[first]);
1207 // winerror(log_line);
1210 flag = input_ln(stdin, true);
1214 fatal_error("End of file on the terminal!");
1215 return; // abort_flag set
1219 // echo what was typed into Console buffer also
1221 for (k = first; k <= last - 1; k++)
1225 decr(selector); // shut off echo
1228 for (k = first; k <= last - 1; k++)
1232 incr(selector); // reset selector again
1236 void int_error_ (integer n)
1244 void normalize_selector (void)
1247 selector = term_and_log;
1249 selector = term_only;
1254 if (interaction == batch_mode)
1258 void pause_for_instructions (void)
1260 if (OK_to_interrupt)
1262 interaction = error_stop_mode;
1264 if ((selector == log_only) || (selector == no_print))
1267 print_err("Interruption");
1269 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
1270 "unless you just want to quit by typing `X'.");
1271 deletions_allowed = false;
1273 deletions_allowed = true;
1278 integer half_(integer x)
1281 return ((x + 1) / 2);
1286 scaled round_decimals_(small_number k)
1295 a = (a + dig[k] * 131072L) / 10; /* 2^17 */
1298 return ((a + 1) / 2);
1301 /* This has some minor speedup changes - no real advantage probably ... */
1302 void print_scaled_(scaled s)
1312 print_int(s / 65536L);
1314 s = 10 * (s % 65536L) + 5;
1320 s = s - 17232; /* 2^15 - 50000 - rounding */
1321 print_char('0' + (s / 65536L));
1322 s = 10 * (s % 65536L);
1325 while (!(s <= delta));
1328 scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
1338 else if (((x <= (maxanswer - y) / n) && (- (integer) x <= (maxanswer + y) / n)))
1347 scaled x_over_n_(scaled x, integer n)
1349 register scaled Result;
1372 tex_remainder = x % n;
1376 Result = - (integer) ((- (integer) x)/ n);
1377 tex_remainder = - (integer) ((- (integer) x)% n);
1382 tex_remainder = - (integer) tex_remainder;
1387 scaled xn_over_d_(scaled x, integer n, integer d)
1389 register scaled Result;
1391 nonnegative_integer t, u, v;
1401 t =(x % 32767L) * n;
1402 u =(x / 32768L)* n +(t / 32768L);
1403 v =(u % d)* 32768L +(t % 32768L);
1405 if (u / d >= 32768L)
1408 u = 32768L * (u / d) + (v / d);
1413 tex_remainder = v % d;
1417 Result = - (integer) u;
1418 tex_remainder = - (integer)(v % d);
1424 halfword badness_(scaled t, scaled s)
1436 else if (s >= 1663497L)
1444 return (r * r * r + 131072L) / 262144L; /* 2^17 */
1449 void print_word_(memory_word w)
1453 print_scaled(w.cint);
1455 print_scaled(round(65536L * w.gr));
1457 print_int(w.hh.v.LH);
1463 print_int(w.hh.v.RH);
1465 print_int(w.qqqq.b0);
1467 print_int(w.qqqq.b1);
1469 print_int(w.qqqq.b2);
1471 print_int(w.qqqq.b3);
1473 /* need this version only if SHORTFONTINFO defined */
1474 void zprintfword(fmemoryword w)
1478 print_scaled(w.cint);
1480 print_scaled(round(65536L * w.gr));
1482 print_int(w.hh.v.LH);
1486 print_int(w .hh.b1);
1488 print_int(w.hh.v.RH);
1490 print_int(w.qqqq.b0);
1492 print_int(w.qqqq.b1);
1494 print_int(w.qqqq.b2);
1496 print_int(w.qqqq.b3);
1500 void show_token_list_(integer p, integer q, integer l)
1503 ASCII_code match_chr;
1510 while ((p != 0) && (tally < l))
1514 first_count = tally;
1515 trick_count = tally + 1 + error_line - half_error_line;
1517 if (trick_count < error_line)
1518 trick_count = error_line;
1521 if ((p < hi_mem_min) || (p > mem_end))
1523 print_esc("CLOBBERED.");
1527 if (info(p) >= cs_token_flag)
1528 print_cs(info(p) - cs_token_flag);
1560 print_char(c + '0');
1569 match_chr = (ASCII_code) c;
1598 if (scanner_status > 1)
1600 print_nl("Runaway ");
1602 switch (scanner_status)
1605 print_string("definition");
1610 print_string("argument");
1615 print_string("preamble");
1620 print_string("text");
1627 show_token_list(link(p), 0, error_line - 10);
1631 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1632 /* first try list of available nodes (avail != NULL) */
1633 /* then see if can go upwards (mem_end < mem_max) */
1634 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
1635 /* if not, extend memory at the top and grab from there --- new */
1636 /* else fail ! paragraph 120 */
1637 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1638 halfword get_avail (void)
1645 avail = link(avail);
1646 else if (mem_end < mem_max)
1656 if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
1659 mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
1664 if (mem_end >= mem_max)
1667 overflow("main memory size", mem_max + 1 - mem_min);
1668 return 0; // abort_flag set
1670 incr(mem_end); /* then grab from new area */
1671 p = mem_end; /* 1993/Dec/14 */
1675 link(p) = 0; /* link(p) = null !!! */
1684 void flush_list_(halfword p) /* paragraph 123 */
1688 if (p != 0) /* null !!! */
1700 while (!(r == 0)); /* r != null */
1707 halfword get_node_(integer s)
1709 register halfword Result;
1720 q = p + node_size(p);
1722 while ((mem[q].hh.v.RH == empty_flag))
1729 llink(t) = llink(q);
1730 rlink(llink(q)) = t;
1731 q = q + node_size(q);
1736 if (r > toint(p + 1))
1738 node_size(p) = r - p;
1753 node_size(p) = q - p;
1756 while (!(p == rover));
1758 if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
1760 Result = max_halfword;
1763 show_line("Merged adjacent multi-word nodes\n", 0);
1768 /* maybe try downward epxansion first instead ? */
1769 if (lo_mem_max + 2 < hi_mem_min)
1770 if (lo_mem_max + 2 <= mem_bot + max_halfword) /* silly ? flush 93/Dec/16 */
1772 /* if (hi_mem_min - lo_mem_max >= 1998) */
1773 if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
1774 /* t = lo_mem_max + 1000; */
1775 t = lo_mem_max + block_size;
1777 t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
1784 if (t > mem_bot + max_halfword)
1785 t = mem_bot + max_halfword; /* silly ? flush 93/Dec/16 */
1789 link(q) = empty_flag;
1790 node_size(q) = t - lo_mem_max; /* block size */
1792 link(lo_mem_max) = 0;
1793 info(lo_mem_max) = 0;
1798 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1799 /* we've run out of space in the middle for variable length blocks */
1800 /* try and add new block from below mem_bot *//* first check if space ! */
1801 if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
1803 mem = realloc_main (mem_top/2 + block_size, 0); /* zzzaa = zmem = mem */
1811 if (mem_min - (block_size + 1) <= mem_start) /* check again */
1815 sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
1816 show_line(log_line, 0);
1819 overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
1820 return 0; // abort_flag set
1822 /* avoid function call in following ? */
1823 add_variable_space (block_size); /* now to be found in itex.c */
1824 goto lab20; /* go try get_node again */
1830 var_used = var_used + s;
1837 void free_node_(halfword p, halfword s)
1842 link(p) = empty_flag;
1849 var_used = var_used - s;
1853 halfword new_null_box (void)
1857 p = get_node(box_node_size);
1858 type(p) = hlist_node;
1859 subtype(p) = min_quarterword;
1863 shift_amount(p) = 0;
1865 glue_sign(p) = normal;
1866 glue_order(p) = normal;
1872 halfword new_rule (void)
1876 p = get_node(rule_node_size);
1877 type(p) = rule_node;
1879 width(p) = null_flag;
1880 depth(p) = null_flag;
1881 height(p) = null_flag;
1886 halfword new_ligature_(quarterword f, quarterword c, halfword q)
1890 p = get_node(small_node_size);
1891 type(p) = ligature_node;
1892 font(lig_char(p)) = f;
1893 character(lig_char(p)) = c;
1900 halfword new_lig_item_(quarterword c)
1904 p = get_node(small_node_size);
1911 halfword new_disc (void)
1915 p = get_node(small_node_size);
1916 type(p) = disc_node;
1917 replace_count(p) = 0;
1924 halfword new_math_(scaled w, small_number s)
1928 p = get_node(small_node_size);
1929 type(p) = math_node;
1936 halfword new_spec_(halfword p)
1940 q = get_node(glue_spec_size);
1942 glue_ref_count(q) = 0;
1943 width(q) = width(p);
1944 stretch(q) = stretch(p);
1945 shrink(q) = shrink(p);
1950 halfword new_param_glue_(small_number n)
1955 p = get_node(small_node_size);
1956 type(p) = glue_node;
1961 incr(glue_ref_count(q));
1966 halfword new_glue_(halfword q)
1970 p = get_node(small_node_size);
1971 type(p) = glue_node;
1972 subtype(p) = normal;
1975 incr(glue_ref_count(q));
1980 halfword new_skip_param_(small_number n)
1984 temp_ptr = new_spec(glue_par(n));
1985 p = new_glue(temp_ptr);
1986 glue_ref_count(temp_ptr) = 0;
1992 halfword new_kern_(scaled w)
1996 p = get_node(small_node_size);
1997 type(p) = kern_node;
1998 subtype(p) = normal;
2004 halfword new_penalty_(integer m)
2008 p = get_node(small_node_size);
2009 type(p) = penalty_node;
2018 void check_mem_(bool printlocs)
2023 for (p = mem_min; p <= lo_mem_max; p++) freearr[p] = false;
2024 for (p = hi_mem_min; p <= mem_end; p++) freearr[p] = false;
2029 if ((p > mem_end) || (p < hi_mem_min))
2031 else if (freearr[p])
2036 print_nl("AVAIL list clobbered at ");
2049 if ((p >= lo_mem_max) || (p < mem_min))
2051 else if ((rlink(p) >= lo_mem_max) || (rlink(p) < mem_min))
2053 else if (!(is_empty(p)) || (node_size(p) < 2) ||
2054 (p + node_size(p) > lo_mem_max) || (llink(rlink(p)) != p))
2059 print_nl("Double-AVAIL list clobbered at ");
2064 for (q = p; q <= p + node_size(p) - 1; q++)
2068 print_nl("Doubly free location at ");
2076 } while (!(p == rover));
2079 while (p <= lo_mem_max) {
2082 print_nl("Bad flag at ");
2085 while ((p <= lo_mem_max) && !freearr[p]) incr(p);
2086 while ((p <= lo_mem_max) && freearr[p]) incr(p);
2091 print_nl("New busy locs:");
2093 for (p = mem_min; p <= lo_mem_max; p++)
2094 if (!freearr[p] && ((p > was_lo_max) || wasfree[p]))
2100 for (p = hi_mem_min; p <= mem_end; p++)
2101 if (!freearr[p] && ((p < was_hi_min) || (p > was_mem_end) || wasfree[p]))
2108 for (p = mem_min; p <= lo_mem_max; p++) wasfree[p] = freearr[p];
2109 for (p = hi_mem_min; p <= mem_end; p++) wasfree[p] = freearr[p];
2111 was_mem_end = mem_end;
2112 was_lo_max = lo_mem_max;
2113 was_hi_min = hi_mem_min;
2119 void search_mem_(halfword p)
2123 for (q = mem_min; q <= lo_mem_max; q++)
2139 for (q = hi_mem_min; q <= mem_end; q++)
2155 for (q = active_base; q <= box_base + 255; q++)
2164 for (q = 0; q <= save_ptr - 1; q++)
2166 if (equiv_field(save_stack[q]) == p)
2174 for (q = 0; q <= hyphen_prime; q++)
2175 if (hyph_list[q] == p)
2184 void short_display_(integer p)
2188 while (p != 0) { /* want p != null here bkph 93/Dec/15 !!! NOTE: still not fixed in 3.14159 ! */
2189 if (is_char_node(p))
2193 if (font(p) != font_in_short_display)
2195 if ((font(p) > font_max))
2200 print(font_id_text(font(p)));
2203 font_in_short_display = font(p);
2205 print(character(p));
2208 else switch (mem[p].hh.b0)
2223 if (glue_ptr(p) != 0)
2230 short_display(lig_ptr(p));
2233 short_display(pre_break(p));
2234 short_display(post_break(p));
2235 n = replace_count(p);
2238 if (link(p) != 0) /* if link(p)<>null then */
2250 void print_font_and_char_ (integer p)
2253 print_esc("CLOBBERED.");
2256 if ((font(p) > font_max))
2261 print(font_id_text(font(p)));
2265 print(character(p));
2269 void print_mark_ (integer p)
2273 if ((p < hi_mem_min)||(p > mem_end))
2274 print_esc("CLOBBERED.");
2276 show_token_list(link(p), 0, max_print_line - 10);
2281 void print_rule_dimen_ (scaled d)
2283 if ((d == -1073741824L)) /* - 2^30 */
2289 void print_glue_(scaled d, integer order, char * s)
2293 if ((order < normal) || (order > filll))
2294 print_string("foul");
2297 print_string("fil");
2303 } else if (*s != '\0')
2307 void print_spec_(integer p, char * s)
2309 if ((p < mem_min)||(p >= lo_mem_max))
2313 print_scaled(width(p));
2318 if (stretch(p) != 0)
2320 print_string("plus");
2321 print_glue(stretch(p), stretch_order(p), s);
2326 print_string("minus");
2327 print_glue(shrink(p), shrink_order(p), s);
2332 void print_fam_and_char_(halfword p)
2337 print(character(p));
2340 void print_delimiter_(halfword p)
2344 a = small_fam(p) * 256 + small_char(p);
2345 a = a * 4096 + large_fam(p) * 256 + large_char(p);
2353 void print_subsidiary_data_(halfword p, ASCII_code c)
2355 if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
2357 if (math_type(p) != 0)
2358 print_string(" []");
2365 switch (math_type(p))
2369 print_current_string();
2370 print_fam_and_char(p);
2381 print_current_string();
2396 void print_style_(integer c)
2401 print_esc("displaystyle");
2404 print_esc("textstyle");
2407 print_esc("scriptstyle");
2410 print_esc("scriptscriptstyle");
2413 print_string("Unknown style!");
2418 void print_skip_param_(integer n)
2422 case line_skip_code:
2423 print_esc("lineskip");
2426 case baseline_skip_code:
2427 print_esc("baselineskip");
2431 print_esc("parskip");
2434 case above_display_skip_code:
2435 print_esc("abovedisplayskip");
2438 case below_display_skip_code:
2439 print_esc("belowdisplayskip");
2442 case above_display_short_skip_code:
2443 print_esc("abovedisplayshortskip");
2446 case below_display_short_skip_code:
2447 print_esc("belowdisplayshortskip");
2450 case left_skip_code:
2451 print_esc("leftskip");
2454 case right_skip_code:
2455 print_esc("rightskip");
2459 print_esc("topskip");
2462 case split_top_skip_code:
2463 print_esc("splittopskip");
2467 print_esc("tabskip");
2470 case space_skip_code:
2471 print_esc("spaceskip");
2474 case xspace_skip_code:
2475 print_esc("xspaceskip");
2478 case par_fill_skip_code:
2479 print_esc("parfillskip");
2482 case thin_mu_skip_code:
2483 print_esc("thinmuskip");
2486 case med_mu_skip_code:
2487 print_esc("medmuskip");
2490 case thick_mu_skip_code:
2491 print_esc("thickmuskip");
2495 print_string("[unknown glue parameter!]");
2500 void show_node_list_(integer p)
2505 if (cur_length > depth_threshold)
2507 /* if (p > 0) */ /* was p>null !!! line 3662 in tex.web */
2508 if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
2509 print_string(" []");
2515 while (p != 0) { /* want p != null - bkph 93/Dec/15 NOTE: still not fixed in 3.14159 ! */
2517 print_current_string();
2521 print_string("Bad link, display aborted.");
2527 if (n > breadth_max)
2529 print_string("etc.");
2533 if ((p >= hi_mem_min))
2534 print_font_and_char(p);
2535 else switch (type(p))
2541 if (type(p) == hlist_node)
2543 else if (type(p) == vlist_node)
2545 else print_esc("unset");
2547 print_string("box(");
2548 print_scaled(height(p));
2550 print_scaled(depth(p));
2552 print_scaled(width(p));
2554 if (type(p) == unset_node)
2556 if (span_count(p) != 0)
2559 print_int(span_count(p) + 1);
2560 print_string(" columns)");
2563 if (glue_stretch(p) != 0)
2565 print_string(", stretch ");
2566 print_glue(glue_stretch(p), glue_order(p), "");
2569 if (glue_shrink(p) != 0)
2571 print_string(", shrink ");
2572 print_glue(glue_shrink(p), glue_sign(p), "");
2579 if ((g != 0.0) && (glue_sign(p) != 0))
2581 print_string(", glue set ");
2583 if (glue_sign(p) == shrinking)
2586 if (fabs(g)> 20000.0)
2591 print_string("< -");
2593 print_glue(20000 * 65536L, glue_order(p), "");
2596 print_glue(round(65536L * g), glue_order(p), "");
2599 if (shift_amount(p) != 0)
2601 print_string(", shifted ");
2602 print_scaled(shift_amount(p));
2608 str_pool[pool_ptr] = 46;
2611 show_node_list(mem[p + 5].hh.v.RH);
2620 print_rule_dimen(height(p));
2622 print_rule_dimen(depth(p));
2624 print_rule_dimen(width(p));
2630 print_esc("insert");
2631 print_int(subtype(p));
2632 print_string(", natural size ");
2633 print_scaled(height(p));
2634 print_string("; split(");
2635 print_spec(split_top_ptr(p), "");
2637 print_scaled(depth(p));
2638 print_string("); float cost ");
2639 print_int(float_cost(p));
2642 str_pool[pool_ptr] = 46;
2645 show_node_list(mem[p + 4].hh.v.LH);
2655 print_write_whatsit(1279, p); /* debug # (-1 to exit): */
2657 print_file_name(open_name(p), open_area(p), open_ext(p));
2663 print_write_whatsit(591, p); /* write */
2664 print_mark(write_tokens(p));
2669 print_write_whatsit(1280, p); /* closeout */
2674 print_esc("special");
2675 print_mark(write_tokens(p));
2681 print_esc("setlanguage");
2682 print_int(what_lang(p));
2683 print_string(" (hyphenmin ");
2684 print_int(what_lhm(p));
2686 print_int(what_rhm(p));
2692 print_string("whatsit?");
2698 if (subtype(p) >= a_leaders)
2702 if (subtype(p) == c_leaders)
2704 else if (subtype(p) == x_leaders)
2707 print_string("leaders ");
2709 print_spec(glue_ptr(p), "");
2712 str_pool[pool_ptr] = 46;
2715 show_node_list(mem[p + 1].hh.v.RH);
2723 if (subtype(p) != normal)
2727 if (subtype(p) < cond_math_glue)
2728 print_skip_param(subtype(p) - 1);
2729 else if (subtype(p) == cond_math_glue)
2730 print_esc("nonscript");
2731 else print_esc("mskip");
2736 if (subtype(p) != cond_math_glue)
2740 if (subtype(p) < cond_math_glue)
2741 print_spec(glue_ptr(p), "");
2743 print_spec(glue_ptr(p), "mu");
2749 if (subtype(p) != mu_glue)
2753 if (subtype(p) != normal)
2756 print_scaled(width(p));
2758 if (subtype(p) == acc_kern)
2759 print_string(" (for accent)");
2764 print_scaled(width(p));
2773 if (subtype(p) == before)
2776 print_string("off");
2780 print_string(", surrounded ");
2781 print_scaled(width(p));
2788 print_font_and_char(lig_char(p));
2789 print_string("(ligature ");
2794 font_in_short_display = font(lig_char(p));
2795 short_display(lig_ptr(p));
2797 if (odd(subtype(p)))
2806 print_esc("penalty ");
2807 print_int(penalty(p));
2813 print_esc("discretionary");
2815 if (replace_count(p) > 0)
2817 print_string(" replacing ");
2818 print_int(replace_count(p));
2823 str_pool[pool_ptr] = 46;
2826 show_node_list(mem[p + 1].hh.v.LH);
2830 str_pool[pool_ptr]= 124;
2833 show_node_list(mem[p + 1].hh.v.RH);
2841 print_mark(mark_ptr(p));
2847 print_esc("vadjust");
2850 str_pool[pool_ptr] = 46;
2853 show_node_list(mem[p + 1].cint);
2860 print_style(subtype(p));
2865 print_esc("mathchoice");
2867 show_node_list(display_mlist(p));
2870 show_node_list(text_mlist(p));
2873 show_node_list(script_mlist(p));
2876 show_node_list(script_script_mlist(p));
2900 print_esc("mathord");
2904 print_esc("mathop");
2908 print_esc("mathbin");
2912 print_esc("mathrel");
2916 print_esc("mathopen");
2920 print_esc("mathclose");
2924 print_esc("mathpunct");
2928 print_esc("mathinner");
2932 print_esc("overline");
2936 print_esc("underline");
2940 print_esc("vcenter");
2945 print_esc("radical");
2946 print_delimiter(left_delimiter(p));
2952 print_esc("accent");
2953 print_fam_and_char(accent_chr(p));
2960 print_delimiter(delimiter(p));
2967 print_delimiter(delimiter(p));
2972 if (subtype(p) != normal)
2973 if (subtype(p) == limits)
2974 print_esc("limits");
2976 print_esc("nolimits");
2978 if (type(p) < left_noad)
2979 print_subsidiary_data(nucleus(p), '.');
2981 print_subsidiary_data(supscr(p), '^');
2982 print_subsidiary_data(subscr(p), '_');
2988 print_esc("fraction, thickness ");
2990 if (thickness(p) == 1073741824L) /* 2^30 */
2991 print_string("= default");
2993 print_scaled(thickness(p));
2995 if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
2996 (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
2998 print_string(", left-delimiter ");
2999 print_delimiter(left_delimiter(p));
3002 if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
3003 (large_fam(right_delimiter(p)) != 0)||(large_char(right_delimiter(p)) != 0))
3005 print_string(", right-delimiter ");
3006 print_delimiter(right_delimiter(p));
3009 print_subsidiary_data(numerator(p), '\\');
3010 print_subsidiary_data(denominator(p), '/');
3015 print_string("Unknown node type!");