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)
847 register bool Result;
854 cur_input.loc_field = first;
856 while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
857 incr(cur_input.loc_field); // step over initial white space
859 if (cur_input.loc_field < last)
862 return Result; // there is an input file name
866 // failed to find input file name
870 flag = ConsoleInput("**", "Please type a file name or a control sequence\r\n(or ^z to exit)", (char *) &buffer[first]);
871 last = first + strlen((char *) &buffer[first]); /* -1 ? */
872 // may need to be more elaborate see input_line in texmf.c
874 (void) fputs("**", stdout);
876 flag = input_ln(stdin, true);
882 show_line("! End of file on the terminal... why?\n", 1);
887 cur_input.loc_field = first;
889 while ((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
890 incr(cur_input.loc_field); // step over intial white space
892 if (cur_input.loc_field < last)
895 return Result; // there is an input file name
898 sprintf(log_line, "%s\n", "Please type the name of your input file.");
899 show_line(log_line, 1);
903 // Make string from str_start[str_ptr] to pool_ptr
904 str_number make_string (void)
906 #ifdef ALLOCATESTRING
907 if (str_ptr == current_max_strings)
908 str_start = realloc_str_start(increment_max_strings);
910 if (str_ptr == current_max_strings)
912 overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/9 */
913 return 0; // abort_flag set
916 if (str_ptr == max_strings)
918 overflow("number of strings", max_strings - init_str_ptr);
919 return 0; // abort_flag set
923 str_start[str_ptr] = pool_ptr;
925 return (str_ptr - 1);
928 bool str_eq_buf_ (str_number s, integer k)
930 register bool Result;
936 while (j < str_start[s + 1])
938 if (str_pool[j] != buffer[k])
953 bool str_eq_str_ (str_number s, str_number t)
955 register bool Result;
961 if (length(s) != length(t))
967 while (j < str_start[s + 1])
969 if (str_pool[j] != str_pool[k])
981 void print_two_(integer n)
984 print_char('0' + (n / 10));
985 print_char('0' + (n % 10));
988 void print_hex_(integer n)
997 dig[k] = (unsigned char) (n % 16);
1006 void print_roman_int_(integer n)
1009 nonnegative_integer u, v;
1011 j = str_start[260]; /* m2d5c2l5x2v5i */
1018 print_char(str_pool[j]);
1026 u = v / (str_pool[k - 1] - '0');
1028 if (str_pool[k - 1] == 50)
1031 u = u / (str_pool[k - 1] - '0');
1036 print_char(str_pool[k]);
1042 v = v / (str_pool[j - 1] - '0');
1047 void print_current_string (void)
1051 j = str_start[str_ptr];
1053 while (j < pool_ptr)
1055 print_char(str_pool[j]);
1060 int stringlength (int str_ptr)
1062 return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2;
1065 char * add_string (char *s, char * str_string)
1069 n = strlen(str_string);
1070 memcpy(s, &str_string, n);
1077 int addextrahelp = 1;
1079 // make one long \r\n separated string out of help lines
1080 // str_pool is packed_ASCII_code *
1082 char * make_up_help_string (int nhelplines)
1084 char * helpstring, *s;
1087 // get length of help for this specific message
1088 for (k = nhelplines - 1; k >= 0; k--)
1090 nlen += strlen(help_line[k]);
1093 nlen += 2; // for blank line separator: "\r\n"
1097 nlen += stringlength(265);
1098 nlen += stringlength(266);
1099 nlen += stringlength(267);
1102 nlen += stringlength(268);
1104 if (deletions_allowed)
1105 nlen += stringlength(269);
1107 nlen += stringlength(270);
1110 helpstring = (char *) malloc(nlen + 1); // +1 = '\0'
1113 for (k = nhelplines-1; k >= 0; k--)
1115 s = add_string(s, help_line[k]);
1122 s = add_string(s, "Type <return> to proceed, S to scroll future error messages,");
1123 s = add_string(s, "R to run without stopping, Q to run quietly,");
1124 s = add_string(s, "I to insert something, ");
1127 s = add_string(s, "E to edit your file, ");
1129 if (deletions_allowed)
1130 s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
1132 s = add_string(s, "H for help, X to quit.");
1138 char * make_up_query_string (int promptstr)
1141 int nstart, nnext, n;
1144 nstart = str_start[ promptstr];
1145 nnext = str_start[ promptstr + 1];
1147 querystr = (char *) malloc(n + 1);
1149 memcpy(s, &str_pool[nstart], n);
1156 // abort_flag set if input_line / ConsoleInput returns non-zero
1157 // should set interrupt instead ???
1158 // called from tex0.c, tex2.c, tex3.c
1160 // void term_input(void)
1161 void term_input (char * term_str, int term_help_lines)
1165 char * helpstring = NULL;
1167 char * querystring = NULL;
1169 // if (nhelplines != 0) {
1170 // helpstring = make_up_help_string (nhelplines);
1171 // printf(helpstring);
1172 // free(helpstring);
1174 show_line("\n", 0); // force it to show what may be buffered up ???
1178 if (term_str != NULL)
1179 querystring = term_str;
1181 if (term_help_lines != NULL)
1182 helpstring = make_up_help_string(term_help_lines);
1184 if (helpstring == NULL && querystring != NULL)
1186 if (strcmp(querystring, ": ") == 0)
1187 helpstring = xstrdup("Please type another file name (or ^z to exit):");
1188 else if (strcmp(querystring, "=>") == 0) // from firm_up_the_line
1189 helpstring = xstrdup("Please type <enter> to accept this line\r\nor type a replacement line");
1190 else if (strcmp(querystring, "insert>") == 0) // from error() after "I"
1191 helpstring = xstrdup("Please type something to insert here");
1192 else if (strcmp(querystring, "") == 0) // from read_toks
1193 helpstring = xstrdup("Please type a control sequence");
1194 else if (strcmp(querystring, "= ") == 0) // from read_toks
1195 helpstring = xstrdup("Please type a token");
1196 else if (strcmp(querystring, "*") == 0) // get_next
1197 helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)");
1200 flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]); // ???
1201 // flag == 0 means trouble --- EOF on terminal
1202 if (querystring != NULL)
1205 if (helpstring != NULL)
1208 helpstring = querystring = NULL;
1210 last = first + strlen((char *) &buffer[first]); /* -1 ? */
1211 // flag = (last > first);
1212 // may need to be more elaborate see input_line in texmf.c ???
1213 // sprintf(log_line, "first %d last %d flag %d - %s",
1214 // first, last, flag, (char *) &buffer[first]);
1215 // winerror(log_line);
1218 flag = input_ln(stdin, true);
1222 fatal_error("End of file on the terminal!");
1223 return; // abort_flag set
1227 // echo what was typed into Console buffer also
1229 for (k = first; k <= last - 1; k++)
1233 decr(selector); // shut off echo
1236 for (k = first; k <= last - 1; k++)
1240 incr(selector); // reset selector again
1244 void int_error_ (integer n)
1252 void normalize_selector (void)
1255 selector = term_and_log;
1257 selector = term_only;
1262 if (interaction == batch_mode)
1266 void pause_for_instructions (void)
1268 if (OK_to_interrupt)
1270 interaction = error_stop_mode;
1272 if ((selector == log_only) || (selector == no_print))
1275 print_err("Interruption");
1277 "Try to insert some instructions for me (e.g.,`I\\showlists'),",
1278 "unless you just want to quit by typing `X'.");
1279 deletions_allowed = false;
1281 deletions_allowed = true;
1286 integer half_(integer x)
1289 return ((x + 1) / 2);
1294 scaled round_decimals_(small_number k)
1303 a = (a + dig[k] * 131072L) / 10; /* 2^17 */
1306 return ((a + 1) / 2);
1309 /* This has some minor speedup changes - no real advantage probably ... */
1310 void print_scaled_(scaled s)
1320 print_int(s / 65536L);
1322 s = 10 * (s % 65536L) + 5;
1328 s = s - 17232; /* 2^15 - 50000 - rounding */
1329 print_char('0' + (s / 65536L));
1330 s = 10 * (s % 65536L);
1333 while (!(s <= delta));
1336 scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
1346 else if (((x <= (maxanswer - y) / n) && (- (integer) x <= (maxanswer + y) / n)))
1355 scaled x_over_n_(scaled x, integer n)
1357 register scaled Result;
1380 tex_remainder = x % n;
1384 Result = - (integer) ((- (integer) x)/ n);
1385 tex_remainder = - (integer) ((- (integer) x)% n);
1390 tex_remainder = - (integer) tex_remainder;
1395 scaled xn_over_d_(scaled x, integer n, integer d)
1397 register scaled Result;
1399 nonnegative_integer t, u, v;
1409 t =(x % 32767L) * n;
1410 u =(x / 32768L)* n +(t / 32768L);
1411 v =(u % d)* 32768L +(t % 32768L);
1413 if (u / d >= 32768L)
1416 u = 32768L * (u / d) + (v / d);
1421 tex_remainder = v % d;
1425 Result = - (integer) u;
1426 tex_remainder = - (integer)(v % d);
1432 halfword badness_(scaled t, scaled s)
1444 else if (s >= 1663497L)
1452 return (r * r * r + 131072L) / 262144L; /* 2^17 */
1457 void print_word_(memory_word w)
1461 print_scaled(w.cint);
1463 print_scaled(round(65536L * w.gr));
1465 print_int(w.hh.v.LH);
1471 print_int(w.hh.v.RH);
1473 print_int(w.qqqq.b0);
1475 print_int(w.qqqq.b1);
1477 print_int(w.qqqq.b2);
1479 print_int(w.qqqq.b3);
1481 /* need this version only if SHORTFONTINFO defined */
1482 void zprintfword(fmemoryword w)
1486 print_scaled(w.cint);
1488 print_scaled(round(65536L * w.gr));
1490 print_int(w.hh.v.LH);
1494 print_int(w .hh.b1);
1496 print_int(w.hh.v.RH);
1498 print_int(w.qqqq.b0);
1500 print_int(w.qqqq.b1);
1502 print_int(w.qqqq.b2);
1504 print_int(w.qqqq.b3);
1508 void show_token_list_(integer p, integer q, integer l)
1511 ASCII_code match_chr;
1518 while ((p != 0) && (tally < l))
1522 first_count = tally;
1523 trick_count = tally + 1 + error_line - half_error_line;
1525 if (trick_count < error_line)
1526 trick_count = error_line;
1529 if ((p < hi_mem_min) || (p > mem_end))
1531 print_esc("CLOBBERED.");
1535 if (info(p) >= cs_token_flag)
1536 print_cs(info(p) - cs_token_flag);
1568 print_char(c + '0');
1577 match_chr = (ASCII_code) c;
1606 if (scanner_status > 1)
1608 print_nl("Runaway ");
1610 switch (scanner_status)
1613 print_string("definition");
1618 print_string("argument");
1623 print_string("preamble");
1628 print_string("text");
1635 show_token_list(link(p), 0, error_line - 10);
1639 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1640 /* first try list of available nodes (avail != NULL) */
1641 /* then see if can go upwards (mem_end < mem_max) */
1642 /* then see if can go downwards (hi_mem_min > lo_mem_max) */
1643 /* if not, extend memory at the top and grab from there --- new */
1644 /* else fail ! paragraph 120 */
1645 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1646 halfword get_avail (void)
1653 avail = link(avail);
1654 else if (mem_end < mem_max)
1664 if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
1667 mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
1672 if (mem_end >= mem_max)
1675 overflow("main memory size", mem_max + 1 - mem_min);
1676 return 0; // abort_flag set
1678 incr(mem_end); /* then grab from new area */
1679 p = mem_end; /* 1993/Dec/14 */
1683 link(p) = 0; /* link(p) = null !!! */
1692 void flush_list_(halfword p) /* paragraph 123 */
1696 if (p != 0) /* null !!! */
1708 while (!(r == 0)); /* r != null */
1715 halfword get_node_(integer s)
1717 register halfword Result;
1728 q = p + node_size(p);
1730 while ((mem[q].hh.v.RH == empty_flag))
1737 llink(t) = llink(q);
1738 rlink(llink(q)) = t;
1739 q = q + node_size(q);
1744 if (r > toint(p + 1))
1746 node_size(p) = r - p;
1761 node_size(p) = q - p;
1764 while (!(p == rover));
1766 if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
1768 Result = max_halfword;
1771 show_line("Merged adjacent multi-word nodes\n", 0);
1776 /* maybe try downward epxansion first instead ? */
1777 if (lo_mem_max + 2 < hi_mem_min)
1778 if (lo_mem_max + 2 <= mem_bot + max_halfword) /* silly ? flush 93/Dec/16 */
1780 /* if (hi_mem_min - lo_mem_max >= 1998) */
1781 if (hi_mem_min - lo_mem_max >= (block_size + block_size - 2))
1782 /* t = lo_mem_max + 1000; */
1783 t = lo_mem_max + block_size;
1785 t = lo_mem_max + 1 + (hi_mem_min - lo_mem_max) / 2;
1792 if (t > mem_bot + max_halfword)
1793 t = mem_bot + max_halfword; /* silly ? flush 93/Dec/16 */
1797 link(q) = empty_flag;
1798 node_size(q) = t - lo_mem_max; /* block size */
1800 link(lo_mem_max) = 0;
1801 info(lo_mem_max) = 0;
1806 /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
1807 /* we've run out of space in the middle for variable length blocks */
1808 /* try and add new block from below mem_bot *//* first check if space ! */
1809 if (mem_min - (block_size + 1) <= mem_start) /* extend lower memory downwards */
1811 mem = realloc_main (mem_top/2 + block_size, 0); /* zzzaa = zmem = mem */
1819 if (mem_min - (block_size + 1) <= mem_start) /* check again */
1823 sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
1824 show_line(log_line, 0);
1827 overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
1828 return 0; // abort_flag set
1830 /* avoid function call in following ? */
1831 add_variable_space (block_size); /* now to be found in itex.c */
1832 goto lab20; /* go try get_node again */
1838 var_used = var_used + s;
1845 void free_node_(halfword p, halfword s)
1850 link(p) = empty_flag;
1857 var_used = var_used - s;
1861 halfword new_null_box (void)
1865 p = get_node(box_node_size);
1866 type(p) = hlist_node;
1867 subtype(p) = min_quarterword;
1871 shift_amount(p) = 0;
1873 glue_sign(p) = normal;
1874 glue_order(p) = normal;
1880 halfword new_rule (void)
1884 p = get_node(rule_node_size);
1885 type(p) = rule_node;
1887 width(p) = null_flag;
1888 depth(p) = null_flag;
1889 height(p) = null_flag;
1894 halfword new_ligature_(quarterword f, quarterword c, halfword q)
1898 p = get_node(small_node_size);
1899 type(p) = ligature_node;
1900 font(lig_char(p)) = f;
1901 character(lig_char(p)) = c;
1908 halfword new_lig_item_(quarterword c)
1912 p = get_node(small_node_size);
1919 halfword new_disc (void)
1923 p = get_node(small_node_size);
1924 type(p) = disc_node;
1925 replace_count(p) = 0;
1932 halfword new_math_(scaled w, small_number s)
1936 p = get_node(small_node_size);
1937 type(p) = math_node;
1944 halfword new_spec_(halfword p)
1948 q = get_node(glue_spec_size);
1950 glue_ref_count(q) = 0;
1951 width(q) = width(p);
1952 stretch(q) = stretch(p);
1953 shrink(q) = shrink(p);
1958 halfword new_param_glue_(small_number n)
1963 p = get_node(small_node_size);
1964 type(p) = glue_node;
1969 incr(glue_ref_count(q));
1974 halfword new_glue_(halfword q)
1978 p = get_node(small_node_size);
1979 type(p) = glue_node;
1980 subtype(p) = normal;
1983 incr(glue_ref_count(q));
1988 halfword new_skip_param_(small_number n)
1992 temp_ptr = new_spec(glue_par(n));
1993 p = new_glue(temp_ptr);
1994 glue_ref_count(temp_ptr) = 0;
2000 halfword new_kern_(scaled w)
2004 p = get_node(small_node_size);
2005 type(p) = kern_node;
2006 subtype(p) = normal;
2012 halfword new_penalty_(integer m)
2016 p = get_node(small_node_size);
2017 type(p) = penalty_node;
2026 void check_mem_(bool printlocs)
2031 for (p = mem_min; p <= lo_mem_max; p++) freearr[p] = false;
2032 for (p = hi_mem_min; p <= mem_end; p++) freearr[p] = false;
2037 if ((p > mem_end) || (p < hi_mem_min))
2039 else if (freearr[p])
2044 print_nl("AVAIL list clobbered at ");
2057 if ((p >= lo_mem_max) || (p < mem_min))
2059 else if ((rlink(p) >= lo_mem_max) || (rlink(p) < mem_min))
2061 else if (!(is_empty(p)) || (node_size(p) < 2) ||
2062 (p + node_size(p) > lo_mem_max) || (llink(rlink(p)) != p))
2067 print_nl("Double-AVAIL list clobbered at ");
2072 for (q = p; q <= p + node_size(p) - 1; q++)
2076 print_nl("Doubly free location at ");
2084 } while (!(p == rover));
2087 while (p <= lo_mem_max) {
2090 print_nl("Bad flag at ");
2093 while ((p <= lo_mem_max) && !freearr[p]) incr(p);
2094 while ((p <= lo_mem_max) && freearr[p]) incr(p);
2099 print_nl("New busy locs:");
2101 for (p = mem_min; p <= lo_mem_max; p++)
2102 if (!freearr[p] && ((p > was_lo_max) || wasfree[p]))
2108 for (p = hi_mem_min; p <= mem_end; p++)
2109 if (!freearr[p] && ((p < was_hi_min) || (p > was_mem_end) || wasfree[p]))
2116 for (p = mem_min; p <= lo_mem_max; p++) wasfree[p] = freearr[p];
2117 for (p = hi_mem_min; p <= mem_end; p++) wasfree[p] = freearr[p];
2119 was_mem_end = mem_end;
2120 was_lo_max = lo_mem_max;
2121 was_hi_min = hi_mem_min;
2127 void search_mem_(halfword p)
2131 for (q = mem_min; q <= lo_mem_max; q++)
2147 for (q = hi_mem_min; q <= mem_end; q++)
2163 for (q = active_base; q <= box_base + 255; q++)
2172 for (q = 0; q <= save_ptr - 1; q++)
2174 if (equiv_field(save_stack[q]) == p)
2182 for (q = 0; q <= hyphen_prime; q++)
2183 if (hyph_list[q] == p)
2192 void short_display_(integer p)
2196 while (p != 0) { /* want p != null here bkph 93/Dec/15 !!! NOTE: still not fixed in 3.14159 ! */
2197 if (is_char_node(p))
2201 if (font(p) != font_in_short_display)
2203 if ((font(p) > font_max))
2208 print(font_id_text(font(p)));
2211 font_in_short_display = font(p);
2213 print(character(p));
2216 else switch (mem[p].hh.b0)
2231 if (glue_ptr(p) != 0)
2238 short_display(lig_ptr(p));
2241 short_display(pre_break(p));
2242 short_display(post_break(p));
2243 n = replace_count(p);
2246 if (link(p) != 0) /* if link(p)<>null then */
2258 void print_font_and_char_ (integer p)
2261 print_esc("CLOBBERED.");
2264 if ((font(p) > font_max))
2269 print(font_id_text(font(p)));
2273 print(character(p));
2277 void print_mark_ (integer p)
2281 if ((p < hi_mem_min)||(p > mem_end))
2282 print_esc("CLOBBERED.");
2284 show_token_list(link(p), 0, max_print_line - 10);
2289 void print_rule_dimen_ (scaled d)
2291 if ((d == -1073741824L)) /* - 2^30 */
2297 void print_glue_(scaled d, integer order, char * s)
2301 if ((order < normal) || (order > filll))
2302 print_string("foul");
2305 print_string("fil");
2311 } else if (*s != '\0')
2315 void print_spec_(integer p, char * s)
2317 if ((p < mem_min)||(p >= lo_mem_max))
2321 print_scaled(width(p));
2326 if (stretch(p) != 0)
2328 print_string("plus");
2329 print_glue(stretch(p), stretch_order(p), s);
2334 print_string("minus");
2335 print_glue(shrink(p), shrink_order(p), s);
2340 void print_fam_and_char_(halfword p)
2345 print(character(p));
2348 void print_delimiter_(halfword p)
2352 a = small_fam(p) * 256 + small_char(p);
2353 a = a * 4096 + large_fam(p) * 256 + large_char(p);
2361 void print_subsidiary_data_(halfword p, ASCII_code c)
2363 if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
2365 if (math_type(p) != 0)
2366 print_string(" []");
2373 switch (math_type(p))
2377 print_current_string();
2378 print_fam_and_char(p);
2389 print_current_string();
2404 void print_style_(integer c)
2409 print_esc("displaystyle");
2412 print_esc("textstyle");
2415 print_esc("scriptstyle");
2418 print_esc("scriptscriptstyle");
2421 print_string("Unknown style!");
2426 void print_skip_param_(integer n)
2430 case line_skip_code:
2431 print_esc("lineskip");
2434 case baseline_skip_code:
2435 print_esc("baselineskip");
2439 print_esc("parskip");
2442 case above_display_skip_code:
2443 print_esc("abovedisplayskip");
2446 case below_display_skip_code:
2447 print_esc("belowdisplayskip");
2450 case above_display_short_skip_code:
2451 print_esc("abovedisplayshortskip");
2454 case below_display_short_skip_code:
2455 print_esc("belowdisplayshortskip");
2458 case left_skip_code:
2459 print_esc("leftskip");
2462 case right_skip_code:
2463 print_esc("rightskip");
2467 print_esc("topskip");
2470 case split_top_skip_code:
2471 print_esc("splittopskip");
2475 print_esc("tabskip");
2478 case space_skip_code:
2479 print_esc("spaceskip");
2482 case xspace_skip_code:
2483 print_esc("xspaceskip");
2486 case par_fill_skip_code:
2487 print_esc("parfillskip");
2490 case thin_mu_skip_code:
2491 print_esc("thinmuskip");
2494 case med_mu_skip_code:
2495 print_esc("medmuskip");
2498 case thick_mu_skip_code:
2499 print_esc("thickmuskip");
2503 print_string("[unknown glue parameter!]");
2508 void show_node_list_(integer p)
2513 if (cur_length > depth_threshold)
2515 /* if (p > 0) */ /* was p>null !!! line 3662 in tex.web */
2516 if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
2517 print_string(" []");
2523 while (p != 0) { /* want p != null - bkph 93/Dec/15 NOTE: still not fixed in 3.14159 ! */
2525 print_current_string();
2529 print_string("Bad link, display aborted.");
2535 if (n > breadth_max)
2537 print_string("etc.");
2541 if ((p >= hi_mem_min))
2542 print_font_and_char(p);
2543 else switch (type(p))
2549 if (type(p) == hlist_node)
2551 else if (type(p) == vlist_node)
2553 else print_esc("unset");
2555 print_string("box(");
2556 print_scaled(height(p));
2558 print_scaled(depth(p));
2560 print_scaled(width(p));
2562 if (type(p) == unset_node)
2564 if (span_count(p) != 0)
2567 print_int(span_count(p) + 1);
2568 print_string(" columns)");
2571 if (glue_stretch(p) != 0)
2573 print_string(", stretch ");
2574 print_glue(glue_stretch(p), glue_order(p), "");
2577 if (glue_shrink(p) != 0)
2579 print_string(", shrink ");
2580 print_glue(glue_shrink(p), glue_sign(p), "");
2587 if ((g != 0.0) && (glue_sign(p) != 0))
2589 print_string(", glue set ");
2591 if (glue_sign(p) == shrinking)
2594 if (fabs(g)> 20000.0)
2599 print_string("< -");
2601 print_glue(20000 * 65536L, glue_order(p), "");
2604 print_glue(round(65536L * g), glue_order(p), "");
2607 if (shift_amount(p) != 0)
2609 print_string(", shifted ");
2610 print_scaled(shift_amount(p));
2616 str_pool[pool_ptr] = 46;
2619 show_node_list(mem[p + 5].hh.v.RH);
2628 print_rule_dimen(height(p));
2630 print_rule_dimen(depth(p));
2632 print_rule_dimen(width(p));
2638 print_esc("insert");
2639 print_int(subtype(p));
2640 print_string(", natural size ");
2641 print_scaled(height(p));
2642 print_string("; split(");
2643 print_spec(split_top_ptr(p), "");
2645 print_scaled(depth(p));
2646 print_string("); float cost ");
2647 print_int(float_cost(p));
2650 str_pool[pool_ptr] = 46;
2653 show_node_list(mem[p + 4].hh.v.LH);
2663 print_write_whatsit(1279, p); /* debug # (-1 to exit): */
2665 print_file_name(open_name(p), open_area(p), open_ext(p));
2671 print_write_whatsit(591, p); /* write */
2672 print_mark(write_tokens(p));
2677 print_write_whatsit(1280, p); /* closeout */
2682 print_esc("special");
2683 print_mark(write_tokens(p));
2689 print_esc("setlanguage");
2690 print_int(what_lang(p));
2691 print_string(" (hyphenmin ");
2692 print_int(what_lhm(p));
2694 print_int(what_rhm(p));
2700 print_string("whatsit?");
2706 if (subtype(p) >= a_leaders)
2710 if (subtype(p) == c_leaders)
2712 else if (subtype(p) == x_leaders)
2715 print_string("leaders ");
2717 print_spec(glue_ptr(p), "");
2720 str_pool[pool_ptr] = 46;
2723 show_node_list(mem[p + 1].hh.v.RH);
2731 if (subtype(p) != normal)
2735 if (subtype(p) < cond_math_glue)
2736 print_skip_param(subtype(p) - 1);
2737 else if (subtype(p) == cond_math_glue)
2738 print_esc("nonscript");
2739 else print_esc("mskip");
2744 if (subtype(p) != cond_math_glue)
2748 if (subtype(p) < cond_math_glue)
2749 print_spec(glue_ptr(p), "");
2751 print_spec(glue_ptr(p), "mu");
2757 if (subtype(p) != mu_glue)
2761 if (subtype(p) != normal)
2764 print_scaled(width(p));
2766 if (subtype(p) == acc_kern)
2767 print_string(" (for accent)");
2772 print_scaled(width(p));
2781 if (subtype(p) == before)
2784 print_string("off");
2788 print_string(", surrounded ");
2789 print_scaled(width(p));
2796 print_font_and_char(lig_char(p));
2797 print_string("(ligature ");
2802 font_in_short_display = font(lig_char(p));
2803 short_display(lig_ptr(p));
2805 if (odd(subtype(p)))
2814 print_esc("penalty ");
2815 print_int(penalty(p));
2821 print_esc("discretionary");
2823 if (replace_count(p) > 0)
2825 print_string(" replacing ");
2826 print_int(replace_count(p));
2831 str_pool[pool_ptr] = 46;
2834 show_node_list(mem[p + 1].hh.v.LH);
2838 str_pool[pool_ptr]= 124;
2841 show_node_list(mem[p + 1].hh.v.RH);
2849 print_mark(mark_ptr(p));
2855 print_esc("vadjust");
2858 str_pool[pool_ptr] = 46;
2861 show_node_list(mem[p + 1].cint);
2868 print_style(subtype(p));
2873 print_esc("mathchoice");
2875 show_node_list(display_mlist(p));
2878 show_node_list(text_mlist(p));
2881 show_node_list(script_mlist(p));
2884 show_node_list(script_script_mlist(p));
2908 print_esc("mathord");
2912 print_esc("mathop");
2916 print_esc("mathbin");
2920 print_esc("mathrel");
2924 print_esc("mathopen");
2928 print_esc("mathclose");
2932 print_esc("mathpunct");
2936 print_esc("mathinner");
2940 print_esc("overline");
2944 print_esc("underline");
2948 print_esc("vcenter");
2953 print_esc("radical");
2954 print_delimiter(left_delimiter(p));
2960 print_esc("accent");
2961 print_fam_and_char(accent_chr(p));
2968 print_delimiter(delimiter(p));
2975 print_delimiter(delimiter(p));
2980 if (subtype(p) != normal)
2981 if (subtype(p) == limits)
2982 print_esc("limits");
2984 print_esc("nolimits");
2986 if (type(p) < left_noad)
2987 print_subsidiary_data(nucleus(p), '.');
2989 print_subsidiary_data(supscr(p), '^');
2990 print_subsidiary_data(subscr(p), '_');
2996 print_esc("fraction, thickness ");
2998 if (thickness(p) == 1073741824L) /* 2^30 */
2999 print_string("= default");
3001 print_scaled(thickness(p));
3003 if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
3004 (large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
3006 print_string(", left-delimiter ");
3007 print_delimiter(left_delimiter(p));
3010 if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
3011 (large_fam(right_delimiter(p)) != 0)||(large_char(right_delimiter(p)) != 0))
3013 print_string(", right-delimiter ");
3014 print_delimiter(right_delimiter(p));
3017 print_subsidiary_data(numerator(p), '\\');
3018 print_subsidiary_data(denominator(p), '/');
3023 print_string("Unknown node type!");