02110-1301 USA. */
#define EXTERN extern
-
#include "texd.h"
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-void synch_h(void)
-{
- if (cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, right1);
- dvi_h = cur_h;
- }
-}
-void synch_v(void)
-{
- if (cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, down1);
- dvi_v = cur_v;
- }
-}
-void set_cur_lang(void)
-{
- if (language <= 0)
- cur_lang = 0;
- else if (language > 255)
- cur_lang = 0;
- else
- cur_lang = language;
-}
-INLINE void free_avail_(halfword p)
-{
- link(p) = avail;
- avail = p;
-#ifdef STAT
- decr(dyn_used);
-#endif /* STAT */
-}
-INLINE void dvi_out_(ASCII_code op)
-{
- dvi_buf[dvi_ptr] = op;
- incr(dvi_ptr);
-
- if (dvi_ptr == dvi_limit)
- dvi_swap();
-}
-INLINE void succumb (void)
-{
- if (interaction == error_stop_mode)
- interaction = scroll_mode;
-
- if (log_opened)
- {
- error();
- }
-
-#ifdef DEBUG
- if (interaction > 0)
- debug_help();
-#endif
-
- history = 3;
- jump_out();
-}
-INLINE void flush_string (void)
-{
- decr(str_ptr);
- pool_ptr = str_start[str_ptr];
-}
-INLINE void append_char (ASCII_code c)
-{
- str_pool[pool_ptr] = c;
- incr(pool_ptr);
-}
-INLINE void append_lc_hex (ASCII_code c)
-{
- if (c < 10)
- append_char(c + '0');
- else
- append_char(c - 10 + 'a');
-}
-INLINE void print_err (const char * s)
-{
- if (interaction == error_stop_mode);
- print_nl("! ");
- print_string(s);
-}
-INLINE void tex_help (unsigned int n, ...)
-{
- int i;
- va_list help_arg;
-
- if (n > 6)
- n = 6;
-
- help_ptr = n;
- va_start(help_arg, n);
-
- for (i = n - 1; i > -1; --i)
- help_line[i] = va_arg(help_arg, char *);
-
- va_end(help_arg);
-}
-INLINE void str_room_ (int val)
-{
-#ifdef ALLOCATESTRING
- if (pool_ptr + val > current_pool_size)
- str_pool = realloc_str_pool(increment_pool_size);
-
- if (pool_ptr + val > current_pool_size)
- {
- overflow("pool size", current_pool_size - init_pool_ptr);
- }
-#else
- if (pool_ptr + val > pool_size)
- {
- overflow("pool size", pool_size - init_pool_ptr);
- }
-#endif
-}
-INLINE void tail_append_ (pointer val)
-{
- link(tail) = val;
- tail = link(tail);
-}
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
/* sec 0058 */
void print_ln (void)
{
case term_and_log:
show_char('\n');
term_offset = 0;
- (void) putc ('\n', log_file);
+ putc('\n', log_file);
file_offset = 0;
break;
case log_only:
- (void) putc ('\n', log_file);
+ putc('\n', log_file);
file_offset = 0;
break;
case no_print:
case pseudo:
case new_string:
+ do_nothing();
break;
default:
- (void) putc ('\n', write_file[selector]);
+ putc('\n', write_file[selector]);
break;
}
}
void print_char_ (ASCII_code s)
{
if (s == new_line_char)
- {
if (selector < pseudo)
{
print_ln();
return;
}
- }
switch (selector)
{
case term_and_log:
- (void) show_char(Xchr(s));
+ show_char(xchr[s]);
incr(term_offset);
- (void) putc(Xchr(s), log_file);
+ putc(xchr[s], log_file);
incr(file_offset);
if (term_offset == max_print_line)
if (file_offset == max_print_line)
{
- (void) putc ('\n', log_file);
+ putc ('\n', log_file);
file_offset = 0;
}
break;
case log_only:
- (void) putc(Xchr(s), log_file);
+ putc(xchr[s], log_file);
incr(file_offset);
if (file_offset == max_print_line)
break;
case term_only:
- (void) show_char(Xchr(s));
+ show_char(xchr[s]);
incr(term_offset);
if (term_offset == max_print_line)
break;
case no_print:
+ do_nothing();
break;
case pseudo:
case new_string:
#ifdef ALLOCATESTRING
if (pool_ptr + 1 > current_pool_size)
- {
str_pool = realloc_str_pool (increment_pool_size);
- }
if (pool_ptr < current_pool_size)
- {
- str_pool[pool_ptr]= s;
- incr(pool_ptr);
- }
+ append_char(s);
#else
if (pool_ptr < pool_size)
- {
- str_pool[pool_ptr]= s;
- incr(pool_ptr);
- }
+ append_char(s);
#endif
break;
default:
- (void) putc(Xchr(s), write_file[selector]);
+ putc(xchr[s], write_file[selector]);
break;
}
return;
}
- if ((s == new_line_char))
+ if (s == new_line_char)
if (selector < pseudo)
{
print_ln();
return;
}
- nl = new_line_char;
- new_line_char = -1;
-/* translate ansi to dos 850 */
- if (!show_in_hex && s < 256 && s >= 32)
+ nl = new_line_char;
+ new_line_char = -1;
+
+ /* translate ansi to dos 850 */
+ if (!show_in_hex && s < 256 && s >= 32)
+ {
+ if (show_in_dos && s > 127)
{
- if (show_in_dos && s > 127)
+ if (wintodos[s - 128] > 0)
{
- if (wintodos[s - 128] > 0)
- {
- print_char (wintodos[s - 128]);
- }
- else
- {
- j = str_start[s];
-
- while (j < str_start[s + 1])
- {
- print_char(str_pool[j]);
- incr(j);
- }
- }
+ print_char(wintodos[s - 128]);
}
else
{
- print_char(s); /* don't translate to hex */
+ j = str_start[s];
+
+ while (j < str_start[s + 1])
+ {
+ print_char(str_pool[j]);
+ incr(j);
+ }
}
}
else
- { /* not just a character */
- j = str_start[s];
+ {
+ print_char(s); /* don't translate to hex */
+ }
+ }
+ else
+ { /* not just a character */
+ j = str_start[s];
- while (j < str_start[s + 1])
- {
- print_char(str_pool[j]);
- incr(j);
- }
+ while (j < str_start[s + 1])
+ {
+ print_char(str_pool[j]);
+ incr(j);
}
+ }
- new_line_char = nl; /* restore eol */
- return;
+ new_line_char = nl; /* restore eol */
+ return;
}
}
}
}
}
/* string version print. */
-void print_string_ (unsigned char *s)
+void prints_ (const char *s)
{
while (*s > 0)
print_char(*s++);
pool_pointer j;
if ((s >= str_ptr) || (s < 256))
- {
print(s);
- }
else
{
j = str_start[s];
}
}
/* sec 0062 */
-void print_nl_ (const char * s)
+void print_nl (const char * s)
{
if (((term_offset > 0) && (odd(selector))) ||
((file_offset > 0) && (selector >= log_only)))
print_ln();
- print_string(s);
+ prints(s);
}
/* sec 0063 */
-void print_esc_ (const char * s)
+void print_esc (const char * s)
{
integer c;
if (c < 256)
print(c);
- print_string(s);
+ prints(s);
}
/* sec 0064 */
void print_the_digs_ (eight_bits k)
}
else if (p < active_base)
print_esc("IMPOSSIBLE.");
- else print(p - active_base);
+ else
+ print(p - active_base);
else if (p >= undefined_control_sequence)
print_esc("IMPOSSIBLE.");
else if ((text(p) >= str_ptr))
print_esc("scriptscriptfont");
}
/* sec 1355 */
-void print_write_whatsit_(str_number s, halfword p)
+void print_write_whatsit_(const char * s, pointer p)
{
- print_esc("");
- print(s);
+ print_esc(s);
if (write_stream(p) < 16)
print_int(write_stream(p));
ready_already = 0;
if (trace_flag)
- show_line("EXITING at JUMPOUT\n", 0);
+ puts("EXITING at JUMPOUT");
if ((history != 0) && (history != 1))
code = 1;
if (interaction == error_stop_mode)
while (true)
{
-lab22:
+continu:
clear_for_error_prompt();
-
- { /* prompt_input */
- print_string("? ");
- term_input("? ", help_ptr);
- }
+ prompt_input("? ");
if (last == first)
return; // no input
- c = buffer[first]; // analyze first letter typed
+ c = buffer[first];
- if (c >= 'a') // uppercase letter first
- c = (unsigned char) (c + 'A' - 'a');
+ if (c >= 'a')
+ c = (c + 'A' - 'a');
switch (c)
{
OK_to_interrupt = false;
if ((last > first + 1) && (buffer[first + 1] >= '0') && (buffer[first + 1] <= '9'))
- c = (unsigned char) (c * 10 + buffer[first + 1] - '0' * 11);
+ c = (c * 10 + buffer[first + 1] - '0' * 11);
else
- c = (unsigned char) (c - 48);
+ c = (c - 48);
while (c > 0)
{
help2("I have just deleted some text, as you asked.",
"You can now delete more, or insert, or whatever.");
show_context();
- goto lab22; /* loop again */
+ goto continu;
}
break;
case 'D':
{
debug_help();
- goto lab22; /* loop again */
+ goto continu;
}
break;
-#endif /* DEBUG */
+#endif
+
case 'E':
if (base_ptr > 0)
{
if (help_ptr == 0)
help2("Sorry, I don't know how to help in this situation.",
"Maybe you should try asking a human?");
- do {
- decr(help_ptr);
- print_string(help_line[help_ptr]);
- print_ln();
- } while (!(help_ptr == 0));
+ do
+ {
+ decr(help_ptr);
+ prints(help_line[help_ptr]);
+ print_ln();
+ }
+ while (!(help_ptr == 0));
}
help4("Sorry, I already gave what help I could...",
"Maybe you should try asking a human?",
"An error might have occurred before I noticed any problems.",
"``If all else fails, read the instructions.''");
- goto lab22; /* loop again */
+ goto continu;
}
break;
if (last > first + 1)
{
- cur_input.loc_field = first + 1;
+ loc = first + 1;
buffer[first] = 32;
}
else
{
- { /* prompt_input */
- print_string("insert>");
- term_input("insert>", 0);
- }
- cur_input.loc_field = first;
+ prompt_input("insert>");
+ loc = first;
}
+
first = last;
- cur_input.limit_field = last - 1;
+ limit = last - 1;
+
return;
}
break;
{
error_count = 0;
interaction = 0 + c - 81; /* Q = 0, R = 1, S = 2, T = 3 */
- print_string("OK, entering ");
+ prints("OK, entering ");
switch (c)
{
print_esc("batchmode");
decr(selector);
break;
+
case 'R':
print_esc("nonstopmode");
break;
+
case 'S':
print_esc("scrollmode");
break;
}
- print_string("...");
+ prints("...");
print_ln();
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
+ update_terminal();
return;
}
break;
} /* end of switch analysing response character */
{
- print_string("Type <return> to proceed, S to scroll future error messages,");
+ prints("Type <return> to proceed, S to scroll future error messages,");
print_nl("R to run without stopping, Q to run quietly,");
print_nl("I to insert something, ");
if (base_ptr > 0)
- print_string("E to edit your file,");
+ prints("E to edit your file,");
if (deletions_allowed)
print_nl("1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
print_nl("H for help, X to quit.");
}
- } /* end of while(true) loop */
+ }
incr(error_count);
print_ln();
give_err_help();
}
- else while(help_ptr > 0)
+ else while (help_ptr > 0)
{
decr(help_ptr);
print_nl(help_line[help_ptr] == NULL ? "" : help_line[help_ptr]);
print_ln();
}
/* sec 0093 */
-void fatal_error_(char * s)
+void fatal_error(char * s)
{
normalize_selector();
print_err("Emergency stop");
{
normalize_selector();
print_err("TeX capacity exceeded, sorry [");
- print_string(s);
+ prints(s);
print_char('=');
print_int(n);
print_char(']');
if (!knuth_flag)
{
- if (!strcmp(s, "pattern memory") && n == trie_size)
+ if (!strcmp(s, "pattern memory") && (n == trie_size))
{
sprintf(log_line, "\n (Maybe use -h=... on command line in ini-TeX)\n");
show_line(log_line, 0);
}
- else if (!strcmp(s, "exception dictionary") && n == hyphen_prime)
+ else if (!strcmp(s, "exception dictionary") && (n == hyphen_prime))
{
sprintf(log_line, "\n (Maybe use -e=... on command line in ini-TeX)\n");
show_line(log_line, 0);
succumb();
}
/* sec 0095 */
-void confusion_(char * s)
+void confusion_(const char * s)
{
normalize_selector();
if (history < error_message_issued)
{
print_err("This can't happen (");
- print_string(s);
+ prints(s);
print_char(')');
help1("I'm broken. Please show this to someone who can fix can fix");
}
succumb();
}
/* sec 0037 */
-bool init_terminal (void)
+boolean init_terminal (void)
{
int flag;
if (last > first)
{
- cur_input.loc_field = first;
+ loc = first;
- while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
- incr(cur_input.loc_field); // step over initial white space
+ while ((loc < last) && (buffer[loc]== ' '))
+ incr(loc); // step over initial white space
- if (cur_input.loc_field < last)
+ if (loc < last)
return true;
}
// failed to find input file name
while (true)
{
-#ifdef _WINDOWS
- flag = ConsoleInput("**", "Please type a file name or a control sequence\r\n(or ^z to exit)", (char *) &buffer[first]);
- last = first + strlen((char *) &buffer[first]); /* -1 ? */
-// may need to be more elaborate see input_line in texmf.c
-#else
- (void) fputs("**", stdout);
- fflush(stdout);
+ fputs("**", stdout);
+ update_terminal();
flag = input_ln(stdin, true);
-#endif
if (!flag)
{
show_char('\n');
- show_line("! End of file on the terminal... why?\n", 1);
+ puts("! End of file on the terminal... why?\n");
return false;
}
- cur_input.loc_field = first;
+ loc = first;
- while ((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
- incr(cur_input.loc_field); // step over intial white space
+ while ((loc < last) && (buffer[loc]== ' '))
+ incr(loc); // step over intial white space
- if (cur_input.loc_field < last)
+ if (loc < last)
return true;
sprintf(log_line, "%s\n", "Please type the name of your input file.");
if (str_ptr == current_max_strings)
{
overflow("number of strings", current_max_strings - init_str_ptr); /* 97/Mar/9 */
- return 0; // abort_flag set
+ return 0;
}
#else
if (str_ptr == max_strings)
{
overflow("number of strings", max_strings - init_str_ptr);
- return 0; // abort_flag set
+ return 0;
}
#endif
+
incr(str_ptr);
str_start[str_ptr] = pool_ptr;
return (str_ptr - 1);
}
/* sec 0044 */
-bool str_eq_buf_ (str_number s, integer k)
+boolean str_eq_buf_ (str_number s, integer k)
{
- register bool Result;
pool_pointer j;
- bool result;
+ boolean result;
j = str_start[s];
if (str_pool[j] != buffer[k])
{
result = false;
- goto lab45;
+ goto not_found;
}
incr(j);
incr(k);
}
+
result = true;
-lab45:
- Result = result;
- return Result;
+
+not_found:
+ return result;
}
/* sec 0045 */
-bool str_eq_str_ (str_number s, str_number t)
+boolean str_eq_str_ (str_number s, str_number t)
{
- register bool Result;
pool_pointer j, k;
- bool result;
+ boolean result;
result = false;
if (length(s) != length(t))
- goto lab45;
+ goto not_found;
j = str_start[s];
k = str_start[t];
while (j < str_start[s + 1])
{
if (str_pool[j] != str_pool[k])
- goto lab45;
+ goto not_found;
incr(j);
incr(k);
}
+
result = true;
-lab45:
- Result = result;
- return Result;
+
+not_found:
+ return result;
}
/* sec 0066 */
void print_two_(integer n)
}
}
-int stringlength (int str_ptr)
-{
- return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2;
-}
-
-char * add_string (char *s, char * str_string)
-{
- int n;
-
- n = strlen(str_string);
- memcpy(s, &str_string, n);
- s += n;
- strcpy(s, "\r\n");
- s += 2;
-
- return s;
-}
-
-int addextrahelp = 1;
-
-// make one long \r\n separated string out of help lines
-// str_pool is packed_ASCII_code *
-
-char * make_up_help_string (int nhelplines)
-{
- char * helpstring, *s;
- int k, nlen = 0;
-
-// get length of help for this specific message
- for (k = nhelplines - 1; k >= 0; k--)
- {
- nlen += strlen(help_line[k]);
- }
-
- nlen += 2; // for blank line separator: "\r\n"
-
- if (addextrahelp)
- {
- nlen += stringlength(265);
- nlen += stringlength(266);
- nlen += stringlength(267);
-
- if (base_ptr > 0)
- nlen += stringlength(268);
-
- if (deletions_allowed)
- nlen += stringlength(269);
-
- nlen += stringlength(270);
- }
-
- helpstring = (char *) malloc(nlen + 1); // +1 = '\0'
- s = helpstring;
-
- for (k = nhelplines-1; k >= 0; k--)
- {
- s = add_string(s, help_line[k]);
- }
-
- if (addextrahelp)
- {
- strcpy(s, "\r\n");
- s += 2;
- s = add_string(s, "Type <return> to proceed, S to scroll future error messages,");
- s = add_string(s, "R to run without stopping, Q to run quietly,");
- s = add_string(s, "I to insert something, ");
-
- if (base_ptr > 0)
- s = add_string(s, "E to edit your file, ");
-
- if (deletions_allowed)
- s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,");
-
- s = add_string(s, "H for help, X to quit.");
- }
-
- return helpstring;
-}
-
-char * make_up_query_string (int promptstr)
-{
- char *querystr;
- int nstart, nnext, n;
- char *s;
-
- nstart = str_start[ promptstr];
- nnext = str_start[ promptstr + 1];
- n = nnext - nstart;
- querystr = (char *) malloc(n + 1);
- s = querystr;
- memcpy(s, &str_pool[nstart], n);
- s += n;
- *s = '\0';
-
- return querystr;
-}
-
-// abort_flag set if input_line / ConsoleInput returns non-zero
-// should set interrupt instead ???
-// called from tex0.c, tex2.c, tex3.c
/* sec 0071 */
-// void term_input(void)
-void term_input (char * term_str, int term_help_lines)
+void term_input(void)
{
integer k;
int flag;
- char * helpstring = NULL;
-#ifdef _WINDOWS
- char * querystring = NULL;
-#endif
-// if (nhelplines != 0) {
-// helpstring = make_up_help_string (nhelplines);
-// printf(helpstring);
-// free(helpstring);
-// }
- show_line("\n", 0); // force it to show what may be buffered up ???
- helpstring = NULL;
-
-#ifdef _WINDOWS
- if (term_str != NULL)
- querystring = term_str;
-
- if (term_help_lines != NULL)
- helpstring = make_up_help_string(term_help_lines);
-
- if (helpstring == NULL && querystring != NULL)
- {
- if (strcmp(querystring, ": ") == 0)
- helpstring = xstrdup("Please type another file name (or ^z to exit):");
- else if (strcmp(querystring, "=>") == 0) // from firm_up_the_line
- helpstring = xstrdup("Please type <enter> to accept this line\r\nor type a replacement line");
- else if (strcmp(querystring, "insert>") == 0) // from error() after "I"
- helpstring = xstrdup("Please type something to insert here");
- else if (strcmp(querystring, "") == 0) // from read_toks
- helpstring = xstrdup("Please type a control sequence");
- else if (strcmp(querystring, "= ") == 0) // from read_toks
- helpstring = xstrdup("Please type a token");
- else if (strcmp(querystring, "*") == 0) // get_next
- helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)");
- }
-
- flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]); // ???
-// flag == 0 means trouble --- EOF on terminal
- if (querystring != NULL)
- free(querystring);
-
- if (helpstring != NULL)
- free(helpstring);
-
- helpstring = querystring = NULL;
+
+ if (!knuth_flag)
+ show_line("\n", 0);
- last = first + strlen((char *) &buffer[first]); /* -1 ? */
-// flag = (last > first);
-// may need to be more elaborate see input_line in texmf.c ???
-// sprintf(log_line, "first %d last %d flag %d - %s",
-// first, last, flag, (char *) &buffer[first]);
-// winerror(log_line);
-#else
- fflush(stdout);
+ update_terminal();
flag = input_ln(stdin, true);
-#endif
+
if (!flag)
{
fatal_error("End of file on the terminal!");
- return; // abort_flag set
+ return;
}
+
term_offset = 0;
-#ifdef _WINDOWS
-// echo what was typed into Console buffer also
- if (last != first)
- for (k = first; k <= last - 1; k++)
- print(buffer[k]);
- print_ln();
-#else
decr(selector); // shut off echo
if (last != first)
print_ln();
incr(selector); // reset selector again
-#endif
}
/* sec 0091 */
void int_error_ (integer n)
{
- print_string(" (");
+ prints(" (");
print_int(n);
print_char(')');
error();
{
if (delta > 65536L)
s = s - 17232; /* 2^15 - 50000 - rounding */
+
print_char('0' + (s / 65536L));
s = 10 * (s % 65536L);
delta = delta * 10;
scaled x_over_n_(scaled x, integer n)
{
register scaled Result;
- bool negative;
+ boolean negative;
negative = false;
scaled xn_over_d_(scaled x, integer n, integer d)
{
register scaled Result;
- bool positive;
+ boolean positive;
nonnegative_integer t, u, v;
if (x >= 0)
if (info(p) < 0)
print_esc("BAD.");
- else
- switch (m)
- {
- case left_brace:
- case right_brace:
- case math_shift:
- case tab_mark:
- case sup_mark:
- case sub_mark:
- case spacer:
- case letter:
- case other_char:
- print(c);
- break;
-
- case mac_param:
- print(c);
- print(c);
- break;
-
- case out_param:
- print(match_chr);
-
- if (c <= 9)
- print_char(c + '0');
- else
- {
- print_char('!');
- return;
- }
- break;
-
- case match:
- match_chr = (ASCII_code) c;
- print(c);
- incr(n);
- print_char(n);
-
- if (n > '9')
- return;
- break;
-
- case end_match:
- print_string("->");
- break;
-
- default:
- print_esc("BAD.");
- break;
- }
+ else switch (m)
+ {
+ case left_brace:
+ case right_brace:
+ case math_shift:
+ case tab_mark:
+ case sup_mark:
+ case sub_mark:
+ case spacer:
+ case letter:
+ case other_char:
+ print(c);
+ break;
+
+ case mac_param:
+ print(c);
+ print(c);
+ break;
+
+ case out_param:
+ print(match_chr);
+
+ if (c <= 9)
+ print_char(c + '0');
+ else
+ {
+ print_char('!');
+ return;
+ }
+ break;
+
+ case match:
+ match_chr = (ASCII_code) c;
+ print(c);
+ incr(n);
+ print_char(n);
+
+ if (n > '9')
+ return;
+ break;
+
+ case end_match:
+ prints("->");
+ break;
+
+ default:
+ print_esc("BAD.");
+ break;
+ }
}
p = link(p);
}
switch (scanner_status)
{
case defining:
- print_string("definition");
+ prints("definition");
p = def_ref;
break;
case matching:
- print_string("argument");
+ prints("argument");
p = temp_head;
break;
case aligning:
- print_string("preamble");
+ prints("preamble");
p = hold_head;
break;
case absorbing:
- print_string("text");
+ prints("text");
p = def_ref;
break;
}
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
halfword get_avail (void)
{
- halfword p;
+ pointer p;
p = avail;
{
runaway();
overflow("main memory size", mem_max + 1 - mem_min);
- return 0; // abort_flag set
+ return 0;
}
incr(mem_end); /* then grab from new area */
return p;
}
/* sec 0123 */
-void flush_list_(halfword p) /* paragraph 123 */
+void flush_list_(pointer p)
{
- halfword q, r;
+ pointer q, r;
if (p != 0) /* null !!! */
{
}
}
/* sec 0125 */
-halfword get_node_(integer s)
+pointer get_node_(integer s)
{
- register halfword Result;
- halfword p;
- halfword q;
+ pointer p;
+ pointer q;
integer r;
integer t;
-lab20:
+restart:
p = rover;
{
q = p + node_size(p);
- while ((mem[q].hh.rh == empty_flag))
+ while (is_empty(q))
{
t = rlink(q);
{
node_size(p) = r - p;
rover = p;
- goto lab40;
+ goto found;
}
if (r == p)
t = llink(p);
llink(rover) = t;
rlink(t) = rover;
- goto lab40;
+ goto found;
}
node_size(p) = q - p;
if (s == 1073741824L) /* 2^30 - special case - merge adjacent */
{
- Result = max_halfword;
-
if (trace_flag)
- show_line("Merged adjacent multi-word nodes\n", 0);
+ puts("Merged adjacent multi-word nodes\n");
- return Result;
+ return max_halfword;
}
/* maybe try downward epxansion first instead ? */
link(lo_mem_max) = 0;
info(lo_mem_max) = 0;
rover = q;
- goto lab20;
+ goto restart;
}
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
{
if (trace_flag)
{
- sprintf(log_line, "mem_min %d, mem_start %d, block_size %d\n", mem_min, mem_start, block_size);
+ sprintf(log_line, "mem_min %lld, mem_start %ld, block_size %d\n", mem_min, mem_start, block_size);
show_line(log_line, 0);
}
overflow("main memory size", mem_max + 1 - mem_min); /* darn: allocation failed ! */
- return 0; // abort_flag set
+ return 0;
}
-/* avoid function call in following ? */
- add_variable_space (block_size); /* now to be found in itex.c */
- goto lab20; /* go try get_node again */
-lab40:
+ add_variable_space (block_size);
+ goto restart; /* go try get_node again */
+
+found:
link(r) = 0;
#ifdef STAT
var_used = var_used + s;
#endif /* STAT */
- Result = r;
- return Result;
+ return r;
}
/* sec 0130 */
void free_node_(halfword p, halfword s)
{
- halfword q;
+ pointer q;
node_size(p) = s;
link(p) = empty_flag;
rlink(p) = rover;
llink(rover) = p;
rlink(q) = p;
+
#ifdef STAT
var_used = var_used - s;
#endif /* STAT */
}
/* sec 0136 */
-halfword new_null_box (void)
+pointer new_null_box (void)
{
- halfword p;
+ pointer p;
p = get_node(box_node_size);
type(p) = hlist_node;
return p;
}
/* sec 0139 */
-halfword new_rule (void)
+pointer new_rule (void)
{
- halfword p;
+ pointer p;
p = get_node(rule_node_size);
type(p) = rule_node;
return p;
}
/* sec 0144 */
-halfword new_ligature_(quarterword f, quarterword c, halfword q)
+pointer new_ligature_(quarterword f, quarterword c, pointer q)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
type(p) = ligature_node;
return p;
}
/* sec 0144 */
-halfword new_lig_item_(quarterword c)
+pointer new_lig_item_(quarterword c)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
character(p) = c;
return p;
}
/* sec 0145 */
-halfword new_disc (void)
+pointer new_disc (void)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
type(p) = disc_node;
return p;
}
/* sec 0147 */
-halfword new_math_(scaled w, small_number s)
+pointer new_math_(scaled w, small_number s)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
type(p) = math_node;
return p;
}
/* sec 0151 */
-halfword new_spec_(halfword p)
+pointer new_spec_(pointer p)
{
- halfword q;
+ pointer q;
q = get_node(glue_spec_size);
mem[q] = mem[p];
return q;
}
/* se 0152 */
-halfword new_param_glue_(small_number n)
+pointer new_param_glue_(small_number n)
{
- halfword p;
- halfword q;
+ pointer p;
+ pointer q;
p = get_node(small_node_size);
type(p) = glue_node;
return p;
}
/* sec 0153 */
-halfword new_glue_(halfword q)
+pointer new_glue_(pointer q)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
type(p) = glue_node;
return p;
}
/* sec 0154 */
-halfword new_skip_param_(small_number n)
+pointer new_skip_param_(small_number n)
{
- halfword p;
+ pointer p;
temp_ptr = new_spec(glue_par(n));
p = new_glue(temp_ptr);
return p;
}
/* sec 0155 */
-halfword new_kern_(scaled w)
+pointer new_kern(scaled w)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
type(p) = kern_node;
return p;
}
/* sec 0158 */
-halfword new_penalty_(integer m)
+pointer new_penalty(integer m)
{
- halfword p;
+ pointer p;
p = get_node(small_node_size);
type(p) = penalty_node;
#ifdef DEBUG
/* sec 0167 */
-void check_mem_(bool printlocs)
+void check_mem(boolean printlocs)
{
- halfword p, q;
- bool clobbered;
+ pointer p, q;
+ boolean clobbered;
for (p = mem_min; p <= lo_mem_max; p++) freearr[p] = false;
for (p = hi_mem_min; p <= mem_end; p++) freearr[p] = false;
{
print_nl("AVAIL list clobbered at ");
print_int(q);
- goto lab31;
+ goto done1;
}
freearr[p] = true;
q = p;
p = link(q);
}
-lab31:;
+done1:;
p = rover;
q = 0;
clobbered = false;
{
print_nl("Double-AVAIL list clobbered at ");
print_int(q);
- goto lab32;
+ goto done2;
}
for (q = p; q <= p + node_size(p) - 1; q++)
{
print_nl("Doubly free location at ");
print_int(q);
- goto lab32;
+ goto done2;
}
freearr[q]= true;
}
q = p;
p = rlink(p);
} while (!(p == rover));
-lab32:;
+done2:;
p = mem_min;
while (p <= lo_mem_max) {
if (is_empty(p))
{
integer n;
- while (p != 0) { /* want p != null here bkph 93/Dec/15 !!! NOTE: still not fixed in 3.14159 ! */
+ while (p != 0) /* want p != null here ! */
+ {
if (is_char_node(p))
{
if (p <= mem_end)
print_esc("");
print(font_id_text(font(p)));
}
+
print_char(' ');
font_in_short_display = font(p);
}
case mark_node:
case adjust_node:
case unset_node:
- print_string("[]");
+ prints("[]");
break;
case rule_node:
print_char('|');
short_display(post_break(p));
n = replace_count(p);
- while (n > 0) {
- if (link(p) != 0) /* if link(p)<>null then */
+ while (n > 0)
+ {
+ if (link(p) != 0)
p = link(p);
+
decr(n);
}
break;
}
}
/* sec 0176 */
-void print_font_and_char_ (integer p)
+void print_font_and_char (integer p)
{
if (p > mem_end)
print_esc("CLOBBERED.");
{
print_char('{');
- if ((p < hi_mem_min)||(p > mem_end))
+ if ((p < hi_mem_min) || (p > mem_end))
print_esc("CLOBBERED.");
else
show_token_list(link(p), 0, max_print_line - 10);
print_char('}');
}
/* sec 0176 */
-void print_rule_dimen_ (scaled d)
+void print_rule_dimen(scaled d)
{
- if ((d == -1073741824L)) /* - 2^30 */
+ if (is_running(d))
print_char('*');
else
print_scaled(d);
print_scaled(d);
if ((order < normal) || (order > filll))
- print_string("foul");
+ prints("foul");
else if (order > 0)
{
- print_string("fil");
+ prints("fil");
- while (order > 1) {
+ while (order > 1)
+ {
print_char('l');
decr(order);
}
- } else if (*s != '\0')
- print_string(s);
+ }
+ else if (*s != '\0')
+ prints(s);
}
/* sec 0178 */
void print_spec_(integer p, char * s)
{
- if ((p < mem_min)||(p >= lo_mem_max))
+ if ((p < mem_min) || (p >= lo_mem_max))
print_char('*');
else
{
print_scaled(width(p));
if (*s != '\0')
- print_string(s);
+ prints(s);
if (stretch(p) != 0)
{
- print_string("plus");
+ prints("plus");
print_glue(stretch(p), stretch_order(p), s);
}
if (shrink(p) != 0)
{
- print_string("minus");
+ prints("minus");
print_glue(shrink(p), shrink_order(p), s);
}
}
if ((pool_ptr - str_start[str_ptr]) >= depth_threshold)
{
if (math_type(p) != 0)
- print_string(" []");
+ prints(" []");
}
else
{
{
print_ln();
print_current_string();
- print_string("{}");
+ prints("{}");
}
else
show_info();
print_esc("scriptscriptstyle");
break;
default:
- print_string("Unknown style!");
+ prints("Unknown style!");
break;
}
}
break;
default:
- print_string("[unknown glue parameter!]");
+ prints("[unknown glue parameter!]");
break;
}
}
if (cur_length > depth_threshold)
{
if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
- print_string(" []");
+ prints(" []");
return;
}
if (p > mem_end)
{
- print_string("Bad link, display aborted.");
+ prints("Bad link, display aborted.");
return;
}
if (n > breadth_max)
{
- print_string("etc.");
+ prints("etc.");
return;
}
- if ((p >= hi_mem_min))
+ if (is_char_node(p))
print_font_and_char(p);
else switch (type(p))
{
print_esc("v");
else print_esc("unset");
- print_string("box(");
+ prints("box(");
print_scaled(height(p));
print_char('+');
print_scaled(depth(p));
- print_string(")x");
+ prints(")x");
print_scaled(width(p));
if (type(p) == unset_node)
{
if (span_count(p) != 0)
{
- print_string(" (");
+ prints(" (");
print_int(span_count(p) + 1);
- print_string(" columns)");
+ prints(" columns)");
}
if (glue_stretch(p) != 0)
{
- print_string(", stretch ");
+ prints(", stretch ");
print_glue(glue_stretch(p), glue_order(p), "");
}
if (glue_shrink(p) != 0)
{
- print_string(", shrink ");
+ prints(", shrink ");
print_glue(glue_shrink(p), glue_sign(p), "");
}
}
if ((g != 0.0) && (glue_sign(p) != 0))
{
- print_string(", glue set ");
+ prints(", glue set ");
if (glue_sign(p) == shrinking)
- print_string("- ");
+ prints("- ");
if (fabs(g)> 20000.0)
{
if (g > 0.0)
print_char('>');
else
- print_string("< -");
+ prints("< -");
- print_glue(20000 * 65536L, glue_order(p), "");
+ print_glue(20000 * unity, glue_order(p), "");
}
else
- print_glue(round(65536L * g), glue_order(p), "");
+ print_glue(round(unity * g), glue_order(p), "");
}
if (shift_amount(p) != 0)
{
- print_string(", shifted ");
+ prints(", shifted ");
print_scaled(shift_amount(p));
}
}
- {
- {
- str_pool[pool_ptr] = 46;
- incr(pool_ptr);
- }
- show_node_list(mem[p + 5].hh.rh);
- decr(pool_ptr);
- }
+ node_list_display(list_ptr(p));
}
break;
print_rule_dimen(height(p));
print_char('+');
print_rule_dimen(depth(p));
- print_string(")x");
+ prints(")x");
print_rule_dimen(width(p));
}
break;
{
print_esc("insert");
print_int(subtype(p));
- print_string(", natural size ");
+ prints(", natural size ");
print_scaled(height(p));
- print_string("; split(");
+ prints("; split(");
print_spec(split_top_ptr(p), "");
print_char(',');
print_scaled(depth(p));
- print_string("); float cost ");
+ prints("); float cost ");
print_int(float_cost(p));
- {
- {
- str_pool[pool_ptr] = 46;
- incr(pool_ptr);
- }
- show_node_list(mem[p + 4].hh.lh);
- decr(pool_ptr);
- }
+ node_list_display(ins_ptr(p));
}
break;
- case 8:
+
+ case whatsit_node:
switch (subtype(p))
{
case open_node:
{
- print_write_whatsit(1279, p); /* debug # (-1 to exit): */
+ print_write_whatsit("openout", p);
print_char('=');
print_file_name(open_name(p), open_area(p), open_ext(p));
}
case write_node:
{
- print_write_whatsit(591, p); /* write */
+ print_write_whatsit("write", p);
print_mark(write_tokens(p));
}
break;
case close_node:
- print_write_whatsit(1280, p); /* closeout */
+ print_write_whatsit("closeout", p);
break;
case special_node:
{
print_esc("setlanguage");
print_int(what_lang(p));
- print_string(" (hyphenmin ");
+ prints(" (hyphenmin ");
print_int(what_lhm(p));
print_char(',');
print_int(what_rhm(p));
break;
default:
- print_string("whatsit?");
+ prints("whatsit?");
break;
}
break;
else if (subtype(p) == x_leaders)
print_char('x');
- print_string("leaders ");
-
+ prints("leaders ");
print_spec(glue_ptr(p), "");
- {
- {
- str_pool[pool_ptr] = 46;
- incr(pool_ptr);
- }
- show_node_list(mem[p + 1].hh.rh);
- decr(pool_ptr);
- }
+ node_list_display(leader_ptr(p));
}
else
{
print_scaled(width(p));
if (subtype(p) == acc_kern)
- print_string(" (for accent)");
+ prints(" (for accent)");
}
else
{
print_esc("mkern");
print_scaled(width(p));
- print_string("mu");
+ prints("mu");
}
break;
print_esc("math");
if (subtype(p) == before)
- print_string("on");
+ prints("on");
else
- print_string("off");
+ prints("off");
if (width(p) != 0)
{
- print_string(", surrounded ");
+ prints(", surrounded ");
print_scaled(width(p));
}
}
case ligature_node:
{
print_font_and_char(lig_char(p));
- print_string("(ligature ");
+ prints("(ligature ");
if (subtype(p) > 1)
print_char('|');
if (replace_count(p) > 0)
{
- print_string(" replacing ");
+ prints(" replacing ");
print_int(replace_count(p));
}
- {
- {
- str_pool[pool_ptr] = 46;
- incr(pool_ptr);
- }
- show_node_list(mem[p + 1].hh.lh);
- decr(pool_ptr);
- }
- {
- str_pool[pool_ptr]= 124;
- incr(pool_ptr);
- }
- show_node_list(mem[p + 1].hh.rh);
+ node_list_display(pre_break(p));
+ append_char('|');
+ show_node_list(post_break(p));
decr(pool_ptr);
}
break;
case adjust_node:
{
print_esc("vadjust");
- {
- {
- str_pool[pool_ptr] = 46;
- incr(pool_ptr);
- }
- show_node_list(mem[p + 1].cint);
- decr(pool_ptr);
- }
+ node_list_display(adjust_ptr(p));
}
break;
print_esc("fraction, thickness ");
if (thickness(p) == 1073741824L) /* 2^30 */
- print_string("= default");
+ prints("= default");
else
print_scaled(thickness(p));
if ((small_fam(left_delimiter(p)) != 0) || (small_char(left_delimiter(p)) != 0) ||
(large_fam(left_delimiter(p)) != 0) || (large_char(left_delimiter(p)) != 0))
{
- print_string(", left-delimiter ");
+ prints(", left-delimiter ");
print_delimiter(left_delimiter(p));
}
if ((small_fam(right_delimiter(p)) != 0) || (small_char(right_delimiter(p)) != 0) ||
- (large_fam(right_delimiter(p)) != 0)||(large_char(right_delimiter(p)) != 0))
+ (large_fam(right_delimiter(p)) != 0) || (large_char(right_delimiter(p)) != 0))
{
- print_string(", right-delimiter ");
+ prints(", right-delimiter ");
print_delimiter(right_delimiter(p));
}
break;
default:
- print_string("Unknown node type!");
+ prints("Unknown node type!");
break;
}
p = link(p);