Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
-#ifdef _WINDOWS
- #define NOCOMM
- #define NOSOUND
- #define NODRIVERS
- #define STRICT
- #pragma warning(disable:4115) // kill rpcasync.h complaint
- #include <windows.h>
- #define MYLIBAPI __declspec(dllexport)
-#endif
-
-#include "texwin.h"
-
-#pragma warning(disable:4996)
-#pragma warning(disable:4131) // old style declarator
-#pragma warning(disable:4135) // conversion between different integral types
-#pragma warning(disable:4127) // conditional expression is constant
-
-#include <setjmp.h>
-
#define EXTERN extern
#include "texd.h"
-#pragma warning(disable:4244) /* 96/Jan/10 */
-
-#include <time.h>
-
#define BEGINFMTCHECKSUM 367403084L
#define ENDFMTCHECKSUM 69069L
-extern clock_t start_time, main_time, finish_time; /* in local.c */
-
-/* imported from pascal.h */
-/* localized here to avoid conflict with io.h in other code */
-
-#define read(f, b) ((b) = getc (f))
-#define readln(f) { register int c; while ((c = getc (f)) != '\n' && c != EOF); }
+extern clock_t start_time, main_time, finish_time;
#ifdef INITEX
- void do_initex (void); /* later in this file */
+ void do_initex (void);
#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-
+/* sec 0004 */
void initialize (void)
{
integer i;
integer k;
integer flag; /* bkph */
+
#ifndef ALLOCATEHYPHEN
hyph_pointer z;
#endif
-/* We already initialized xchr if we are using non_ascii setup */
-/* Normally, there is no translation of character code numbers */
if (!non_ascii)
{
for (i = 0; i <= 255; i++)
xchr[i] = (char) i;
-/* This is a kind of joke, since the characters are given as numeric codes ! */
+
#ifdef JOKE
xchr[32] = ' '; xchr[33] = '!'; xchr[34] = '"'; xchr[35] = '#';
xchr[36] = '$'; xchr[37] = '%'; xchr[38] = '&'; xchr[39] = '\'';
for (i = 127; i <= 255; i++)
xchr[i]= chr(i);
-#endif /* end of JOKE */
+#endif
}
-/* end of plain ASCII case (otherwise have read in xchr vector before) */
-/* Fill in background of `delete' for inverse mapping */
+
for (i = 0; i <= 255; i++)
xord[chr(i)] = 127;
+
#ifdef JOKE
for (i = 128; i <= 255 ; i++)
xord[xchr[i]] = i;
for (i = 0; i <= 126; i++)
xord[xchr[i]] = i;
#endif
-
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* Now invert the xchr mapping to get xord mapping */
+
for (i = 0; i <= 255; i++)
xord[xchr[i]] = (char) i;
- xord[127] = 127; /* hmm, a fixed point ? why ? */
+ xord[127] = 127;
- flag = 0; /* 93/Dec/28 - bkph */
+ flag = 0;
if (trace_flag != 0)
{
-/* entries in xord / xchr */
for (k = 0; k < 256; k++)
if (xord[k] != k)
{
flag = 1;
break;
}
-/* 127 here means mapping undefined */
+
if (flag)
{
- show_line("Inverted mapping xord[] pairs:\n", 0);
+ puts("Inverted mapping xord[] pairs:\n");
for (k = 0; k < 256; k++)
{
-/* entries in xord / xchr */
if (xord[k] != 127)
{
sprintf(log_line, "%d => %d\n", k, xord[k]);
}
}
}
-/* may now set in local.c bkph */
- if (interaction < 0)
+
+ if (interaction < batch_mode)
interaction = error_stop_mode;
deletions_allowed = true;
use_err_help = false;
interrupt = 0;
OK_to_interrupt = true;
-/* darn, need to know mem_top, mem_max etc for the following ... */
+
#ifdef DEBUG
was_mem_end = mem_min;
-/* was_lo_max = mem_min; */
- was_lo_max = mem_bot;
-/* was_hi_min = mem_max; */
- was_hi_min = mem_top;
+ was_lo_max = mem_bot; // mem_min
+ was_hi_min = mem_top; // mem_max
panicking = false;
-#endif /* DEBUG */
+#endif
+
nest_ptr = 0;
max_nest_stack = 0;
mode = 1;
shown_mode = 0;
page_contents = 0;
page_tail = page_head;
+
#ifdef ALLOCATEMAIN
- if (is_initex) /* in iniTeX we did already allocate mem [] */
+ if (is_initex)
#endif
- mem[page_head].hh.v.RH = 0;
-/* last_glue = 262143L; */ /* NO! */
+ link(page_head) = 0;
+
last_glue = empty_flag;
last_penalty = 0;
last_kern = 0;
xeq_level[k] = level_one;
no_new_control_sequence = true;
- hash[hash_base].v.LH = 0; /* next(hash_base):= 0 */
- hash[hash_base].v.RH = 0; /* text(hash_base):= 0 */
-/* 514 + hash_size + 266 = hashbase + hashsize + 10 + font_max */
-/* for k <- hashbase+1 to undefined_control_sequence - 1 do ... p.257 */
+ next(hash_base) = 0;
+ text(hash_base) = 0;
+
for (k = hash_base + 1; k <= undefined_control_sequence - 1; k++)
hash[k] = hash[hash_base];
adjust_tail = 0;
last_badness = 0;
pack_begin_line = 0;
- empty_field.v.RH = 0;
- empty_field.v.LH = 0;
+ empty_field.rh = 0;
+ empty_field.lh = 0;
null_delimiter.b0 = 0;
null_delimiter.b1 = 0;
null_delimiter.b2 = 0;
cur_loop = 0;
cur_head = 0;
cur_tail = 0;
+
/* *not* OK with ALLOCATEHYPHEN, since may not be allocated yet */
#ifndef ALLOCATEHYPHEN
for (z = 0; z <= hyphen_prime; z++)
{
- hyph_word[z]= 0;
- hyph_list[z]= 0;
+ hyph_word[z] = 0;
+ hyph_list[z] = 0;
}
#endif
+
hyph_count = 0;
output_active = false;
insert_penalties = 0;
write_open[k] = false;
edit_name_start = 0;
+
#ifdef INITEX
-/* initex stuff split off for convenience of optimization adjustments */
if (is_initex)
{
do_initex();
}
-#else
-/* trap the -i on command line situation if INITEX was NOT defined */
- if (is_initex)
- {
- show_line("Sorry, somebody forgot to make an INITEX!\n", 1);
- }
-#endif /* not INITEX */
+#endif
}
/* do the part of initialize() that requires mem_top, mem_max or mem[] */
{
#ifdef DEBUG
was_mem_end = mem_min;
-/* was_lo_max = mem_min; */
- was_lo_max = mem_bot;
-/* was_hi_min = mem_max; */
- was_hi_min = mem_top;
+ was_lo_max = mem_bot; // mem_min
+ was_hi_min = mem_top; // mem_max
panicking = false;
-#endif /* DEBUG */
+#endif
+
/* nest_ptr = 0; */
/* max_nest_stack = 0; */
mode = 1;
/* shown_mode = 0; */
/* page_contents = 0; */
page_tail = page_head;
- //mem[mem_top - 2].hh.v.RH = 0;
link(page_head) = 0;
}
#endif // end of ifdef ALLOCATEMAIN
/* sec 0815 */
void line_break_ (integer final_widow_penalty)
{
- bool auto_breaking;
+ boolean auto_breaking;
halfword prevp;
halfword q, r, s, prevs;
internal_font_number f;
pack_begin_line = mode_line;
link(temp_head) = link(head);
- if ((tail >= hi_mem_min))
- {
+ if (is_char_node(tail))
tail_append(new_penalty(inf_penalty));
- }
else if (type(tail) != glue_node)
- {
tail_append(new_penalty(inf_penalty));
- }
else
{
type(tail) = penalty_node;
{
right_skip = finite_shrink(right_skip);
}
+
q = left_skip;
r = right_skip;
background[1] = width(q) + width(r);
if (threshold >= 0)
{
+
#ifdef STAT
if (tracing_paragraphs > 0)
{
print_nl("@firstpass");
}
#endif /* STAT */
+
second_pass = false;
final_pass = false;
first_pass_count++; /* 96 Feb 9 */
threshold = tolerance;
second_pass = true;
final_pass = (emergency_stretch <= 0);
+
#ifdef STAT
if (tracing_paragraphs > 0)
begin_diagnostic();
{
if (trie_not_ready)
init_trie();
- } /* bkph */
-#endif /* INITEX */
+ }
+#endif
cur_lang = init_cur_lang;
lhyf = init_l_hyf;
auto_breaking = true;
prevp = cur_p;
- while((cur_p != 0) && (link(active) != active))
+ while ((cur_p != 0) && (link(active) != active))
{
- if ((cur_p >= hi_mem_min))
+ if (is_char_node(cur_p))
{
prevp = cur_p;
active_width[1] = active_width[1] + char_width(f, char_info(f, character(cur_p)));
cur_p = link(cur_p);
}
- while(!(!(cur_p >= hi_mem_min)));
+ while (!(!is_char_node(cur_p)));
}
switch(type(cur_p))
{
if (auto_breaking)
{
- if ((prevp >= hi_mem_min))
+ if (is_char_node(prevp))
try_break(0, unhyphenated);
else if ((mem[prevp].hh.b0 < 9))
try_break(0, unhyphenated);
{
while (true)
{
- if ((s >= hi_mem_min))
+ if (is_char_node(s))
{
c = character(s);
hf = font(s);
while (true)
{
- if ((s >= hi_mem_min))
+ if (is_char_node(s))
{
if (font(s) != hf)
goto lab33;
while (true)
{
- if (!((s >= hi_mem_min)))
+ if (!(is_char_node(s)))
switch(type(s))
{
case ligature_node:
case kern_node:
if (subtype(cur_p) == explicit)
{
- if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
+ if (!is_char_node(link(cur_p)) && auto_breaking)
if (type(link(cur_p)) == glue_node)
try_break(0, unhyphenated);
{
do
{
- if ((s >= hi_mem_min))
+ if (is_char_node(s))
{
f = font(s);
disc_width = disc_width + char_width(f, char_info(f, character(s)));
}
s = link(s);
}
- while(!(s == 0));
+ while (!(s == 0));
active_width[1] = active_width[1] + disc_width;
try_break(hyphen_penalty, hyphenated);
while (r > 0)
{
- if ((s >= hi_mem_min))
+ if (is_char_node(s))
{
f = font(s);
active_width[1] = active_width[1] + char_width(f, char_info(f, character(s)));
active_width[1] = active_width[1] + char_width(f, char_info(f, character(lig_char(s))));
}
break;
+
case hlist_node:
case vlist_node:
case rule_node:
case kern_node:
active_width[1] = active_width[1] + width(s);
break;
+
default:
{
confusion("disc4");
}
break;
}
+
decr(r);
s = link(s);
}
+
prevp = cur_p;
cur_p = s;
goto lab35;
}
break;
+
case math_node:
{
auto_breaking = (subtype(cur_p) == 1);
{
- if (!(link(cur_p) >= hi_mem_min) && auto_breaking)
+ if (!is_char_node(link(cur_p)) && auto_breaking)
if (type(link(cur_p)) == glue_node)
try_break(0, unhyphenated);
}
}
break;
+
case penalty_node:
try_break(penalty(cur_p), unhyphenated);
break;
+
case mark_node:
case ins_node:
case adjust_node:
break;
+
default:
{
confusion("paragraph");
}
break;
}
+
prevp = cur_p;
cur_p = link(cur_p);
lab35:;
fewest_demerits = 1073741823L; /* 2^30 - 1 */
do
- {
- if (type(r) != 2)
- if (total_demerits(r) < fewest_demerits)
- {
- fewest_demerits = total_demerits(r);
- best_bet = r;
- }
- r = link(r);
- }
+ {
+ if (type(r) != 2)
+ if (total_demerits(r) < fewest_demerits)
+ {
+ fewest_demerits = total_demerits(r);
+ best_bet = r;
+ }
+
+ r = link(r);
+ }
while (!(r == active));
+
best_line = line_number(best_bet);
if (looseness == 0)
{
r = link(active);
actual_looseness = 0;
+
do
- {
- if (type(r) != 2)
{
- line_diff = toint(line_number(r)) - toint(best_line);
-
- if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
- ((line_diff > actual_looseness) && (looseness >= line_diff)))
- {
- best_bet = r;
- actual_looseness = line_diff;
- fewest_demerits = total_demerits(r);
- }
- else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
+ if (type(r) != 2)
{
- best_bet = r;
- fewest_demerits = total_demerits(r);
+ line_diff = toint(line_number(r)) - toint(best_line);
+
+ if (((line_diff < actual_looseness) && (looseness <= line_diff)) ||
+ ((line_diff > actual_looseness) && (looseness >= line_diff)))
+ {
+ best_bet = r;
+ actual_looseness = line_diff;
+ fewest_demerits = total_demerits(r);
+ }
+ else if ((line_diff == actual_looseness) && (total_demerits(r) < fewest_demerits))
+ {
+ best_bet = r;
+ fewest_demerits = total_demerits(r);
+ }
}
+
+ r = link(r);
}
- r = link(r);
- }
while (!(r == active));
+
best_line = line_number(best_bet);
}
/* can only get here is \emergencystretch has been set positive */
background[2] = background[2] + emergency_stretch;
final_pass = true;
- final_pass_count++; /* 96 Feb 9 */
+ ++final_pass_count; /* 96 Feb 9 */
} /* end of if second_pass */
- } /* end of while(true)do */
+ } /* end of while (true)do */
/* cannot drop through from above loop */
lab30: /* common exit point */
if (best_line == 2)
single_line++;
+
#ifdef STAT
if (tracing_paragraphs > 0)
{
normalize_selector();
}
#endif /* STAT */
+
post_line_break(final_widow_penalty);
q = link(active);
q = passive;
- while (q != 0) /* while q<>null do l.16979 */
+ while (q != 0)
{
cur_p = link(q);
free_node(q, 2);
internal_font_number f;
halfword j;
font_index k;
- halfword p, q;
+ pointer p, q;
integer n;
- bool e;
+ boolean e;
a = 0;
while (cur_cmd == prefix)
{
if (!odd(a / cur_chr))
- a = a + cur_chr; /* small_number a; */
+ a = a + cur_chr;
do
{
get_x_token();
}
- while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+ while (!((cur_cmd != spacer) && (cur_cmd != relax)));
if (cur_cmd <= max_non_prefixed_command)
{
else
eq_define(cur_font_loc, data, cur_chr);
break;
+
case def:
{
if (odd(cur_chr) && !(a >= 4) && (global_defs >= 0))
eq_define(p, call + (a % 4), def_ref);
}
break;
+
case let:
{
n = cur_chr;
}
if (cur_cmd >= call)
- incr(mem[cur_chr].hh.v.LH);
+ incr(mem[cur_chr].hh.lh);
if ((a >= 4))
geq_define(p, cur_cmd, cur_chr);
eq_define(p, cur_cmd, cur_chr);
}
break;
+
case shorthand_def:
{
n = cur_chr;
eq_define(p, char_given, cur_val);
}
break;
+
case math_char_def_code:
{
scan_fifteen_bit_int();
eq_define(p, math_given, cur_val);
}
break;
+
default:
{
scan_eight_bit_int();
else
eq_define(p, assign_int, count_base + cur_val);
break;
+
case dimen_def_code:
if ((a >= 4))
geq_define(p, assign_dimen, scaled_base + cur_val);
else
eq_define(p, assign_dimen, scaled_base + cur_val);
break;
+
case skip_def_code:
if ((a >= 4))
geq_define(p, assign_glue, skip_base + cur_val);
else
eq_define(p, assign_glue, skip_base + cur_val);
break;
+
case mu_skip_def_code:
if ((a >= 4))
geq_define(p, assign_mu_glue, mu_skip_base + cur_val);
else
eq_define(p, assign_mu_glue, mu_skip_base + cur_val);
break;
+
case toks_def_code:
if ((a >= 4))
geq_define(p, assign_toks, toks_base + cur_val);
}
}
break;
+
case read_to_cs:
{
scan_int();
eq_define(p, call, cur_val);
}
break;
+
case toks_register:
case assign_toks:
{
{
get_x_token();
}
- while(!((cur_cmd != spacer) && (cur_cmd != relax)));
+ while (!((cur_cmd != spacer) && (cur_cmd != relax)));
if (cur_cmd != left_brace)
{
eq_define(p, undefined_cs, 0);
else
{
- incr(mem[q].hh.v.LH);
+ incr(mem[q].hh.lh);
if ((a >= 4))
geq_define(p, call, q);
}
}
break;
+
case assign_int:
{
p = cur_chr;
eq_word_define(p, cur_val);
}
break;
+
case assign_dimen:
{
p = cur_chr;
eq_word_define(p, cur_val);
}
break;
+
case assign_glue:
case assign_mu_glue:
{
eq_define(p, glue_ref, cur_val);
}
break;
+
case def_code:
{
if (cur_chr == cat_code_base)
n = max_char_code;
else if (cur_chr == math_code_base)
- n = 32768L; /* 2^15 */
+ n = 32768L; /* 2^15 */
else if (cur_chr == sf_code_base)
- n = 32767; /* 2^15 - 1*/
+ n = 32767; /* 2^15 - 1*/
else if (cur_chr == del_code_base)
- n = 16777215L; /* 2^24 - 1 */
+ n = 16777215L; /* 2^24 - 1 */
else
- n = 255; /* 2^8 - 1 */
+ n = 255; /* 2^8 - 1 */
p = cur_chr;
scan_char_num();
eq_word_define(p, cur_val);
}
break;
+
case def_family:
{
p = cur_chr;
eq_define(p, data, cur_val);
}
break;
+
case tex_register:
case advance:
case multiply:
case divide:
do_register_command(a);
break;
+
case set_box:
{
scan_eight_bit_int();
}
}
break;
+
case set_aux:
alter_aux();
break;
+
case set_prev_graf:
alter_prev_graf();
break;
+
case set_page_dimen:
alter_page_so_far();
break;
+
case set_page_int:
alter_integer();
break;
+
case set_box_dimen:
alter_box_dimen();
break;
+
case set_shape:
{
scan_optional_equals();
eq_define(par_shape_loc, shape_ref, p);
}
break;
+
case hyph_data:
if (cur_chr == 1)
{
{
get_token();
}
- while(!(cur_cmd == right_brace));
+ while (!(cur_cmd == right_brace));
return;
}
goto lab30;
}
break;
+
case assign_font_dimen:
{
find_font_dimen(true);
font_info[k].cint = cur_val;
}
break;
+
case assign_font_int:
{
n = cur_chr;
skew_char[f] = cur_val;
}
break;
+
case def_font:
new_font(a);
break;
+
case set_interaction:
new_interaction();
break;
+
default:
{
confusion("prefix");
return; // abort_flag set
}
break;
- } /* end of cur_cmd switch */
+ }
lab30:
if (after_token != 0)
after_token = 0;
}
}
-
-/* added following explanations 96/Jan/10 */
-
-void bad_formator_pool (char *name, char *defaultname, char *envvar)
-{
- if (name == NULL)
- name = defaultname;
-
- sprintf(log_line, "(Perhaps %s is for an older version of TeX)\n", name);
- show_line(log_line, 0);
- name_of_file[name_length + 1] = '\0';
- sprintf(log_line, "(Alternatively, %s may have been corrupted)\n", name_of_file + 1);
- show_line(log_line, 0);
- name_of_file[name_length + 1] = ' ';
- sprintf(log_line, "(Perhaps your %s environment variable is not set correctly)\n", envvar);
- show_line(log_line, 0);
- {
- char *s; /* extra info 99/April/28 */
-
- if ((s = grabenv(envvar)) != NULL)
- {
- sprintf(log_line, "(%s=%s)\n", envvar, s);
- show_line(log_line, 0);
- }
- else
- {
- sprintf(log_line, "%s environment variable not set\n", envvar);
- show_line(log_line, 0);
- }
- }
-#ifndef _WINDOWS
- fflush(stdout);
-#endif
-}
/* sec 1303 */
-bool load_fmt_file (void)
+boolean load_fmt_file (void)
{
- register bool Result;
integer j, k;
- halfword p, q;
+ pointer p, q;
integer x;
undump_int(x);
- if (x != BEGINFMTCHECKSUM) /* magic FMT file start 4C 20 E6 15 hex */
- goto lab6666;
+ if (x != BEGINFMTCHECKSUM)
+ goto lab_bad_fmt;
undump_int(x); /* mem_bot */
if (x != mem_bot)
- goto lab6666;
+ goto lab_bad_fmt;
undump_int(x); /* mem_top */
exit(1); /* redundant sanity test ! */
initialize_aux(); /* do `mem' part of initialize */
-/* mem = zmem; */ /* update pointer to main memory */
#endif
if (x != mem_top)
- goto lab6666;
+ goto lab_bad_fmt;
- undump_int(x); /* eqtbsize */
+ undump_int(x); /* eqtb_size */
if (x != (eqtb_size))
- goto lab6666;
+ goto lab_bad_fmt;
undump_int(x); /* hash_prime */
if (x != hash_prime)
- goto lab6666;
+ goto lab_bad_fmt;
undump_int(x); /* hyphen_prime */
#endif
if (x != hyphen_prime)
- goto lab6666;
+ goto lab_bad_fmt;
{
undump_int(x); /* pool_size */
if (x < 0)
- goto lab6666;
+ goto lab_bad_fmt;
#ifdef ALLOCATESTRING
if (x > current_pool_size)
sprintf(log_line, "undump string pool reallocation (%d > %d)\n", x, current_pool_size);
show_line(log_line, 0);
}
+
str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size);
}
+
if (x > current_pool_size) /* 94/Jan/24 */
#else
if (x > pool_size)
{
sprintf(log_line, "%s%s\n", "---! Must increase the ", "string pool size");
show_line(log_line, 0);
- goto lab6666;
+ goto lab_bad_fmt;
}
else
pool_ptr = x;
}
+
{
undump_int(x); /* max_strings */
+
if (x < 0)
- goto lab6666;
+ goto lab_bad_fmt;
#ifdef ALLOCATESTRING
if (x > current_max_strings)
sprintf(log_line, "undump string pointer reallocation (%d > %d)\n", x, current_max_strings);
show_line(log_line, 0);
}
+
str_start = realloc_str_start(x - current_max_strings + increment_max_strings);
}
+
if (x > current_max_strings) /* 94/Jan/24 */
#else
if (x > max_strings)
{
sprintf(log_line, "%s%s\n", "---! Must increase the ", "max strings");
show_line(log_line, 0);
- goto lab6666;
+ goto lab_bad_fmt;
}
else
str_ptr = x;
if (undumpthings(str_start[0], str_ptr + 1)) /* undump string ptrs */
return -1;
+
if (undumpthings(str_pool[0], pool_ptr)) /* undump string pool */
return -1;
init_str_ptr = str_ptr;
init_pool_ptr = pool_ptr;
-/* undump the dynamic memory - paragraph 1312 in the book */
- {
- undump_int(x);
- if ((x < lo_mem_stat_max + 1000) || (x > hi_mem_stat_min - 1))
- goto lab6666;
- else
- lo_mem_max = x;
- }
- {
- undump_int(x);
- if ((x < lo_mem_stat_max + 1) || (x > lo_mem_max))
- goto lab6666;
- else
- rover = x;
- }
- p = 0; /* mem_bot */
+ undump(lo_mem_stat_max + 1000, hi_mem_stat_min - 1, lo_mem_max);
+ undump(lo_mem_stat_max + 1, lo_mem_max, rover);
+ p = mem_bot;
q = rover;
- do {
- if (undumpthings(mem[p], q + 2 - p))
- return -1;
- p = q + node_size(q);
+ do
+ {
+ if (undumpthings(mem[p], q + 2 - p))
+ return -1;
+
+ p = q + node_size(q);
- if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
- goto lab6666;
+ if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover)))
+ goto lab_bad_fmt;
- q = rlink(q);
- } while (!(q == rover));
+ q = rlink(q);
+ }
+ while (!(q == rover));
if (undumpthings(mem[p], lo_mem_max + 1 - p))
return -1;
- if (mem_min < mem_bot - 2) /* ? splice in block below */
+ if (mem_min < mem_bot - 2) /* ? splice in block below */
{
/* or call add_variable_space(mem_bot - (mem_min + 1)) */
if (trace_flag)
- show_line("Splicing in mem_min space in undump!\n", 0);
+ puts("Splicing in mem_min space in undump!\n");
p = llink(rover);
q = mem_min + 1;
rlink(q) = rover;
llink(q) = p;
link(q) = empty_flag;
- node_size(q) = mem_bot - q; /* ? size of block */
- }
- {
- undump_int(x);
- if ((x < lo_mem_max + 1) || (x > hi_mem_stat_min))
- goto lab6666;
- else
- hi_mem_min = x;
+ node_size(q) = mem_bot - q;
}
- {
- undump_int(x);
- if ((x < mem_bot) || (x > mem_top))
- goto lab6666;
- else
- avail = x;
- }
+ undump(lo_mem_max + 1, hi_mem_stat_min, hi_mem_min);
+ undump(mem_bot, mem_top, avail);
mem_end = mem_top;
if (undumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
undump_int(dyn_used);
k = active_base;
- do {
- undump_int(x);
- if ((x < 1) || (k + x > (eqtb_size + 1)))
- goto lab6666;
- if (undumpthings(eqtb[k], x))
- return -1;
+ do
+ {
+ undump_int(x);
- k = k + x;
- undump_int(x);
+ if ((x < 1) || (k + x > (eqtb_size + 1)))
+ goto lab_bad_fmt;
- if ((x < 0) || (k + x > (eqtb_size + 1)))
- goto lab6666;
+ if (undumpthings(eqtb[k], x))
+ return -1;
- for (j = k; j <= k + x - 1; j++)
- {
- eqtb[j] = eqtb[k - 1];
+ k = k + x;
+ undump_int(x);
+
+ if ((x < 0) || (k + x > (eqtb_size + 1)))
+ goto lab_bad_fmt;
+
+ for (j = k; j <= k + x - 1; j++)
+ eqtb[j] = eqtb[k - 1];
+
+ k = k + x;
}
- k = k + x;
- } while(!(k > (eqtb_size)));
- {
- undump_int(x);
- if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
- goto lab6666;
- else
- par_loc = x;
- }
- par_token = 4095 + par_loc;
- {
- undump_int(x);
- if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
- goto lab6666;
- else
- write_loc = x;
- }
- {
- undump_int(x);
- if ((x < hash_base) || (x > (frozen_control_sequence))) /*96/Jan/10*/
- goto lab6666;
- else
- hash_used = x;
- }
+ while (!(k > eqtb_size));
+
+ undump(hash_base, frozen_control_sequence, par_loc);
+ par_token = cs_token_flag + par_loc;
+ undump(hash_base, frozen_control_sequence, write_loc);
+ undump(hash_base, frozen_control_sequence, hash_used);
+
p = hash_base - 1;
- do {
+
+ do
{
- undump_int(x);
- if ((x < p + 1) || (x > hash_used))
- goto lab6666;
- else
- p = x;
+ undump(p + 1, hash_used, p);
+ undump_hh(hash[p]);
}
- undump_hh(hash[p]);
- } while (!(p == hash_used));
+ while (!(p == hash_used));
- if (undumpthings(hash[hash_used + 1], (undefined_control_sequence - 1) - hash_used))
+ if (undumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
return -1;
- undump_int(cs_count); /* cs_count */
+ undump_int(cs_count);
+
if (trace_flag)
{
- sprintf(log_line, "itex undump cs_count %d ", cs_count); /* debugging */
+ sprintf(log_line, "itex undump cs_count %d ", cs_count);
show_line(log_line, 0);
}
+
{
undump_int(x); /* font_mem_size */
+
if (x < 7)
- goto lab6666;
+ goto lab_bad_fmt;
+
#ifdef ALLOCATEFONT
if (trace_flag)
{
sprintf(log_line, "Read from fmt fmem_ptr = %d\n", x);
show_line(log_line, 0);
}
+
if (x > current_font_mem_size) /* 93/Nov/28 dynamic allocate font_info */
{
if (trace_flag)
sprintf(log_line, "Undump realloc font_info (%d > %d)\n", x, current_font_mem_size);
show_line(log_line, 0);
}
+
font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size);
}
+
if (x > current_font_mem_size) /* in case allocation failed 94/Jan/24 */
#else
if (x > font_mem_size)
{
sprintf(log_line, "%s%s\n", "---! Must increase the ", "font mem size");
show_line(log_line, 0);
- goto lab6666;
+ goto lab_bad_fmt;
}
else
fmem_ptr = x;
}
+
{
if (undumpthings(font_info[0], fmem_ptr))
return -1;
+
{
undump_int(x); /* font_max */
+
if (x < 0)
- goto lab6666;
+ goto lab_bad_fmt;
+
if (x > font_max)
{
sprintf(log_line, "%s%s\n", "---! Must increase the ", "font max");
show_line(log_line, 0);
- goto lab6666;
+ goto lab_bad_fmt;
}
else
font_ptr = x;
}
- frozenfontptr = font_ptr; /* remember number of fonts frozen into format */
+
+ frozen_font_ptr = font_ptr; /* remember number of fonts frozen into format */
+
if (undumpthings(font_check[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_size[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_dsize[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_params[0], font_ptr + 1))
return -1;
+
if (undumpthings(hyphen_char[0], font_ptr + 1))
return -1;
+
if (undumpthings(skew_char[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_name[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_area[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_bc[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_ec[0], font_ptr + 1))
return -1;
+
if (undumpthings(char_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(width_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(height_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(depth_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(italic_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(lig_kern_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(kern_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(exten_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(param_base[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_glue[0], font_ptr + 1))
return -1;
+
if (undumpthings(bchar_label[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_bchar[0], font_ptr + 1))
return -1;
+
if (undumpthings(font_false_bchar[0], font_ptr + 1))
return -1;
}
#ifdef ALLOCATEFONT
/* deal with fmt files dumped with *different* font_mem_size 93/Nov/29 */
- {
- int count = 0, oldfont_mem_size = 0;
-
- for (x = 0; x <= font_ptr; x++)
- {
- if (bchar_label[x] > oldfont_mem_size)
- oldfont_mem_size = bchar_label[x];
- }
-
-/* somewhat arbitrary sanity check ... */
-/* if (oldfont_mem_size != font_mem_size && oldfont_mem_size > font_max) { */
- if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) /* 96/Jan/16 */
- {
- for (x = 0; x <= font_ptr; x++)
- {
- if (bchar_label[x] == oldfont_mem_size)
- {
- /* bchar_label[x] = font_mem_size; */
- bchar_label[x] = non_address; /* 96/Jan/16 */
- count++;
- }
- }
- if (trace_flag)
- {
- sprintf(log_line, "oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
- oldfont_mem_size, count, non_address);
- show_line(log_line, 0);
- }
- }
- }
-#endif
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* undump(0)(hyph_size)(hyph_count); */
- {
- undump_int(x);
-
- if ((x < 0) || (x > hyphen_prime))
- goto lab6666;
- else
- hyph_count = x;
- }
-/* undump hypenation exception tables p.1325 */
- for (k = 1; k <= hyph_count; k++)
{
+ int count = 0, oldfont_mem_size = 0;
+
+ for (x = 0; x <= font_ptr; x++)
{
- undump_int(x);
- if ((x < 0) || (x > hyphen_prime))
- goto lab6666;
- else
- j = x;
- }
- {
- undump_int(x);
- if ((x < 0) || (x > str_ptr))
- goto lab6666;
- else
- hyph_word[j] = x;
+ if (bchar_label[x] > oldfont_mem_size)
+ oldfont_mem_size = bchar_label[x];
}
+
+ /* somewhat arbitrary sanity check ... */
+ if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) /* 96/Jan/16 */
{
- undump_int(x);
- if ((x < 0) || (x > max_halfword)) /* mem_top ? no p.1325 */
- goto lab6666;
- else
- hyph_list[j] = x;
- }
- }
+ for (x = 0; x <= font_ptr; x++)
+ {
+ if (bchar_label[x] == oldfont_mem_size)
+ {
+ /* bchar_label[x] = font_mem_size; */
+ bchar_label[x] = non_address; /* 96/Jan/16 */
+ count++;
+ }
+ }
-#ifdef ALLOCATEHYPHEN
-/* if user specified new hyphen prime - flush existing exception patterns ! */
+ if (trace_flag)
+ {
+ sprintf(log_line, "oldfont_mem_size is %d --- hit %d times. Using non_address %d\n",
+ oldfont_mem_size, count, non_address);
+ show_line(log_line, 0);
+ }
+ }
+ }
+#endif
+
+ undump(0, hyphen_prime, hyph_count);
+
+ for (k = 1; k <= hyph_count; k++)
+ {
+ undump(0, hyphen_prime, j);
+ undump(0, str_ptr, hyph_word[j]);
+ undump(0, max_halfword, hyph_list[j]);
+ }
+
+#ifdef ALLOCATEHYPHEN
+/* if user specified new hyphen prime - flush existing exception patterns ! */
/* but, we can reclaim the string storage wasted ... */
if (is_initex)
{
{
undump_int(x);
+
if (x < 0)
- goto lab6666;
+ goto lab_bad_fmt;
#ifdef ALLOCATETRIES
if (!is_initex)
{
sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie size");
show_line(log_line, 0);
- goto lab6666;
+ goto lab_bad_fmt;
}
else
j = x;
}
+
#ifdef INITEX
- if (is_initex) /* bkph */
+ if (is_initex)
trie_max = j;
-#endif /* INITEX */
+#endif
+
if (undumpthings(trie_trl[0], j + 1))
return -1;
+
if (undumpthings(trie_tro[0], j + 1))
return -1;
+
if (undumpthings(trie_trc[0], j + 1))
return -1;
+
{
undump_int(x);
+
if (x < 0)
- goto lab6666;
+ goto lab_bad_fmt;
+
if (x > trie_op_size)
{
sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie op size");
show_line(log_line, 0);
- goto lab6666;
+ goto lab_bad_fmt;
}
else
j = x;
}
#ifdef INITEX
- if (is_initex) /* bkph */
+ if (is_initex)
trie_op_ptr = j;
-#endif /* INITEX */
+#endif
if (undumpthings(hyf_distance[1], j))
return -1;
+
if (undumpthings(hyf_num[1], j))
return -1;
+
if (undumpthings(hyf_next[1], j))
return -1;
#ifdef INITEX
- if (is_initex) /* bkph */
+ if (is_initex)
{
for (k = 0; k <= 255; k++)
- {
- trie_used[k] = 0;
- }
+ trie_used[k] = min_quarterword;
}
-#endif /* INITEX */
+#endif
+
k = 256;
- while (j > 0) {
- {
- undump_int(x);
- if ((x < 0) || (x > k - 1))
- goto lab6666;
- else
- k = x;
- }
- {
- undump_int(x);
- if ((x < 1) || (x > j))
- goto lab6666;
- else
- x = x;
- }
+
+ while (j > 0)
+ {
+ undump(0, k - 1, k);
+ undump(1, j, x);
+
#ifdef INITEX
- if (is_initex) /* bkph */
+ if (is_initex)
trie_used[k] = x;
-#endif /* INITEX */
-/* j:=j-x; op_start[k]:=qo(j); */
+#endif
+
j = j - x;
op_start[k] = j;
}
+
#ifdef INITEX
- if (is_initex) /* bkph */
+ if (is_initex)
trie_not_ready = false;
-#endif /* INITEX */
- {
- undump_int(x);
- if ((x < batch_mode) || (x > error_stop_mode))
- goto lab6666;
-/* else interaction = x; */
- if (interaction < batch_mode) /* may now set in local.c bkph 94/Jan/8 */
- interaction = x;
- }
- {
- undump_int(x);
- if ((x < 0) || (x > str_ptr))
- goto lab6666;
- else
- format_ident = x;
- }
+#endif
+
+ undump(batch_mode, error_stop_mode, interaction);
+ undump(0, str_ptr, format_ident);
undump_int(x);
-/* test_eof(fmt_file)? */
- if ((x != ENDFMTCHECKSUM) || feof(fmt_file)) /* magic checksum --- change ? */
- goto lab6666;
+ if ((x != ENDFMTCHECKSUM) || feof(fmt_file))
+ goto lab_bad_fmt;
- Result = true;
- return(Result);
+ return true;
-lab6666:;
+lab_bad_fmt:;
sprintf(log_line, "(Fatal format file error; I'm stymied)\n");
show_line(log_line, 1);
-/* added following bit of explanation 96/Jan/10 */
- if (!knuth_flag)
- bad_formator_pool(format_file, "the format file", "TEXFORMATS");
- Result = false;
- return Result;
+
+ return false;
}
/* sec 1335 */
void final_cleanup (void)
{
small_number c;
+
c = cur_chr;
+
if (job_name == 0)
open_log_file();
while (input_ptr > 0)
{
- if (cur_input.state_field == 0)
+ if (state == 0)
{
end_token_list();
}
if_line = mem[cond_ptr + 1].cint;
cur_if = mem[cond_ptr].hh.b1;
temp_ptr = cond_ptr;
- cond_ptr = mem[cond_ptr].hh.v.RH;
+ cond_ptr = mem[cond_ptr].hh.rh;
free_node(temp_ptr, 2);
}
if (selector == term_and_log)
{
selector = term_only;
- print_nl(" (see the transcript file for additional information)");
+ print_nl("(see the transcript file for additional information)");
selector = term_and_log;
}
delete_glue_ref(last_glue);
store_fmt_file(); // returns a value ?
}
-#endif /* INITEX */
- if (!is_initex) /* 2000/March/3 */
- print_nl(" (\\dump is performed only by INITEX)");
- }
-}
-// debugging code for checking the string pool
-#ifdef CHECKPOOL
-int checkpool (char *task)
-{
- int c, i, k, n, st, flag, bad = 0;
+#endif
- if (task != NULL)
- {
- sprintf(log_line, "Check on string pool start (%s)\n", task);
- show_line(log_line, 0);
- }
- for (k = 0; k < 32; k++)
- {
- if (str_start[k] != 3 * k)
- {
- sprintf(log_line, "k %d str_start[k] %d\n", k, str_start[k]);
- show_line(log_line, 0);
- }
- }
- for (k = 32; k < 128; k++)
- {
- if (str_start[k] != 96 + (k - 32))
- {
- sprintf(log_line, "k %d str_start[k] %d\n", k, str_start[k]);
- show_line(log_line, 0);
- }
- }
- for (k = 128; k < 256; k++)
- {
- if (str_start[k] != 194 + 4 * (k - 128))
- {
- sprintf(log_line, "k %d str_start[k] %d\n", k, str_start[k]);
- show_line(log_line, 0);
- }
- }
- if (task != NULL)
- {
- sprintf(log_line, "Check on string pool (%s)\n", task);
- show_line(log_line, 0);
- }
- for (k = 0; k < str_ptr; k++)
- {
- if (str_start[k + 1] == 0)
- break;
- n = length(k);
- if (n < 0)
- break;
- st = str_start[k];
- flag = 0;
- for (i = 0; i < n; i++)
- {
- if (str_pool[st + i] == 0)
- {
- flag = 1; break;
- }
- if (str_pool[st + i] > 255)
- {
- flag = 1; break;
- }
- }
- if (flag)
- {
- bad++;
- sprintf(log_line, "BAD %d (start at %d): ", k, st);
- show_line(log_line, 0);
- s = log_line;
- for (i = 0; i < n; i++)
- {
- c = str_pool[st + i];
- if (c > 255)
- {
- sprintf(s, "%d ", c);
- s += strlen(s);
- continue;
- }
- if (c >= 128)
- {
- c -= 128;
- sprintf(s, "M-");
- s += strlen(s);
- }
- if (c < 32)
- {
- c += 64;
- sprintf(s, "C-");
- s += strlen(s);
- }
-// putc(c, stdout);
- *s++ = c; // ???
- }
- *s++ = '\n';
- *s++ = '\0';
- show_line(log_line, stdout);
- }
- }
- sprintf(log_line, "end of check (%s)\n", bad ? "BAD" : "OK");
- show_line(log_line, 0);
- if (bad)
- {
- if (task == NULL)
- return bad;
- else
- exit(1);
+ if (!is_initex)
+ print_nl("(\\dump is performed only by INITEX)");
}
- return bad;
-} /* DEBUGGING ONLY */
-#endif
+}
void show_frozen (void)
{
fprintf(log_file, ") ");
}
-/* Main entry point called from texmf.c int main(int ac, char *av[]) */
-/* call from main_program in texmf.c */
-/* This in turn calls initialize() */
-
-#pragma warning(disable:4127) // conditional expression is constant
-
-/* void texbody() */
-int texbody (void) /* now returns a value --- bkph */
+int main_program (void)
{
- history = 3;
+ history = fatal_error_stop;
- set_paths(TEXFORMATPATHBIT + TEXINPUTPATHBIT + TEXPOOLPATHBIT + TFMFILEPATHBIT);
-/* magic number */
if (ready_already == 314159L)
goto lab1;
-/* These tests are almost all compile time tests and so could be eliminated */
+
bad = 0;
+
if ((half_error_line < 30) || (half_error_line > error_line - 15))
bad = 1;
+
if (max_print_line < 60)
bad = 2;
+
if (dvi_buf_size % 8 != 0)
bad = 3;
- if (1100 > mem_top)
- bad = 4; /* not compile time */
-/* if (hash_prime > hash_size) */
+
+ if (mem_bot + 1100 > mem_top)
+ bad = 4;
+
if (hash_prime > (hash_size + hash_extra))
bad = 5;
+
if (max_in_open >= 128)
- bad = 6; /* p.14 */
- if (mem_top < 267)
- bad = 7; /* where from ? *//* not compile time */
+ bad = 6;
+
+ if (mem_top < 256 + 11)
+ bad = 7;
+
#ifdef INITEX
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
if (is_initex)
{
if ((mem_min != 0) || (mem_max != mem_top))
bad = 10;
}
-#endif /* INITEX */
-/* if ((mem_min > 0)||(mem_max < mem_top)) */
+#endif
+
if ((mem_min > mem_bot) || (mem_max < mem_top))
bad = 10;
+
if ((min_quarterword > 0) || (max_quarterword < 255))
bad = 11;
-/* if ((0 > 0)||(262143L < 32767)) */
+
if ((min_halfword > 0) || (max_halfword < 32767))
bad = 12;
-/* if ((0 < 0)||(255 > 262143L)) */
+
if ((min_quarterword < min_halfword) || (max_quarterword > max_halfword))
bad = 13;
-/* if ((mem_min < 0)||(mem_max >= 262143L)||(-0 - mem_min > 262144L)) */
+
if ((mem_min < min_halfword) || (mem_max >= max_halfword) || (mem_bot - mem_min >= max_halfword))
bad = 14;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- if (mem_max > mem_top + mem_extra_high) /* not compile time */
- bad = 14; /* ha ha */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
-/* if ((0 < 0)||(font_max > 255)) */
- if ((0 < min_quarterword) || (font_max > max_quarterword)) /* 93/Dec/3 */
+
+ if (mem_max > mem_top + mem_extra_high)
+ bad = 14;
+
+ if ((0 < min_quarterword) || (font_max > max_quarterword))
bad = 15;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
#ifdef INCREASEFONTS
- if (font_max > 1024) /* 96/Jan/17 */
+ if (font_max > 1024)
#else
if (font_max > 256)
#endif
bad = 16;
-/* if ((save_size > 262143L)||(max_strings > 262143L)) */
+
if ((save_size > max_halfword) || (max_strings > max_halfword))
bad = 17;
+
if (buf_size > max_halfword)
bad = 18;
+
if (max_quarterword - min_quarterword < 255)
bad = 19;
-/* if cs_token_flag + undefined_control_sequence > max_halfword then bad <- 21;*/
-/* if ((hash_size + 4876) > 262143L)*/
-/* if ((hash_size + 4876) > max_halfword) */
- if ((hash_size + 4095 + 781) > max_halfword)
+
+ if (cs_token_flag + undefined_control_sequence > max_halfword)
bad = 21;
- if (format_default_length > PATHMAX)
+
+ if (format_default_length > file_name_size)
bad = 31;
-/* if (2 * 262143L < mem_top - mem_min) */
+
if (max_halfword < (mem_top - mem_min) / 2)
bad = 41;
+
if (bad > 0)
{
sprintf(log_line, "%s%s%ld\n", "Ouch---my internal constants have been clobbered!",
"---case ", (long) bad);
show_line(log_line, 1);
- if (! knuth_flag)
- bad_formator_pool(format_file, "the format file", "TEXFORMATS"); /* 96/Jan/17 */
- goto lab9999; // abort
+
+ goto lab9999;
}
+
initialize();
+
#ifdef INITEX
if (is_initex)
{
if (!get_strings_started())
- goto lab9999; // abort
+ goto lab9999;
+
init_prim();
init_str_ptr = str_ptr;
init_pool_ptr = pool_ptr;
- dateandtime(tex_time, day, month, year);
+ fix_date_and_time();
}
-#endif /* INITEX */
- ready_already = 314159L; /* magic number */
+#endif
+
+ ready_already = 314159L;
-lab1: /* get here directly if ready_already already set ... */
+lab1:
selector = term_only;
tally = 0;
term_offset = 0;
file_offset = 0;
show_line(tex_version, 0);
- sprintf(log_line, " (%s %s)", application, yandyversion);
+
+ {
+#ifdef _WIN32
+ #ifdef _WIN64
+ sprintf(log_line, " (%s %s/Windows 64bit)", application, yandyversion);
+ #else
+ sprintf(log_line, " (%s %s/Windows 32bit)", application, yandyversion);
+ #endif
+#else
+ sprintf(log_line, " (%s %s/Linux)", application, yandyversion);
+#endif
+ }
+
show_line(log_line, 0);
+
if (format_ident > 0)
slow_print(format_ident);
+
print_ln();
+
#ifndef _WINDOWS
fflush(stdout);
#endif
+
job_name = 0;
name_in_progress = false;
log_opened = false;
output_file_name = 0;
+
{
{
input_ptr = 0;
max_in_stack = 0;
in_open = 0;
- high_in_open = 0; /* max_in_open name already used 1999 Jan 17 */
+ high_in_open = 0;
open_parens = 0;
- max_open_parens = 0; /* max_open_parens */
+ max_open_parens = 0;
max_buf_stack = 0;
param_ptr = 0;
max_param_stack = 0;
+
#ifdef ALLOCATEBUFFER
-/* first = current_buf_size; */
- memset (buffer, 0, current_buf_size); /* redundant */
+ memset (buffer, 0, current_buf_size);
#else
-/* first = buf_size; */
- memset (buffer, 0, buf_size); /* redundant ? */
+ memset (buffer, 0, buf_size);
#endif
-/* do {
- buffer[first]= 0;
- decr(first);
- } while(!(first == 0)); */
- first = 0; /* 1999/Jan/22 */
+ first = 0;
scanner_status = 0;
- warning_index = 0; /* warning_index:=null; l.7068 */
+ warning_index = 0;
first = 1;
- cur_input.state_field = 33;
- cur_input.start_field = 1;
- cur_input.index_field = 0;
+ state = new_line;
+ start = 1;
+ index = 0;
line = 0;
cur_input.name_field = 0;
force_eof = false;
align_state = 1000000L;
+
if (!init_terminal())
- goto lab9999; // abort
- cur_input.limit_field = last;
+ goto lab9999;
+
+ limit = last;
first = last + 1;
}
-/* if ((format_ident == 0)||(buffer[cur_input.loc_field]== 38)) */
-/* For Windows NT, lets allow + instead of & for format specification */
+
if ((format_ident == 0) ||
- (buffer[cur_input.loc_field] == '&') ||
- (buffer[cur_input.loc_field] == '+'))
+ (buffer[loc] == '&') ||
+ (buffer[loc] == '+'))
{
if (format_ident != 0)
initialize();
+
if (!open_fmt_file ())
- goto lab9999; // abort
+ goto lab9999;
+
if (!load_fmt_file ())
{
+#ifdef COMPACTFORMAT
+ gzclose(gz_fmt_file);
+#else
w_close(fmt_file);
- goto lab9999; // abort
+#endif
+ goto lab9999;
}
+
+#ifdef COMPACTFORMAT
+ gzclose(gz_fmt_file);
+#else
w_close(fmt_file);
- while ((cur_input.loc_field < cur_input.limit_field) &&
- (buffer[cur_input.loc_field] == 32))
- incr(cur_input.loc_field);
- }
-#ifdef CHECKEQTB
- if (debug_flag)
- check_eqtb("after format"); /* debugging 94/Apr/5 */
#endif
+
+ while ((loc < limit) &&
+ (buffer[loc] == ' '))
+ incr(loc);
+ }
+
if ((end_line_char < 0) || (end_line_char > 255))
- decr(cur_input.limit_field);
+ decr(limit);
else
- buffer[cur_input.limit_field] = end_line_char;
- dateandtime(tex_time, day, month, year);
- magic_offset = str_start[886] - 9 * 16; /* following: */
-/* "0234000122*4000133**3**344*0400400*000000234000111*1111112341011" */
+ buffer[limit] = end_line_char;
+
+ fix_date_and_time();
+ magic_offset = str_start[886] - 9 * ord_noad;
+
if (interaction == batch_mode)
selector = no_print;
else
selector = term_only;
- if ((cur_input.loc_field < cur_input.limit_field) &&
- (eqtb[(hash_size + 1883) + buffer[cur_input.loc_field]].hh.v.RH != 0))
+ if ((loc < limit) &&
+ (cat_code(buffer[loc]) != escape))
start_input();
}
-/* show font TFMs frozen into format file */
-/* moved here after start_input to ensure the log file is open */
- if (show_tfm_flag && log_opened && font_ptr > 0) /* 98/Sep/28 */
+ if (show_tfm_flag && log_opened && font_ptr > 0)
show_frozen();
main_time = clock();
- history = 0;
+ history = spotless;
if (show_cs_names)
- print_cs_names(stdout, 0); /* 98/Mar/31 */
+ print_cs_names(stdout, 0);
- main_control(); /* read-eval-print loop :-) in tex8.c */
-
-// what if abort_flag is set now ?
+ main_control();
if (show_cs_names)
- print_cs_names(stdout, 1); /* 98/Mar/31 */
-
-// what if abort_flag is set now ?
+ print_cs_names(stdout, 1);
final_cleanup();
-
-// if (abort_flag) return -1;
-
close_files_and_terminate();
lab9999:
{
int code;
+
#ifndef _WINDOWS
fflush(stdout);
#endif
+
ready_already = 0;
+
if ((history != 0) && (history != 1))
code = 1;
else
code = 0;
-// now return instead of exit to allow cleanup in local.c
+
return code;
-// uexit(code);
}
-} /* end of texbody */
+}
#ifdef ALLOCATEMAIN
/* add a block of variable size node space below mem_bot */
-/* used in tex0.c, local.c, itex.c */
void add_variable_space(int size)
{
halfword p;
integer t;
if (mem_min == 0)
- t = mem_min; /* bottom of present block */
+ t = mem_min;
else
t = mem_min + 1;
mem_min = t - (size + 1); /* first word in new block - 1 */
-/* mem_min = mem_start; */ /* allocate all of it at once */
+
if (mem_min < mem_start) /* sanity test */
{
if (trace_flag)
- show_line("WARNING: mem_min < mem_start!\n", 0);
+ puts("WARNING: mem_min < mem_start!\n");
+
mem_min = mem_start;
}
- p = mem[rover + 1].hh.v.LH;
+
+ p = llink(rover);
q = mem_min + 1;
- mem[mem_min].hh.v.RH = 0; /* insert blank word below ??? */
- mem[mem_min].hh.v.LH = 0; /* insert blank word below ??? */
- mem[p + 1].hh.v.RH = q;
- mem[rover + 1].hh.v.LH = q;
- mem[q + 1].hh.v.RH = rover;
- mem[q + 1].hh.v.LH = p;
- mem[q].hh.v.RH = empty_flag;
- mem[q].hh.v.LH = t - q; /* block size */
+ link(mem_min) = 0; /* insert blank word below ??? */
+ info(mem_min) = 0; /* insert blank word below ??? */
+ rlink(p) = q;
+ llink(rover) = q;
+ rlink(q) = rover;
+ llink(q) = p;
+ link(q) = empty_flag;
+ info(q) = t - q; /* block size */
rover = q;
}
#endif
/**************************************************************************/
-/* All ini TeX code is here at end so can use same pragma optimize for it */
-/* Ini-TeX code is rarely needed/used so make it small rather than fast */
-
-#pragma optimize("t", off)
-#pragma optimize("s", on)
#ifdef INITEX
/* split out to allow sharing of code from do_initex and newpattern */
void reset_trie (void)
{
integer k;
+
for (k = - (integer) trie_op_size; k <= trie_op_size; k++)
trie_op_hash[k] = 0;
+
for (k = 0; k <= 255; k++)
trie_used[k] = min_trie_op;
+
max_op_used = min_trie_op;
trie_op_ptr = 0;
trie_not_ready = true;
for (z = 0; z <= hyphen_prime; z++)
{
hyph_word[z] = 0;
- hyph_list[z] = 0; /* hyph_list[z]:=null; l.18131 */
+ hyph_list[z] = 0;
}
+
hyph_count = 0;
}
/* split out to allow optimize for space, not time */
integer k;
/* hyph_pointer z; */
-/* -> 0164 */
for (k = mem_bot + 1; k <= lo_mem_stat_max; k++)
mem[k].cint = 0;
k = mem_bot;
- while(k <= lo_mem_stat_max)
+ while (k <= lo_mem_stat_max)
{
glue_ref_count(k) = 1;
stretch_order(k) = normal;
type(page_head) = glue_node;
subtype(page_head) = normal;
avail = 0; /* avail <- null p.164 */
- mem_end = mem_top; /* mem_end <- mem_top */
+ mem_end = mem_top;
hi_mem_min = hi_mem_stat_min;
- var_used = 20; /* var_used <- lo_mem_stat_max */
- dyn_used = 14; /* dyn_used <- hi_mem_stat_usage */
+ var_used = lo_mem_stat_max + 1 - mem_bot;
+ dyn_used = hi_mem_stat_usage;
eq_type(undefined_control_sequence) = undefined_cs;
equiv(undefined_control_sequence) = 0;
eq_level(undefined_control_sequence) = level_zero;
cs_count = 0;
if (trace_flag)
- show_line("initex cs_count = 0 ", 0); /* debugging */
+ puts("initex cs_count = 0 ");
eq_type(frozen_dont_expand) = dont_expand;
text(frozen_dont_expand) = 499; /* notexpanded */
font_glue[null_font] = 0;
font_params[null_font] = 7;
param_base[null_font] = -1;
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- reset_trie(); /* shared 93/Nov/26 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+ for (k = 0; k <= 6; k++)
+ font_info[k].cint = 0;
+
+ reset_trie();
text(frozen_protection) = 1184; /* "inaccessible" */
format_ident = 1251;
text(end_write) = 1290;
eq_type(end_write) = outer_call;
equiv(end_write) = 0;
}
-#endif /* INITEX */
+#endif
#ifdef INITEX
-/* starts string pool with strings for 256 chars and then reads tex.pool */
-/* adjusted to try both "tex.pool" and "tex.poo" 95/Feb/19 */
-/* I have added a texpool file, but I need merge the pool to the binary */
-/* lots of things updates the kpathsea sources -- Clerk Ma */
-
-bool get_strings_started (void)
+/* sec 0047 */
+boolean get_strings_started (void)
{
- register bool Result;
- unsigned char k/*, l*/;
- /* ASCII_code m, n;*/
+ integer k;
str_number g;
- /* integer a; */ /* not used */
- /*bool c;*/
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
- /*int flag;*/ /* 95/Feb/19 */
-/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
+
pool_ptr = 0;
str_ptr = 0;
str_start[0] = 0;
+ for (k = 0; k <= 255; k++)
{
- register integer for_end;
- k = 0;
- for_end = 255;
- if (k <= for_end)
- do {
- if (((k < ' ') || (k > '~')))
- {
- append_char('^');
- append_char('^');
- if (k < 64)
- append_char(k + 64);
- else
- if (k < 128)
- append_char(k - 64);
- else
- {
- append_lc_hex(k / 16);
- append_lc_hex(k % 16);
- }
- }
- else
- append_char(k);
- g = make_string();
- } while(k++ < for_end);
- }
-#ifdef STDPOOL
- vstrcpy((char *) name_of_file + 1, pool_name);
- name_of_file[0] = ' ';
- name_of_file[strlen(pool_name) + 1] = ' ';
- name_length = strlen(pool_name);
-/* if (a_open_in(pool_file, TEXPOOLPATH)) */
- flag = a_open_in(pool_file, TEXPOOLPATH);
- if (flag == 0) /* 95/Feb/19 */
- {
- pool_name [name_length - 1] = '\0'; /* `tex.pool' => `tex.poo' */
- vstrcpy((char *) name_of_file + 1, pool_name);
- name_of_file[0] = ' ';
- name_of_file[strlen(pool_name) + 1] = ' ';
- name_length = strlen(pool_name);
- flag = a_open_in(pool_file, TEXPOOLPATH);
- }
- if (flag)
- {
- c = false;
- do {
- {
- if (test_eof(pool_file))
- {
- show_line("! string pool file has no check sum.\n", 1);
- if (! knuth_flag)
- bad_formator_pool(string_file, "the pool file", "TEXPOOL");
- (void) a_close(pool_file);
- Result = false;
- return(Result);
- }
- read(pool_file, m);
- read(pool_file, n);
- if (m == '*') /* last line starts with * */
- {
- a = 0;
- k = 1;
- while (true) {
- if ((xord[n]< 48) || (xord[n]> 57))
- {
- show_line("! string pool file check sum doesn't have nine digits.\n", 1);
- if (!knuth_flag)
- bad_formator_pool(string_file, "the pool file", "TEXPOOL");
- (void) a_close(pool_file);
- Result = false;
- return(Result);
- }
- a = 10 * a + xord[n] - 48;
- if (k == 9)
- goto lab30;
- incr(k);
- read(pool_file, n);
- }
-/* tex.pool file check sum *367403084 */
-lab30:
- if (a != BEGINFMTCHECKSUM)
- {
- show_line("! string pool check sum doesn't match; tangle me again.\n", 1);
- if (!knuth_flag)
- bad_formator_pool(string_file, "the pool file", "TEXPOOL");
- (void) a_close(pool_file);
- Result = false;
- return(Result);
- }
- c = true;
- }
+ if (((k < ' ') || (k > '~')))
+ {
+ append_char('^');
+ append_char('^');
+
+ if (k < 64)
+ append_char(k + 64);
+ else
+ if (k < 128)
+ append_char(k - 64);
else
{
- if ((xord[m] < 48) || (xord[m] > 57) || (xord[n] < 48) || (xord[n] > 57))
- {
- show_line("! string pool line doesn't begin with two digits.\n", 1);
- if (! knuth_flag)
- bad_formator_pool(string_file, "the pool file", "TEXPOOL");
- (void) a_close(pool_file);
- Result = false;
- return(Result);
- }
- l = xord[m] * 10 + xord[n] - 48 * 11;
-#ifdef ALLOCATESTRING
-/* can freely extend memory, so we need not be paranoid - stringvacancies */
-/* if (pool_ptr + l + stringvacancies > current_pool_size)*/
- if (pool_ptr + l + stringmargin > current_pool_size)
- {
- if (trace_flag)
- show_line("String margin reallocation\n", 0);
-/* str_pool = realloc_str_pool (pool_ptr + l + stringvacancies */
- str_pool = realloc_str_pool (pool_ptr + l + stringmargin - current_pool_size + increment_pool_size);
- }
- if (pool_ptr + l + stringmargin > current_pool_size) /* 94/Jan/24 */
-#else
- if (pool_ptr + l + stringvacancies > pool_size)
-#endif
- {
- show_line("! You have to increase POOLSIZE.\n", 1);
- (void) a_close(pool_file);
- Result = false;
- return(Result);
- }
- {
- register integer for_end;
- k = 1;
- for_end = l;
- if (k <= for_end)
- do {
- if (eoln(pool_file))
- m = ' ';
- else read(pool_file, m);
- {
- str_pool[pool_ptr] = xord[m];
- incr(pool_ptr);
- }
- } while(k++ < for_end);
- }
- readln(pool_file); /* flush rest to end of file / end of line */
- g = make_string();
+ append_lc_hex(k / 16);
+ append_lc_hex(k % 16);
}
- }
- } while (!(c));
- (void) a_close(pool_file);
- Result = true;
- }
- else
- {
- sprintf(log_line, "! I can't read %s.\n", pool_name);
- show_line(log_line, 1);
- if (!knuth_flag)
- show_line(" (Was unable to find tex.poo or tex.pool)\n", 0); /* extra explain */
- Result = false;
- return(Result);
+ }
+ else
+ append_char(k);
+
+ g = make_string();
}
-#endif
- g = load_pool_strings(pool_size - stringvacancies);
+
+ g = load_pool_strings(pool_size - string_vacancies);
if (g == 0)
{
fprintf(stdout , "%s\n", "! You have to increase POOLSIZE." );
- Result = false;
- return Result;
+ return false;
}
- Result = true;
- return Result;
+ return true;
}
#endif /* INITEX */
#ifdef INITEX
+/* sec 0131 */
void sort_avail (void)
{
- halfword p, q, r;
- halfword old_rover;
+ pointer p, q, r;
+ pointer old_rover;
p = get_node(1073741824L); /* 2^30 merge adjacent free nodes */
p = rlink(rover);
rlink(rover) = empty_flag;
old_rover = rover;
- while (p != old_rover) {
+
+ while (p != old_rover)
+ {
if (p < rover)
{
q = p;
else
{
q = rover;
+
while (rlink(q) < p)
q = rlink(q);
+
r = rlink(p);
rlink(p) = rlink(q);
rlink(q) = p;
p = r;
}
}
+
p = rover;
- while (rlink(p) != empty_flag) {
+
+ while (rlink(p) != empty_flag)
+ {
llink(rlink(p)) = p;
p = rlink(p);
}
- mem[p + 1].hh.v.RH = rover;
+
+ rlink(p) = rover;
llink(rover) = p;
}
-#endif /* INITEX */
+#endif
#ifdef INITEX
-/*****************APTEX********************/
-str_number make_string_pool (char *s)
-{
- int slen = strlen(s);
-
- if (slen == 1)
- {
- return ((str_number)s[0]);
- }
- else
- {
- memcpy(str_pool + pool_ptr, s, slen);
- pool_ptr += slen;
- return (make_string());
- }
-}
-/*****************APTEX********************/
+/* sec 0264 */
void primitive_ (str_number s, quarterword c, halfword o)
{
pool_pointer k;
{
k = str_start[s];
l = str_start[s + 1] - k; /* small_number l */
+
for (j = 0; j <= l - 1; j++)
- {
buffer[j] = str_pool[k + j];
- }
+
cur_val = id_lookup(0, l);
flush_string();
-/* ********************** debugging only 96/Jan/20 should not happen */
+
#ifdef SHORTHASH
if (s > 65535L)
- show_line("ERROR: hash entry too large\n", 1);
+ puts("ERROR: hash entry too large\n");
#endif
- hash[cur_val].v.RH = s;
+
+ text(cur_val) = s;
}
- eqtb[cur_val].hh.b1 = 1;
- eqtb[cur_val].hh.b0 = c;
- eqtb[cur_val].hh.v.RH = o;
-}
-#endif /* INITEX */
-/* more weird constants ? page 394 */
+ eq_level(cur_val) = level_one;
+ eq_type(cur_val) = c;
+ equiv(cur_val) = o;
+}
+#endif
#ifdef INITEX
+/* sec 0944 */
trie_op_code new_trie_op_ (small_number d, small_number n, trie_op_code v)
{
- register trie_op_code Result;
integer h;
trie_op_code u;
integer l;
-/* the 313, 361 and 1009 are hard-wired constants here p.944 */
-/* begin h:=abs(n+313*d+361*v+1009*cur_lang) mod (trie_op_size+trie_op_size) */
- h = abs(toint(n) + 313 * toint(d) + 361 * toint(v) + 1009 * toint(cur_lang)) % (trie_op_size - neg_trie_op_size) + neg_trie_op_size;
- while (true) {
+
+ h = abs(n + 313 * d + 361 * v + 1009 * cur_lang) % (trie_op_size + trie_op_size) + neg_trie_op_size;
+
+ while (true)
+ {
l = trie_op_hash[h];
+
if (l == 0)
{
if (trie_op_ptr == trie_op_size)
{
- /* pattern memory ops - NOT DYNAMIC */
overflow("pattern memory ops", trie_op_size);
return 0; // abort_flag set
}
+
u = trie_used[cur_lang];
-/* if u=max_quarterword then ??? */
+
if (u == max_trie_op)
{
-/* overflow("pattern memory ops per language", max_quarterword-min_quarterword); ??? */
- /* pattern memory ops per language */
overflow("pattern memory ops per language", max_trie_op - min_trie_op);
return 0; // abort_flag set
}
+
incr(trie_op_ptr);
incr(u);
trie_used[cur_lang] = u;
+
if (u > max_op_used)
max_op_used = u;
+
hyf_distance[trie_op_ptr] = d;
hyf_num[trie_op_ptr] = n;
hyf_next[trie_op_ptr] = v;
trie_op_lang[trie_op_ptr] = cur_lang;
trie_op_hash[h] = trie_op_ptr;
trie_op_val[trie_op_ptr] = u;
- Result = u;
- return(Result);
+ return u;
}
+
if ((hyf_distance[l]== d) && (hyf_num[l]== n) && (hyf_next[l]== v) && (trie_op_lang[l]== cur_lang))
{
- Result = trie_op_val[l];
- return(Result);
+ return trie_op_val[l];
}
+
if (h > - (integer) trie_op_size)
decr(h);
else
h = trie_op_size;
}
-/* return Result; */ /* unreachable code */
}
-/* what are those horrible constants there ? page 395 */
+/* sec 0948 */
trie_pointer trie_node_ (trie_pointer p)
{
- register trie_pointer Result;
trie_pointer h;
trie_pointer q;
-/* the 1009, 2718, 3142 are hard-wired constants here (not hyphen_prime) */
- h = abs(toint(trie_c[p]) + 1009 * toint(trie_o[p]) +
- 2718 * toint(trie_l[p]) + 3142 * toint(trie_r[p])) % trie_size;
- while (true) {
+
+ /* the 1009, 2718, 3142 are hard-wired constants here (not hyphen_prime) */
+ /* compute hash value */
+ h = abs(trie_c[p] + 1009 * trie_o[p] + 2718 * trie_l[p] + 3142 * trie_r[p]) % trie_size;
+
+ while (true)
+ {
q = trie_hash[h];
+
if (q == 0)
{
trie_hash[h] = p;
- Result = p;
- return(Result);
+ return p;
}
+
if ((trie_c[q] == trie_c[p]) && (trie_o[q] == trie_o[p]) &&
- (trie_l[q]== trie_l[p]) && (trie_r[q]== trie_r[p]))
+ (trie_l[q] == trie_l[p]) && (trie_r[q] == trie_r[p]))
{
- Result = q;
- return(Result);
+ return q;
}
+
if (h > 0)
decr(h);
else
h = trie_size;
}
-/* return Result; */ /* unreachable code */
}
+/* sec 0949 */
trie_pointer compress_trie_ (trie_pointer p)
{
- register trie_pointer Result;
-
if (p == 0)
- Result = 0;
+ return 0;
else
{
trie_l[p] = compress_trie(trie_l[p]);
trie_r[p] = compress_trie(trie_r[p]);
- Result = trie_node(p);
+ return trie_node(p);
}
- return Result;
}
+/* sec 0953 */
void first_fit_ (trie_pointer p)
{
trie_pointer h;
c = trie_c[p];
z = trie_min[c];
- while (true) {
+
+ while (true)
+ {
h = z - c;
+
if (trie_max < h + 256)
{
if (trie_size <= h + 256)
{
- /* pattern memory - NOT DYNAMIC */
overflow("pattern memory", trie_size);
/* not dynamic ---- but can be set -h=... from command line in ini-TeX */
return; // abort_flag set
}
- do {
- incr(trie_max);
- trie_taken[trie_max] = false;
- trie_trl[trie_max] = trie_max + 1;
- trie_tro[trie_max] = trie_max - 1;
- } while (!(trie_max == h + 256));
+
+ do
+ {
+ incr(trie_max);
+ trie_taken[trie_max] = false;
+ trie_trl[trie_max] = trie_max + 1;
+ trie_tro[trie_max] = trie_max - 1;
+ }
+ while (!(trie_max == h + 256));
}
+
if (trie_taken[h])
goto lab45;
+
q = trie_r[p];
- while (q > 0) {
+
+ while (q > 0)
+ {
if (trie_trl[h + trie_c[q]] == 0)
goto lab45;
+
q = trie_r[q];
}
+
goto lab40;
lab45:
z = trie_trl[z];
trie_taken[h] = true; /* h may be used without ... */
trie_hash[p] = h;
q = p;
- do {
- z = h + trie_c[q];
- l = trie_tro[z];
- r = trie_trl[z];
- trie_tro[r] = l;
- trie_trl[l] = r;
- trie_trl[z] = 0;
- if (l < 256)
+
+ do
{
- if (z < 256)
- ll = z; /* short ll */
- else
- ll = 256;
- do {
- trie_min[l] = r;
- incr(l);
- } while (!(l == ll));
+ z = h + trie_c[q];
+ l = trie_tro[z];
+ r = trie_trl[z];
+ trie_tro[r] = l;
+ trie_trl[l] = r;
+ trie_trl[z] = 0;
+
+ if (l < 256)
+ {
+ if (z < 256)
+ ll = z; /* short ll */
+ else
+ ll = 256;
+
+ do
+ {
+ trie_min[l] = r;
+ incr(l);
+ }
+ while (!(l == ll));
+ }
+
+ q = trie_r[q];
}
- q = trie_r[q];
- } while (!(q == 0));
+ while (!(q == 0));
}
+/* sec 0957 */
void trie_pack_ (trie_pointer p)
{
trie_pointer q;
- do {
- q = trie_l[p];
- if ((q > 0) && (trie_hash[q]== 0))
+
+ do
{
- first_fit(q);
- trie_pack(q);
+ q = trie_l[p];
+
+ if ((q > 0) && (trie_hash[q]== 0))
+ {
+ first_fit(q);
+ trie_pack(q);
+ }
+
+ p = trie_r[p];
}
- p = trie_r[p];
- } while(!(p == 0));
+ while (!(p == 0));
}
+/* sec 0959 */
void trie_fix_ (trie_pointer p)
{
trie_pointer q;
trie_pointer z;
z = trie_hash[p];
- do {
- q = trie_l[p];
- c = trie_c[p];
- trie_trl[z + c] = trie_hash[q];
- trie_trc[z + c] = c;
- trie_tro[z + c] = trie_o[p];
- if (q > 0)
- trie_fix(q);
- p = trie_r[p];
- } while(!(p == 0));
+
+ do
+ {
+ q = trie_l[p];
+ c = trie_c[p];
+ trie_trl[z + c] = trie_hash[q];
+ trie_trc[z + c] = c;
+ trie_tro[z + c] = trie_o[p];
+
+ if (q > 0)
+ trie_fix(q);
+
+ p = trie_r[p];
+ }
+ while (!(p == 0));
}
+/* sec 0960 */
void new_patterns (void)
{
/* ******************************************************************* */
/* was small_number k, l; in 3.141 */
char k, l;
/* ******************************************************************* */
- bool digitsensed;
+ boolean digitsensed;
trie_op_code v;
trie_pointer p, q;
- bool firstchild;
+ boolean firstchild;
/* ASCII_code c; */
int c; /* 95/Jan/7 */
if (allow_patterns)
{
if (trace_flag)
- show_line("Resetting patterns\n", 0);
+ puts("Resetting patterns\n");
reset_trie(); /* RESET PATTERNS - 93/Nov/26 */
if (reset_exceptions)
{
if (trace_flag)
- show_line("Resetting exceptions\n", 0);
+ puts("Resetting exceptions\n");
reset_hyphen(); /* RESET HYPHENEXCEPTIONS - 93/Nov/26 */
}
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
if (trie_not_ready)
{
- if (language <= 0)
- cur_lang = 0;
- else if (language > 255)
- cur_lang = 0;
- else
- cur_lang = language;
+ set_cur_lang();
scan_left_brace();
k = 0;
hyf[0] = 0;
digitsensed = false;
- while (true) {
+
+ while (true)
+ {
get_x_token();
+
switch (cur_cmd)
{
- case 11:
- case 12:
- if (digitsensed || (cur_chr < 48) || (cur_chr > 57))
+ case letter:
+ case other_char:
+ if (digitsensed || (cur_chr < '0') || (cur_chr > '9'))
{
if (cur_chr == '.')
cur_chr = 0;
else
{
- cur_chr = eqtb[(hash_size + 2139) + cur_chr].hh.v.RH;
+ cur_chr = lc_code(cur_chr);
+
if (cur_chr == 0)
{
print_err("Nonletter");
error();
}
}
+
if (k < 63)
{
incr(k);
}
else if (k < 63)
{
- hyf[k] = cur_chr - 48;
+ hyf[k] = cur_chr - '0';
digitsensed = true;
}
break;
- case 10:
- case 2:
+ case spacer:
+ case right_brace:
{
if (k > 0)
{
if (hc[1] == 0)
hyf[0] = 0;
+
if (hc[k] == 0)
hyf[k] = 0;
+
l = k;
v = min_trie_op;
+
while (true) {
if (hyf[l]!= 0)
v = new_trie_op(k - l, hyf[l], v);
+
if (l > 0)
decr(l);
else
goto lab31;
}
lab31:
- ;
q = 0;
hc[0] = cur_lang;
+
while (l <= k) {
c = hc[l];
incr(l);
p = trie_l[q];
firstchild = true;
+
while ((p > 0) && (c > trie_c[p])) {
q = p;
p = trie_r[q];
firstchild = false;
}
+
if ((p == 0) || (c < trie_c[p]))
{
if (trie_ptr == trie_size)
/* not dynamic ---- but can be set -h=... from command line in ini-TeX */
return; // abort_flag set
}
+
incr(trie_ptr);
trie_r[trie_ptr] = p;
p = trie_ptr;
trie_l[p] = 0;
+
if (firstchild)
trie_l[q]= p;
else
trie_r[q]= p;
+
trie_c[p] = c;
trie_o[p] = min_trie_op;
}
q = p;
}
+
if (trie_o[q]!= min_trie_op)
{
print_err("Duplicate pattern");
help1("(See Appendix H.)");
error();
}
+
trie_o[q]= v;
}
- if (cur_cmd == 2)
+
+ if (cur_cmd == right_brace)
goto lab30;
+
k = 0;
hyf[0] = 0;
digitsensed = false;
print_esc("patterns");
help1("All patterns must be given before typesetting begins.");
error();
- mem[lig_trick].hh.v.RH = scan_toks(false, false);
+ link(garbage) = scan_toks(false, false);
flush_list(def_ref);
}
}
+/* sec 0966 */
void init_trie (void)
{
trie_pointer p;
integer j, k;
int t; /* 95/Jan/7 */
trie_pointer r, s;
- op_start[0]= - (integer) min_trie_op;
+
+ op_start[0] = - (integer) min_trie_op;
for (j = 1; j <= 255; j++)
{
op_start[j] = op_start[j - 1] + trie_used[j - 1];
}
+
for (j = 1; j <= trie_op_ptr; j++)
{
trie_op_hash[j] = op_start[trie_op_lang[j]] + trie_op_val[j];
}
+
for (j = 1; j <= trie_op_ptr; j++)
{
- while (trie_op_hash[j] > j) {
+ while (trie_op_hash[j] > j)
+ {
k = trie_op_hash[j];
t = hyf_distance[k];
hyf_distance[k] = hyf_distance[j];
trie_op_hash[k] = k;
}
}
+
for (p = 0; p <= trie_size; p++)
{
trie_hash[p] = 0;
}
+
trie_l[0] = compress_trie(trie_l[0]);
+
for (p = 0; p <= trie_ptr; p++)
{
trie_hash[p]= 0;
}
+
for (p = 0; p <= 255; p++)
{
trie_min[p] = p + 1;
}
+
trie_trl[0] = 1;
trie_max = 0;
+
if (trie_l[0] != 0)
{
first_fit(trie_l[0]);
trie_pack(trie_l[0]);
}
+
if (trie_l[0] == 0)
{
for (r = 0; r <= 256; r++)
{
trie_fix(trie_l[0]);
r = 0;
- do {
- s = trie_trl[r];
+
+ do
{
- trie_trl[r] = 0;
- trie_tro[r] = min_trie_op;
- trie_trc[r] = 0;
+ s = trie_trl[r];
+ {
+ trie_trl[r] = 0;
+ trie_tro[r] = min_trie_op;
+ trie_trc[r] = 0;
+ }
+
+ r = s;
}
- r = s;
- } while(!(r > trie_max));
+ while (!(r > trie_max));
}
+
trie_trc[0] = 63;
trie_not_ready = false;
}
#endif /* INITEX */
#ifdef INITEX
+/* sec 1302 */
void store_fmt_file (void)
{
integer j, k, l;
- halfword p, q;
+ pointer p, q;
integer x;
- if (!is_initex) /* redundant check 94/Feb/14 */
+ if (!is_initex)
{
- show_line("! \\dump is performed only by INITEX\n", 1);
+ puts("! \\dump is performed only by INITEX\n");
- if (! knuth_flag)
- show_line(" (Use -i on the command line)\n", 0);
+ if (!knuth_flag)
+ puts(" (Use -i on the command line)\n");
abort_flag++;
return;
if (save_ptr != 0)
{
print_err("You can't dump inside a group");
- help1("`{...\\dump}' is a no-no..");
+ help1("`{...\\dump}' is a no-no.");
succumb();
- } /* end of if save_ptr != 0 */
+ }
selector = new_string;
print_string(" (format=");
str_room(1);
format_ident = make_string();
- pack_job_name(780); /* .fmt */
- //pack_job_name(make_string_pool(".fmt"));
+ pack_job_name(".fmt");
- while(! w_open_out(fmt_file))
+ while (!w_open_out(fmt_file))
{
- prompt_file_name(1267, 780); /* format file name .fmt */
+ prompt_file_name("format file name", ".fmt");
}
print_nl("Beginning to dump on file ");
flush_string();
print_nl("");
slow_print(format_ident);
- dump_int(BEGINFMTCHECKSUM); /* magic FMT file start 4C 20 E6 15 hex */
+ dump_int(BEGINFMTCHECKSUM);
dump_int(mem_bot);
dump_int(mem_top);
dump_int(eqtb_size);
dump_int(hash_prime);
- dump_int(hyphen_prime); /* bkph */
-
+ dump_int(hyphen_prime);
dump_int(pool_ptr);
dump_int(str_ptr);
+
if (dumpthings(str_start[0], str_ptr + 1))
return;
+
if (dumpthings(str_pool[0], pool_ptr))
return;
+
print_ln();
print_int(str_ptr);
print_string(" strings of total length ");
p = 0;
q = rover;
x = 0;
- do {
- if (dumpthings(mem[p], q + 2 - p))
- return;
- x = x + q + 2 - p;
- var_used = var_used + q - p;
- p = q + mem[q].hh.v.LH;
- q = mem[q + 1].hh.v.RH;
- } while (!(q == rover));
+
+ do
+ {
+ if (dumpthings(mem[p], q + 2 - p))
+ return;
+
+ x = x + q + 2 - p;
+ var_used = var_used + q - p;
+ p = q + node_size(q);
+ q = rlink(q);
+ }
+ while (!(q == rover));
+
var_used = var_used + lo_mem_max - p;
dyn_used = mem_end + 1 - hi_mem_min;
+
if (dumpthings(mem[p], lo_mem_max + 1 - p))
return;
+
x = x + lo_mem_max + 1 - p;
dump_int(hi_mem_min);
- dump_int(avail);
+ dump_int(avail);
+
if (dumpthings(mem[hi_mem_min], mem_end + 1 - hi_mem_min))
return;
+
x = x + mem_end + 1 - hi_mem_min;
p = avail;
- while (p != 0) {
+
+ while (p != 0)
+ {
decr(dyn_used);
- p = mem[p].hh.v.RH;
+ p = mem[p].hh.rh;
}
+
dump_int(var_used);
dump_int(dyn_used);
print_ln();
print_int(dyn_used);
k = active_base;
- do {
- j = k;
- while (j < (int_base - 1)) {
- if ((equiv(j) == equiv(j + 1)) &&
+
+ do
+ {
+ j = k;
+
+ while (j < (int_base - 1))
+ {
+ if ((equiv(j) == equiv(j + 1)) &&
(eq_type(j) == eq_type(j + 1)) &&
(eq_level(j) == eq_level(j + 1)))
- goto lab41;
- incr(j);
- }
- l = (int_base);
- goto lab31;
+ goto lab41;
+ incr(j);
+ }
+
+ l = (int_base);
+ goto lab31;
lab41:
- incr(j);
- l = j;
- while (j < (int_base - 1)) {
- if ((equiv(j) != equiv(j + 1)) ||
+ incr(j);
+ l = j;
+ while (j < (int_base - 1))
+ {
+ if ((equiv(j) != equiv(j + 1)) ||
(eq_type(j) != eq_type(j + 1)) ||
(eq_level(j) != eq_level(j + 1)))
- goto lab31;
- incr(j);
- }
+ goto lab31;
+ incr(j);
+ }
lab31:
- dump_int(l - k);
- if (dumpthings(eqtb[k], l - k))
- return;
- k = j + 1;
- dump_int(k - l);
- } while (!(k == (int_base)));
-
- do {
- j = k;
- while (j < (eqtb_size)) {
- if (eqtb[j].cint == eqtb[j + 1].cint)
- goto lab42;
- incr(j);
+ dump_int(l - k);
+
+ if (dumpthings(eqtb[k], l - k))
+ return;
+
+ k = j + 1;
+ dump_int(k - l);
}
- l = (eqtb_size + 1);
- goto lab32;
+ while (!(k == (int_base)));
+
+ do
+ {
+ j = k;
+
+ while (j < (eqtb_size))
+ {
+ if (eqtb[j].cint == eqtb[j + 1].cint)
+ goto lab42;
+ incr(j);
+ }
+
+ l = (eqtb_size + 1);
+ goto lab32;
lab42:
- incr(j);
- l = j;
- while (j < (eqtb_size)) {
- if (eqtb[j].cint != eqtb[j + 1].cint)
- goto lab32;
incr(j);
- }
+ l = j;
+
+ while (j < (eqtb_size))
+ {
+ if (eqtb[j].cint != eqtb[j + 1].cint)
+ goto lab32;
+ incr(j);
+ }
lab32:
- dump_int(l - k);
- if (dumpthings(eqtb[k], l - k))
- return;
- k = j + 1;
- dump_int(k - l);
- } while (!(k > (eqtb_size)));
+ dump_int(l - k);
+
+ if (dumpthings(eqtb[k], l - k))
+ return;
+
+ k = j + 1;
+ dump_int(k - l);
+ }
+ while (!(k > (eqtb_size)));
dump_int(par_loc);
dump_int(write_loc);
if (trace_flag)
{
- /* debugging */
sprintf(log_line, "itex cs_count %d hash_size %d hash_extra %d hash_used %d",
cs_count, hash_size, hash_extra, hash_used);
show_line(log_line, 0);
for (p = hash_base; p <= hash_used; p++)
{
- if (hash[p].v.RH != 0)
+ if (text(p) != 0)
{
dump_int(p);
dump_hh(hash[p]);
if (trace_flag)
{
sprintf(log_line, "itex cs_count++ ");
- show_line(log_line, 0); /* debugging */
+ show_line(log_line, 0);
}
-
}
}
-/* ??? */
-/* for p <- hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]) */
- if (dumpthings(hash[hash_used + 1], (hash_size + 780) - hash_used))
+
+ if (dumpthings(hash[hash_used + 1], undefined_control_sequence - 1 - hash_used))
return;
+
dump_int(cs_count);
print_ln();
print_int(cs_count);
print_string(" multiletter control sequences");
dump_int(fmem_ptr);
+
{
if (dumpthings(font_info[0], fmem_ptr))
return;
-/* frozenfontptr = font_ptr; */ /* number of fonts frozen into format */
+
dump_int(font_ptr);
+
if (dumpthings(font_check[0], font_ptr + 1))
return;
+
if (dumpthings(font_size[0], font_ptr + 1))
return;
+
if (dumpthings(font_dsize[0], font_ptr + 1))
return;
+
if (dumpthings(font_params[0], font_ptr + 1))
return;
+
if (dumpthings(hyphen_char[0], font_ptr + 1))
return;
+
if (dumpthings(skew_char[0], font_ptr + 1))
return;
+
if (dumpthings(font_name[0], font_ptr + 1))
return;
+
if (dumpthings(font_area[0], font_ptr + 1))
return;
+
if (dumpthings(font_bc[0], font_ptr + 1))
return;
+
if (dumpthings(font_ec[0], font_ptr + 1))
return;
+
if (dumpthings(char_base[0], font_ptr + 1))
return;
+
if (dumpthings(width_base[0], font_ptr + 1))
return;
+
if (dumpthings(height_base[0], font_ptr + 1))
return;
+
if (dumpthings(depth_base[0], font_ptr + 1))
return;
+
if (dumpthings(italic_base[0], font_ptr + 1))
return;
+
if (dumpthings(lig_kern_base[0], font_ptr + 1))
return;
+
if (dumpthings(kern_base[0], font_ptr + 1))
return;
+
if (dumpthings(exten_base[0], font_ptr + 1))
return;
+
if (dumpthings(param_base[0], font_ptr + 1))
return;
+
if (dumpthings(font_glue[0], font_ptr + 1))
return;
+
if (dumpthings(bchar_label[0], font_ptr + 1))
return;
+
if (dumpthings(font_bchar[0], font_ptr + 1))
return;
+
if (dumpthings(font_false_bchar[0], font_ptr + 1))
return;
+
for (k = 0; k <= font_ptr; k++)
{
print_nl("\\font");
-/* print_esc(hash[(hash_size + 524) + k].v.RH); */
-/* print_esc(hash[(hash_size + hash_extra + 524) + k].v.RH); */
- print_esc("");print(hash[(hash_size + hash_extra + 524) + k].v.RH);
+ print_esc("");
+ print(font_id_text(k));
print_char('=');
print_file_name(font_name[k], font_area[k], 335);
+
if (font_size[k] != font_dsize[k])
{
print_string(" at ");
}
}
}
+
print_ln();
print_int(fmem_ptr - 7);
print_string(" words of font info for ");
print_int(font_ptr - 0);
print_string(" preloaded font");
+
if (font_ptr != 1)
print_char('s');
dump_int(hyph_count);
+
for (k = 0; k <= hyphen_prime; k++)
{
if (hyph_word[k]!= 0)
dump_int(hyph_list[k]);
}
}
+
print_ln();
print_int(hyph_count);
print_string(" hyphenation exception");
+
if (hyph_count != 1)
print_char('s');
+
if (trie_not_ready)
init_trie();
+
dump_int(trie_max);
+
if (dumpthings(trie_trl[0], trie_max + 1))
return;
+
if (dumpthings(trie_tro[0], trie_max + 1))
return;
+
if (dumpthings(trie_trc[0], trie_max + 1))
return;
+
dump_int(trie_op_ptr);
+
if (dumpthings(hyf_distance[1], trie_op_ptr))
return;
+
if (dumpthings(hyf_num[1], trie_op_ptr))
return;
+
if (dumpthings(hyf_next[1], trie_op_ptr))
return;
+
print_nl("Hyphenation trie of length ");
print_int(trie_max);
print_string(" has ");
print_int(trie_op_ptr);
print_string(" op");
+
if (trie_op_ptr != 1)
print_char('s');
+
print_string(" out of ");
print_int(trie_op_size);
+
for (k = 255; k >= 0; k--)
{
if (trie_used[k] > 0)
dump_int(trie_used[k]);
}
}
+
dump_int(interaction);
dump_int(format_ident);
- dump_int(ENDFMTCHECKSUM); /* magic checksum end of FMT file --- change ??? */
+ dump_int(ENDFMTCHECKSUM);
tracing_stats = 0;
+#ifdef COMPACTFORMAT
+ gzclose(gz_fmt_file);
+#else
w_close(fmt_file);
-} /* end of store_fmt_file */
-#endif /* INITEX */
+#endif
+}
+#endif
#ifdef INITEX
/* sec 01336 */
primitive("divide", divide, 0);
primitive("endcsname", end_cs_name, 0);
primitive("endgroup", end_group, 0);
- text(frozen_end_group) = 513;
+ text(frozen_end_group) = make_string_pool("endgroup");
eqtb[frozen_end_group] = eqtb[cur_val];
primitive("expandafter", expand_after, 0);
primitive("font", def_font, 0);
primitive("radical", radical, 0);
primitive("read", read_to_cs, 0);
primitive("relax", relax, 256);
- text(frozen_relax) = 532;
+ text(frozen_relax) = make_string_pool("relax");
eqtb[frozen_relax] = eqtb[cur_val];
primitive("setbox", set_box, 0);
primitive("the", the, 0);
primitive("iffalse", if_test, 15);
primitive("ifcase", if_test, 16);
primitive("fi", fi_or_else, 2);
- text(frozen_fi) = 770;
+ text(frozen_fi) = make_string_pool("fi");
eqtb[frozen_fi] = eqtb[cur_val];
primitive("or", fi_or_else, 4);
primitive("else", fi_or_else, 3);
eqtb[frozen_null_font] = eqtb[cur_val];
primitive("span", tab_mark, 256);
primitive("cr", car_ret, 257);
- text(frozen_cr) = 893; /* cr */
+ text(frozen_cr) = make_string_pool("cr");
eqtb[frozen_cr] = eqtb[cur_val];
primitive("crcr", car_ret, 258);
- text(frozen_end_template) = 895; /* endtemplate */
- text(frozen_endv) = 895; /* endtemplate */
+ text(frozen_end_template) = make_string_pool("endtemplate");
+ text(frozen_endv) = make_string_pool("endtemplate");
eq_type(frozen_endv) = endv;
equiv(frozen_endv) = null_list;
eq_level(frozen_endv) = level_one;
primitive("atopwithdelims", above, 5);
primitive("left", left_right, 30);
primitive("right", left_right, 31);
- text(frozen_right) = 871; /* right */
+ text(frozen_right) = make_string_pool("right");
eqtb[frozen_right] = eqtb[cur_val];
primitive("long", prefix, 1);
primitive("outer", prefix, 2);
primitive("skipdef", shorthand_def, 4);
primitive("muskipdef", shorthand_def, 5);
primitive("toksdef", shorthand_def, 6);
- primitive("catcode", def_code, (hash_size + 1883));
- primitive("mathcode", def_code, (hash_size + 2907));
- primitive("lccode", def_code, (hash_size + 2139));
- primitive("uccode", def_code, (hash_size + 2395));
- primitive("sfcode", def_code, (hash_size + 2651));
+ primitive("catcode", def_code, cat_code_base);
+ primitive("mathcode", def_code, math_code_base);
+ primitive("lccode", def_code, lc_code_base);
+ primitive("uccode", def_code, uc_code_base);
+ primitive("sfcode", def_code, sf_code_base);
primitive("delcode", def_code, (hash_size + 3474));
primitive("textfont", def_family, (hash_size + 1835));
primitive("scriptfont", def_family, (hash_size + 1851));
primitive("setlanguage", extension, 5);
no_new_control_sequence = true;
}
-#endif /* INITEX */
-
-#pragma optimize("s", off) /* 96/Sep/12 */
-#pragma optimize("t", on) /* 96/Sep/12 */
+#endif
\ No newline at end of file