" -a write AUX file in specified directory (default current directory)");
strcat(s, "\n");
show_line(log_line, 1);
+
#ifndef _WINDOWS
uexit(1); // has this been setup yet ???
#endif
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
#define MAXCHRS 256
-#define NOTDEF 127
+#define NOTDEF 127
void read_xchr_sub (FILE * xchr_input)
{
memset (xchr, NOTDEF, MAXCHRS); /* mark unused */
#else
for (k = 0; k < MAXCHRS; k++)
- xchr[k]= -1; /* mark unused */
+ xchr[k] = -1; /* mark unused */
#endif
#ifdef USEMEMSET
memset (xord, NOTDEF, MAXCHRS); /* mark unused */
#else
for (k = 0; k < MAXCHRS; k++)
- xord[k]= -1; /* mark unused */
+ xord[k] = -1; /* mark unused */
#endif
#ifdef ALLOCATEBUFFER
int k, count=0;
memory_word *eqtb = zeqtb;
-/* for (k = 10280 + hash_extra; k < 10280 + eqtb_extra; k++) { */
for (k = hash_size + 780 + hash_extra; k < hash_size + 780 + eqtb_extra; k++)
{
if (eqtb[k].cint != 0)
#ifndef _WINDOWS
#ifdef HEAPWALK
-unsigned int heapthreshold=0; /* smallest size block interested in ... */
+unsigned int heapthreshold = 0; /* smallest size block interested in ... */
unsigned int heap_dump (FILE *output, int verbose)
{
unsigned heaptotal = 0; /* no longer used */
heaptotal = heap_dump(stdout, 0); /* 94/Apr/3 */
#endif
+
sprintf(log_line, "Max allocated %d --- max address %d\n", total_allocated, max_address);
// if (output != NULL) fputs(log_line, output); // log file
// else if (flag == 0) show_line(log_line, 0); // informative
if (trace_flag)
trace_memory("hyphen trie", n);
- trie_trl = (halfword *) malloc (roundup(nl));
- trie_tro = (halfword *) malloc (roundup(no));
+ trie_trl = (halfword *) malloc (roundup(nl));
+ trie_tro = (halfword *) malloc (roundup(no));
trie_trc = (quarterword *) malloc (roundup(nc));
if (trie_trl == NULL || trie_tro == NULL || trie_trc == NULL)
sprintf(log_line, "Addresses trie_trl %d trie_tro %d trie_trc %d\n", trie_trl, trie_tro, trie_trc);
show_line(log_line, 0);
}
+
update_statistics ((int) trie_trl, nl, 0);
update_statistics ((int) trie_tro, no, 0);
update_statistics ((int) trie_trc, nc, 0);
{
sprintf(log_line, "ERROR: non-prime hyphen exception number (%d)\n", hyphen_prime);
show_line(log_line, 1);
-// exit (1);
return -1;
}
/* need not/cannot preserve old contents when hyphen prime is changed */
#else
for (k = 0; k <= hyphen_prime; k++) hyph_list[k]= 0;
#endif
-
hyph_count = 0; /* or use reset_hyphen() in itex.c */
if (current_prime != 0)
}
#endif
-int current_mem_size=0; /* current total words in main mem allocated -1 */
+int current_mem_size = 0; /* current total words in main mem allocated -1 */
/* this gets called from itex.c when it figures out what mem_top is */
/* or gets called from here when in ini_TeX mode */ /* and nowhere else */
if (is_initex)
{
show_line("ERROR: Cannot extent main memory in iniTeX\n", 1);
+
if (! knuth_flag)
show_line("Please use `-m=...' on command line\n", 0);
// abort_flag++; // ???
int current_font_mem_size=0;
/* fmemoryword can be either halfword or memory_word */
-fmemoryword *realloc_font_info (int size)
+fmemoryword * realloc_font_info (int size)
{
fmemoryword *newfontinfo = NULL;
int k, minsize;
#endif
#ifdef ALLOCATESTRING
-int current_pool_size=0;
+int current_pool_size = 0;
-packed_ASCII_code *realloc_str_pool (int size)
+packed_ASCII_code * realloc_str_pool (int size)
{
int k, minsize;
int newsize=0;
}
n = (inputsize + 1) * sizeof(memory_word);
- if (trace_flag) trace_memory("input_stack", n);
+
+ if (trace_flag)
+ trace_memory("input_stack", n);
+
/* input_stack = (memory_word *) malloc ((inputsize + 1) * sizeof (memory_word)); */
input_stack = (memory_word *) malloc (roundup(n));
- if (input_stack == NULL) {
+
+ if (input_stack == NULL)
+ {
memory_error("input_stack", n);
// exit (1); /* serious error */
return -1; /* serious error */
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-// print newline
/* sec 0058 */
void print_ln (void)
{
(void) putc ('\n', log_file);
file_offset = 0;
break;
+
case log_only:
(void) putc ('\n', log_file);
file_offset = 0;
break;
+
case term_only:
show_char('\n');
term_offset = 0;
break;
+
case no_print:
case pseudo:
case new_string:
break;
+
default:
(void) putc ('\n', write_file[selector]);
break;
}
}
-/* sec 0059 */
+/* sec 0058 */
void print_char_ (ASCII_code s)
{
if (s == new_line_char)
+ {
if (selector < pseudo)
{
print_ln();
return;
}
+ }
switch (selector)
{
}
break;
+
case log_only:
(void) putc(Xchr(s), log_file);
incr(file_offset);
+
if (file_offset == max_print_line)
print_ln();
+
break;
+
case term_only:
(void) show_char(Xchr(s));
incr(term_offset);
+
if (term_offset == max_print_line)
print_ln();
+
break;
+
case no_print:
break;
+
case pseudo:
if (tally < trick_count)
trick_buf[tally % error_line] = s;
+
break;
+
case new_string:
#ifdef ALLOCATESTRING
if (pool_ptr + 1 > current_pool_size)
}
#endif
break;
+
default:
(void) putc(Xchr(s), write_file[selector]);
break;
}
+
incr(tally);
}
/* sec 0059 */
-/* This could be made more efficient using fputs ? ... bkph */
void print_ (integer s)
{
pool_pointer j;
integer nl;
+
if (s >= str_ptr)
s = 259; /* ??? */
- else if (s < 256)
- if (s < 0)
- s = 259; /* ??? */
- else {
- if (selector > pseudo)
+ else
+ {
+ if (s < 256)
+ {
+ if (s < 0)
+ s = 259; /* ??? */
+ else
{
- print_char(s);
- return;
- }
-
- if ((s == new_line_char))
- if (selector < 20)
+ if (selector > pseudo)
{
- print_ln();
+ print_char(s);
return;
}
- nl = new_line_char;
- new_line_char = -1;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+ 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)
- {
- if (show_in_dos && s > 127)
- {
- if (wintodos[s-128] > 0)
- print_char (wintodos[s - 128]);
- else
+ if (!show_in_hex && s < 256 && s >= 32)
{
- j = str_start[s];
+ if (show_in_dos && s > 127)
+ {
+ 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);
+ }
+ }
+ }
+ else
+ {
+ 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);
}
}
- }
- else
- 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);
- }
+ new_line_char = nl; /* restore eol */
+ return;
}
- new_line_char = nl; /* restore eol */
- return;
}
+ }
/* we get here with s > 256 - i.e. not a single character */
- j = str_start[s];
+ j = str_start[s];
+
while (j < str_start[s + 1])
{
print_char(str_pool[j]);
pool_pointer j;
if ((s >= str_ptr) || (s < 256))
+ {
print(s);
+ }
else
{
j = str_start[s];
+
while (j < str_start[s + 1])
{
-/* if (str_pool[j]>= 128) print(str_pool[j] - 128); */ // debugging only
-/* if (str_pool[j]== 0) print(36); */ // debugging only
print(str_pool[j]);
incr(j);
}
while (k > 0)
{
decr(k);
+
if (dig[k]< 10)
print_char('0' + dig[k]);
else
if (n < 0)
{
print_char('-');
+
if (n > -100000000L)
n = - (integer) n;
else
}
}
}
- do {
- dig[k] = (char) (n % 10);
- n = n / 10;
- incr(k);
- } while (!(n == 0));
+
+ do
+ {
+ dig[k] = (char) (n % 10);
+ n = n / 10;
+ incr(k);
+ }
+ while (!(n == 0));
+
print_the_digs(k);
}
/* sec 0262 */
}
else
{
- print_esc("");print(p - 257);
-/* if cat_code(p - single_base) = letter then ... p.262 */
- if (eqtb[(hash_size + 1883) + p - 257].hh.v.RH == letter)
+ print_esc(""); print(p - 257);
+
+ if (cat_code(p - single_base) == letter)
print_char(' ');
}
else if (p < 1)
print_esc("IMPOSSIBLE.");
else print(p - 1);
- else if (p >= (hash_size + 781)) /* undefined_control_sequence */
+ else if (p >= undefined_control_sequence)
print_esc("IMPOSSIBLE.");
- else if ((hash[p].v.RH >= str_ptr))
+ else if ((text(p) >= str_ptr))
print_esc("NONEXISTENT.");
else
{
/* sec 0263 */
void sprint_cs_(halfword p)
{
- if (p < hash_base) /* if p < hash_base then ... p.263 */
- if (p < single_base) /* if p < single_base then ... p.263 */
- print(p - active_base); /* print (p - active_base); */
- else if (p < null_cs) /* else if p < null_cs then ... */
+ if (p < hash_base)
+ if (p < single_base)
+ print(p - active_base);
+ else if (p < null_cs)
{
print_esc(""); print(p - single_base);
}
/* ! I can't find file ` c:/foo/ accents .tex '. */
void print_file_name_(integer n, integer a, integer e)
{
-/* sprintf(log_line, "\na %d n %d e %d\n", a, n, e); */
-/* show_line(log_line, 0); */
-// print_char('!'); // debugging only
slow_print(a);
-// print_char('!'); // debugging only
slow_print(n);
-// print_char('!'); // debugging only
slow_print(e);
-// print_char('!'); // debugging only
}
/* sec 0699 */
void print_size_ (integer s)
void print_write_whatsit_(str_number s, halfword p)
{
print_esc(""); print(s);
- if (mem[p + 1].hh.v.LH < 16)
- print_int(mem[p + 1].hh.v.LH);
- else if (mem[p + 1].hh.v.LH == 16)
+ if (write_stream(p) < 16)
+ print_int(write_stream(p));
+ else if (write_stream(p) == 16)
print_char('*');
else print_char('-');
}
goto lab22; /* loop again */
}
break;
+
#ifdef DEBUG
case 'D':
{
jump_out();
}
break;
+
case 'H':
{
if (use_err_help)
goto lab22; /* loop again */
}
break;
+
case 'I':
{
begin_file_reading();
return;
}
break;
+
case 'Q':
case 'R':
case 'S':
return;
}
break;
+
case 'X':
{
interaction = 2;
jump_out();
}
break;
+
default:
break;
} /* end of switch analysing response character */
help2("One of your faux pas seems to have wounded me deeply...",
"in fact, I'm barely conscious. Please fix it and try again.");
}
+
succumb();
}
/* sec 0037 */
if (last > first)
{
cur_input.loc_field = first;
+
while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
incr(cur_input.loc_field); // step over initial white space
+
if (cur_input.loc_field < last)
{
Result = true;
}
// failed to find input file name
- while (true) {
+ 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 ? */
}
cur_input.loc_field = first;
+
while ((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' '))
incr(cur_input.loc_field); // step over intial white space
+
if (cur_input.loc_field < last)
{
Result = true;
// Make string from str_start[str_ptr] to pool_ptr
str_number make_string (void)
{
- register str_number Result;
-
#ifdef ALLOCATESTRING
if (str_ptr == current_max_strings)
str_start = realloc_str_start(increment_max_strings);
#endif
incr(str_ptr);
str_start[str_ptr] = pool_ptr;
- Result = str_ptr - 1;
- return Result;
+ return (str_ptr - 1);
}
/* sec 0044 */
bool str_eq_buf_ (str_number s, integer k)
register bool Result;
pool_pointer j;
bool result;
+
j = str_start[s];
+
while (j < str_start[s + 1])
{
- if (str_pool[j]!= buffer[k])
+ if (str_pool[j] != buffer[k])
{
result = false;
goto lab45;
register bool Result;
pool_pointer j, k;
bool result;
+
result = false;
+
if (length(s) != length(t))
goto lab45;
+
j = str_start[s];
k = str_start[t];
+
while (j < str_start[s + 1])
{
if (str_pool[j] != str_pool[k])
goto lab45;
+
incr(j);
incr(k);
}
void print_hex_(integer n)
{
char k;
+
k = 0;
print_char('"');
+
do {
dig[k] = (unsigned char) (n % 16);
n = n / 16;
incr(k);
} while (!(n == 0));
+
print_the_digs(k);
}
/* sec 0069 */
{
pool_pointer j, k;
nonnegative_integer u, v;
+
j = str_start[260]; /* m2d5c2l5x2v5i */
v = 1000;
- while (true) {
- while (n >= v) {
+
+ while (true)
+ {
+ while (n >= v)
+ {
print_char(str_pool[j]);
n = n - v;
}
+
if (n <= 0)
return;
+
k = j + 2;
u = v / (str_pool[k - 1] - '0');
+
if (str_pool[k - 1] == 50)
{
k = k + 2;
u = u / (str_pool[k - 1] - '0');
}
+
if (n + u >= v)
{
print_char(str_pool[k]);
void print_current_string (void)
{
pool_pointer j;
+
j = str_start[str_ptr];
+
while (j < pool_ptr)
{
print_char(str_pool[j]);
char * add_string (char *s, char * str_string)
{
int n;
+
n = strlen(str_string);
memcpy(s, &str_string, n);
s += n;
return s;
}
-int addextrahelp=1;
+int addextrahelp = 1;
// make one long \r\n separated string out of help lines
// str_pool is packed_ASCII_code *
if (OK_to_interrupt)
{
interaction = error_stop_mode;
+
if ((selector == log_only) || (selector == no_print))
incr(selector);
+
print_err("Interruption");
help3("You rang?",
"Try to insert some instructions for me (e.g.,`I\\showlists'),",
/* sec 0100 */
integer half_(integer x)
{
- register integer Result;
if (odd(x))
- Result =(x + 1) / 2;
+ return ((x + 1) / 2);
else
- Result = x / 2;
- return Result;
+ return (x / 2);
}
/* sec 0102 */
scaled round_decimals_(small_number k)
{
- register scaled Result;
integer a;
+
a = 0;
+
while (k > 0) {
decr(k);
a = (a + dig[k] * 131072L) / 10; /* 2^17 */
}
- Result =(a + 1) / 2;
- return Result;
+
+ return ((a + 1) / 2);
}
/* sec 0103 */
/* This has some minor speedup changes - no real advantage probably ... */
void print_scaled_(scaled s)
{
scaled delta;
+
if (s < 0)
{
print_char('-');
print_char('.');
s = 10 * (s % 65536L) + 5;
delta = 10;
+
do {
if (delta > 65536L)
s = s - 17232; /* 2^15 - 50000 - rounding */
/* sec 0105 */
scaled mult_and_add_(integer n, scaled x, scaled y, scaled maxanswer)
{
- register scaled Result;
if (n < 0)
{
x = - (integer) x;
}
if (n == 0)
- Result = y;
+ return y;
else if (((x <= (maxanswer - y) / n) && (- (integer) x <= (maxanswer + y) / n)))
- Result = n * x + y;
- else {
+ return (n * x + y);
+ else
+ {
arith_error = true;
- Result = 0;
+ return 0;
}
-
- return Result;
}
/* sec 0106 */
scaled x_over_n_(scaled x, integer n)
nonnegative_integer t, u, v;
if (x >= 0)
positive = true;
- else {
+ else
+ {
x = - (integer) x;
positive = false;
}
-/* t =(x % 32768L)* n; */
- t =(x & 32767L) * n;
-/* u =(x / 32768L)* n +(t / 32768L); */
- u =(x >> 15) * n + (t >> 15);
-/* v =(u % d)* 32768L +(t % 32768L); */
- v =((u % d) << 15) + (t & 32767L);
+
+ t =(x % 32767L) * n;
+ u =(x / 32768L)* n +(t / 32768L);
+ v =(u % d)* 32768L +(t % 32768L);
+
if (u / d >= 32768L)
arith_error = true;
-/* else u = 32768L *(u / d)+(v / d); */
- else u =((u / d) << 15) + (v / d);
+ else u = 32768L * (u / d) + (v / d);
if (positive)
{
/* sec 0108 */
halfword badness_(scaled t, scaled s)
{
- register halfword Result;
integer r;
+
if (t == 0)
- Result = 0;
+ return 0;
else if (s <= 0)
- Result = 10000;
- else {
+ return 10000;
+ else
+ {
if (t <= 7230584L)
r = (t * 297) / s;
else if (s >= 1663497L)
r = t / (s / 297);
else
r = t;
+
if (r > 1290)
- Result = 10000;
-/* safe to assume that r is positive ? */
-/* else Result =(r * r * r + 131072L)/ 262144L; */
+ return 10000;
else
- Result = (r * r * r + 131072L) >> 18; /* 2^17 */
+ return (r * r * r + 131072L) / 262144L; /* 2^17 */
}
- return Result;
}
#ifdef DEBUG
integer m, c;
ASCII_code match_chr;
ASCII_code n;
- match_chr = 35;
- n = 48;
+
+ match_chr = '#';
+ n = '0';
tally = 0;
-/* while (p<>null) and (tally<l) do l.6239 */
- while ((p != 0) && (tally < l)) {
+
+ while ((p != 0) && (tally < l))
+ {
if (p == q)
{
first_count = tally;
return;
}
- if (info(p) >= 4095)
- print_cs(info(p) - 4095);
- else {
+ if (info(p) >= cs_token_flag)
+ print_cs(info(p) - cs_token_flag);
+ else
+ {
m = info(p) / 256;
c = info(p) % 256;
+
if (info(p) < 0)
print_esc("BAD.");
else
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
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;
void runaway (void)
{
halfword p;
+
if (scanner_status > 1)
{
print_nl("Runaway ");
+
switch (scanner_status)
{
case defining:
print_string("definition");
p = def_ref;
break;
+
case matching:
print_string("argument");
p = temp_head;
break;
+
case aligning:
print_string("preamble");
p = hold_head;
break;
+
case absorbing:
print_string("text");
p = def_ref;
break;
}
+
print_char('?');
print_ln();
show_token_list(link(p), 0, error_line - 10);
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
halfword get_avail (void)
{
- register halfword Result;
halfword p;
+
p = avail;
- if (p != 0) /* while p<>null do */
+
+ if (p != 0)
avail = link(avail);
- else if (mem_end < mem_max) /* mem_end + 1 < mem_max ? NO */
+ else if (mem_end < mem_max)
{
incr(mem_end);
p = mem_end;
{
decr(hi_mem_min);
p = hi_mem_min;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
if (hi_mem_min <= lo_mem_max) /* have we run out in middle ? */
{
- incr(hi_mem_min); /* undo the change */
-/* realloc_main (0, mem_top/2); */ /* extend main memory at hi end */
+ incr(hi_mem_min);
mem = realloc_main (0, mem_top / 2); /* zzzaa = zmem = mem */
+
if (mem == NULL)
return 0;
-/* presumably now mem_end < mem_max - but need test in case allocation fails */
+
if (mem_end >= mem_max)
{
runaway();
- overflow("main memory size", mem_max + 1 - mem_min); /* main memory size */
+ overflow("main memory size", mem_max + 1 - mem_min);
return 0; // abort_flag set
}
incr(mem_end); /* then grab from new area */
p = mem_end; /* 1993/Dec/14 */
}
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
}
+
link(p) = 0; /* link(p) = null !!! */
- ;
+
#ifdef STAT
incr(dyn_used);
#endif /* STAT */
- Result = p;
- return Result;
+
+ return p;
}
/* sec 0123 */
void flush_list_(halfword p) /* paragraph 123 */
{
- halfword q, r;
+ halfword q, r;
+
if (p != 0) /* null !!! */
{
r = p;
+
do {
q = r;
r = link(r);
- ;
#ifdef STAT
decr(dyn_used);
#endif /* STAT */
} while (!(r == 0)); /* r != null */
+
link(q) = avail;
avail = p;
}
integer r;
integer t;
lab20:
+
p = rover;
do {
q = p + mem[p].hh.v.LH;
Result = r;
return Result;
}
-/* sec */
+/* sec 0130 */
void free_node_(halfword p, halfword s)
{
halfword q;
- mem[p].hh.v.LH = s;
+
+ node_size(p) = s;
link(p) = empty_flag;
q = llink(rover);
llink(p) = q;
halfword new_null_box (void)
{
halfword p;
+
p = get_node(box_node_size);
type(p) = hlist_node;
subtype(p) = min_quarterword;
glue_sign(p) = normal;
glue_order(p) = normal;
glue_set(p) = 0.0;
+
return p;
}
/* sec 0139 */
halfword new_rule (void)
{
halfword p;
+
p = get_node(rule_node_size);
type(p) = rule_node;
subtype(p) = 0;
width(p) = null_flag;
depth(p) = null_flag;
height(p) = null_flag;
+
return p;
}
/* sec 0144 */
halfword new_ligature_(quarterword f, quarterword c, halfword q)
{
- halfword p;
+ halfword p;
+
p = get_node(small_node_size);
type(p) = ligature_node;
font(lig_char(p)) = f;
character(lig_char(p)) = c;
lig_ptr(p) = q;
subtype(p) = 0;
+
return p;
}
/* sec 0144 */
halfword new_lig_item_(quarterword c)
{
halfword p;
+
p = get_node(small_node_size);
character(p) = c;
lig_ptr(p) = 0;
+
return p;
}
/* sec 0145 */
halfword new_disc (void)
{
halfword p;
+
p = get_node(small_node_size);
type(p) = disc_node;
replace_count(p) = 0;
pre_break(p) = 0;
post_break(p) = 0;
+
return p;
}
/* sec 0147 */
halfword new_math_(scaled w, small_number s)
{
halfword p;
+
p = get_node(small_node_size);
type(p) = math_node;
subtype(p) = s;
width(p) = w;
+
return p;
}
/* sec 0151 */
halfword new_spec_(halfword p)
{
halfword q;
+
q = get_node(glue_spec_size);
mem[q] = mem[p];
glue_ref_count(q) = 0;
width(q) = width(p);
stretch(q) = stretch(p);
shrink(q) = shrink(p);
+
return q;
}
/* se 0152 */
{
halfword p;
halfword q;
+
p = get_node(small_node_size);
type(p) = glue_node;
subtype(p) = n + 1;
q = glue_par(n);
glue_ptr(p) = q;
incr(glue_ref_count(q));
+
return p;
}
/* sec 0153 */
halfword new_glue_(halfword q)
{
halfword p;
+
p = get_node(small_node_size);
type(p) = glue_node;
subtype(p) = normal;
leader_ptr(p) = 0;
glue_ptr(p) = q;
incr(glue_ref_count(q));
+
return p;
}
/* sec 0154 */
halfword new_skip_param_(small_number n)
{
halfword p;
+
temp_ptr = new_spec(glue_par(n));
p = new_glue(temp_ptr);
glue_ref_count(temp_ptr) = 0;
subtype(p) = n + 1;
+
return p;
}
/* sec 0155 */
halfword new_kern_(scaled w)
{
- halfword p;
+ halfword p;
+
p = get_node(small_node_size);
type(p) = kern_node;
subtype(p) = normal;
width(p) = w;
+
return p;
}
/* sec 0158 */
halfword new_penalty_(integer m)
{
halfword p;
+
p = get_node(small_node_size);
type(p) = penalty_node;
subtype(p) = 0;
penalty(p) = m;
+
return p;
}
void short_display_(integer p)
{
integer n;
-/* while(p > mem_min){ */
+
while (p != 0) { /* want p != null here bkph 93/Dec/15 !!! NOTE: still not fixed in 3.14159 ! */
if (is_char_node(p))
{
else
{
print_esc("");
- print(hash[(hash_size + hash_extra + 524) + mem[p].hh.b0].v.RH);
+ print(font_id_text(font(p)));
}
print_char(' ');
font_in_short_display = font(p);
short_display(pre_break(p));
short_display(post_break(p));
n = replace_count(p);
+
while (n > 0) {
if (link(p) != 0) /* if link(p)<>null then */
p = link(p);
{
if (p > mem_end)
print_esc("CLOBBERED.");
- else {
+ else
+ {
if ((font(p) > font_max))
print_char('*');
else
{
print_esc("");
- print(hash[(hash_size + hash_extra + 524) + mem[p].hh.b0].v.RH);
+ print(font_id_text(font(p)));
}
+
print_char(' ');
print(character(p));
}
void print_mark_ (integer p)
{
print_char('{');
+
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_glue_(scaled d, integer order, char * s)
{
print_scaled(d);
+
if ((order < normal) || (order > filll))
print_string("foul");
else if (order > 0)
{
print_string("fil");
+
while (order > 1) {
print_char('l');
decr(order);
{
if ((p < mem_min)||(p >= lo_mem_max))
print_char('*');
- else {
- print_scaled(mem[p + 1].cint);
+ else
+ {
+ print_scaled(width(p));
if (*s != '\0')
print_string(s);
void print_fam_and_char_(halfword p)
{
print_esc("fam");
- print_int(mem[p].hh.b0);
+ print_int(fam(p));
print_char(' ');
- print(mem[p].hh.b1);
+ print(character(p));
}
/* sec 0691 */
void print_delimiter_(halfword p)
{
integer a;
- a = mem[p].qqqq.b0 * 256 + mem[p].qqqq.b1;
- a = a * 4096 + mem[p].qqqq.b2 * 256 + mem[p].qqqq.b3;
+
+ a = small_fam(p) * 256 + small_char(p);
+ a = a * 4096 + large_fam(p) * 256 + large_char(p);
+
if (a < 0)
print_int(a);
else
{
append_char(c);
temp_ptr = p;
- switch (mem[p].hh.v.RH)
+
+ switch (math_type(p))
{
- case 1:
+ case math_char:
print_ln();
print_current_string();
print_fam_and_char(p);
break;
- case 2:
+
+ case sub_box:
show_info();
break;
- case 3:
+
+ case sub_mlist:
if (info(p) == 0)
{
print_ln();
else
show_info();
break;
+
default:
break;
}
+
decr(pool_ptr);
}
}
case line_skip_code:
print_esc("lineskip");
break;
+
case baseline_skip_code:
print_esc("baselineskip");
break;
+
case par_skip_code:
print_esc("parskip");
break;
+
case above_display_skip_code:
print_esc("abovedisplayskip");
break;
+
case below_display_skip_code:
print_esc("belowdisplayskip");
break;
+
case above_display_short_skip_code:
print_esc("abovedisplayshortskip");
break;
+
case below_display_short_skip_code:
print_esc("belowdisplayshortskip");
break;
+
case left_skip_code:
print_esc("leftskip");
break;
+
case right_skip_code:
print_esc("rightskip");
break;
+
case top_skip_code:
print_esc("topskip");
break;
+
case split_top_skip_code:
print_esc("splittopskip");
break;
+
case tab_skip_code:
print_esc("tabskip");
break;
+
case space_skip_code:
print_esc("spaceskip");
break;
+
case xspace_skip_code:
print_esc("xspaceskip");
break;
+
case par_fill_skip_code:
print_esc("parfillskip");
break;
+
case thin_mu_skip_code:
print_esc("thinmuskip");
break;
+
case med_mu_skip_code:
print_esc("medmuskip");
break;
+
case thick_mu_skip_code:
print_esc("thickmuskip");
break;
+
default:
print_string("[unknown glue parameter!]");
break;
if (p != 0) /* fixed 94/Mar/23 BUG FIX NOTE: still not fixed in 3.14159 ! */
print_string(" []");
return;
- }
+ }
+
n = 0;
-/* while(p > mem_min){ */ /* was p>mem_min !!! line 3667 in tex.web */
+
while (p != 0) { /* want p != null - bkph 93/Dec/15 NOTE: still not fixed in 3.14159 ! */
print_ln();
print_current_string();
+
if (p > mem_end)
{
print_string("Bad link, display aborted.");
return;
}
+
incr(n);
+
if (n > breadth_max)
{
print_string("etc.");
return;
}
+
if ((p >= hi_mem_min))
print_font_and_char(p);
- else switch (mem[p].hh.b0)
+ else switch (type(p))
{
- case 0:
- case 1:
- case 13:
+ case hlist_node:
+ case vlist_node:
+ case unset_node:
{
- if (mem[p].hh.b0 == 0)
+ if (type(p) == hlist_node)
print_esc("h");
- else if (mem[p].hh.b0 == 1)
+ else if (type(p) == vlist_node)
print_esc("v");
else print_esc("unset");
+
print_string("box(");
- print_scaled(mem[p + 3].cint);
+ print_scaled(height(p));
print_char('+');
- print_scaled(mem[p + 2].cint);
- print_string(", shifted ");
- print_scaled(mem[p + 1].cint);
- if (mem[p].hh.b0 == 13)
+ print_scaled(depth(p));
+ print_string(")x");
+ print_scaled(width(p));
+
+ if (type(p) == unset_node)
{
- if (mem[p].hh.b1 != 0)
+ if (span_count(p) != 0)
{
print_string(" (");
- print_int(mem[p].hh.b1 + 1);
+ print_int(span_count(p) + 1);
print_string(" columns)");
}
- if (mem[p + 6].cint != 0)
+
+ if (glue_stretch(p) != 0)
{
print_string(", stretch ");
- print_glue(mem[p + 6].cint, mem[p + 5].hh.b1, "");
+ print_glue(glue_stretch(p), glue_order(p), "");
}
- if (mem[p + 4].cint != 0)
+
+ if (glue_shrink(p) != 0)
{
print_string(", shrink ");
- print_glue(mem[p + 4].cint, mem[p + 5].hh.b0, "");
+ print_glue(glue_shrink(p), glue_sign(p), "");
}
- } else {
- g = mem[p + 6].gr;
- if ((g != 0.0)&&(mem[p + 5].hh.b0 != 0))
+ }
+ else
+ {
+ g = glue_set(p);
+
+ if ((g != 0.0) && (glue_sign(p) != 0))
{
print_string(", glue set ");
- if (mem[p + 5].hh.b0 == 2)
+
+ if (glue_sign(p) == shrinking)
print_string("- ");
+
if (fabs(g)> 20000.0)
{
if (g > 0.0)
print_char('>');
else
print_string("< -");
- print_glue(20000 * 65536L, mem[p + 5].hh.b1, "");
- } else print_glue(round(65536L * g), mem[p + 5].hh.b1, "");
+
+ print_glue(20000 * 65536L, glue_order(p), "");
+ }
+ else
+ print_glue(round(65536L * g), glue_order(p), "");
}
- if (mem[p + 4].cint != 0)
+
+ if (shift_amount(p) != 0)
{
- print_string("shifted");
- print_scaled(mem[p + 4].cint);
+ print_string(", shifted ");
+ print_scaled(shift_amount(p));
}
}
+
{
{
str_pool[pool_ptr]= 46;
}
}
break;
- case 2:
+
+ case rule_node:
{
print_esc("rule(");
print_rule_dimen(mem[p + 3].cint);
s++;
else
s = comm;
-/* program_name = s; */
+
return s;
}
int main (int ac, char *av[])
{
- int flag=0, ret=0;
+ int flag = 0, ret = 0;
+
#ifndef INI
char custom_default[PATH_MAX];
#endif
+
gargc = ac; /* make available globally */
gargv = av; /* make available globally */
+
#ifdef MSDOS
program_name = set_program_name(av[0]); /* rewritten 1994/Mar/1 - bkph */
#else
program_name = strrchr (av[0], PATH_SEP);
+
if (program_name == NULL)
program_name = av[0];
else
#endif /* INIVIR */
dump_default_var = dump_default;
-/* dump_default_length = strlen (dump_default + 1); */
dump_default_length = strlen (dump_default_var + 1); /* 93/Nov/20 */
/* The following doesn't make sense on DOS since we can't core dump */
ret = setjmp(jumpbuffer);
if (ret == 0)
- { // get here when setting up jumpbuffer
+ {
flag = main_program(); // texbody in itex.c
+
if (trace_flag)
{
sprintf(log_line, "EXITING at %s %d %d %d\n", "MAIN", flag, ret, jump_used);
}
}
else
- { // get here from non-local jump via jumpbuffer - if any
+ {
if (trace_flag)
{
sprintf(log_line, "EXITING at %s %d %d %d\n", "JUMPOUT", flag, ret, jump_used);
if (endit(flag) != 0)
flag = 1; /* do final clean up in local.c */
+
if (flag == 0)
return 0;
+
#ifdef _WINDOWS
return flag;
#else
for (i = optind; i < gargc; i++) /* 94/Apr/10 */
#else
/* We do have command line arguments. */
- if (gargc > 1)
- {
- for (i = 1; i < gargc; i++)
+ if (gargc > 1)
+ {
+ for (i = 1; i < gargc; i++)
#endif
{
/* the following won't happen if pseudo_space is set ... */
variable `interrupt'; then they will do everything needed. */
static RETSIGTYPE
-/* catch_interrupt () */
catch_interrupt (int err)
{
(void) signal (SIGINT, SIG_IGN); /* turn off interrupts for now */
/* time_t clock = time ((long *) 0); */
/* clock = time (NULL); */
- (void) time (&clock); /* - seconds since 1970 */
+ (void) time (&clock); /* - seconds since 1970 */
+
if (trace_flag)
{
sprintf(log_line, "The time is %u\n", clock); /* debugging */
if (clock < 0)
{
show_line("Time not available!\n", 1);
- /* clock = 0; *//* 901621283 1998 July 28 06:21:00 */
}
+
tmptr = localtime (&clock);
/* MS C runtime library has trouble for clock >= 2^31 !!! */
if (tmptr == NULL) /* debugging 95/Dec/30*/
{
sprintf(log_line, "Cannot convert time (%0ld)!\n", clock);
show_line(log_line, 1);
- *pyear=2038; *pmonth=1; *pday=18; *minutes=22 * 60 + 14;
+ *pyear = 2038;
+ *pmonth = 1;
+ *pday = 18;
+ *minutes = 22 * 60 + 14;
}
else
{
void complain_line (FILE *output)
{
show_line("\n", 0);
+
#ifdef ALLOCATEBUFFER
sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", current_buf_size);
#else
sprintf(log_line, "! Unable to read an entire line---buf_size=%d.\n", buf_size);
#endif
+
if (output == stderr)
show_line(log_line, 1);
else
show_line(log_line, 0);
else
fputs(log_line, output); // never
+
show_line(" (File may have a line termination problem.)", 0);
}
void show_bad_line (FILE *output, int first, int last)
-{ /* 1994/Jan/21 */
+{
int i, c, d, ch;
- char *s=log_line;
+ char *s = log_line;
for (i = first; i <= last; i++)
{
ch = buffer[i];
+
if ((show_in_hex && ch > 127))
{
c = ch >> 4;
break;
else if (i == '\t' && tab_step != 0) // deal with tab
{
-/* i = ' '; */
buffer[last++] = (ASCII_code) ' ';
+
#ifdef ALLOCATEBUFFER
if (last >= current_buf_size)
{
break;
}
#endif
+
#ifdef ALLOCATEBUFFER
while ((last - first) % tab_step != 0)
#else
{
buffer[last++] = (ASCII_code) ' ';
+
#ifdef ALLOCATEBUFFER
if (last >= current_buf_size)
{
/* called from close_files_and_terminate in tex9.c */
-void call_edit (ASCII_code *stringpool, pool_pointer fnstart,
- integer fnlength, integer linenumber)
+void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, integer linenumber)
{
char *command, *s, *t, *u;
char c;
(void) fclose (input_file[i]);
n = fcloseall(); /* paranoia 1994/Aug/10 */
+
if (n > 0 && verbose_flag)
{
sprintf(log_line, "Closed %d streams\n", n);
#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
swap_items (p, nitems, item_size);
#endif
-/* if (fwrite (p, item_size, nitems, out_file) != nitems) */ /* bkph */
+
if ((int) fwrite (p, item_size, nitems, out_file) != nitems)
{
show_line("\n", 0);
uexit(1);
}
- /* Have to restore the old contents of memory, since some of it might
- get used again. */
+/* Have to restore the old contents of memory, since some of it might get used again. */
#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
swap_items (p, nitems, item_size);
#endif
/* Here is the dual of the writing routine. */
int do_undump (char *p, int item_size, int nitems, FILE *in_file)
{
-/* if (fread(p, item_size, nitems, in_file) != nitems) */ /* bkph */
-/* try and speed this up a bit using read() ? bkph 93/Nov/26 */
-/* doubt whether it makes any real difference ... so forget it ! */
-#ifdef MSDOS_HACK
- unsigned int nbytes = item_size * nitems;
-
- if ((unsigned int) read(fileno (in_file), p, nbytes) != nbytes)
- {
- show_line("\n", 0);
- sprintf(log_line, "! Could not read %d %d-byte item%s.\n",
- nitems, item_size, (nitems > 1) ? "s" : "");
- show_line(log_line, 1);
- uexit(1);
- }
-#else
if ((int) fread((void *) p, item_size, nitems, in_file) != nitems)
{
show_line("\n", 0);
show_line(log_line, 1);
uexit(1);
}
-#endif
#if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP)
swap_items (p, nitems, item_size);