void trace_memory (char *s, int n)
{
- sprintf(log_line, "Allocating %d bytes for %s\n", n, s);
- show_line(log_line, 0);
+ printf("Allocating %d bytes for %s\n", n, s);
}
void update_statistics (int address, int size, int old_size)
void probe_memory (void)
{
- char *s;
-
- s = (char *) malloc(4); /* get current top address */
+ char *s = (char *) malloc(4); /* get current top address */
free(s);
update_statistics ((int) s, 0, 0); /* show where we are */
}
}
#ifdef ALLOCATETRIES
-/* using allocating hyphenation trie slows things down maybe 1% */
-/* but saves typically (270k - 55k) = 215k of memory */
-/* NOTE: it's safe to allocate based on the trie_max read from fmt file */
-/* since hyphenation trie cannot be extended (after iniTeX) */
-/* for iniTeX, however, we need to allocate the full trie_size ahead of time */
-/* */
-/* NOTE: we don't ever reallocate these */
-/* returns -1 if it fails */
+/* returns -1 if it fails */
int allocate_tries (int trie_max)
{
#ifdef USEMEMSET
memset(hyph_word, 0, (hyphen_prime + 1) * sizeof (hyph_word[0]));
#else
- for (k = 0; k <= hyphen_prime; k++) hyph_word[k]= 0;
+ for (k = 0; k <= hyphen_prime; k++)
+ hyph_word[k]= 0;
#endif
#ifdef USEMEMSET
memset(hyph_list, 0, (hyphen_prime + 1) * sizeof (hyph_list[0]));
#else
- for (k = 0; k <= hyphen_prime; k++) hyph_list[k]= 0;
+ for (k = 0; k <= hyphen_prime; k++)
+ hyph_list[k]= 0;
#endif
hyph_count = 0;
if (main_memory != NULL)
{
if (trace_flag)
- puts("Reallocating initial memory allocation\n");
+ puts("Reallocating initial memory allocation");
}
mem_top = mem_bot + size;
{
puts("ERROR: Cannot extent main memory in iniTeX\n");
- if (! knuth_flag)
- puts("Please use `-m=...' on command line\n");
+ if (!knuth_flag)
+ puts("Please use `-m=...' on command line");
return NULL;
}
if (new_size >= max_mem_size) /* bump against limit - ha ha ha */
{
- while (new_size >= max_mem_size) {
- lo_size = lo_size / 2; hi_size = hi_size / 2;
+ while (new_size >= max_mem_size)
+ {
+ lo_size = lo_size / 2;
+ hi_size = hi_size / 2;
new_size = current_mem_size + lo_size + hi_size;
}
}
new_memory, (current_mem_size + 1) * sizeof(memory_word));
show_line(log_line, 0);
}
+
memmove (new_memory + lo_size, new_memory,
(current_mem_size + 1) * sizeof(memory_word));
/* could reduce words moved by (mem_max - mem_end) */
}
+
main_memory = new_memory; /* remember for free later */
if (lo_size > 0)
if (current_mem_size != mem_max - mem_start)
{
- puts("ERROR: Impossible Memory Error\n");
+ puts("ERROR: Impossible Memory Error");
}
if (mem_start != 0)
#endif
#ifdef ALLOCATEFONT
-/* font_mem_size = 10000L ==> font_info array 100k * 8 = 800 kilobytes */
-
int current_font_mem_size = 0;
/* fmemoryword can be either halfword or memory_word */
}
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))
else
free_node(p, noad_size);
}
+
goto done;
}
break;
while (words > 0)
{
decr(words);
- mem[r + words] = mem[p + words]; /* r may be used without having ... */
+ mem[r + words] = mem[p + words];
}
link(q) = r;
else
{
if (m == 0)
- {
print_string("no");
- }
else
{
switch ((- (integer) m) / (max_command + 1))
}
if (nest[p].ml_field < 0)
- {
print_string(" (\\output routine)");
- }
if (p == 0)
{
print_nl("### current page:");
if (output_active)
- {
print_string(" (held over for next output)");
- }
show_box(link(page_head));
#endif
}
- goto found;
+ goto found;
}
p = next(p);
else if (cur_level > level_one)
eq_save(p, eq_level(p));
- eq_level(p) = (quarterword) cur_level; /* because cur_level padded out */
+ eq_level(p) = (quarterword) cur_level;
eq_type(p) = t;
equiv(p) = e;
}
if (xeq_level[p] != cur_level)
{
eq_save(p, xeq_level[p]);
- xeq_level[p] = (quarterword) cur_level; /* because cur_level padded out */
+ xeq_level[p] = (quarterword) cur_level;
}
eqtb[p].cint = w;
else
{
delete_token_ref(start);
+
if (index == macro)
while (param_ptr > limit)
{
/* sec 0330 */
void clear_for_error_prompt (void)
{
- while ((state != 0) && (cur_input.name_field == 0) && (input_ptr > 0) &&
- (loc > limit))
+ while ((state != 0) && (cur_input.name_field == 0) &&
+ (input_ptr > 0) && (loc > limit))
end_file_reading();
print_ln();
store_new_token(cur_tok);
}
- incr(m); /* m may be used without having been ... */
+ incr(m);
if (info(r) > end_match_token)
goto continu;
{
if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head))
{
- link(rbrace_ptr) = 0; /* rbrace_ptr may be used without ... */
+ link(rbrace_ptr) = 0;
free_avail(p);
p = link(temp_head);
pstack[n] = link(p);
if (tracing_macros > 0)
{
begin_diagnostic();
- //print_nl(match_chr); /* matchchar may be used without ... */
+ //print_nl(match_chr);
print_nl(""); print(match_chr);
print_int(n);
print_string("<-");
if (max_param_stack > current_param_size)
param_stack = realloc_param_stack(increment_param_size);
- if (max_param_stack > current_param_size) /* check again after allocation */
+ if (max_param_stack > current_param_size)
{
overflow("parameter stack size", current_param_size);
return;
#else
if (max_param_stack > param_size)
{
- overflow("parameter stack size", param_size); /* parameter stack - not dynamic */
+ overflow("parameter stack size", param_size);
return;
}
#endif
{
scan_int();
- if ((cur_val < 0) || (cur_val > 134217727L)) /* 2^27 - 1 */
+ if ((cur_val < 0) || (cur_val > 134217727L))
{
print_err("Bad delimiter code");
help2("A numeric delimiter code must be between 0 and 2^{27}-1.",
int gargc; /* number of args - set to zero after initialization */
char **gargv;
-/* The entry point: set up for reading the command line, which will
- happen in `t_open_in', then call the main body. */
-
int jump_used = 0;
jmp_buf jumpbuffer;
{
ch = buffer[i];
- if ((show_in_hex && ch > 127))
+ if (show_in_hex && (ch > 127))
{
c = ch >> 4;
- d = ch & 15;
+ d = ch & 15;
+
if (c > 9)
c = c + 'a' - 10;
else
c = c + '0';
+
if (d > 9)
d = d + 'a' - 10;
else
d = d + '0';
-/* putc('^', output); putc('^', output); */
+
*s++ = '^';
*s++ = '^';
-/* putc (c, output); putc (d, output); */
+
*s++ = (char) c;
*s++ = (char) d;
}
+ else if (ch < 32)
+ {
+ *s++ = '^';
+ *s++ = '^';
+ *s++ = (char) (ch + 64);
+ }
+ else if (ch == 127)
+ {
+ *s++ = '^';
+ *s++ = '^';
+ *s++ = (char) (ch - 64);
+ }
else
- if (ch < 32)
- {
-/* putc('^', output); putc('^', output); */
- *s++ = '^';
- *s++ = '^';
-/* putc (ch + 64, output); */
- *s++ = (char) (ch + 64);
- }
- else
- if (ch == 127)
- {
-/* putc('^', output); putc('^', output); */
- *s++ = '^';
- *s++ = '^';
-/* putc (ch - 64, output); */
- *s++ = (char) (ch - 64);
- }
- else
- {
-/* putc(ch, output); */
- *s++ = (char) ch;
- }
+ {
+ *s++ = (char) ch;
+ }
}
-// putc(' ', output); /* putc('\n', output); */
+
*s++ = ' ';
*s++ = '\0';
fputs(log_line, output); // log_file
}
-// split off for convenience and use in ConsoleInput
boolean input_line_finish (void)
{
int i = '\0';
int ch, flag;
-
-/* if last line in file does not end with \n - never happens ? */
-/* if (i == EOF && buffer[last] != '\n') buffer[last++] = '\n'; */
- buffer[last] = ' '; /* space terminate */
+ buffer[last] = ' ';
if (last >= max_buf_stack)
- max_buf_stack = last; /* remember longest line */
+ max_buf_stack = last;
-/* Trim trailing whitespace. */
-/* #define isblank(c) ((c) == ' ' || (c) == '\t') */
-/* What about \n ? Can't get in here ?- bkph */
-/* What about control-Z that gets read in binary mode ? - bkph */
-// #ifdef MYDEBUG
-/* while (last > first && buffer[last - 1] <= ' ') --last; */
while (last > first)
{
i = buffer[last - 1];
break;
}
-/* following added to check source file integrity ASCII 32 - 127 */
-/* allow space, tab, new-page - also allow return, newline ? */
if (restrict_to_ascii)
{
flag = 0;
+
for (i = first; i <= last; i++)
{
ch = buffer[i];
-/* if (ch > 127 || (ch < ' ' && ch != '\t' && ch != '\f')) */
-/* 1 -- 8, 11, 14 -- 31 are not good ASCII characters */
+
if (ch > 126 || (ch < ' ' && ch != '\t' && ch != '\f' && ch != '\r' && ch != '\n'))
{
sprintf(log_line, "\n! non ASCII char (%d) in line: ", ch);
if (log_opened)
fprintf(log_file, "\n! non ASCII char (%d) in line: ", ch);
-/* buffer[i]= 127; */ /* not defined - invalid char */
flag = 1;
break;
}
}
+
if (flag)
{
show_bad_line(errout, first, last);
+
if (log_opened)
show_bad_line(log_file, first, last);
}
}
-/* Don't bother using xord if we don't need to. */ /* for input line */
-/* #ifdef NONASCII */ /* has been turned into command line flag - bkph */
+
if (non_ascii)
{
for (i = first; i <= last; i++)
buffer[i] = xord[buffer[i]];
}
-/* #endif */
+
return true;
}