From eee899f5da43574ecac091920101615a365a357e Mon Sep 17 00:00:00 2001 From: maqiyuan Date: Thu, 12 Jun 2014 04:19:54 +0800 Subject: [PATCH] PATH_MAX -> file_name_size undump macro is_char_node removed some macros in coerce.h show_line -> puts --- src/texsourc/Makefile.gcc | 2 +- src/texsourc/coerce.h | 47 ++-- src/texsourc/itex.c | 403 +++++++++-------------------- src/texsourc/local.c | 80 +++--- src/texsourc/makefile | 55 ++-- src/texsourc/openinou.c | 8 +- src/texsourc/subroute.c | 2 +- src/texsourc/tex0.c | 227 ++++++++++------ src/texsourc/tex1.c | 385 +++++++++++++-------------- src/texsourc/tex2.c | 526 ++++++++++++++++--------------------- src/texsourc/tex3.c | 546 +++++++++++++++++++-------------------- src/texsourc/tex4.c | 22 +- src/texsourc/tex5.c | 14 +- src/texsourc/tex6.c | 26 +- src/texsourc/tex7.c | 20 +- src/texsourc/tex8.c | 20 +- src/texsourc/tex9.c | 16 +- src/texsourc/texd.h | 205 ++------------- src/texsourc/texmf.h | 99 +++++++ src/texsourc/texmfmem.h | 69 +++++ src/texsourc/yandy_backend_pdf.c | 6 +- src/texsourc/yandy_macros.h | 170 ++++-------- src/texsourc/yandy_pool.c | 2 +- src/texsourc/yandytex.c | 60 +++-- src/texsourc/yandytex.h | 5 +- 25 files changed, 1376 insertions(+), 1639 deletions(-) create mode 100644 src/texsourc/texmf.h create mode 100644 src/texsourc/texmfmem.h diff --git a/src/texsourc/Makefile.gcc b/src/texsourc/Makefile.gcc index dc3e3f4..247e825 100644 --- a/src/texsourc/Makefile.gcc +++ b/src/texsourc/Makefile.gcc @@ -20,7 +20,7 @@ objects = yandytex.o itex.o openinou.o subroute.o local.o \ tex5.o tex6.o tex7.o tex8.o tex9.o \ yandy_pool.o md5.o yandy_backend_pdf.o -headers = yandytex.h texd.h coerce.h +headers = yandytex.h texd.h coerce.h texmf.h texmfmem.h yandytex: $(objects) $(CC) -o yandytex $(objects) $(LDFLAGS) diff --git a/src/texsourc/coerce.h b/src/texsourc/coerce.h index d52795e..bff03cb 100644 --- a/src/texsourc/coerce.h +++ b/src/texsourc/coerce.h @@ -27,10 +27,8 @@ void print_string_(unsigned char * s); #define print_string(s) print_string_((unsigned char *) s) void slow_print_(integer); #define slow_print(s) slow_print_((integer) (s)) -void print_nl_(const char *); -#define print_nl(s) print_nl_((const char *) (s)) -void print_esc_(const char *); -#define print_esc(s) print_esc_((const char *) (s)) +void print_nl(const char *); +void print_esc(const char *); void print_the_digs_(eight_bits); #define print_the_digs(k) print_the_digs_((eight_bits) (k)) void print_int_(integer); @@ -47,12 +45,11 @@ void print_write_whatsit_(str_number, pointer); #define print_write_whatsit(s, p) print_write_whatsit_((str_number) (s), (pointer) (p)) void jump_out(void); void error(void); -void fatal_error_(char *); -#define fatal_error(s) fatal_error_((char *) (s)) +void fatal_error(char *); void overflow_(char *, integer); #define overflow(s, n) overflow_((char *) (s), (integer) (n)) -void confusion_(char *); -#define confusion(s) confusion_((char *) (s)) +void confusion_(const char *); +#define confusion(s) confusion_((const char *) (s)) boolean init_terminal(void); str_number make_string(void); boolean str_eq_buf_(str_number, integer); @@ -116,22 +113,17 @@ pointer new_glue_(pointer); #define new_glue(q) new_glue_((pointer) (q)) pointer new_skip_param_(small_number); #define new_skip_param(n) new_skip_param_((small_number) (n)) -pointer new_kern_(scaled); -#define new_kern(w) new_kern_((scaled) (w)) -pointer new_penalty_(integer); -#define new_penalty(m) new_penalty_((integer) (m)) -void check_mem_(boolean); -#define check_mem(printlocs) check_mem_((boolean) (printlocs)) +pointer new_kern(scaled); +pointer new_penalty(integer); +void check_mem(boolean); void search_mem_(halfword); #define search_mem(p) search_mem_((halfword) (p)) void short_display_(integer); #define short_display(p) short_display_((integer) (p)) -void print_font_and_char_(integer); -#define print_font_and_char(p) print_font_and_char_((integer) (p)) +void print_font_and_char(integer); void print_mark_(integer); #define print_mark(p) print_mark_((integer) (p)) -void print_rule_dimen_(scaled); -#define print_rule_dimen(d) print_rule_dimen_((scaled) (d)) +void print_rule_dimen(scaled); void print_glue_(scaled, integer, char *); #define print_glue(d, order, s) print_glue_((scaled) (d), (integer) (order), (char *) (s)) void print_spec_(integer, char *); @@ -224,8 +216,7 @@ void get_x_token(void); void x_token(void); void scan_left_brace(void); void scan_optional_equals(void); -boolean scan_keyword_(const char *); -#define scan_keyword(s) scan_keyword_((const char *) (s)) +boolean scan_keyword(const char *); void mu_error(void); void scan_eight_bit_int(void); void scan_char_num(void); @@ -265,12 +256,12 @@ void pack_file_name_(str_number, str_number, str_number); void pack_buffered_name_(small_number, integer, integer); #define pack_buffered_name(n, a, b) pack_buffered_name_((small_number) (n), (integer) (a), (integer) (b)) str_number make_name_string(void); -str_number a_make_name_string_(alpha_file *); -#define a_make_name_string(f) a_make_name_string_((alpha_file *) &(f)) -str_number b_make_name_string_(byte_file *); -#define b_make_name_string(f) b_make_name_string_((byte_file *) &(f)) -str_number w_make_name_string_(word_file *); -#define w_make_name_string(f) w_make_name_string_((word_file *) &(f)) +str_number a_make_name_string_(void); +#define a_make_name_string(f) a_make_name_string_() +str_number b_make_name_string_(void); +#define b_make_name_string(f) b_make_name_string_() +str_number w_make_name_string_(void); +#define w_make_name_string(f) w_make_name_string_() void scan_file_name(void); void pack_job_name_(str_number); #define pack_job_name(s) pack_job_name_(make_string_pool((char*)s)) @@ -287,8 +278,8 @@ halfword new_character_(internal_font_number, eight_bits); void dvi_swap(void); void dvi_four_(integer); #define dvi_four(x) dvi_four_((integer) (x)) -void zdvipop(integer); -#define dvi_pop(l) zdvipop((integer) (l)) +void dvi_pop_(integer); +#define dvi_pop(l) dvi_pop_((integer) (l)) void dvi_font_def_(internal_font_number); #define dvi_font_def(f) dvi_font_def_((internal_font_number) (f)) void zmovement(scaled, eight_bits); diff --git a/src/texsourc/itex.c b/src/texsourc/itex.c index dc7a32d..d4797a2 100644 --- a/src/texsourc/itex.c +++ b/src/texsourc/itex.c @@ -109,7 +109,7 @@ void initialize (void) if (flag) { - show_line("Inverted mapping xord[] pairs:\n", 0); + puts("Inverted mapping xord[] pairs:\n"); for (k = 0; k < 256; k++) { @@ -312,14 +312,10 @@ void line_break_ (integer final_widow_penalty) 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; @@ -450,8 +446,8 @@ void line_break_ (integer final_widow_penalty) { if (trie_not_ready) init_trie(); - } /* bkph */ -#endif /* INITEX */ + } +#endif cur_lang = init_cur_lang; lhyf = init_l_hyf; @@ -482,9 +478,9 @@ void line_break_ (integer final_widow_penalty) 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; @@ -494,7 +490,7 @@ void line_break_ (integer final_widow_penalty) 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)) @@ -516,7 +512,7 @@ void line_break_ (integer final_widow_penalty) { 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); @@ -543,7 +539,7 @@ void line_break_ (integer final_widow_penalty) { while (true) { - if ((s >= hi_mem_min)) + if (is_char_node(s)) { c = character(s); hf = font(s); @@ -599,7 +595,7 @@ lab32: while (true) { - if ((s >= hi_mem_min)) + if (is_char_node(s)) { if (font(s) != hf) goto lab33; @@ -671,7 +667,7 @@ lab33:; while (true) { - if (!((s >= hi_mem_min))) + if (!(is_char_node(s))) switch(type(s)) { case ligature_node: @@ -704,7 +700,7 @@ lab31:; 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); @@ -730,7 +726,7 @@ lab31:; { 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))); @@ -758,7 +754,7 @@ lab31:; } s = link(s); } - while(!(s == 0)); + while (!(s == 0)); active_width[1] = active_width[1] + disc_width; try_break(hyphen_penalty, hyphenated); @@ -769,7 +765,7 @@ lab31:; 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))); @@ -812,7 +808,7 @@ lab31:; { 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); @@ -955,7 +951,7 @@ lab35:; final_pass = true; ++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) @@ -1017,7 +1013,7 @@ void prefixed_command (void) { get_x_token(); } - while(!((cur_cmd != spacer) && (cur_cmd != relax))); + while (!((cur_cmd != spacer) && (cur_cmd != relax))); if (cur_cmd <= max_non_prefixed_command) { @@ -1250,7 +1246,7 @@ void prefixed_command (void) { get_x_token(); } - while(!((cur_cmd != spacer) && (cur_cmd != relax))); + while (!((cur_cmd != spacer) && (cur_cmd != relax))); if (cur_cmd != left_brace) { @@ -1383,7 +1379,7 @@ void prefixed_command (void) scan_optional_equals(); scan_int(); - if (((cur_val < 0) && (p < del_code_base)) || (cur_val > n)) + if (((cur_val < 0) && (p < del_code_base)) ||(cur_val > n)) { print_err("Invalid code("); print_int(cur_val); @@ -1532,7 +1528,7 @@ void prefixed_command (void) { get_token(); } - while(!(cur_cmd == right_brace)); + while (!(cur_cmd == right_brace)); return; } @@ -1601,13 +1597,13 @@ boolean load_fmt_file (void) 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 */ @@ -1625,21 +1621,20 @@ boolean load_fmt_file (void) 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); /* 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 */ @@ -1650,13 +1645,13 @@ boolean load_fmt_file (void) #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) @@ -1677,7 +1672,7 @@ boolean load_fmt_file (void) { 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; @@ -1685,8 +1680,9 @@ boolean load_fmt_file (void) { undump_int(x); /* max_strings */ + if (x < 0) - goto lab6666; + goto lab_bad_fmt; #ifdef ALLOCATESTRING if (x > current_max_strings) @@ -1707,7 +1703,7 @@ boolean load_fmt_file (void) { 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; @@ -1721,26 +1717,8 @@ boolean load_fmt_file (void) 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; - } - + 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; @@ -1752,7 +1730,7 @@ boolean load_fmt_file (void) p = q + node_size(q); if ((p > lo_mem_max) || ((q >= rlink(q)) && (rlink(q) != rover))) - goto lab6666; + goto lab_bad_fmt; q = rlink(q); } @@ -1765,7 +1743,7 @@ boolean load_fmt_file (void) { /* 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; @@ -1776,27 +1754,11 @@ boolean load_fmt_file (void) 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; - } - - { - undump_int(x); - - if ((x < mem_bot) || (x > mem_top)) - goto lab6666; - else - avail = x; + node_size(q) = mem_bot - q; } + 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)) @@ -1812,7 +1774,7 @@ boolean load_fmt_file (void) undump_int(x); if ((x < 1) || (k + x > (eqtb_size + 1))) - goto lab6666; + goto lab_bad_fmt; if (undumpthings(eqtb[k], x)) return -1; @@ -1821,58 +1783,25 @@ boolean load_fmt_file (void) undump_int(x); if ((x < 0) || (k + x > (eqtb_size + 1))) - goto lab6666; + goto lab_bad_fmt; for (j = k; j <= k + x - 1; j++) - { eqtb[j] = eqtb[k - 1]; - } 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; - } + while (!(k > eqtb_size)); + undump(hash_base, frozen_control_sequence, par_loc); par_token = cs_token_flag + 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; - } + undump(hash_base, frozen_control_sequence, write_loc); + undump(hash_base, frozen_control_sequence, hash_used); p = hash_base - 1; 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]); } while (!(p == hash_used)); @@ -1892,7 +1821,7 @@ boolean load_fmt_file (void) undump_int(x); /* font_mem_size */ if (x < 7) - goto lab6666; + goto lab_bad_fmt; #ifdef ALLOCATEFONT if (trace_flag) @@ -1919,7 +1848,7 @@ boolean load_fmt_file (void) { 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; @@ -1933,13 +1862,13 @@ boolean load_fmt_file (void) 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; @@ -1980,9 +1909,6 @@ boolean load_fmt_file (void) if (undumpthings(char_base[0], font_ptr + 1)) return -1; - if (undumpthings(ctype_base[0], font_ptr + 1)) - return -1; - if (undumpthings(width_base[0], font_ptr + 1)) return -1; @@ -2057,46 +1983,14 @@ boolean load_fmt_file (void) } } #endif -/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -/* undump(0)(hyph_size)(hyph_count); */ - { - undump_int(x); - if ((x < 0) || (x > hyphen_prime)) - goto lab6666; - else - hyph_count = x; - } + undump(0, hyphen_prime, hyph_count); - /* undump hypenation exception tables p.1325 */ for (k = 1; k <= hyph_count; k++) { - { - 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; - } - - { - undump_int(x); - - if ((x < 0) || (x > max_halfword)) /* mem_top ? no p.1325 */ - goto lab6666; - else - hyph_list[j] = x; - } + undump(0, hyphen_prime, j); + undump(0, str_ptr, hyph_word[j]); + undump(0, max_halfword, hyph_list[j]); } #ifdef ALLOCATEHYPHEN @@ -2116,7 +2010,7 @@ boolean load_fmt_file (void) undump_int(x); if (x < 0) - goto lab6666; + goto lab_bad_fmt; #ifdef ALLOCATETRIES if (!is_initex) @@ -2130,15 +2024,17 @@ boolean load_fmt_file (void) { 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; @@ -2152,22 +2048,22 @@ boolean load_fmt_file (void) 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; @@ -2179,74 +2075,44 @@ boolean load_fmt_file (void) 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); + undump(0, k - 1, k); + undump(1, j, 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; - } #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; - - 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); if ((x != ENDFMTCHECKSUM) || feof(fmt_file)) - goto lab6666; + goto lab_bad_fmt; return true; -lab6666:; +lab_bad_fmt:; sprintf(log_line, "(Fatal format file error; I'm stymied)\n"); show_line(log_line, 1); @@ -2264,7 +2130,7 @@ void final_cleanup (void) while (input_ptr > 0) { - if (cur_input.state_field == 0) + if (state == 0) { end_token_list(); } @@ -2443,7 +2309,7 @@ int main_program (void) if (cs_token_flag + undefined_control_sequence > max_halfword) bad = 21; - if (format_default_length > PATH_MAX) + if (format_default_length > file_name_size) bad = 31; if (max_halfword < (mem_top - mem_min) / 2) @@ -2532,9 +2398,9 @@ lab1: scanner_status = 0; warning_index = 0; first = 1; - cur_input.state_field = new_line; - 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; @@ -2543,13 +2409,13 @@ lab1: if (!init_terminal()) goto lab9999; - cur_input.limit_field = last; + limit = last; first = last + 1; } if ((format_ident == 0) || - (buffer[cur_input.loc_field] == '&') || - (buffer[cur_input.loc_field] == '+')) + (buffer[loc] == '&') || + (buffer[loc] == '+')) { if (format_ident != 0) initialize(); @@ -2573,15 +2439,15 @@ lab1: w_close(fmt_file); #endif - while ((cur_input.loc_field < cur_input.limit_field) && - (buffer[cur_input.loc_field] == ' ')) - incr(cur_input.loc_field); + 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; + buffer[limit] = end_line_char; fix_date_and_time(); magic_offset = str_start[886] - 9 * ord_noad; @@ -2591,8 +2457,8 @@ lab1: else selector = term_only; - if ((cur_input.loc_field < cur_input.limit_field) && - (cat_code(buffer[cur_input.loc_field]) != escape)) + if ((loc < limit) && + (cat_code(buffer[loc]) != escape)) start_input(); } @@ -2650,7 +2516,7 @@ void add_variable_space(int size) 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; } @@ -2795,12 +2661,6 @@ void do_initex (void) cur_font = null_font; eq_type(cur_font_loc) = data; eq_level(cur_font_loc) = level_one; - cur_jfont = null_font; - eq_type(cur_jfont_loc) = data; - eq_level(cur_jfont_loc) = level_one; - cur_tfont = null_font; - eq_type(cur_tfont_loc) = data; - eq_level(cur_tfont_loc) = level_one; for (k = math_font_base; k <= math_font_base + 47; k++) eqtb[k] = eqtb[cur_font_loc]; @@ -2812,20 +2672,11 @@ void do_initex (void) for (k = cat_code_base; k <= int_base - 1; k++) eqtb[k] = eqtb[cat_code_base]; - eqtb[auto_spacing_code] = eqtb[cat_code_base]; - eqtb[auto_xspacing_code] = eqtb[cat_code_base]; - for (k = 0; k <= 255; k++) { cat_code(k) = other_char; - kcat_code(k) = other_char; math_code(k) = k; sf_code(k) = 1000; - auto_xsp_code(k) = 0; - inhibit_xsp_code(k) = 0; - inhibit_xsp_type(k) = 0; - kinsoku_code(k) = 0; - kinsoku_type(k) = 0; } cat_code(carriage_return) = car_ret; @@ -2873,7 +2724,7 @@ void do_initex (void) cs_count = 0; if (trace_flag) - show_line("initex cs_count = 0 ", 0); + puts("initex cs_count = 0 "); eq_type(frozen_dont_expand) = dont_expand; text(frozen_dont_expand) = 499; /* notexpanded */ @@ -2891,7 +2742,6 @@ void do_initex (void) font_ec[null_font] = 0; font_size[null_font] = 0; font_dsize[null_font] = 0; - ctype_base[null_font] = 0; char_base[null_font] = 0; width_base[null_font] = 0; height_base[null_font] = 0; @@ -3036,7 +2886,7 @@ void primitive_ (str_number s, quarterword c, halfword o) #ifdef SHORTHASH if (s > 65535L) - show_line("ERROR: hash entry too large\n", 1); + puts("ERROR: hash entry too large\n"); #endif text(cur_val) = s; @@ -3252,7 +3102,7 @@ void trie_pack_ (trie_pointer p) p = trie_r[p]; } - while(!(p == 0)); + while (!(p == 0)); } /* sec 0959 */ void trie_fix_ (trie_pointer p) @@ -3276,7 +3126,7 @@ void trie_fix_ (trie_pointer p) p = trie_r[p]; } - while(!(p == 0)); + while (!(p == 0)); } /* sec 0960 */ void new_patterns (void) @@ -3297,14 +3147,14 @@ void new_patterns (void) 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 */ } @@ -3553,7 +3403,7 @@ void init_trie (void) r = s; } - while(!(r > trie_max)); + while (!(r > trie_max)); } trie_trc[0] = 63; @@ -3571,10 +3421,10 @@ void store_fmt_file (void) 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; @@ -3607,7 +3457,7 @@ void store_fmt_file (void) format_ident = make_string(); pack_job_name(".fmt"); - while(!w_open_out(fmt_file)) + while (!w_open_out(fmt_file)) { prompt_file_name("format file name", ".fmt"); } @@ -3618,8 +3468,7 @@ void store_fmt_file (void) 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); @@ -3841,9 +3690,6 @@ lab32: if (dumpthings(char_base[0], font_ptr + 1)) return; - if (dumpthings(ctype_base[0], font_ptr + 1)) - return; - if (dumpthings(width_base[0], font_ptr + 1)) return; @@ -4008,8 +3854,6 @@ void init_prim (void) primitive("spaceskip", assign_glue, glue_base + space_skip_code); primitive("xspaceskip", assign_glue, glue_base + xspace_skip_code); primitive("parfillskip", assign_glue, glue_base + par_fill_skip_code); - primitive("kanjiskip", assign_glue, glue_base + kanji_skip_code); - primitive("xkanjiskip", assign_glue, glue_base + xkanji_skip_code); primitive("thinmuskip", assign_mu_glue, glue_base + thin_mu_skip_code); primitive("medmuskip", assign_mu_glue, glue_base + med_mu_skip_code); primitive("thickmuskip", assign_mu_glue, glue_base + thick_mu_skip_code); @@ -4072,8 +3916,6 @@ void init_prim (void) primitive("defaultskewchar", assign_int, int_base + default_skew_char_code); primitive("endlinechar", assign_int, int_base + end_line_char_code); primitive("newlinechar", assign_int, int_base + new_line_char_code); - primitive("jfam", assign_int, int_base + cur_jfam_code); - primitive("jcharwidowpenalty", assign_int, int_base + jchr_widow_penalty_code); primitive("language", assign_int, int_base + language_code); primitive("lefthyphenmin", assign_int, int_base + left_hyphen_min_code); primitive("righthyphenmin", assign_int, int_base + right_hyphen_min_code); @@ -4099,8 +3941,6 @@ void init_prim (void) primitive("hangindent", assign_dimen, dimen_base + hang_indent_code); primitive("hoffset", assign_dimen, dimen_base + h_offset_code); primitive("voffset", assign_dimen, dimen_base + v_offset_code); - primitive("tbaselineshift", assign_dimen, dimen_base + t_baseline_shift_code); - primitive("ybaselineshift", assign_dimen, dimen_base + y_baseline_shift_code); primitive("emergencystretch", assign_dimen, dimen_base + emergency_stretch_code); primitive(" ", ex_space, 0); primitive("/", ital_corr, 0); @@ -4119,8 +3959,6 @@ void init_prim (void) eqtb[frozen_end_group] = eqtb[cur_val]; primitive("expandafter", expand_after, 0); primitive("font", def_font, 0); - //primitive("jfont", def_jfont, 0); - //primitive("tfont", def_tfont, 0); primitive("fontdimen", assign_font_dimen, 0); primitive("halign", halign, 0); primitive("hrule", hrule, 0); @@ -4315,16 +4153,14 @@ void init_prim (void) primitive("muskipdef", shorthand_def, 5); primitive("toksdef", shorthand_def, 6); primitive("catcode", def_code, cat_code_base); - primitive("kcatcode", def_code, kcat_code_base); - primitive("xspcode", def_code, auto_xsp_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, del_code_base); - primitive("textfont", def_family, math_font_base); - primitive("scriptfont", def_family, math_font_base + script_size); - primitive("scriptscriptfont", def_family, math_font_base + script_script_size); + primitive("delcode", def_code, (hash_size + 3474)); + primitive("textfont", def_family, (hash_size + 1835)); + primitive("scriptfont", def_family, (hash_size + 1851)); + primitive("scriptscriptfont", def_family, (hash_size + 1867)); primitive("hyphenation", hyph_data, 0); primitive("patterns", hyph_data, 1); primitive("hyphenchar", assign_font_int, 0); @@ -4337,13 +4173,12 @@ void init_prim (void) primitive("closein", in_stream, 0); primitive("message", message, 0); primitive("errmessage", message, 1); - primitive("lowercase", case_shift, lc_code_base); - primitive("uppercase", case_shift, uc_code_base); - primitive("show", xray, show_code); - primitive("showbox", xray, show_box_code); - primitive("showthe", xray, show_the_code); - primitive("showlists", xray, show_lists); - //primitive("showmode", xray, show_mode); + primitive("lowercase", case_shift, (hash_size + 2139)); + primitive("uppercase", case_shift, (hash_size + 2395)); + primitive("show", xray, 0); + primitive("showbox", xray, 1); + primitive("showthe", xray, 2); + primitive("showlists", xray, 3); primitive("openout", extension, 0); primitive("write", extension, 1); write_loc = cur_val; diff --git a/src/texsourc/local.c b/src/texsourc/local.c index 2212dca..801ea83 100644 --- a/src/texsourc/local.c +++ b/src/texsourc/local.c @@ -125,7 +125,7 @@ void show_usage (void) show_line(log_line, 1); #ifndef _WINDOWS - uexit(1); // has this been setup yet ??? + uexit(EXIT_FAILURE); // has this been setup yet ??? #endif } @@ -205,7 +205,7 @@ void stampcopy (char *s) void read_xchr_sub (FILE * xchr_input) { - char buffer[PATH_MAX]; + char buffer[file_name_size]; int k, from, to, count = 0; char *s; @@ -285,7 +285,7 @@ char *replacement[MAXCHRS]; /* pointers to replacement strings */ void read_repl_sub (FILE * repl_input) { int k, n, m, chrs; - char buffer[PATH_MAX]; + char buffer[file_name_size]; char charname[128]; int charnum[10]; char *s, *t; @@ -293,7 +293,7 @@ void read_repl_sub (FILE * repl_input) memset(replacement, 0, MAXCHRS * sizeof(replacement[ 0])); - while (fgets(buffer, PATH_MAX, repl_input) != NULL) + while (fgets(buffer, file_name_size, repl_input) != NULL) { if (*buffer == '%' || *buffer == ';' || *buffer == '\n') continue; @@ -351,7 +351,7 @@ void read_repl_sub (FILE * repl_input) if (trace_flag) { - show_line("Key replacement table\n", 0); + puts("Key replacement table\n"); for (k = 0; k < MAXCHRS; k++) { @@ -369,7 +369,7 @@ void read_repl_sub (FILE * repl_input) int read_xchr_file (char *filename, int flag, char *argv[]) { FILE *pinput; - char infile[PATH_MAX]; + char infile[file_name_size]; char *s; if (filename == NULL) @@ -798,7 +798,7 @@ memory_word *allocate_main_memory (int size) if (main_memory != NULL) { if (trace_flag) - show_line("Reallocating initial memory allocation\n", 1); + puts("Reallocating initial memory allocation\n"); } mem_top = mem_bot + size; @@ -869,10 +869,10 @@ memory_word * realloc_main (int lo_size, int hi_size) if (is_initex) { - show_line("ERROR: Cannot extent main memory in iniTeX\n", 1); + puts("ERROR: Cannot extent main memory in iniTeX\n"); if (! knuth_flag) - show_line("Please use `-m=...' on command line\n", 0); + puts("Please use `-m=...' on command line\n"); return NULL; } @@ -970,7 +970,6 @@ memory_word * realloc_main (int lo_size, int 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) */ @@ -989,7 +988,7 @@ memory_word * realloc_main (int lo_size, int hi_size) if (current_mem_size != mem_max - mem_start) { - show_line("ERROR: Impossible Memory Error\n", 1); + puts("ERROR: Impossible Memory Error\n"); } if (mem_start != 0) @@ -1735,16 +1734,15 @@ int allocate_memory (void) current_pool_size = 0; str_start = NULL; current_max_strings = 0; -/* need to create space because iniTeX writes in before reading pool file */ -/* for a start, puts in strings for 256 characters */ + /* maybe taylor allocations to actual pool file 1300 strings 27000 bytes ? */ if (is_initex) { if (trace_flag) - show_line("ini TeX pool and string allocation\n", 0); + puts("ini TeX pool and string allocation\n"); - str_pool = realloc_str_pool (initial_pool_size); - str_start = realloc_str_start (initial_max_strings); + str_pool = realloc_str_pool(initial_pool_size); + str_start = realloc_str_start(initial_max_strings); } #endif @@ -1829,7 +1827,7 @@ int free_memory (void) unsigned int heap_total = 0; if (trace_flag) - show_line("free_memory ", 0); + puts("free_memory "); if (verbose_flag || trace_flag) show_maximums(stdout); @@ -1849,7 +1847,7 @@ int free_memory (void) } if (trace_flag) - show_line("Freeing memory again\n", 0); + puts("Freeing memory again\n"); /* only free memory if safe ... additional check */ #ifdef ALLOCATEINI @@ -2129,7 +2127,7 @@ void check_fixed_align (int flag) { if (test_align ((int) &mem_top, 4, "FIXED ALIGNMENT")) { - show_line("PLEASE RECOMPILE ME!\n", 1); + puts("PLEASE RECOMPILE ME!\n"); } #ifdef CHECKALIGNMENT @@ -2256,7 +2254,7 @@ void check_fixed_align (int flag) void check_alloc_align (int flag) { if (test_align ((int) eqtb, sizeof(eqtb[0]), "ALLOCATED ALIGNMENT")) - show_line("PLEASE RECOMPILE ME!\n", 1); + puts("PLEASE RECOMPILE ME!\n"); #ifdef CHECKALIGNMENT if (!flag) @@ -2378,7 +2376,6 @@ void knuthify (void) ignore_frozen = false; suppress_f_ligs = false; full_file_name_flag = false; - save_strings_flag = false; knuth_flag = true; /* so other code can know about this */ } @@ -2507,10 +2504,6 @@ int analyze_flag (int c, char *optarg) case 'z': full_file_name_flag = false; // 00 Jun 18 break; - case 'X': - save_strings_flag = false; // 00 Aug 15 - break; -/* following are unannounced options */ /* some may be recycled ... */ case 't': trace_flag = true; break; @@ -2757,7 +2750,7 @@ int read_command_line (int ac, char **av) if (read_xchr_file(repl_file, 1, av)) { if (trace_flag) - show_line("KEY REPLACE ON\n", 0); + puts("KEY REPLACE ON\n"); key_replace = true; } @@ -2768,7 +2761,7 @@ int read_command_line (int ac, char **av) if (read_xchr_file(xchr_file, 0, av)) { if (trace_flag) - show_line("NON ASCII ON\n", 0); + puts("NON ASCII ON\n"); non_ascii = true; } @@ -2812,10 +2805,9 @@ int init_commands (int ac, char **av) show_line_break_stats = true; /* show line break statistics 96/Feb/8 */ show_fonts_used = true; /* show fonts used in LOG file 97/Dec/24 */ allow_quoted_names = true; /* allow quoted names with spaces 98/Mar/15 */ - show_cs_names = false; /* don't show csnames on start 98/Mar/31 */ + show_cs_names = false; knuth_flag = false; /* allow extensions to TeX */ full_file_name_flag = true; /* new default 2000 June 18 */ - save_strings_flag = true; errout = stdout; /* as opposed to stderr say --- used ??? */ abort_flag = 0; // not yet hooked up ??? err_level = 0; // not yet hooked up ??? @@ -2872,7 +2864,7 @@ void initial_memory (void) #if defined(ALLOCATEHIGH) || defined(ALLOCATELOW) if (mem_extra_high != 0 || mem_extra_low != 0) { - show_line("ERROR: Cannot extend main memory in iniTeX\n", 1); + puts("ERROR: Cannot extend main memory in iniTeX\n"); mem_extra_high = 0; mem_extra_low = 0; } #endif @@ -2881,13 +2873,13 @@ void initial_memory (void) { if (mem_initex != 0) { - show_line("ERROR: Can only set initial main memory size in iniTeX\n", 1); + puts("ERROR: Can only set initial main memory size in iniTeX\n"); mem_initex = 0; } if (trie_size != 0) { - show_line("ERROR: Need only set hyphenation trie size in iniTeX\n", 1); + puts("ERROR: Need only set hyphenation trie size in iniTeX\n"); /* trie_size = 0; */ } } @@ -2908,7 +2900,7 @@ void initial_memory (void) if (mem_initex > 2048L * 1024L) /* extend main memory by 16 mega byte! */ { - show_line("WARNING: There may be no benefit to asking for so much memory\n", 0); + puts("WARNING: There may be no benefit to asking for so much memory\n"); /* mem_initex = 2048 * 1024; */ } @@ -2918,7 +2910,7 @@ void initial_memory (void) if (new_hyphen_prime > 0) { if (! is_initex) - show_line("ERROR: Can only set hyphen prime in iniTeX\n", 1); + puts("ERROR: Can only set hyphen prime in iniTeX\n"); else { if (new_hyphen_prime % 2 == 0) @@ -2993,7 +2985,7 @@ void hidetwiddle (char *name) void deslash_all (int ac, char **av) { - char buffer[PATH_MAX]; + char buffer[file_name_size]; char *s; if ((s = grabenv("TEXDVI")) != NULL) @@ -3193,7 +3185,7 @@ int main_init (int ac, char **av) closed_already = 0; if (trace_flag) - show_line("Entering init (local.c)\n", 0); + puts("Entering init (local.c)\n"); probe_memory(); /* show top address */ ini_max_address = max_address; /* initial max address */ @@ -3206,9 +3198,7 @@ int main_init (int ac, char **av) no_interrupts = 0; if (format_spec && mem_spec_flag) - { - show_line("WARNING: Cannot change initial main memory size when format specified", 1); - } + puts("WARNING: Cannot change initial main memory size when format specified"); if (allocate_memory() != 0) return -1; @@ -3278,21 +3268,21 @@ int endit (int flag) if (verbose_flag) { - show_line("Total ", 0); + puts("Total "); show_inter_val(finish_time - start_time); - show_line(" sec (", 0); + puts(" sec ("); show_inter_val(main_time - start_time); - show_line(" format load + ", 0); + puts(" format load + "); show_inter_val(finish_time - main_time); - show_line(" processing) ", 0); + puts(" processing) "); if (total_pages > 0) { show_inter_val((finish_time - main_time) / total_pages); - show_line(" sec per page.", 0); + puts(" sec per page."); } - show_line("\n", 0); + puts("\n"); } return flag; diff --git a/src/texsourc/makefile b/src/texsourc/makefile index f88c766..3bd81ce 100644 --- a/src/texsourc/makefile +++ b/src/texsourc/makefile @@ -9,11 +9,31 @@ CC = cl LINK = link RC = rc +# -Gf saves about 7k bytes in EXE file + +# For production (-Bd show compiler passes) +# ASSUMING WE WORK WITH MS COMPILER AND LINKER ONLY use -Gy and -Gf +# CFLAGS=-c -DDOS -DMSDOS -DPHARLAP -DTeX -DMYDEBUG -Ilib -Ox -Gy -Gf -W3 +# CFLAGS=-c -DDOS -DMSDOS -DPHARLAP -DTeX -DMYDEBUG -Ilib -YX -Ox -Ge -Gy -Gf -W4 +# Release version +# CFLAGS=/c /Ge /Gy /Gf /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG /Ilib /YX CFLAGS=/nologo /c /MT /GF /Gy /Ox /W4 /DMSDOS /DTeX /DPHARLAP /DNDEBUG \ /I"kpathsea" /I"libharu/include" /I"libharu/win32/include" /I"zlib" \ - /I"libmd5" /I"libtoua/ptexenc" + /I"libmd5" +# Debugging version +# CFLAGS=/c /Ge /Gy /Gf /Od /Zi /W4 /DMSDOS /DTeX /DPHARLAP /Ilib /YX +# NOTE: -Ox => -Ogityb1 -Gs + +# Link with MS LINK +# LFLAGS=@yandytex.nt /MAP lib\libdos.lib +# Release version +# LFLAGS=/MAP lib\libdos.lib LFLAGS=/NOLOGO /MAP +# /MACHINE:X86 +# debugging version +# LFLAGS=@yandytex.nt /MAP /DEBUG /PDB:yandytex.pdb lib\libdos.lib +# LFLAGS=/MAP /DEBUG /PDB:yandytex.pdb objs = yandytex.obj itex.obj openinou.obj subroute.obj local.obj \ tex0.obj tex1.obj tex2.obj tex3.obj tex4.obj \ @@ -29,7 +49,6 @@ yandytex.exe: $(objs) kpathsea\kpathsea.lib libharu\libhpdf.lib libpng\libpng.lib zlib\zlib.lib del ..\yandy\bin\yandytex.exe copy yandytex.exe ..\yandy\bin\yandytex.exe - # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### yandy_backend_pdf.obj: yandy_backend_pdf.c $(CC) $(CFLAGS) yandy_backend_pdf.c @@ -41,59 +60,59 @@ yandytex.res: yandytex.rc rc yandytex.rc yandytex.obj: yandytex.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h $(CC) /DINITEX /DINI $(CFLAGS) yandytex.c itex.obj: itex.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h $(CC) /DINITEX $(CFLAGS) itex.c openinou.obj: openinou.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h $(CC) $(CFLAGS) openinou.c subroute.obj: subroute.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h $(CC) $(CFLAGS) subroute.c local.obj: local.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h $(CC) /DINITEX $(CFLAGS) local.c # NOTE: cannot compile tex5.c and tex6.c with full optimizations ... tex0.obj: tex0.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex1.obj: tex1.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex2.obj: tex2.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex3.obj: tex3.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex4.obj: tex4.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex5.obj: tex5.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex6.obj: tex6.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex7.obj: tex7.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex8.obj: tex8.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h tex9.obj: tex9.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h yandy_pool.obj: yandy_pool.c \ - texd.h coerce.h yandy_macros.h + texd.h texmf.h texmfmem.h coerce.h yandy_macros.h .SUFFIXES: .SUFFIXES: .obj .c diff --git a/src/texsourc/openinou.c b/src/texsourc/openinou.c index 335c220..8f04ed5 100644 --- a/src/texsourc/openinou.c +++ b/src/texsourc/openinou.c @@ -28,7 +28,7 @@ #define BUILDNAMEDIRECT -extern int shorten_file_name; /* in local.c bkph */ +extern int shorten_file_name; #ifdef FUNNY_CORE_DUMP extern void funny_core_dump(void); @@ -340,12 +340,12 @@ extern char * pdf_directory; int check_fclose (FILE * f) { if (f == NULL) - return 0; // sanity check + return 0; if (ferror(f) || fclose (f)) { perrormod("\n! I/O Error"); - uexit (1); + uexit(EXIT_FAILURE); } return 0; @@ -399,7 +399,7 @@ boolean open_output (FILE **f, char *fopen_mode) if (temp_dir != NULL) { #ifdef BUILDNAMEDIRECT - unsigned char temp_name[PATH_MAX]; + unsigned char temp_name[file_name_size]; xconcat3((char *) temp_name, temp_dir, PATH_SEP_STRING, (char *) name_of_file + 1); #else string temp_name = concat3 (temp_dir, PATH_SEP_STRING, name_of_file + 1); diff --git a/src/texsourc/subroute.c b/src/texsourc/subroute.c index 2efc5ab..fd76055 100644 --- a/src/texsourc/subroute.c +++ b/src/texsourc/subroute.c @@ -39,7 +39,7 @@ void uexit (int unix_code) if (jump_used) { - show_line("Jump Buffer already used\n", 1); + puts("Jump Buffer already used\n"); exit(1); } diff --git a/src/texsourc/tex0.c b/src/texsourc/tex0.c index aed2ea1..64af5a1 100644 --- a/src/texsourc/tex0.c +++ b/src/texsourc/tex0.c @@ -19,12 +19,7 @@ #include "texd.h" -/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -INLINE void pack_cur_name(void) -{ - pack_file_name(cur_name, cur_area, cur_ext); -} -INLINE void prompt_input(const char *s) +INLINE void prompt_input(const char * s) { print_string(s); term_input(); @@ -70,7 +65,7 @@ INLINE void dvi_out_(ASCII_code op) if (dvi_ptr == dvi_limit) dvi_swap(); } -INLINE void succumb(void) +INLINE void succumb (void) { if (interaction == error_stop_mode) interaction = scroll_mode; @@ -88,30 +83,30 @@ INLINE void succumb(void) history = 3; jump_out(); } -INLINE void flush_string(void) +INLINE void flush_string (void) { decr(str_ptr); pool_ptr = str_start[str_ptr]; } -INLINE void append_char(ASCII_code c) +INLINE void append_char (ASCII_code c) { str_pool[pool_ptr] = c; incr(pool_ptr); } -INLINE void append_lc_hex(ASCII_code c) +INLINE void append_lc_hex (ASCII_code c) { if (c < 10) append_char(c + '0'); else append_char(c - 10 + 'a'); } -INLINE void print_err(const char * s) +INLINE void print_err (const char * s) { if (interaction == error_stop_mode); print_nl("! "); print_string(s); } -INLINE void tex_help(unsigned int n, ...) +INLINE void tex_help (unsigned int n, ...) { int i; va_list help_arg; @@ -127,7 +122,7 @@ INLINE void tex_help(unsigned int n, ...) va_end(help_arg); } -INLINE void str_room_(int val) +INLINE void str_room_ (int val) { #ifdef ALLOCATESTRING if (pool_ptr + val > current_pool_size) @@ -144,7 +139,7 @@ INLINE void str_room_(int val) } #endif } -INLINE void tail_append_(pointer val) +INLINE void tail_append_ (pointer val) { link(tail) = val; tail = link(tail); @@ -199,9 +194,9 @@ void print_char_ (ASCII_code s) switch (selector) { case term_and_log: - (void) show_char(Xchr(s)); + (void) show_char(xchr[s]); incr(term_offset); - (void) putc(Xchr(s), log_file); + (void) putc(xchr[s], log_file); incr(file_offset); if (term_offset == max_print_line) @@ -219,7 +214,7 @@ void print_char_ (ASCII_code s) break; case log_only: - (void) putc(Xchr(s), log_file); + (void) putc(xchr[s], log_file); incr(file_offset); if (file_offset == max_print_line) @@ -228,7 +223,7 @@ void print_char_ (ASCII_code s) break; case term_only: - (void) show_char(Xchr(s)); + (void) show_char(xchr[s]); incr(term_offset); if (term_offset == max_print_line) @@ -267,7 +262,7 @@ void print_char_ (ASCII_code s) break; default: - (void) putc(Xchr(s), write_file[selector]); + (void) putc(xchr[s], write_file[selector]); break; } @@ -381,7 +376,7 @@ void slow_print_ (integer s) } } /* sec 0062 */ -void print_nl_ (const char * s) +void print_nl (const char * s) { if (((term_offset > 0) && (odd(selector))) || ((file_offset > 0) && (selector >= log_only))) @@ -390,7 +385,7 @@ void print_nl_ (const char * s) print_string(s); } /* sec 0063 */ -void print_esc_ (const char * s) +void print_esc (const char * s) { integer c; @@ -553,7 +548,7 @@ void jump_out (void) ready_already = 0; if (trace_flag) - show_line("EXITING at JUMPOUT\n", 0); + puts("EXITING at JUMPOUT\n"); if ((history != 0) && (history != 1)) code = 1; @@ -687,16 +682,16 @@ lab22: if (last > first + 1) { - cur_input.loc_field = first + 1; + loc = first + 1; buffer[first] = 32; } else { prompt_input("insert>"); - cur_input.loc_field = first; + loc = first; } first = last; - cur_input.limit_field = last - 1; + limit = last - 1; return; } break; @@ -756,7 +751,7 @@ lab22: print_nl("H for help, X to quit."); } - } /* end of while(true) loop */ + } /* end of while (true) loop */ incr(error_count); @@ -775,7 +770,7 @@ lab22: print_ln(); give_err_help(); } - else while(help_ptr > 0) + else while (help_ptr > 0) { decr(help_ptr); print_nl(help_line[help_ptr] == NULL ? "" : help_line[help_ptr]); @@ -789,7 +784,7 @@ lab22: print_ln(); } /* sec 0093 */ -void fatal_error_(char * s) +void fatal_error(char * s) { normalize_selector(); print_err("Emergency stop"); @@ -810,12 +805,12 @@ void overflow_(char * s, integer n) if (!knuth_flag) { - if (!strcmp(s, "pattern memory") && n == trie_size) + if (!strcmp(s, "pattern memory") && (n == trie_size)) { sprintf(log_line, "\n (Maybe use -h=... on command line in ini-TeX)\n"); show_line(log_line, 0); } - else if (!strcmp(s, "exception dictionary") && n == hyphen_prime) + else if (!strcmp(s, "exception dictionary") && (n == hyphen_prime)) { sprintf(log_line, "\n (Maybe use -e=... on command line in ini-TeX)\n"); show_line(log_line, 0); @@ -825,7 +820,7 @@ void overflow_(char * s, integer n) succumb(); } /* sec 0095 */ -void confusion_(char * s) +void confusion_(const char * s) { normalize_selector(); @@ -854,41 +849,35 @@ boolean init_terminal (void) if (last > first) { - cur_input.loc_field = first; + loc = first; - while((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' ')) - incr(cur_input.loc_field); // step over initial white space + while ((loc < last) && (buffer[loc]== ' ')) + incr(loc); // step over initial white space - if (cur_input.loc_field < last) + if (loc < last) return true; } // failed to find input file name while (true) { -#ifdef _WINDOWS - flag = ConsoleInput("**", "Please type a file name or a control sequence\r\n(or ^z to exit)", (char *) &buffer[first]); - last = first + strlen((char *) &buffer[first]); /* -1 ? */ -// may need to be more elaborate see input_line in texmf.c -#else - (void) fputs("**", stdout); + fputs("**", stdout); fflush(stdout); flag = input_ln(stdin, true); -#endif if (!flag) { show_char('\n'); - show_line("! End of file on the terminal... why?\n", 1); + puts("! End of file on the terminal... why?\n"); return false; } - cur_input.loc_field = first; + loc = first; - while ((cur_input.loc_field < last) && (buffer[cur_input.loc_field]== ' ')) - incr(cur_input.loc_field); // step over intial white space + while ((loc < last) && (buffer[loc]== ' ')) + incr(loc); // step over intial white space - if (cur_input.loc_field < last) + if (loc < last) return true; sprintf(log_line, "%s\n", "Please type the name of your input file."); @@ -1049,31 +1038,133 @@ void print_current_string (void) incr(j); } } + +int stringlength (int str_ptr) +{ + return (str_start[str_ptr + 1] - str_start[str_ptr]) + 2; +} + +char * add_string (char *s, char * str_string) +{ + int n; + + n = strlen(str_string); + memcpy(s, &str_string, n); + s += n; + strcpy(s, "\r\n"); + s += 2; + + return s; +} + +int addextrahelp = 1; + +// make one long \r\n separated string out of help lines +// str_pool is packed_ASCII_code * + +char * make_up_help_string (int nhelplines) +{ + char * helpstring, *s; + int k, nlen = 0; + +// get length of help for this specific message + for (k = nhelplines - 1; k >= 0; k--) + { + nlen += strlen(help_line[k]); + } + + nlen += 2; // for blank line separator: "\r\n" + + if (addextrahelp) + { + nlen += stringlength(265); + nlen += stringlength(266); + nlen += stringlength(267); + + if (base_ptr > 0) + nlen += stringlength(268); + + if (deletions_allowed) + nlen += stringlength(269); + + nlen += stringlength(270); + } + + helpstring = (char *) malloc(nlen + 1); // +1 = '\0' + s = helpstring; + + for (k = nhelplines-1; k >= 0; k--) + { + s = add_string(s, help_line[k]); + } + + if (addextrahelp) + { + strcpy(s, "\r\n"); + s += 2; + s = add_string(s, "Type to proceed, S to scroll future error messages,"); + s = add_string(s, "R to run without stopping, Q to run quietly,"); + s = add_string(s, "I to insert something, "); + + if (base_ptr > 0) + s = add_string(s, "E to edit your file, "); + + if (deletions_allowed) + s = add_string(s, "1 or ... or 9 to ignore the next 1 to 9 tokens of input,"); + + s = add_string(s, "H for help, X to quit."); + } + + return helpstring; +} + +char * make_up_query_string (int promptstr) +{ + char *querystr; + int nstart, nnext, n; + char *s; + + nstart = str_start[ promptstr]; + nnext = str_start[ promptstr + 1]; + n = nnext - nstart; + querystr = (char *) malloc(n + 1); + s = querystr; + memcpy(s, &str_pool[nstart], n); + s += n; + *s = '\0'; + + return querystr; +} + +// abort_flag set if input_line / ConsoleInput returns non-zero +// should set interrupt instead ??? +// called from tex0.c, tex2.c, tex3.c /* sec 0071 */ void term_input(void) { integer k; - + int flag; + if (!knuth_flag) - show_line("\n", 0); // force it to show what may be buffered up ??? + show_line("\n", 0); fflush(stdout); + flag = input_ln(stdin, true); - if (!input_ln(stdin, true)) + if (!flag) { fatal_error("End of file on the terminal!"); - return; + return; // abort_flag set } - term_offset = 0; - decr(selector); + decr(selector); // shut off echo if (last != first) for (k = first; k <= last - 1; k++) print(buffer[k]); print_ln(); - incr(selector); + incr(selector); // reset selector again } /* sec 0091 */ void int_error_ (integer n) @@ -1600,7 +1691,7 @@ lab20: if (s == 1073741824L) /* 2^30 - special case - merge adjacent */ { if (trace_flag) - show_line("Merged adjacent multi-word nodes\n", 0); + puts("Merged adjacent multi-word nodes\n"); return max_halfword; } @@ -1829,7 +1920,7 @@ pointer new_skip_param_(small_number n) return p; } /* sec 0155 */ -pointer new_kern_(scaled w) +pointer new_kern(scaled w) { pointer p; @@ -1841,7 +1932,7 @@ pointer new_kern_(scaled w) return p; } /* sec 0158 */ -pointer new_penalty_(integer m) +pointer new_penalty(integer m) { pointer p; @@ -1855,7 +1946,7 @@ pointer new_penalty_(integer m) #ifdef DEBUG /* sec 0167 */ -void check_mem_(boolean printlocs) +void check_mem(boolean printlocs) { pointer p, q; boolean clobbered; @@ -2087,7 +2178,7 @@ void short_display_(integer p) } } /* sec 0176 */ -void print_font_and_char_ (integer p) +void print_font_and_char (integer p) { if (p > mem_end) print_esc("CLOBBERED."); @@ -2118,7 +2209,7 @@ void print_mark_ (integer p) print_char('}'); } /* sec 0176 */ -void print_rule_dimen_ (scaled d) +void print_rule_dimen(scaled d) { if ((d == -1073741824L)) /* - 2^30 */ print_char('*'); @@ -2319,16 +2410,6 @@ void print_skip_param_(integer n) print_esc("parfillskip"); break; - ///* - case kanji_skip_code: - print_esc("kanjiskip"); - break; - - case xkanji_skip_code: - print_esc("xkanjiskip"); - break; - //*/ - case thin_mu_skip_code: print_esc("thinmuskip"); break; @@ -2341,10 +2422,6 @@ void print_skip_param_(integer n) print_esc("thickmuskip"); break; - case jfm_skip: - print("refer from jfm"); - break; - default: print_string("[unknown glue parameter!]"); break; @@ -2384,7 +2461,7 @@ void show_node_list_(integer p) return; } - if ((p >= hi_mem_min)) + if (is_char_node(p)) print_font_and_char(p); else switch (type(p)) { diff --git a/src/texsourc/tex1.c b/src/texsourc/tex1.c index 9f51f99..1e4df8e 100644 --- a/src/texsourc/tex1.c +++ b/src/texsourc/tex1.c @@ -249,7 +249,7 @@ pointer copy_node_list_(pointer p) { words = 1; - if ((p >= hi_mem_min)) + if (is_char_node(p)) r = get_avail(); else switch (type(p)) { @@ -831,14 +831,6 @@ void print_param_(integer n) print_esc("newlinechar"); break; - case cur_jfam_code: - print_esc("jfam"); - break; - - case jchr_widow_penalty_code: - print_esc("jcharwidowpenalty"); - break; - case language_code: print_esc("language"); break; @@ -972,14 +964,6 @@ void print_length_param_ (integer n) print_esc("voffset"); break; - case t_baseline_shift_code: - print_esc("tbaselineshift"); - break; - - case y_baseline_shift_code: - print_esc("ybaselineshift"); - break; - case emergency_stretch_code: print_esc("emergencystretch"); break; @@ -1907,10 +1891,6 @@ void print_cmd_chr_ (quarterword cmd, halfword chr_code) case def_code: if (chr_code == cat_code_base) print_esc("catcode"); - else if (chr_code == kcat_code_base) - print_esc("kcatcode"); - else if (chr_code == auto_xsp_code_base) - print_esc("xspcode"); else if (chr_code == math_code_base) print_esc("mathcode"); else if (chr_code == lc_code_base) @@ -2010,10 +1990,6 @@ void print_cmd_chr_ (quarterword cmd, halfword chr_code) print_esc("showlists"); break; - //case show_mode: - // print_esc("showmode"); - // break; - default: print_esc("show"); break; @@ -2089,204 +2065,193 @@ void show_eqtb_(halfword n) { if (n < active_base) print_char('?'); - else if (n < glue_base) - { - sprint_cs(n); - print_char('='); - print_cmd_chr(eq_type(n), equiv(n)); - - if (eq_type(n) >= call) - { - print_char(':'); - show_token_list(link(equiv(n)), 0, 32); - } - } - else if (n < local_base) - if (n < skip_base) - { - print_skip_param(n - glue_base); - print_char('='); - - if (n < glue_base + thin_mu_skip_code) - print_spec(equiv(n), "pt"); - else - print_spec(equiv(n), "mu"); - } - else if (n < mu_skip_base) - { - print_esc("skip"); - print_int(n - skip_base); - print_char('='); - print_spec(equiv(n), "pt"); - } - else - { - print_esc("muskip"); - print_int(n - mu_skip_base); - print_char('='); - print_spec(equiv(n), "mu"); - } - else if (n < int_base) - if (n == par_shape_loc) - { - print_esc("parshape"); - print_char('='); - - if (par_shape_ptr == 0) - print_char('0'); - else - print_int(info(par_shape_ptr)); - } - else if (n < toks_base) - { - print_cmd_chr(assign_toks, n); - print_char('='); - - if (equiv(n) != 0) - show_token_list(link(equiv(n)), 0, 32); - } - else if (n < box_base) + else + if (n < glue_base) { - print_esc("toks"); - print_int(n - toks_base); + sprint_cs(n); print_char('='); + print_cmd_chr(eq_type(n), equiv(n)); - if (equiv(n) != 0) - show_token_list(link(equiv(n)), 0, 32); - } - else if (n < cur_font_loc) - { - print_esc("box"); - print_int(n - box_base); - print_char('='); - - if (equiv(n) == 0) - print_string("void"); - else + if (eq_type(n) >= call) { - depth_threshold = 0; - breadth_max = 1; - show_node_list(equiv(n)); + print_char(':'); + show_token_list(link(equiv(n)), 0, 32); } } - else if (n < cat_code_base) + else + if (n < local_base) + if (n < skip_base) + { + print_skip_param(n - glue_base); + print_char('='); + + if (n < glue_base + thin_mu_skip_code) + print_spec(equiv(n), "pt"); + else + print_spec(equiv(n), "mu"); + } + else + if (n < mu_skip_base) + { + print_esc("skip"); + print_int(n - skip_base); + print_char('='); + print_spec(equiv(n), "pt"); + } + else + { + print_esc("muskip"); + print_int(n - mu_skip_base); + print_char('='); + print_spec(equiv(n), "mu"); + } + else + if (n < int_base) + if (n == par_shape_loc) + { + print_esc("parshape"); + print_char('='); + + if (par_shape_ptr == 0) + print_char('0'); + else + print_int(info(par_shape_ptr)); + } + else + if (n < toks_base) + { + print_cmd_chr(assign_toks, n); + print_char('='); + + if (equiv(n) != 0) + show_token_list(link(equiv(n)), 0, 32); + } + else + if (n < box_base) + { + print_esc("toks"); + print_int(n - toks_base); + print_char('='); + + if (equiv(n) != 0) + show_token_list(link(equiv(n)), 0, 32); + } + else + if (n < cur_font_loc) + { + print_esc("box"); + print_int(n - box_base); + print_char('='); + + if (equiv(n) == 0) + print_string("void"); + else + { + depth_threshold = 0; + breadth_max = 1; + show_node_list(equiv(n)); + } + } + else + if (n < cat_code_base) + { + if (n == cur_font_loc) + print_string("current font"); + else + if (n < math_font_base + 16) + { + print_esc("textfont"); + print_int(n - math_font_base); + } + else + if (n < math_font_base + 32) + { + print_esc("scriptfont"); + print_int(n - math_font_base - 16); + } + else + { + print_esc("scriptscriptfont"); + print_int(n - math_font_base - 32); + } + + print_char('='); + print_esc(""); + print(hash[font_id_base + equiv(n)].rh); + } + else + if (n < math_code_base) + { + if (n < lc_code_base) + { + print_esc("catcode"); + print_int(n - cat_code_base); + } + else + if (n < uc_code_base) + { + print_esc("lccode"); + print_int(n - lc_code_base); + } + else + if (n < sf_code_base) + { + print_esc("uccode"); + print_int(n - uc_code_base); + } + else + { + print_esc("sfcode"); + print_int(n - sf_code_base); + } + + print_char('='); + print_int(equiv(n)); + } + else + { + print_esc("mathcode"); + print_int(n - math_code_base); + print_char('='); + print_int(equiv(n)); + } + else + if (n < dimen_base) { - if (n == cur_font_loc) - print_string("current font"); - else if (n < math_font_base + 16) - { - print_esc("textfont"); - print_int(n - math_font_base); - } - else if (n < math_font_base + 32) - { - print_esc("scriptfont"); - print_int(n - math_font_base - 16); - } + if (n < count_base) + print_param(n - int_base); else - { - print_esc("scriptscriptfont"); - print_int(n - math_font_base - 32); - } - + if (n < del_code_base) + { + print_esc("count"); + print_int(n - count_base); + } + else + { + print_esc("delcode"); + print_int(n - del_code_base); + } + print_char('='); - print_esc(""); - print(hash[font_id_base + equiv(n)].rh); + print_int(eqtb[n].cint); } - else if (n < math_code_base) - { - if (n < kcat_code_base) - { - print_esc("catcode"); - print_int(n - cat_code_base); - } - else if (n < auto_xsp_code_base) - { - print_esc("kcatcode"); - print_int(n - kcat_code_base); - } - else if (n < inhibit_xsp_code_base) - { - print_esc("xspcode"); - print_int(n - auto_xsp_code_base); - } - else if (n < kinsoku_base) - { - print("(inhibitxspcode table) "); - print_int(n - inhibit_xsp_code_base); - } - else if (n < kansuji_base) - { - print("(kinsoku table) "); - print_int(n - kinsoku_base); - } - else if (n < lc_code_base) - { - print_esc("kansujichar"); - print_int(n - kansuji_base); - } - else if (n < uc_code_base) - { - print_esc("lccode"); - print_int(n - lc_code_base); - } - else if (n < sf_code_base) + else + if (n <= eqtb_size) { - print_esc("uccode"); - print_int(n - uc_code_base); + if (n < scaled_base) + print_length_param(n - dimen_base); + else + { + print_esc("dimen"); + print_int(n - scaled_base); + } + + print_char('='); + print_scaled(eqtb[n].cint); + print_string("pt"); } else - { - print_esc("sfcode"); - print_int(n - sf_code_base); - } - - print_char('='); - print_int(equiv(n)); - } - else - { - print_esc("mathcode"); - print_int(n - math_code_base); - print_char('='); - print_int(equiv(n)); - } - else if (n < dimen_base) - { - if (n < count_base) - print_param(n - int_base); - else if (n < del_code_base) - { - print_esc("count"); - print_int(n - count_base); - } - else - { - print_esc("delcode"); - print_int(n - del_code_base); - } - - print_char('='); - print_int(eqtb[n].cint); - } - else if (n < kinsoku_penalty_base) - { - if (n < scaled_base) - print_length_param(n - dimen_base); - else - { - print_esc("dimen"); - print_int(n - scaled_base); - } - - print_char('='); - print_scaled(eqtb[n].cint); - print_string("pt"); - } - else if (n <= eqtb_size) - print_string("kinsoku"); - else - print_char('?'); + print_char('?'); } #endif /* STAT */ /* sec 0259 */ diff --git a/src/texsourc/tex2.c b/src/texsourc/tex2.c index 04f41ce..0e46590 100644 --- a/src/texsourc/tex2.c +++ b/src/texsourc/tex2.c @@ -43,7 +43,9 @@ void unsave (void) if (cur_level > level_one) { decr(cur_level); - while (true) { + + while (true) + { decr(save_ptr); if (save_type(save_ptr) == level_boundary) @@ -75,7 +77,7 @@ void unsave (void) #ifdef STAT if (tracing_restores > 0) restore_trace(p, "retaining"); -#endif /* STAT */ +#endif } else { @@ -84,7 +86,7 @@ void unsave (void) #ifdef STAT if (tracing_restores > 0) restore_trace(p, "restoring"); -#endif /* STAT */ +#endif } else if (xeq_level[p] != level_one) { @@ -93,14 +95,14 @@ void unsave (void) #ifdef STAT if (tracing_restores > 0) restore_trace(p, "restoring"); -#endif /* STAT */ +#endif } else { #ifdef STAT if (tracing_restores > 0) restore_trace(p, "retaining"); -#endif /* STAT */ +#endif } } } @@ -111,7 +113,7 @@ lab30: else { confusion("curlevel"); - return; // abort_flag set + return; } } /* This is where the old tex2.c used to start */ @@ -204,19 +206,19 @@ void show_context (void) { cur_input = input_stack[base_ptr]; - if ((cur_input.state_field != 0)) + if ((state != 0)) if ((cur_input.name_field > 17) || (base_ptr == 0)) bottomline = true; if ((base_ptr == input_ptr) || bottomline || (nn < error_context_lines)) { - if ((base_ptr == input_ptr) || (cur_input.state_field != token_list) || - (cur_input.index_field != backed_up) || (cur_input.loc_field != 0)) + if ((base_ptr == input_ptr) || (state != token_list) || + (index != backed_up) || (loc != 0)) { tally = 0; old_setting = selector; - if (cur_input.state_field != 0) + if (state != 0) { if (cur_input.name_field <= 17) if ((cur_input.name_field == 0)) @@ -238,20 +240,20 @@ void show_context (void) if (c_style_flag) { print_ln(); - /* show current input file name - ignore if from terminal */ - if (cur_input.name_field > 17) /* redundant ? */ + + if (cur_input.name_field > 17) print(cur_input.name_field); print_char('('); - print_int(line); /* line number */ + print_int(line); print_char(')'); print_char(' '); print_char(':'); } else { - print_nl("l."); /* l. ? 573 ????? 98/Dec/8 check ! */ - print_int(line); /* line number */ + print_nl("l."); + print_int(line); } } @@ -264,15 +266,15 @@ void show_context (void) trick_count = 1000000L; } - if (buffer[cur_input.limit_field] == end_line_char) - j = cur_input.limit_field; + if (buffer[limit] == end_line_char) + j = limit; else - j = cur_input.limit_field + 1; + j = limit + 1; if (j > 0) - for (i = cur_input.start_field; i <= j - 1; i++) + for (i = start; i <= j - 1; i++) { - if (i == cur_input.loc_field) + if (i == loc) { first_count = tally; trick_count = tally + 1 + error_line - half_error_line; @@ -285,7 +287,7 @@ void show_context (void) } else { - switch (cur_input.index_field) + switch (index) { case parameter: print_nl(" "); @@ -297,7 +299,7 @@ void show_context (void) break; case backed_up: - if (cur_input.loc_field == 0) + if (loc == 0) print_nl(" "); else print_nl(" "); @@ -364,10 +366,10 @@ void show_context (void) trick_count = 1000000L; } - if (cur_input.index_field < macro) - show_token_list(cur_input.start_field, cur_input.loc_field, 100000L); + if (index < macro) + show_token_list(start, loc, 100000L); else - show_token_list(link(cur_input.start_field), cur_input.loc_field, 100000L); + show_token_list(link(start), loc, 100000L); } selector = old_setting; @@ -464,19 +466,19 @@ void begin_token_list_ (halfword p, quarterword t) incr(input_ptr); } - cur_input.state_field = token_list; - cur_input.start_field = p; - cur_input.index_field = t; + state = token_list; + start = p; + index = t; if (t >= macro) { add_token_ref(p); if (t == macro) - cur_input.limit_field = param_ptr; + limit = param_ptr; else { - cur_input.loc_field = link(p); + loc = link(p); if (tracing_macros > 1) { @@ -494,7 +496,7 @@ void begin_token_list_ (halfword p, quarterword t) break; default: - print_cmd_chr(assign_toks, t - output_text + output_routine_loc); + print_cmd_chr(assign_toks, t + (hash_size + 1307)); break; } @@ -505,28 +507,28 @@ void begin_token_list_ (halfword p, quarterword t) } } else - cur_input.loc_field = p; + loc = p; } //#pragma optimize("", on) /* 98/Dec/10 experiment */ /* sec 0324 */ void end_token_list (void) { - if (cur_input.index_field >= backed_up) + if (index >= backed_up) { - if (cur_input.index_field <= inserted) - flush_list(cur_input.start_field); + if (index <= inserted) + flush_list(start); else { - delete_token_ref(cur_input.start_field); - if (cur_input.index_field == macro) - while (param_ptr > cur_input.limit_field) + delete_token_ref(start); + if (index == macro) + while (param_ptr > limit) { decr(param_ptr); flush_list(param_stack[param_ptr]); } } } - else if (cur_input.index_field == u_template) + else if (index == u_template) if (align_state > 500000L) align_state = 0; else @@ -552,8 +554,8 @@ void back_input (void) { halfword p; - while ((cur_input.state_field == 0) && (cur_input.loc_field == 0) && - (cur_input.index_field != v_template)) + while ((state == 0) && (loc == 0) && + (index != v_template)) { end_token_list(); } @@ -592,10 +594,10 @@ void back_input (void) incr(input_ptr); } - cur_input.state_field = token_list; - cur_input.start_field = p; - cur_input.index_field = backed_up; - cur_input.loc_field = p; + state = token_list; + start = p; + index = backed_up; + loc = p; } /* sec 0327 */ void back_error (void) @@ -610,7 +612,7 @@ void ins_error (void) { OK_to_interrupt = false; back_input(); - cur_input.index_field = inserted; + index = inserted; OK_to_interrupt = true; error(); } @@ -664,20 +666,20 @@ void begin_file_reading (void) input_stack[input_ptr] = cur_input; incr(input_ptr); } - cur_input.index_field = in_open; - line_stack[cur_input.index_field] = line; - cur_input.start_field = first; - cur_input.state_field = 1; + index = in_open; + line_stack[index] = line; + start = first; + state = 1; cur_input.name_field = 0; } /* sec 0329 */ void end_file_reading (void) { - first = cur_input.start_field; - line = line_stack[cur_input.index_field]; + first = start; + line = line_stack[index]; if (cur_input.name_field > 17) - (void) a_close(input_file[cur_input.index_field]); + (void) a_close(input_file[index]); { decr(input_ptr); @@ -689,9 +691,9 @@ void end_file_reading (void) /* sec 0330 */ void clear_for_error_prompt (void) { - while ((cur_input.state_field != 0) && + while ((state != 0) && (cur_input.name_field == 0) && (input_ptr > 0) && - (cur_input.loc_field > cur_input.limit_field)) + (loc > limit)) end_file_reading(); print_ln(); @@ -708,7 +710,7 @@ void check_outer_validity (void) if (cur_cs != 0) { - if ((cur_input.state_field == 0) || (cur_input.name_field < 1) || (cur_input.name_field > 17)) + if ((state == 0) || (cur_input.name_field < 1) || (cur_input.name_field > 17)) { p = get_avail(); info(p) = cs_token_flag + cur_cs; @@ -792,16 +794,12 @@ void check_outer_validity (void) deletions_allowed = true; } } -/*****************************************************************************/ -/* get_next() moved from here to end for pragma optimize reasons 96/Sep/12 */ -void get_next(void); -/*****************************************************************************/ /* sec 0363 */ void firm_up_the_line (void) { integer k; - cur_input.limit_field = last; + limit = last; if (pausing > 0) if (interaction > nonstop_mode) @@ -809,19 +807,19 @@ void firm_up_the_line (void) ; print_ln(); - if (cur_input.start_field < cur_input.limit_field) - for (k = cur_input.start_field; k <= cur_input.limit_field - 1; k++) + if (start < limit) + for (k = start; k <= limit - 1; k++) print(buffer[k]); - first = cur_input.limit_field; + first = limit; prompt_input("=>"); if (last > first) { for (k = first; k <= last - 1; k++) - buffer[k + cur_input.start_field - first] = buffer[k]; + buffer[k + start - first] = buffer[k]; - cur_input.limit_field = cur_input.start_field + last - first; + limit = start + last - first; } } } @@ -846,20 +844,20 @@ void macro_call (void) halfword s; halfword t; halfword u, v; - halfword rbraceptr; + halfword rbrace_ptr; small_number n; halfword unbalance; halfword m; - halfword refcount; - small_number savescannerstatus; - halfword savewarningindex; + halfword ref_count; + small_number save_scanner_status; + halfword save_warning_index; ASCII_code match_chr; - savescannerstatus = scanner_status; - savewarningindex = warning_index; + save_scanner_status = scanner_status; + save_warning_index = warning_index; warning_index = cur_cs; - refcount = cur_chr; - r = link(refcount); + ref_count = cur_chr; + r = link(ref_count); n = 0; if (tracing_macros > 0) @@ -867,7 +865,7 @@ void macro_call (void) begin_diagnostic(); print_ln(); print_cs(warning_index); - token_show(refcount); + token_show(ref_count); end_diagnostic(false); } @@ -955,7 +953,7 @@ lab22: lab30: t = link(t); } - while(!(t == r)); + while (!(t == r)); r = s; } @@ -1029,7 +1027,7 @@ lab30: } } lab31: - rbraceptr = p; + rbrace_ptr = p; store_new_token(cur_tok); } else @@ -1072,7 +1070,7 @@ lab40: { if ((m == 1) && (info(p) < right_brace_limit) && (p != temp_head)) { - link(rbraceptr) = 0; /* rbraceptr may be used without ... */ + link(rbrace_ptr) = 0; /* rbrace_ptr may be used without ... */ free_avail(p); p = link(temp_head); pstack[n] = link(p); @@ -1095,16 +1093,16 @@ lab40: } } } - while(!(info(r) == end_match_token)); + while (!(info(r) == end_match_token)); } - while((cur_input.state_field == token_list) && (cur_input.loc_field == 0) && - (cur_input.index_field != v_template)) + while ((state == token_list) && (loc == 0) && + (index != v_template)) end_token_list(); - begin_token_list(refcount, macro); + begin_token_list(ref_count, macro); cur_input.name_field = warning_index; - cur_input.loc_field = link(r); + loc = link(r); if (n > 0) { @@ -1136,8 +1134,8 @@ lab40: param_ptr = param_ptr + n; } lab10: - scanner_status = savescannerstatus; - warning_index = savewarningindex; + scanner_status = save_scanner_status; + warning_index = save_warning_index; } /* sec 0379 */ void insert_relax (void) @@ -1146,24 +1144,24 @@ void insert_relax (void) back_input(); cur_tok = cs_token_flag + frozen_relax; /* 96/Jan/10 */ back_input(); - cur_input.index_field = inserted; + index = inserted; } /* sec 0366 */ void expand (void) { halfword t; - halfword p, q, r; + pointer p, q, r; integer j; - integer cvbackup; - small_number cvlbackup, radixbackup, cobackup; - halfword backupbackup; - small_number savescannerstatus; + integer cv_backup; + small_number cvl_backup, radix_backup, co_backup; + halfword backup_backup; + small_number save_scanner_status; - cvbackup = cur_val; - cvlbackup = cur_val_level; - radixbackup = radix; - cobackup = cur_order; - backupbackup = link(backup_head); + cv_backup = cur_val; + cvl_backup = cur_val_level; + radix_backup = radix; + co_backup = cur_order; + backup_backup = link(backup_head); if (cur_cmd < call) { @@ -1192,10 +1190,10 @@ void expand (void) break; case no_expand: - savescannerstatus = scanner_status; + save_scanner_status = scanner_status; scanner_status = normal; get_token(); - scanner_status = savescannerstatus; + scanner_status = save_scanner_status; t = cur_tok; back_input(); @@ -1203,9 +1201,9 @@ void expand (void) { p = get_avail(); info(p) = cs_token_flag + frozen_dont_expand; /*96/Jan/10*/ - link(p) = cur_input.loc_field; - cur_input.start_field = p; - cur_input.loc_field = p; + link(p) = loc; + start = p; + loc = p; } break; @@ -1219,7 +1217,7 @@ void expand (void) if (cur_cs == 0) store_new_token(cur_tok); } - while(!(cur_cs != 0)); + while (!(cur_cs != 0)); if (cur_cmd != end_cs_name) { @@ -1310,7 +1308,7 @@ void expand (void) } else { - while(cur_chr != fi_code) + while (cur_chr != fi_code) pass_text(); { @@ -1354,11 +1352,11 @@ void expand (void) back_input(); } - cur_val = cvbackup; - cur_val_level = cvlbackup; - radix = radixbackup; - cur_order = cobackup; - link(backup_head) = backupbackup; + cur_val = cv_backup; + cur_val_level = cvl_backup; + radix = radix_backup; + cur_order = co_backup; + link(backup_head) = backup_backup; } /* sec 0380 */ void get_x_token (void) @@ -1368,12 +1366,13 @@ lab20: if (cur_cmd <= max_command) goto lab30; + if (cur_cmd >= call) if (cur_cmd < end_template) macro_call(); else { - cur_cs = frozen_endv; /* 96/Jan/10 */ + cur_cs = frozen_endv; cur_cmd = endv; goto lab30; } @@ -1381,6 +1380,7 @@ lab20: expand(); goto lab20; + lab30: if (cur_cs == 0) cur_tok = (cur_cmd * 256) + cur_chr; @@ -1408,7 +1408,7 @@ void scan_left_brace (void) { get_x_token(); } - while(!((cur_cmd != spacer) && (cur_cmd != relax))); + while (!((cur_cmd != spacer) && (cur_cmd != relax))); if (cur_cmd != left_brace) { @@ -1431,13 +1431,13 @@ void scan_optional_equals (void) { get_x_token(); } - while(!(cur_cmd != spacer)); + while (!(cur_cmd != spacer)); if (cur_tok != other_token + '=') back_input(); } /* sec 0407 */ -boolean scan_keyword_(const char * s) +boolean scan_keyword(const char * s) { halfword p; halfword q; @@ -1524,6 +1524,7 @@ void scan_four_bit_int (void) void scan_fifteen_bit_int (void) { scan_int(); + if ((cur_val < 0) || (cur_val > 32767)) { print_err("Bad mathchar"); @@ -1604,38 +1605,36 @@ void find_font_dimen_(boolean writing) if (n > font_params[f]) if (f < font_ptr) cur_val = fmem_ptr; - else - { - do - { - #ifdef ALLOCATEFONT - if (fmem_ptr == current_font_mem_size) /* 93/Nov/28 ??? */ + else + { + do { - font_info = realloc_font_info(increment_font_mem_size); - } + #ifdef ALLOCATEFONT + if (fmem_ptr == current_font_mem_size) + font_info = realloc_font_info(increment_font_mem_size); - if (fmem_ptr == current_font_mem_size) /* 94/Jan/24 */ - { - overflow("font memory", current_font_mem_size); /* font memory */ - return; // abort_flag set - } + if (fmem_ptr == current_font_mem_size) + { + overflow("font memory", current_font_mem_size); + return; + } #else - if (fmem_ptr == font_mem_size) - { - overflow("font memory", font_mem_size); /* font memory */ - return; // abort_flag set - } + if (fmem_ptr == font_mem_size) + { + overflow("font memory", font_mem_size); + return; + } #endif - font_info[fmem_ptr].cint = 0; - incr(fmem_ptr); - incr(font_params[f]); - } - while(!(n == font_params[f])); + font_info[fmem_ptr].cint = 0; + incr(fmem_ptr); + incr(font_params[f]); + } + while (!(n == font_params[f])); - cur_val = fmem_ptr - 1; - } - else if (n > 0) - cur_val = n + param_base[f]; + cur_val = fmem_ptr - 1; + } + else if (n > 0) + cur_val = n + param_base[f]; } if (cur_val == fmem_ptr) @@ -1665,20 +1664,11 @@ void scan_something_internal_(small_number level, boolean negative) scan_char_num(); if (m == math_code_base) - { - cur_val = math_code(cur_val); - cur_val_level = int_val; - } + scanned_result(math_code(cur_val), int_val); else if (m < math_code_base) - { - cur_val = equiv(m + cur_val); - cur_val_level = int_val; - } + scanned_result(equiv(m + cur_val), int_val); else - { - cur_val = eqtb[m + cur_val].cint; - cur_val_level = int_val; - } + scanned_result(eqtb[m + cur_val].cint, int_val); } break; @@ -1694,10 +1684,7 @@ void scan_something_internal_(small_number level, boolean negative) "(If you can't figure out why I needed to see a number,", "look up `weird error' in the index to The TeXbook.)"); back_error(); - { - cur_val = 0; - cur_val_level = dimen_val; - } + scanned_result(0, dimen_val); } else if (cur_cmd <= assign_toks) { @@ -1707,49 +1694,30 @@ void scan_something_internal_(small_number level, boolean negative) m = toks_base + cur_val; } - { - cur_val = eqtb[m].hh.rh; - cur_val_level = tok_val; - } + scanned_result(equiv(m), tok_val); } else { back_input(); scan_font_ident(); - - { - cur_val = font_id_base + cur_val; - cur_val_level = ident_val; - } + scanned_result(font_id_base + cur_val, ident_val); } break; case assign_int: - { - cur_val = eqtb[m].cint; - cur_val_level = int_val; - } + scanned_result(eqtb[m].cint, int_val); break; case assign_dimen: - { - cur_val = eqtb[m].cint; - cur_val_level = dimen_val; - } + scanned_result(eqtb[m].cint, dimen_val); break; case assign_glue: - { - cur_val = eqtb[m].hh.rh; - cur_val_level = glue_val; - } + scanned_result(equiv(m), glue_val); break; case assign_mu_glue: - { - cur_val = eqtb[m].hh.rh; - cur_val_level = mu_val; - } + scanned_result(equiv(m), mu_val); break; case set_aux: @@ -1764,34 +1732,19 @@ void scan_something_internal_(small_number level, boolean negative) error(); if (level != tok_val) - { - cur_val = 0; - cur_val_level = dimen_val; - } + scanned_result(0, dimen_val); else - { - cur_val = 0; - cur_val_level = int_val; - } + scanned_result(0, int_val); } else if (m == vmode) - { - cur_val = cur_list.aux_field.cint; - cur_val_level = dimen_val; - } + scanned_result(prev_depth, dimen_val); else - { - cur_val = space_factor; - cur_val_level = int_val; - } + scanned_result(space_factor, int_val); break; case set_prev_graf: if (mode == 0) - { - cur_val = 0; - cur_val_level = int_val; - } + scanned_result(0, int_val); else { nest[nest_ptr] = cur_list; @@ -1800,10 +1753,7 @@ void scan_something_internal_(small_number level, boolean negative) while (abs(nest[p].mode_field) != vmode) decr(p); - { - cur_val = nest[p].pg_field; - cur_val_level = int_val; - } + scanned_result(nest[p].pg_field, int_val); } break; @@ -1822,7 +1772,7 @@ void scan_something_internal_(small_number level, boolean negative) { if ((page_contents == 0) && (! output_active)) if (m == 0) - cur_val = 1073741823L; /* 2^30 - 1 */ + cur_val = max_dimen; else cur_val = 0; else @@ -1858,20 +1808,14 @@ void scan_something_internal_(small_number level, boolean negative) case char_given: case math_given: - { - cur_val = cur_chr; - cur_val_level = int_val; - } + scanned_result(cur_chr, int_val); break; case assign_font_dimen: { find_font_dimen(false); font_info[fmem_ptr].cint = 0; - { - cur_val = font_info[cur_val].cint; - cur_val_level = dimen_val; - } + scanned_result(font_info[cur_val].cint, dimen_val); } break; @@ -1880,15 +1824,9 @@ void scan_something_internal_(small_number level, boolean negative) scan_font_ident(); if (m == 0) - { - cur_val = hyphen_char[cur_val]; - cur_val_level = int_val; - } + scanned_result(hyphen_char[cur_val], int_val); else - { - cur_val = skew_char[cur_val]; - cur_val_level = int_val; - } + scanned_result(skew_char[cur_val], int_val); } break; @@ -1938,7 +1876,7 @@ void scan_something_internal_(small_number level, boolean negative) cur_val_level = cur_chr; - if (!(tail >= hi_mem_min) && (mode != 0)) + if (!is_char_node(tail) && (mode != 0)) switch(cur_chr) { case int_val: @@ -1961,7 +1899,7 @@ void scan_something_internal_(small_number level, boolean negative) } break; } - else if ((mode == 1) && (tail == cur_list.head_field)) + else if ((mode == vmode) && (tail == head)) switch (cur_chr) { case int_val: @@ -1990,15 +1928,9 @@ void scan_something_internal_(small_number level, boolean negative) error(); if (level != tok_val) - { - cur_val = 0; - cur_val_level = dimen_val; - } + scanned_result(0, dimen_val); else - { - cur_val = 0; - cur_val_level = int_val; - } + scanned_result(0, int_val); } break; } @@ -2019,13 +1951,13 @@ void scan_something_internal_(small_number level, boolean negative) cur_val = new_spec(cur_val); { - width(cur_val) = - (integer) width(cur_val); - stretch(cur_val) = - (integer) stretch(cur_val); - shrink(cur_val) = - (integer) shrink(cur_val); + width(cur_val) = -width(cur_val); + stretch(cur_val) = -stretch(cur_val); + shrink(cur_val) = -shrink(cur_val); } } else - cur_val = - (integer) cur_val; + cur_val = -cur_val; else if ((cur_val_level >= glue_val) && (cur_val_level <= mu_val)) add_glue_ref(cur_val); } @@ -2042,17 +1974,17 @@ void get_next (void) lab20: cur_cs = 0; - if (cur_input.state_field != token_list) + if (state != token_list) { lab25: - if (cur_input.loc_field <= cur_input.limit_field) + if (loc <= limit) { - cur_chr = buffer[cur_input.loc_field]; - incr(cur_input.loc_field); + cur_chr = buffer[loc]; + incr(loc); lab21: cur_cmd = cat_code(cur_chr); - switch (cur_input.state_field + cur_cmd) + switch (state + cur_cmd) { case any_state_plus(ignore): case skip_blanks + spacer: @@ -2062,24 +1994,24 @@ lab21: case any_state_plus(escape): { - if (cur_input.loc_field > cur_input.limit_field) + if (loc > limit) cur_cs = null_cs; else { lab26: - k = cur_input.loc_field; + k = loc; cur_chr = buffer[k]; cat = cat_code(cur_chr); incr(k); if (cat == letter) - cur_input.state_field = skip_blanks; + state = skip_blanks; else if (cat == spacer) - cur_input.state_field = skip_blanks; + state = skip_blanks; else - cur_input.state_field = mid_line; + state = mid_line; - if ((cat == letter) && (k <= cur_input.limit_field)) + if ((cat == letter) && (k <= limit)) { do { @@ -2087,12 +2019,12 @@ lab26: cat = cat_code(cur_chr); incr(k); } - while(!((cat != letter) || (k > cur_input.limit_field))); + while (!((cat != letter) || (k > limit))); { if (buffer[k]== cur_chr) if (cat == sup_mark) - if (k < cur_input.limit_field) + if (k < limit) { c = buffer[k + 1]; @@ -2100,7 +2032,7 @@ lab26: { d = 2; if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102)))) - if (k + 2 <= cur_input.limit_field) + if (k + 2 <= limit) { cc = buffer[k + 2]; @@ -2127,10 +2059,10 @@ lab26: else buffer[k - 1] = c - 64; - cur_input.limit_field = cur_input.limit_field - d; + limit = limit - d; first = first - d; - while (k <= cur_input.limit_field) + while (k <= limit) { buffer[k] = buffer[k + d]; incr(k); @@ -2144,10 +2076,10 @@ lab26: if (cat != letter) decr(k); - if (k > cur_input.loc_field + 1) + if (k > loc + 1) { - cur_cs = id_lookup(cur_input.loc_field, k - cur_input.loc_field); - cur_input.loc_field = k; + cur_cs = id_lookup(loc, k - loc); + loc = k; goto lab40; } } @@ -2155,7 +2087,7 @@ lab26: { if (buffer[k] == cur_chr) if (cat == sup_mark) - if (k < cur_input.limit_field) + if (k < limit) { c = buffer[k + 1]; @@ -2163,7 +2095,7 @@ lab26: { d = 2; if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102)))) - if (k + 2 <= cur_input.limit_field) + if (k + 2 <= limit) { cc = buffer[k + 2]; @@ -2190,10 +2122,10 @@ lab26: else buffer[k - 1] = c - 64; - cur_input.limit_field = cur_input.limit_field - d; + limit = limit - d; first = first - d; - while (k <= cur_input.limit_field) + while (k <= limit) { buffer[k] = buffer[k + d]; incr(k); @@ -2202,8 +2134,8 @@ lab26: } } } - cur_cs = single_base + buffer[cur_input.loc_field]; - incr(cur_input.loc_field); + cur_cs = single_base + buffer[loc]; + incr(loc); } lab40: cur_cmd = eq_type(cur_cs); @@ -2219,7 +2151,7 @@ lab40: cur_cs = cur_chr + active_base; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); - cur_input.state_field = mid_line; + state = mid_line; if (cur_cmd >= outer_call) check_outer_validity(); @@ -2228,23 +2160,23 @@ lab40: case any_state_plus(sup_mark): { - if (cur_chr == buffer[cur_input.loc_field]) - if (cur_input.loc_field < cur_input.limit_field) + if (cur_chr == buffer[loc]) + if (loc < limit) { - c = buffer[cur_input.loc_field + 1]; + c = buffer[loc + 1]; if (c < 128) { - cur_input.loc_field = cur_input.loc_field + 2; + loc = loc + 2; if ((((c >= 48) && (c <= 57)) || ((c >= 97) && (c <= 102)))) - if (cur_input.loc_field <= cur_input.limit_field) + if (loc <= limit) { - cc = buffer[cur_input.loc_field]; + cc = buffer[loc]; if ((((cc >= 48) && (cc <= 57)) || ((cc >= 97) && (cc <= 102)))) { - incr(cur_input.loc_field); + incr(loc); if (c <= 57) cur_chr = c - 48; @@ -2269,7 +2201,7 @@ lab40: } } - cur_input.state_field = mid_line; + state = mid_line; } break; @@ -2287,14 +2219,14 @@ lab40: case mid_line + spacer: { - cur_input.state_field = skip_blanks; + state = skip_blanks; cur_chr = ' '; } break; case mid_line + car_ret: { - cur_input.loc_field = cur_input.limit_field + 1; + loc = limit + 1; cur_cmd = spacer; cur_chr = ' '; } @@ -2303,14 +2235,14 @@ lab40: case skip_blanks + car_ret: case any_state_plus(comment): { - cur_input.loc_field = cur_input.limit_field + 1; + loc = limit + 1; goto lab25; } break; case new_line + car_ret: { - cur_input.loc_field = cur_input.limit_field + 1; + loc = limit + 1; cur_cs = par_loc; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); @@ -2327,7 +2259,7 @@ lab40: case skip_blanks + left_brace: case new_line + left_brace: { - cur_input.state_field = mid_line; + state = mid_line; incr(align_state); } break; @@ -2339,14 +2271,14 @@ lab40: case skip_blanks + right_brace: case new_line + right_brace: { - cur_input.state_field = 1; + state = 1; decr(align_state); } break; case add_delims_to(skip_blanks): case add_delims_to(new_line): - cur_input.state_field = 1; + state = 1; break; default: @@ -2355,16 +2287,16 @@ lab40: } else { - cur_input.state_field = new_line; + state = new_line; if (cur_input.name_field > 17) { incr(line); - first = cur_input.start_field; + first = start; if (!force_eof) { - if (input_ln(input_file[cur_input.index_field], true)) + if (input_ln(input_file[index], true)) firm_up_the_line(); else force_eof = true; @@ -2384,12 +2316,12 @@ lab40: } 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; + buffer[limit] = end_line_char; - first = cur_input.limit_field + 1; - cur_input.loc_field = cur_input.start_field; + first = limit + 1; + loc = start; } else { @@ -2412,23 +2344,23 @@ lab40: if (interaction > nonstop_mode) { if ((end_line_char < 0) || (end_line_char > 255)) - incr(cur_input.limit_field); + incr(limit); - if (cur_input.limit_field == cur_input.start_field) + if (limit == start) print_nl("(Please type a command or say `\\end')"); print_ln(); - first = cur_input.start_field; + first = start; prompt_input("*"); - cur_input.limit_field = last; + limit = last; 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; + buffer[limit]= end_line_char; - first = cur_input.limit_field + 1; - cur_input.loc_field = cur_input.start_field; + first = limit + 1; + loc = start; } else { @@ -2447,10 +2379,10 @@ lab40: goto lab25; } } - else if (cur_input.loc_field != 0) + else if (loc != 0) { - t = info(cur_input.loc_field); - cur_input.loc_field = link(cur_input.loc_field); + t = info(loc); + loc = link(loc); if (t >= cs_token_flag) { @@ -2461,8 +2393,8 @@ lab40: if (cur_cmd >= outer_call) if (cur_cmd == dont_expand) { - cur_cs = info(cur_input.loc_field) - cs_token_flag; - cur_input.loc_field = 0; + cur_cs = info(loc) - cs_token_flag; + loc = 0; cur_cmd = eq_type(cur_cs); cur_chr = equiv(cur_cs); @@ -2494,7 +2426,7 @@ lab40: case out_param: { - begin_token_list(param_stack[cur_input.limit_field + cur_chr - 1], parameter); + begin_token_list(param_stack[limit + cur_chr - 1], parameter); goto lab20; } break; diff --git a/src/texsourc/tex3.c b/src/texsourc/tex3.c index 2a6f5a6..44e9726 100644 --- a/src/texsourc/tex3.c +++ b/src/texsourc/tex3.c @@ -685,7 +685,7 @@ void conv_toks (void) { char old_setting; char c; - small_number savescannerstatus; + small_number save_scanner_status; pool_pointer b; c = cur_chr; @@ -699,10 +699,10 @@ void conv_toks (void) case string_code: case meaning_code: - savescannerstatus = scanner_status; + save_scanner_status = scanner_status; scanner_status = 0; get_token(); - scanner_status = savescannerstatus; + scanner_status = save_scanner_status; break; case font_name_code: @@ -1001,16 +1001,16 @@ void read_toks_(integer n, halfword r) } } - cur_input.limit_field = last; + limit = last; 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; + buffer[limit] = end_line_char; - first = cur_input.limit_field + 1; - cur_input.loc_field = cur_input.start_field; - cur_input.state_field = new_line; + first = limit + 1; + loc = start; + state = new_line; while (true) { @@ -1025,7 +1025,7 @@ void read_toks_(integer n, halfword r) { get_token(); } - while(!(cur_tok == 0)); + while (!(cur_tok == 0)); align_state = 1000000L; goto lab30; @@ -1036,7 +1036,7 @@ void read_toks_(integer n, halfword r) lab30: end_file_reading(); } - while(!(align_state == 1000000L)); + while (!(align_state == 1000000L)); cur_val = def_ref; scanner_status = normal; @@ -1046,9 +1046,9 @@ lab30: void pass_text (void) { integer l; - small_number savescannerstatus; + small_number save_scanner_status; - savescannerstatus = scanner_status; + save_scanner_status = scanner_status; scanner_status = skipping; l = 0; skip_line = line; @@ -1069,7 +1069,7 @@ void pass_text (void) incr(l); } lab30: - scanner_status = savescannerstatus; + scanner_status = save_scanner_status; } /* sec 0497 */ void change_if_limit_(small_number l, halfword p) @@ -1108,7 +1108,7 @@ void conditional (void) char r; integer m, n; halfword p, q; - small_number savescannerstatus; + small_number save_scanner_status; halfword savecondptr; small_number thisif; @@ -1191,7 +1191,7 @@ void conditional (void) { get_x_token(); } - while(!(cur_cmd != spacer)); + while (!(cur_cmd != spacer)); if ((cur_tok >= other_token + '<') && (cur_tok <= other_token + '>')) r = cur_tok - other_token; @@ -1267,7 +1267,7 @@ void conditional (void) case ifx_code: { - savescannerstatus = scanner_status; + save_scanner_status = scanner_status; scanner_status = 0; get_next(); n = cur_cs; @@ -1301,7 +1301,7 @@ void conditional (void) } } - scanner_status = savescannerstatus; + scanner_status = save_scanner_status; } break; @@ -1454,107 +1454,6 @@ boolean more_name_(ASCII_code c) } } -// The following code is to save string space used by TeX for filenames -// Not really critical in a system that has dynamic memory allocation -// And may slow it down slightly - although this linear search only -// occurs when opening a file, which is somewhat slow inany case... - -// see if string from str_pool[start] to str_pool[end] -// occurs elsewhere in string pool - returns string number -// returns -1 if not found in string pool 2000 Aug 15 - -int find_string (int start, int end) -{ - int k, nlen = end - start; - char *s; - - if (trace_flag) - { - sprintf(log_line, "\nLOOKING for string (str_ptr %d nlen %d) ", str_ptr, end - start); - s = log_line + strlen(log_line); - strncpy(s, (const char *) str_pool + start, nlen); - strcpy(s + nlen, ""); - show_line(log_line, 0); - } - -// avoid problems with(cur_name == flushablestring)by going only up to str_ptr-1 -// code in new_font (tex8.c) will take care of reuse of font name already - for (k = 0; k < str_ptr - 1; k++) - { - if (length(k) != nlen) - continue; - - if (strncmp((const char *) str_pool + start, (const char *) str_pool + str_start[k], nlen) == 0) - { - if (trace_flag) - { - sprintf(log_line, "\nFOUND the string %d (%d) ", k, str_start[k+1]-str_start[k]); - s = log_line + strlen(log_line); - strncpy(s, (const char *)str_pool + start, nlen); - strcpy(s+nlen, "\n"); - show_line(log_line, 0); - } - return k; // return number of matching string - } - } - - if (trace_flag) - { - sprintf(log_line, "\nNOT FOUND string "); - s = log_line + strlen(log_line); - strncpy(s, (const char*)str_pool + start, nlen); - strcpy(s + nlen, "\n"); - show_line(log_line, 0); - } - - return -1; // no match found -} - -// snip out the string from str_pool[start] to str_pool[end] -// and move everything above it down 2000 Aug 15 - -void remove_string (int start, int end) -{ - int nlen = pool_ptr - end; // how many bytes to move down - char *s; - - if (trace_flag) - { - int n = end - start; - sprintf(log_line, "\nSTRIPPING OUT %d %d ", n, nlen); - s = log_line + strlen(log_line); - strncpy(s, (const char *) str_pool + start, n); - strcpy(s + n, "\n"); - show_line(log_line, 0); - } - - if (nlen > 0) - memcpy(str_pool + start, str_pool + end, nlen); - - pool_ptr = start + nlen; -} - -void show_string (int k) -{ - int nlen = length(k); - char *s; - - sprintf(log_line, "\nSTRING %5d (%3d) %5d--%5d ", - k, nlen, str_start[k], str_start[k+1]); - s = log_line + strlen(log_line); - strncpy(s, (const char *)str_pool + str_start[k], nlen); - strcpy(s + nlen, ""); - show_line(log_line, 0); -} - -void show_all_strings (void) -{ - int k; - - for (k = 0; k < str_ptr; k++) - show_string(k); -} - /* sec 0517 */ void end_name (void) { @@ -1579,53 +1478,22 @@ void end_name (void) cur_area = 335; // "" default area else { - if (save_strings_flag && (cur_area = find_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter)) > 0) - { - remove_string(str_start[str_ptr], str_start[str_ptr] + area_delimiter); - area_delimiter = 0; // area_delimiter - area_delimiter; - - if (ext_delimiter != 0) - ext_delimiter = ext_delimiter - area_delimiter; - } - else // carve out string for "cur_area" - { - cur_area = str_ptr; - str_start[str_ptr + 1] = str_start[str_ptr] + area_delimiter; - incr(str_ptr); - } + cur_area = str_ptr; + str_start[str_ptr + 1] = str_start[str_ptr] + area_delimiter; + incr(str_ptr); } if (ext_delimiter == 0) // no extension delimiter '.' found { cur_ext = 335; // "" default extension - - if (save_strings_flag && (cur_name = find_string(str_start[str_ptr], pool_ptr)) > 0) - { - remove_string(str_start[str_ptr], pool_ptr); - } - else // Make string from str_start[str_ptr]to pool_ptr - cur_name = make_string(); + cur_name = make_string(); } else // did find an extension { - if (save_strings_flag && - (cur_name = find_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter-1)) > 0) - { - remove_string(str_start[str_ptr], str_start[str_ptr] + ext_delimiter - area_delimiter - 1); - } - else // carve out string for "cur_name" - { - cur_name = str_ptr; - str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1; - incr(str_ptr); - } - - if (save_strings_flag && (cur_ext = find_string(str_start[str_ptr], pool_ptr)) > 0) - { - remove_string(str_start[str_ptr], pool_ptr); - } - else // Make string from str_start[str_ptr]to pool_ptr - cur_ext = make_string(); + cur_name = str_ptr; + str_start[str_ptr + 1] = str_start[str_ptr]+ ext_delimiter - area_delimiter - 1; + incr(str_ptr); + cur_ext = make_string(); } } @@ -1641,24 +1509,42 @@ void pack_file_name_(str_number n, str_number a, str_number e) k = 0; for (j = str_start[a]; j <= str_start[a + 1] - 1; j++) - append_to_name(str_pool[j]); + { + c = str_pool[j]; + incr(k); + + if (k <= file_name_size) + name_of_file[k] = xchr[c]; + } for (j = str_start[n]; j <= str_start[n + 1] - 1; j++) - append_to_name(str_pool[j]); + { + c = str_pool[j]; + incr(k); + + if (k <= file_name_size) + name_of_file[k] = xchr[c]; + } for (j = str_start[e]; j <= str_start[e + 1] - 1; j++) - append_to_name(str_pool[j]); + { + c = str_pool[j]; + incr(k); - if (k < PATH_MAX) + if (k <= file_name_size) + name_of_file[k] = xchr[c]; + } + + if (k < file_name_size) name_length = k; else - name_length = PATH_MAX - 1; + name_length = file_name_size - 1; /* pad it out with spaces ... what for ? in case we modify and forget ? */ - for (k = name_length + 1; k <= PATH_MAX; k++) + for (k = name_length + 1; k <= file_name_size; k++) name_of_file[k] = ' '; - name_of_file[PATH_MAX] = '\0'; + name_of_file[file_name_size] = '\0'; /* paranoia 94/Mar/24 */ { name_of_file [name_length+1] = '\0'; @@ -1682,8 +1568,8 @@ void pack_buffered_name_(small_number n, integer a, integer b) ASCII_code c; integer j; - if (n + b - a + 5 > PATH_MAX) - b = a + PATH_MAX - n - 5; + if (n + b - a + 5 > file_name_size) + b = a + file_name_size - n - 5; k = 0; @@ -1693,7 +1579,7 @@ void pack_buffered_name_(small_number n, integer a, integer b) c = xord[TEX_format_default[j]]; incr(k); - if (k <= PATH_MAX) + if (k <= file_name_size) name_of_file[k] = xchr[c]; } /* This loop kicks in when we want a specififed format name */ @@ -1702,7 +1588,7 @@ void pack_buffered_name_(small_number n, integer a, integer b) c = buffer[j]; incr(k); - if (k <= PATH_MAX) + if (k <= file_name_size) name_of_file[k] = xchr[c]; } @@ -1712,20 +1598,20 @@ void pack_buffered_name_(small_number n, integer a, integer b) c = xord[TEX_format_default[j]]; incr(k); - if (k <= PATH_MAX) + if (k <= file_name_size) name_of_file[k] = xchr[c]; } - if (k < PATH_MAX) + if (k < file_name_size) name_length = k; else - name_length = PATH_MAX - 1; + name_length = file_name_size - 1; /* pad it out with spaces ... what for ? */ - for (k = name_length + 1; k <= PATH_MAX; k++) + for (k = name_length + 1; k <= file_name_size; k++) name_of_file[k]= ' '; - name_of_file[PATH_MAX] = '\0'; /* paranoia 94/Mar/24 */ + name_of_file[file_name_size] = '\0'; /* paranoia 94/Mar/24 */ } /* sec 0525 */ str_number make_name_string (void) @@ -1755,17 +1641,20 @@ str_number make_name_string (void) } } /* sec 0525 */ -str_number a_make_name_string_(alpha_file * f) +//str_number a_make_name_string_(alpha_file * f) +str_number a_make_name_string_(void) { return make_name_string(); } /* sec 0525 */ -str_number b_make_name_string_(byte_file * f) +//str_number b_make_name_string_(byte_file * f) +str_number b_make_name_string_(void) { return make_name_string(); } /* sec 0525 */ -str_number w_make_name_string_(word_file * f) +//str_number w_make_name_string_(word_file * f) +str_number w_make_name_string_(void) { return make_name_string(); } @@ -1849,12 +1738,15 @@ void prompt_file_name_(char * s, str_number e) if (interaction < 2) { fatal_error("*** (job aborted, file error in nonstop mode)"); - return; + return; // abort_flag set } if (!knuth_flag) +#ifdef _WINDOWS + show_line(" (or ^z to exit)", 0); +#else show_line(" (or Ctrl-Z to exit)", 0); - +#endif prompt_input(": "); /* should we deal with tilde and space in file name here ??? */ @@ -1932,14 +1824,14 @@ void open_log_file (void) { stamp_it(log_line); strcat(log_line, "\n"); - fputs(log_line, log_file); + (void) fputs(log_line, log_file); stampcopy(log_line); strcat(log_line, "\n"); - fputs(log_line, log_file); + (void) fputs(log_line, log_file); } - fputs(tex_version, log_file); - fprintf(log_file, " (%s %s)", application, yandyversion); + (void) fputs(tex_version, log_file); + (void) fprintf(log_file, " (%s %s)", application, yandyversion); if (format_ident > 0) slow_print(format_ident); @@ -1955,7 +1847,7 @@ void open_log_file (void) months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"; for (k = 3 * month - 2; k <= 3 * month; k++) - putc(months[k], log_file); + (void) putc(months[k], log_file); print_char(' '); @@ -1994,20 +1886,85 @@ void open_log_file (void) selector = old_setting + 2; } + +// Attempt to deal with foo.bar.tex given as foo.bar on command line +// Makes copy of job_name with extension + +void more_name_copy(ASCII_code c) +{ +#ifdef ALLOCATESTRING + if (pool_ptr + 1 > current_pool_size) + str_pool = realloc_str_pool (increment_pool_size); + + if (pool_ptr + 1 > current_pool_size) + { + overflow("pool size", current_pool_size - init_pool_ptr); + return; + } +#else + if (pool_ptr + 1 > pool_size) + { + overflow("pool size", pool_size - init_pool_ptr); + return; + } +#endif + + str_pool[pool_ptr] = c; + incr(pool_ptr); +} + +int end_name_copy(void) +{ +#ifdef ALLOCATESTRING + if (str_ptr + 1 > current_max_strings) + str_start = realloc_str_start(increment_max_strings + 1); + + if (str_ptr + 1 > current_max_strings) + { + overflow("number of strings", current_max_strings - init_str_ptr); + return 0; + } +#else + if (str_ptr + 1 > max_strings) + { + overflow("number of strings", max_strings - init_str_ptr); + return 0; + } +#endif + + return make_string(); +} + +void job_name_append (void) +{ + int k, n; + + k = str_start[job_name]; + n = str_start[job_name + 1]; + + while (k < n) + more_name_copy(str_pool[k++]); + + k = str_start[cur_ext]; + n = str_start[cur_ext + 1]; + + while (k < n) + more_name_copy(str_pool[k++]); + + job_name = end_name_copy(); +} + /* sec 0537 */ void start_input(void) { - boolean added_extension = false; - scan_file_name(); pack_file_name(cur_name, cur_area, cur_ext); while (true) { - added_extension = false; begin_file_reading(); - if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH)) + if (a_open_in(input_file[index], TEXINPUTPATH)) goto lab30; end_file_reading(); @@ -2015,7 +1972,7 @@ void start_input(void) } lab30: - cur_input.name_field = a_make_name_string(input_file[cur_input.index_field]); + cur_input.name_field = a_make_name_string(input_file[index]); if (job_name == 0) { @@ -2040,31 +1997,28 @@ lab30: fflush(stdout); #endif - cur_input.state_field = new_line; + state = new_line; { line = 1; - if (input_ln(input_file[cur_input.index_field], false)); + if (input_ln(input_file[index], false)); firm_up_the_line(); 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; + buffer[limit] = end_line_char; - first = cur_input.limit_field + 1; - cur_input.loc_field = cur_input.start_field; + first = limit + 1; + loc = start; } } /* sec 0560 */ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire, scaled s) { font_index k; - eight_bits jfm_flag; - halfword nt; - KANJI_code cx; boolean file_opened; halfword lf, lh, nw, nh, nd, ni, nl, nk, ne, np; int bc, ec; @@ -2094,31 +2048,6 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire read_sixteen(lf); tfm_temp = getc(tfm_file); read_sixteen(lh); - - if (lf == yoko_jfm_id) - { - jfm_flag = dir_yoko; - nt = lh; - tfm_temp = getc(tfm_file); - read_sixteen(lf); - tfm_temp = getc(tfm_file); - read_sixteen(lh); - } - else if (lf == tate_jfm_id) - { - jfm_flag = dir_tate; - nt = lh; - tfm_temp = getc(tfm_file); - read_sixteen(lf); - tfm_temp = getc(tfm_file); - read_sixteen(lh); - } - else - { - jfm_flag = dir_default; - nt = 0; - } - tfm_temp = getc(tfm_file); read_sixteen(bc); tfm_temp = getc(tfm_file); @@ -2150,25 +2079,14 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire tfm_temp = getc(tfm_file); read_sixteen(np); - if (jfm_flag != dir_default) - { - if (lf != 7 + lh + nt + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np) - goto lab11; - } - else - { - if (lf != 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np) - goto lab11; - } + if (lf != 6 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ne + np) + goto lab11; if ((nw == 0) || (nh == 0) || (nd == 0) || (ni == 0)) goto lab11; } - if (jfm_flag != dir_default) - lf = lf - 7 - lh; - else - lf = lf - 6 - lh; + lf = lf - 6 - lh; if (np < 7) lf = lf + 7 - np; @@ -2216,10 +2134,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire } f = font_ptr + 1; - font_dir[f] = jfm_flag; - font_num_ext[f] = nt; - ctype_base[f] = fmem_ptr; - char_base[f] = ctype_base[f] + nt - bc; + char_base[f] = fmem_ptr - bc; width_base[f] = char_base[f] + ec + 1; height_base[f] = width_base[f] + nw; depth_base[f] = height_base[f] + nh; @@ -2242,7 +2157,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire z =(z * 16) + (tfm_temp / 16); if (z < 65536L) - goto lab11; + goto lab11; while (lh > 2) { @@ -2264,20 +2179,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire font_size[f] = z; } - if (jfm_flag != dir_default) - { - for (k = ctype_base[f]; k <= ctype_base[f] + nt - 1; k++) - { - tfm_temp = getc(tfm_file); - read_sixteen(cx); - font_info[k].hh.rh = cx; - tfm_temp = getc(tfm_file); - read_sixteen(cx); - font_info[k].hh.lh = cx; - } - } - - for (k = char_base[f] + bc; k <= width_base[f] - 1; k++) + for (k = fmem_ptr; k <= width_base[f] - 1; k++) { store_four_quarters(font_info[k].qqqq); @@ -2303,7 +2205,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire goto lab11; } - while (d < k - char_base[f]) + while (d < k + bc - fmem_ptr) { qw = char_info(f, d); @@ -2313,7 +2215,7 @@ internal_font_number read_font_info_(halfword u, str_number nom, str_number aire d = rem_byte(qw); } - if (d == k - char_base[f]) + if (d == k + bc - fmem_ptr) goto lab11; lab45:; } @@ -2392,17 +2294,29 @@ lab45:; else { if (b != bchar) - check_existence(b); + { + { + if ((b < bc) || (b > ec)) /* check-existence(b) */ + goto lab11; /* error in TFM, abort */ + } + + qw = font_info[char_base[f] + b].qqqq; + + if (!(qw.b0 > 0)) + goto lab11; /* error in TFM, abort */ + } if (c < 128) { - if (jfm_flag != dir_default) { - if (d > ne) - goto lab11; + if ((d < bc) || (d > ec)) /* check-existence(d) */ + goto lab11; /* error in TFM, abort */ } - else - check_existence(d); + + qw = font_info[char_base[f] + d].qqqq; + + if (!(qw.b0 > 0)) + goto lab11; /* error in TFM, abort */ } else if (256 * (c - 128) + d >= nk) goto lab11; /* error in TFM, abort */ @@ -2418,29 +2332,78 @@ lab45:; } for (k = kern_base[f] + 256 * (128); k <= exten_base[f] - 1; k++) - store_scaled(font_info[k].cint); - - if (jfm_flag != dir_default) { - for (k = exten_base[f]; k < param_base[f] - 1; k++) - store_scaled(font_info[k].cint); + tfm_temp = getc(tfm_file); + a = tfm_temp; + tfm_temp = getc(tfm_file); + b = tfm_temp; + tfm_temp = getc(tfm_file); + c = tfm_temp; + tfm_temp = getc(tfm_file); + d = tfm_temp; + sw = (((((d * z) / 256) + (c * z)) / 256) + (b * z)) / beta; + + if (a == 0) + font_info[k].cint = sw; + else if (a == 255) + font_info[k].cint = sw - alpha; + else goto lab11; } - else + + /* read extensible character recipes */ + for (k = exten_base[f]; k <= param_base[f] - 1; k++) { - for (k = exten_base[f]; k <= param_base[f] - 1; k++) + store_four_quarters(font_info[k].qqqq); + + if (a != 0) { - store_four_quarters(font_info[k].qqqq); - - if (a != 0) - check_existence(a); + { + if ((a < bc) || (a > ec)) + goto lab11; + } + + qw = font_info[char_base[f] + a].qqqq; + + if (!(qw.b0 > 0)) + goto lab11; + } - if (b != 0) - check_existence(b); + if (b != 0) + { + { + if ((b < bc) || (b > ec)) + goto lab11; + } - if (c != 0) - check_existence(c); + qw = font_info[char_base[f] + b].qqqq; - check_existence(d); + if (!(qw.b0 > 0)) + goto lab11; + } + + if (c != 0) + { + { + if ((c < bc) || (c > ec)) + goto lab11; + } + + qw = font_info[char_base[f] + c].qqqq; + + if (!(qw.b0 > 0)) + goto lab11; + } + + { + { + if ((d < bc) || (d > ec)) + goto lab11; + } + + qw = font_info[char_base[f] + d].qqqq; + + if (!(qw.b0 > 0)) + goto lab11; } } @@ -2462,7 +2425,23 @@ lab45:; font_info[param_base[f]].cint = (sw * 16) + (tfm_temp / 16); } else - store_scaled(font_info[param_base[f] + k - 1].cint); + { + tfm_temp = getc(tfm_file); + a = tfm_temp; + tfm_temp = getc(tfm_file); + b = tfm_temp; + tfm_temp = getc(tfm_file); + c = tfm_temp; + tfm_temp = getc(tfm_file); + d = tfm_temp; + sw = (((((d * z) / 256) + (c * z)) / 256) + (b * z)) / beta; + + if (a == 0) + font_info[param_base[f] + k - 1].cint = sw; + else if (a == 255) + font_info[param_base[f] + k - 1].cint = sw - alpha; + else goto lab11; + } if (feof(tfm_file)) goto lab11; @@ -2490,10 +2469,10 @@ lab45:; if (bchar <= ec) if (bchar >= bc) { - qw = char_info(f, bchar); + qw = font_info[char_base[f] + bchar].qqqq; if ((qw.b0 > 0)) - font_false_bchar[f] = non_char; + font_false_bchar[f] = 256; } font_name[f] = nom; @@ -2501,7 +2480,6 @@ lab45:; font_bc[f] = bc; font_ec[f] = ec; font_glue[f] = 0; - ctype_base[f] = ctype_base[f]; char_base[f] = char_base[f]; width_base[f] = width_base[f]; lig_kern_base[f] = lig_kern_base[f]; diff --git a/src/texsourc/tex4.c b/src/texsourc/tex4.c index 37cfea4..78b48d8 100644 --- a/src/texsourc/tex4.c +++ b/src/texsourc/tex4.c @@ -141,7 +141,7 @@ void dvi_four_(integer x) dvi_out(x % 0400); // dvi_out(x & 255); } /* sec 0601 */ -void zdvipop(integer l) +void dvi_pop_(integer l) { if ((l == dvi_offset + dvi_ptr) && (dvi_ptr > 0)) decr(dvi_ptr); @@ -481,7 +481,7 @@ void write_out_(pointer p) { get_token(); } - while(!(cur_tok == end_write_token)); + while (!(cur_tok == end_write_token)); } mode = oldmode; @@ -541,7 +541,7 @@ void out_what_(pointer p) pack_file_name(cur_name, cur_area, cur_ext); - while(! a_open_out(write_file[j])) + while (! a_open_out(write_file[j])) { prompt_file_name("output file name", ".tex"); } @@ -667,7 +667,7 @@ lab21: cur_h = cur_h + char_width(f, char_info(f, c)); p = link(p); } - while(!(!(p >= hi_mem_min))); + while (!(!is_char_node(p))); dvi_h = cur_h; } @@ -918,7 +918,7 @@ void vlist_out (void) while (p != 0) { - if ((p >= hi_mem_min)) + if (is_char_node(p)) { confusion("vlistout"); return; // abort_flag set @@ -1139,7 +1139,7 @@ void dvi_ship_out_(halfword p) print_char('['); j = 9; - while((count(j) == 0) && (j > 0)) + while ((count(j) == 0) && (j > 0)) decr(j); for (k = 0; k <= j; k++) @@ -1200,7 +1200,7 @@ void dvi_ship_out_(halfword p) pack_job_name(".dvi"); - while(!b_open_out(dvi_file)) + while (!b_open_out(dvi_file)) { prompt_file_name("file name for output", ".dvi"); } @@ -1375,7 +1375,7 @@ halfword hpack_(halfword p, scaled w, small_number m) while (p != 0) { lab21: - while ((p >= hi_mem_min)) + while (is_char_node(p)) { f = font(p); i = char_info(f, character(p)); @@ -1590,7 +1590,7 @@ lab21: { if ((overfull_rule > 0) && (- (integer) x - total_shrink[0] > hfuzz)) { - while(link(q) != 0) + while (link(q) != 0) q = link(q); link(q) = new_rule(); @@ -1683,7 +1683,7 @@ halfword vpackage_(halfword p, scaled h, small_number m, scaled l) while (p != 0) { - if ((p >= hi_mem_min)) + if (is_char_node(p)) { confusion("vpack"); return 0; // abort_flag set @@ -2142,7 +2142,7 @@ lab40: n = 0; if (u > 0) - while(w < v) + while (w < v) { w = w + u; incr(n); diff --git a/src/texsourc/tex5.c b/src/texsourc/tex5.c index b6fdcc0..db6c823 100644 --- a/src/texsourc/tex5.c +++ b/src/texsourc/tex5.c @@ -33,7 +33,7 @@ halfword rebox_(halfword b, scaled w) p = list_ptr(b); - if (((p >= hi_mem_min)) && (link(p) == 0)) + if ((is_char_node(p)) && (link(p) == 0)) { f = font(p); v = char_width(f, char_info(f, character(p))); @@ -175,7 +175,7 @@ halfword clean_box_(halfword p, small_number s) cur_mu = x_over_n(math_quad(cur_size), 18); } lab40: - if ((q >= hi_mem_min) || (q == 0)) + if (is_char_node(q) || (q == 0)) x = hpack(q, 0, 1); else if ((link(q) == 0) && (type(q) <= vlist_node) && (shift_amount(q) == 0)) x = q; @@ -184,13 +184,13 @@ lab40: q = list_ptr(x); - if ((q >= hi_mem_min)) + if (is_char_node(q)) { r = link(q); if (r != 0) if (link(r) == 0) - if (!(r >= hi_mem_min)) + if (!is_char_node(r)) if (type(r) == kern_node) { free_node(r, small_node_size); @@ -1637,7 +1637,7 @@ void fin_align (void) while (q != 0) { - if (!(q >= hi_mem_min)) + if (!is_char_node(q)) if (type(q) == unset_node) { if (mode == -vmode) @@ -1785,7 +1785,7 @@ void fin_align (void) r = link(link(r)); s = link(link(s)); } - while(!(r == 0)); + while (!(r == 0)); } else if (type(q) == rule_node) { @@ -2191,7 +2191,7 @@ void make_scripts_(halfword q, scaled delta) p = new_hlist(q); - if ((p >= hi_mem_min)) + if (is_char_node(p)) { shift_up = 0; shift_down = 0; diff --git a/src/texsourc/tex6.c b/src/texsourc/tex6.c index 0bd1261..1aafbea 100644 --- a/src/texsourc/tex6.c +++ b/src/texsourc/tex6.c @@ -147,7 +147,7 @@ lab22: decr(t); v = link(v); - if ((v >= hi_mem_min)) + if (is_char_node(v)) { f = font(v); break_width[1] = break_width[1] - char_width(f, char_info(f, character(v))); @@ -179,7 +179,7 @@ lab22: while (s != 0) { - if ((s >= hi_mem_min)) + if (is_char_node(s)) { f = font(s); break_width[1] = break_width[1] + char_width(f, char_info(f, character(s))); @@ -219,7 +219,7 @@ lab22: while (s != 0) { - if ((s >= hi_mem_min)) + if (is_char_node(s)) goto lab30; switch (type(s)) @@ -778,7 +778,7 @@ lab30: if (q == cur_break(cur_p)) goto lab31; - if ((q >= hi_mem_min)) + if (is_char_node(q)) goto lab31; if (non_discardable(q)) @@ -835,7 +835,7 @@ small_number reconstitute_(small_number j, small_number n, halfword bchar, halfw if (ligature_present) lft_hit = init_lft; - while(p != 0) /* 94/Mar/22 BUG FIX */ + while (p != 0) /* 94/Mar/22 BUG FIX */ { append_charnode_to_t(character(p)); p = link(p); @@ -1130,7 +1130,7 @@ void hyphenate (void) incr(j); incr(u); } - while(!(j > hn)); + while (!(j > hn)); s = hyph_list[h]; @@ -1181,7 +1181,7 @@ lab45: v = hyf_next[v]; } - while(!(v == min_trie_op)); + while (!(v == min_trie_op)); } incr(l); @@ -1207,7 +1207,7 @@ lab41:; link(ha) = 0; bchar = hyfbchar; - if ((ha >= hi_mem_min)) + if (is_char_node(ha)) if (font(ha) != hf) goto lab42; else @@ -1237,7 +1237,7 @@ lab41:; } else { - if (!(r >= hi_mem_min)) + if (!is_char_node(r)) if (type(r) == ligature_node) if (subtype(r) > 1) goto lab42; @@ -1406,9 +1406,9 @@ lab50: hyphen_passed = j - 1; link(hold_head) = 0; } - while(!(! odd(hyf[j - 1]))); + while (!(! odd(hyf[j - 1]))); } - while(!(j > hn)); + while (!(j > hn)); link(s) = q; flush_list(init_list); @@ -1528,7 +1528,7 @@ lab21: incr(u); incr(v); } - while(!(u == str_start[k + 1])); + while (!(u == str_start[k + 1])); lab40: q = hyph_list[h]; hyph_list[h] = p; @@ -1577,7 +1577,7 @@ halfword prune_page_top_(halfword p) prev_p = temp_head; link(temp_head) = p; - while(p != 0) + while (p != 0) switch(type(p)) { case hlist_node: diff --git a/src/texsourc/tex7.c b/src/texsourc/tex7.c index 81951bc..ce348a4 100644 --- a/src/texsourc/tex7.c +++ b/src/texsourc/tex7.c @@ -714,7 +714,7 @@ void box_end_(integer box_context) { get_x_token(); } - while(!((cur_cmd != spacer) && (cur_cmd != relax))); + while (!((cur_cmd != spacer) && (cur_cmd != relax))); if (((cur_cmd == hskip) && (abs(mode) != vmode)) || ((cur_cmd == vskip) && (abs(mode) == vmode))) { @@ -779,7 +779,7 @@ void begin_box_(integer box_context) } else { - if (!(tail >= hi_mem_min)) + if (!is_char_node(tail)) if ((type(tail) == hlist_node) || (type(tail) == vlist_node)) { q = head; @@ -788,7 +788,7 @@ void begin_box_(integer box_context) { p = q; - if (!(q >= hi_mem_min)) + if (!is_char_node(q)) if (type(q) == disc_node) { for (m = 1; m <= replace_count(q); m++) @@ -991,7 +991,7 @@ void head_for_vmode (void) back_input(); cur_tok = par_token; back_input(); - cur_input.index_field = inserted; + index = inserted; } } /* sec 1096 */ @@ -1082,7 +1082,7 @@ void delete_last (void) } else { - if (!(tail >= hi_mem_min)) + if (!is_char_node(tail)) if (type(tail) == cur_chr) { q = head; @@ -1091,7 +1091,7 @@ void delete_last (void) { p = q; - if (!(q >= hi_mem_min)) + if (!is_char_node(q)) if (type(q) == disc_node) { for (m = 1; m <= replace_count(q); m++) @@ -1155,7 +1155,7 @@ void append_italic_correction (void) if (tail != head) { - if ((tail >= hi_mem_min)) + if (is_char_node(tail)) p = tail; else if (type(tail) == ligature_node) p = tail + 1; @@ -1206,7 +1206,7 @@ void build_discretionary (void) while (p != 0) { - if (!(p >= hi_mem_min)) + if (!is_char_node(p)) if (type(p) > rule_node) if (type(p) != kern_node) if (type(p) != ligature_node) @@ -1487,7 +1487,7 @@ void init_math (void) while (p != 0) { lab21: - if ((p >= hi_mem_min)) + if (is_char_node(p)) { f = font(p); d = char_width(f, char_info(f, character(p))); @@ -1651,7 +1651,7 @@ lab20: { get_x_token(); } - while(!((cur_cmd != spacer) && (cur_cmd != relax))); + while (!((cur_cmd != spacer) && (cur_cmd != relax))); lab21: switch (cur_cmd) diff --git a/src/texsourc/tex8.c b/src/texsourc/tex8.c index d2b55f6..1595304 100644 --- a/src/texsourc/tex8.c +++ b/src/texsourc/tex8.c @@ -242,7 +242,7 @@ void after_math (void) mlist_to_hlist(); link(tail) = link(temp_head); - while(link(tail) != 0) + while (link(tail) != 0) tail = link(tail); tail_append(new_math(math_surround, 1)); @@ -317,7 +317,7 @@ void after_math (void) d = half(z - w - e); if (p != 0) - if (!(p >= hi_mem_min)) + if (!is_char_node(p)) if (type(p) == glue_node) d = 0; } @@ -819,7 +819,7 @@ void new_font_(small_number a) l1 = length(cur_area); l2 = length(cur_name); show_char('\n'); - show_line("FONT ", 0); + puts("FONT "); for (i = 0; i < l1; i++) { @@ -957,7 +957,7 @@ void open_or_close_in (void) if ((cur_ext != 335) && a_open_in(read_file[n], TEXINPUTPATH)) read_open[n] = 1; - else if ((cur_ext != 785) && (name_length + 5 < PATH_MAX)) + else if ((cur_ext != 785) && (name_length + 5 < file_name_size)) { strncpy((char *) name_of_file + name_length + 1, ".tex ", 5); name_length = name_length + 4; @@ -1402,7 +1402,7 @@ void handle_right_brace (void) break; case output_group: { - if ((cur_input.loc_field != 0) || ((token_type != output_text) && (token_type != backed_up))) + if ((loc != 0) || ((token_type != output_text) && (token_type != backed_up))) { print_err("Unbalanced output routine"); help2("Your sneaky output routine has problematic {'s and/or }'s.", @@ -1413,7 +1413,7 @@ void handle_right_brace (void) { get_token(); } - while (!(cur_input.loc_field == 0)); + while (!(loc == 0)); } end_token_list(); @@ -1521,7 +1521,7 @@ void handle_right_brace (void) { q = head; - while(link(q) != tail) + while (link(q) != tail) q = link(q); link(q) = p; @@ -1625,7 +1625,7 @@ lab21: { get_x_token(); } - while(!(cur_cmd != spacer)); + while (!(cur_cmd != spacer)); goto lab21; } break; @@ -2105,7 +2105,7 @@ lab90: cur_l = character(lig_stack); lab91: - if (!(lig_stack >= hi_mem_min)) + if (!is_char_node(lig_stack)) goto lab95; lab92: @@ -2247,7 +2247,7 @@ lab112: lig_stack = new_lig_item(cur_r); bchar = non_char; } - else if ((lig_stack >= hi_mem_min)) + else if (is_char_node(lig_stack)) { main_p = lig_stack; lig_stack = new_lig_item(cur_r); diff --git a/src/texsourc/tex9.c b/src/texsourc/tex9.c index fffb646..e43d925 100644 --- a/src/texsourc/tex9.c +++ b/src/texsourc/tex9.c @@ -30,18 +30,18 @@ boolean open_fmt_file (void) { integer j; - j = cur_input.loc_field; + j = loc; - if (buffer[cur_input.loc_field] == '&' || buffer[cur_input.loc_field] == '+') + if (buffer[loc] == '&' || buffer[loc] == '+') { - incr(cur_input.loc_field); - j = cur_input.loc_field; + incr(loc); + j = loc; buffer[last] = ' '; while (buffer[j] != ' ') incr(j); - pack_buffered_name(0, cur_input.loc_field, j - 1); + pack_buffered_name(0, loc, j - 1); if (w_open_in(fmt_file)) goto lab40; @@ -98,7 +98,7 @@ boolean open_fmt_file (void) } lab40: - cur_input.loc_field = j; + loc = j; return true; } @@ -117,12 +117,12 @@ void close_files_and_terminate (void) if (closed_already++) { - show_line("close_files_and_terminated already ", 0); + puts("close_files_and_terminated already "); return; // sanity check } if (trace_flag) - show_line("\nclose_files_and_terminate ", 0); + puts("\nclose_files_and_terminate "); for (k = 0; k <= 15; k++) if (write_open[k]) diff --git a/src/texsourc/texd.h b/src/texsourc/texd.h index 62c1f7d..e15046a 100644 --- a/src/texsourc/texd.h +++ b/src/texsourc/texd.h @@ -1,3 +1,5 @@ +#ifndef _YANDYTEX_TEXD_H +#define _YANDYTEX_TEXD_H /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ #define ALLOCATEINI /* allocate iniTeX (550 k) trie_c, trie_o, trie_l, trie_r, trie_hash, trie_taken */ #define ALLOCATEMAIN /* allocate main memory for TeX (2 Meg) zmem = zzzaa */ @@ -22,113 +24,9 @@ #define COMPACTFORMAT #define STAT -#include "yandytex.h" - -enum { - out_dvi_flag = (1 << 0), - out_pdf_flag = (1 << 1), - out_xdv_flag = (1 << 2), - out_dpx_flag = (1 << 3), -}; - -#define INLINE inline - -#define dump_file fmt_file -#define out_file dvi_file - -/* Read a line of input as quickly as possible. */ -extern boolean input_line (FILE *); -#define input_ln(stream, flag) input_line(stream) - -/* `b_open_in' (and out) is used only for reading (and writing) .tfm - files; `w_open_in' (and out) only for dump files. The filenames are - passed in as a global variable, `name_of_file'. */ - -#define b_open_in(f) open_input (&(f), TFMFILEPATH, FOPEN_RBIN_MODE) -#define w_open_in(f) open_input (&(f), TEXFORMATPATH, FOPEN_RBIN_MODE) -#define b_open_out(f) open_output (&(f), FOPEN_WBIN_MODE) -#define w_open_out b_open_out -#define b_close a_close -#define w_close a_close -#define gz_w_close gzclose - -/* sec 0241 */ -#define fix_date_and_time() get_date_and_time (&(tex_time), &(day), &(month), &(year)) - -/* If we're running under Unix, use system calls instead of standard I/O - to read and write the output files; also, be able to make a core dump. */ -#ifndef unix - #define dumpcore() exit(1) -#else /* unix */ - #define dumpcore abort -#endif - -#define write_dvi(a, b) \ - if ((size_t) fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]), \ - (size_t) ((size_t)(b) - (size_t)(a) + 1), dvi_file) \ - != (size_t) ((size_t)(b) - (size_t)(a) + 1)) \ - FATAL_PERROR ("\n! dvi file") - -extern int do_dump (char *, int, int, FILE *); -extern int do_undump (char *, int, int, FILE *); - -/* Reading and writing the dump files. `(un)dumpthings' is called from - the change file.*/ -#define dumpthings(base, len) \ - do_dump ((char *) &(base), sizeof (base), (int) (len), dump_file) - -#define undumpthings(base, len) \ - do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file) - -/* Use the above for all the other dumping and undumping. */ -#define generic_dump(x) dumpthings (x, 1) -#define generic_undump(x) undumpthings (x, 1) - -#define dump_wd generic_dump -#define undump_wd generic_undump -#define dump_hh generic_dump -#define undump_hh generic_undump -#define dump_qqqq generic_dump -#define undump_qqqq generic_undump - -/* `dump_int' is called with constant integers, so we put them into a - variable first. */ -#define dump_int(x) \ - do \ - { \ - integer x_val = (x); \ - generic_dump (x_val); \ - } \ - while (0) - -/* web2c/regfix puts variables in the format file loading into - registers. Some compilers aren't willing to take addresses of such - variables. So we must kludge. */ -#ifdef REGFIX -#define undump_int(x) \ - do \ - { \ - integer x_val; \ - generic_undump (x_val); \ - x = x_val; \ - } \ - while (0) -#else -#define undump_int generic_undump -#endif - - -/* If we're running on an ASCII system, there is no need to use the - `xchr' array to convert characters to the external encoding. */ - -#define Xchr(x) xchr[x] +#include "texmf.h" -/* following added from new texmf.c file 1996/Jan/12 */ -/* these, of course are useless definitions since parameters not given */ - -/* Declare routines in texmf.c. */ -extern void t_open_in(); -#include "yandy_macros.h" +#define file_name_size PATH_MAX // #define max_halfword 65535L /* for 32 bit memory word */ #define min_halfword -2147483647L /* for 64 bit memory word (signed) */ @@ -268,61 +166,7 @@ typedef halfword pointer; typedef char two_choices; typedef char four_choices; /* sec 0113 */ -/* - meaning structure TeX Y&Y TeX - ---------------------------------------------------------------------- - integer | int || 4: long | 8: long long | min_quarterword 0 - ---------------------------------------------------------------------- max_quarterword FFFF - scaled | sc || 4: long | 8: long long | min_halfword - ---------------------------------------------------------------------- - glue_ratio | gr || 4: float | 8: double | - ---------------------------------------------------------------------- - halfword | lh | rh || 2: unsigned short | 4: unsigned long | - ---------------------------------------------------------------------- - half+quarter | b0 | b1 | rh || | - ---------------------------------------------------------------------- - quarter | b0 | b1 | b2 | b3 || 1: unsigned char | 2: unsigned short | - ---------------------------------------------------------------------- -*/ - -typedef struct -{ -#ifdef WORDS_BIGENDIAN - halfword rh; - - union - { - halfword lh; - - struct - { - quarterword b0, b1; - }; - }; -#endif -} two_halves; - -typedef struct -{ -#ifdef WORDS_BIGENDIAN - quarterword b0, b1, b2, b3; -#else - quarterword b3, b2, b1, b0; -#endif -} four_quarters; - -typedef union -{ - glue_ratio gr; - two_halves hh; - integer cint; - four_quarters qqqq; -} memory_word; - -#ifndef WORDS_BIGENDIAN - #define cint u.CINT - #define qqqq v.QQQQ -#endif +#include "texmfmem.h" /* sec 0150 */ typedef char glue_ord; /* sec 0212 */ @@ -355,7 +199,7 @@ typedef integer hyph_pointer; EXTERN integer bad; EXTERN ASCII_code xord[256]; EXTERN ASCII_code xchr[256]; -EXTERN unsigned char name_of_file[PATH_MAX + 4]; +EXTERN unsigned char name_of_file[file_name_size + 4]; EXTERN integer name_length; #ifdef ALLOCATESTRING @@ -404,10 +248,12 @@ EXTERN halfword temp_ptr; /* sec 0116 */ #ifdef ALLOCATEMAIN - EXTERN memory_word * main_memory; + EXTERN memory_word * main_memory; /* remembered so can be free() later */ EXTERN memory_word * mem; #else EXTERN memory_word + /* #define zmem (zzzaa - (int)(mem_min)) */ + /* zzzaa[mem_max - mem_min + 1]; */ #define zmem (zzzaa - (int)(mem_bot)) zzzaa[mem_max - mem_bot + 1]; #endif @@ -468,12 +314,12 @@ EXTERN int old_setting; #endif #ifdef ALLOCATEZEQTB - EXTERN memory_word * eqtb; + EXTERN memory_word * zeqtb; #else #ifdef INCREASEFONTS - EXTERN memory_word eqtb[eqtb_size + 1]; + EXTERN memory_word eqtb[(hash_size + 4007) + eqtb_extra]; #else - EXTERN memory_word eqtb[eqtb_size + 1]; + EXTERN memory_word zeqtb[(hash_size + 4007)]; #endif #endif @@ -634,8 +480,6 @@ EXTERN char * log_file_name; EXTERN memory_word font_info[font_mem_size + 1]; #endif -EXTERN eight_bits font_dir[font_max + 1]; -EXTERN integer font_num_ext[font_max + 1]; EXTERN font_index fmem_ptr; EXTERN internal_font_number font_ptr; EXTERN internal_font_number frozen_font_ptr; @@ -653,9 +497,10 @@ EXTERN integer hyphen_char[font_max + 1]; EXTERN integer skew_char[font_max + 1]; EXTERN font_index bchar_label[font_max + 1]; EXTERN short font_bchar[font_max + 1]; +/* don't change above to int or format file will be incompatible */ EXTERN short font_false_bchar[font_max + 1]; +/* don't change above to int or format file will be incompatible */ EXTERN integer char_base[font_max + 1]; -EXTERN integer ctype_base[font_max + 1]; EXTERN integer width_base[font_max + 1]; EXTERN integer height_base[font_max + 1]; EXTERN integer depth_base[font_max + 1]; @@ -810,15 +655,16 @@ EXTERN trie_op_code max_op_used; EXTERN trie_pointer *trie_l; /* left subtrie links */ EXTERN trie_pointer *trie_r; /* right subtrie links */ EXTERN trie_pointer *trie_hash; /* used to identify equivlent subtries */ - #else /* end ALLOCATEINI */ + #else EXTERN packed_ASCII_code trie_c[trie_size + 1]; EXTERN trie_op_code trie_o[trie_size + 1]; EXTERN trie_pointer trie_l[trie_size + 1]; EXTERN trie_pointer trie_r[trie_size + 1]; EXTERN trie_pointer trie_hash[trie_size + 1]; - #endif /* end not ALLOCATEINI */ + #endif + EXTERN trie_pointer trie_ptr; -#endif /* INITEX */ +#endif #ifdef INITEX #ifdef ALLOCATEINI @@ -836,6 +682,7 @@ EXTERN scaled best_height_plus_depth; EXTERN halfword page_tail; EXTERN int page_contents; +/* do *some* sanity checking here --- rather than in TeX later 96/Jan/18 */ /* (cannot catch everything here, since some is now dynamic) */ #if (half_error_line < 30) || (half_error_line > error_line - 15) @@ -921,7 +768,7 @@ EXTERN pool_pointer edit_name_start; EXTERN integer edit_name_length, edit_line; EXTERN int tfm_temp; -/* new stuff defined in local.c - bkph */ +/* new variables defined in local.c */ EXTERN boolean is_initex; EXTERN boolean verbose_flag; EXTERN boolean trace_flag; @@ -945,7 +792,6 @@ EXTERN boolean show_numeric; EXTERN boolean restrict_to_ascii; EXTERN boolean show_missing; EXTERN boolean full_file_name_flag; -EXTERN boolean save_strings_flag; EXTERN int mem_initex; EXTERN int mem_extra_high; EXTERN int mem_extra_low; @@ -1033,14 +879,12 @@ void call_edit (ASCII_code *filename, pool_pointer fnstart, void add_variable_space(int); -void get_date_and_time (integer *, integer *, integer *, integer *); - -//void get_date_and_time (integer *minutes, integer *day, -// integer *month, integer *year); +void get_date_and_time (integer *minutes, integer *day, + integer *month, integer *year); char *unixify (char *); -//#include "yandy_macros.h" +#include "yandy_macros.h" #include "coerce.h" /* sec 79 */ @@ -1091,4 +935,5 @@ EXTERN void pdf_hlist_out (void); EXTERN void pdf_begin_text(void); EXTERN void pdf_font_def(internal_font_number f); EXTERN void pdf_error_handler (HPDF_STATUS error_no, HPDF_STATUS detail_no, void * user_data); -/********BINDING WITH LIBHARU*********/ \ No newline at end of file +/********BINDING WITH LIBHARU*********/ +#endif \ No newline at end of file diff --git a/src/texsourc/texmf.h b/src/texsourc/texmf.h new file mode 100644 index 0000000..d4d108b --- /dev/null +++ b/src/texsourc/texmf.h @@ -0,0 +1,99 @@ +/* Main include file for TeX in C. Originally by Tim Morgan, + December 23, 1987. These routines are also used by Metafont (with + some name changes). + + Copyright 1992 Karl Berry + Copyright 2007 TeX Users Group + Copyright 2014 Clerk Ma + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +#include "yandytex.h" + +enum { + out_dvi_flag = (1 << 0), + out_pdf_flag = (1 << 1), + out_xdv_flag = (1 << 2), + out_dpx_flag = (1 << 3), +}; + +#define INLINE inline + +#define dump_file fmt_file +#define out_file dvi_file + +/* Read a line of input as quickly as possible. */ +extern boolean input_line (FILE *); +#define input_ln(stream, flag) input_line(stream) + +#define b_open_in(f) open_input (&(f), TFMFILEPATH, FOPEN_RBIN_MODE) +#define w_open_in(f) open_input (&(f), TEXFORMATPATH, FOPEN_RBIN_MODE) +#define b_open_out(f) open_output (&(f), FOPEN_WBIN_MODE) +#define w_open_out b_open_out +#define b_close a_close +#define w_close a_close +#define gz_w_close gzclose + +/* sec 0241 */ +#define fix_date_and_time() get_date_and_time (&(tex_time), &(day), &(month), &(year)) + +/* If we're running under Unix, use system calls instead of standard I/O + to read and write the output files; also, be able to make a core dump. */ +#ifndef unix + #define dumpcore() exit(1) +#else /* unix */ + #define dumpcore abort +#endif + +#define write_dvi(a, b) \ + if ((size_t) fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]), \ + (size_t) ((size_t)(b) - (size_t)(a) + 1), dvi_file) \ + != (size_t) ((size_t)(b) - (size_t)(a) + 1)) \ + FATAL_PERROR ("\n! dvi file") + +extern int do_dump (char *, int, int, FILE *); +extern int do_undump (char *, int, int, FILE *); + +/* Reading and writing the dump files. `(un)dumpthings' is called from + the change file.*/ +#define dumpthings(base, len) \ + do_dump ((char *) &(base), sizeof (base), (int) (len), dump_file) + +#define undumpthings(base, len) \ + do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file) + +/* Use the above for all the other dumping and undumping. */ +#define generic_dump(x) dumpthings (x, 1) +#define generic_undump(x) undumpthings (x, 1) + +#define dump_wd generic_dump +#define undump_wd generic_undump +#define dump_hh generic_dump +#define undump_hh generic_undump +#define dump_qqqq generic_dump +#define undump_qqqq generic_undump + +#define dump_int(x) \ + do \ + { \ + integer x_val = (x); \ + generic_dump (x_val); \ + } \ + while (0) + +#define undump_int generic_undump + +extern void t_open_in(); \ No newline at end of file diff --git a/src/texsourc/texmfmem.h b/src/texsourc/texmfmem.h new file mode 100644 index 0000000..82baca6 --- /dev/null +++ b/src/texsourc/texmfmem.h @@ -0,0 +1,69 @@ +/* Copyright 1992 Karl Berry + Copyright 2007 TeX Users Group + Copyright 2014 Clerk Ma + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +/* + meaning structure TeX Y&Y TeX + ---------------------------------------------------------------------- + integer | int || 4: long | 8: long long | min_quarterword 0 + ---------------------------------------------------------------------- max_quarterword FFFF + scaled | sc || 4: long | 8: long long | min_halfword + ---------------------------------------------------------------------- + glue_ratio | gr || 4: float | 8: double | + ---------------------------------------------------------------------- + halfword | lh | rh || 2: unsigned short | 4: unsigned long | + ---------------------------------------------------------------------- + half+quarter | b0 | b1 | rh || | + ---------------------------------------------------------------------- + quarter | b0 | b1 | b2 | b3 || 1: unsigned char | 2: unsigned short | + ---------------------------------------------------------------------- +*/ + +typedef struct +{ +#ifdef WORDS_BIGENDIAN + halfword rh; + + union + { + halfword lh; + + struct + { + quarterword b0, b1; + }; + }; +#endif +} two_halves; + +typedef struct +{ +#ifdef WORDS_BIGENDIAN + quarterword b0, b1, b2, b3; +#else + quarterword b3, b2, b1, b0; +#endif +} four_quarters; + +typedef union +{ + glue_ratio gr; + two_halves hh; + integer cint; + four_quarters qqqq; +} memory_word; \ No newline at end of file diff --git a/src/texsourc/yandy_backend_pdf.c b/src/texsourc/yandy_backend_pdf.c index dc30df6..247188b 100644 --- a/src/texsourc/yandy_backend_pdf.c +++ b/src/texsourc/yandy_backend_pdf.c @@ -450,7 +450,7 @@ void pdf_ship_out(pointer p) print_char('['); j = 9; - while((count(j) == 0) && (j > 0)) + while ((count(j) == 0) && (j > 0)) decr(j); for (k = 0; k <= j; k++) @@ -511,7 +511,7 @@ void pdf_ship_out(pointer p) pack_job_name(".pdf"); - while(!b_open_out(pdf_file)) + while (!b_open_out(pdf_file)) { prompt_file_name("file name for output", ".pdf"); } @@ -612,7 +612,7 @@ lab21: cur_h = cur_h + char_width(f, char_info(f, c)); p = link(p); } - while(((p >= hi_mem_min))); + while (((p >= hi_mem_min))); dvi_h = cur_h; } diff --git a/src/texsourc/yandy_macros.h b/src/texsourc/yandy_macros.h index 52bc2b8..faf1017 100644 --- a/src/texsourc/yandy_macros.h +++ b/src/texsourc/yandy_macros.h @@ -20,6 +20,8 @@ #define null_code 0 // 0 #define carriage_return 015 // 13 #define invalid_code 0177 // 127 +/* sec 0036 */ +#define loc cur_input.loc_field /* sec 0040 */ #define length(s) (str_start[(s) + 1] - str_start[(s)]) /* sec 0041 */ @@ -66,8 +68,8 @@ enum //#define pointer halfword #define null min_halfword /* sec 0118 */ -#define link(p) mem[(p)].hh.rh -#define info(p) mem[(p)].hh.lh +#define link(p) mem[p].hh.rh +#define info(p) mem[p].hh.lh /* sec 0122 */ #ifdef STAT #define fast_get_avail(a) \ @@ -434,13 +436,10 @@ enum #define space_skip_code 12 // 794 #define xspace_skip_code 13 // 795 #define par_fill_skip_code 14 // 796 -#define kanji_skip_code 15 // 000 797 -#define xkanji_skip_code 16 // -#define thin_mu_skip_code 17 //15 // 797 -#define med_mu_skip_code 18 //16 // 798 -#define thick_mu_skip_code 19 //17 // 799 -#define jfm_skip 20 // -#define glue_pars 21 //18 // 800 +#define thin_mu_skip_code 15 // 797 +#define med_mu_skip_code 16 // 798 +#define thick_mu_skip_code 17 // 799 +#define glue_pars 18 // 800 #define skip_base (glue_base + glue_pars) // 800 #define mu_skip_base (skip_base + 256) // 1056 #define local_base (mu_skip_base + 256) // 1312 @@ -463,8 +462,6 @@ enum #define space_skip glue_par(space_skip_code) #define xspace_skip glue_par(xspace_skip_code) #define par_fill_skip glue_par(par_fill_skip_code) -#define kanji_skip glue_par(kanji_skip_code) -#define xkanji_skip glue_par(xkanji_skip_code) #define thin_mu_skip glue_par(thin_mu_skip_code) #define med_mu_skip glue_par(med_mu_skip_code) #define thick_mu_skip glue_par(thick_mu_skip_code) @@ -483,17 +480,8 @@ enum #define box_base (toks_base + 256) // 1578 #define cur_font_loc (box_base + 256) // 1834 #define math_font_base (cur_font_loc + 1) // 1835 -#define cur_jfont_loc (math_font_base + 48) -#define cur_tfont_loc (cur_jfont_loc + 1) -#define auto_spacing_code (cur_tfont_loc + 1) -#define auto_xspacing_code (auto_spacing_code + 1) -#define cat_code_base (auto_xspacing_code + 1) //(math_font_base + 48) // 1883 -#define kcat_code_base (cat_code_base + 256) -#define auto_xsp_code_base (kcat_code_base + 256) -#define inhibit_xsp_code_base (auto_xsp_code_base + 256) -#define kinsoku_base (inhibit_xsp_code_base + 256) -#define kansuji_base (kinsoku_base + 256) -#define lc_code_base (kansuji_base + 10) //(cat_code_base + 256) // 2139 +#define cat_code_base (math_font_base + 48) // 1883 +#define lc_code_base (cat_code_base + 256) // 2139 #define uc_code_base (lc_code_base + 256) // 2395 #define sf_code_base (uc_code_base + 256) // 2651 #define math_code_base (sf_code_base + 256) // 2907 @@ -513,18 +501,7 @@ enum #define box(a) equiv(box_base + a) #define cur_font equiv(cur_font_loc) #define fam_fnt(a) equiv(math_font_base + a) -#define cur_jfont equiv(cur_jfont_loc) -#define cur_tfont equiv(cur_tfont_loc) -#define auto_spacing equiv(auto_spacing_code) -#define auto_xspacing equiv(auto_xspacing_code) #define cat_code(a) equiv(cat_code_base + a) -#define kcat_code(a) equiv(kcat_code_base + a) -#define auto_xsp_code(a) equiv(auto_xsp_code_base + a) -#define inhibit_xsp_type(a) eq_type(inhibit_xsp_code_base + a) -#define inhibit_xsp_code(a) equiv(inhibit_xsp_code_base + a) -#define kinsoku_type(a) eq_type(kinsoku_base + a) -#define kinsoku_code(a) equiv(kinsoku_base + a) -#define kansuji_char(a) equiv(kansuji_base + a) #define lc_code(a) equiv(lc_code_base + a) #define uc_code(a) equiv(uc_code_base + a) #define sf_code(a) equiv(sf_code_base + a) @@ -578,19 +555,17 @@ enum #define floating_penalty_code 42 // 3205 #define global_defs_code 43 // 3206 #define cur_fam_code 44 // 3207 -#define cur_jfam_code 45 -#define escape_char_code 46 //45 // 3208 -#define default_hyphen_char_code 47 //46 // 3209 -#define default_skew_char_code 48 //47 // 3210 -#define end_line_char_code 49 //48 // 3211 -#define new_line_char_code 50 //49 // 3212 -#define language_code 51 //50 // 3213 -#define left_hyphen_min_code 52 //51 // 3214 -#define right_hyphen_min_code 53 //52 // 3215 -#define holding_inserts_code 54 //53 // 3216 -#define error_context_lines_code 55 //54 // 3217 -#define jchr_widow_penalty_code 56 -#define int_pars 57 //55 +#define escape_char_code 45 // 3208 +#define default_hyphen_char_code 46 // 3209 +#define default_skew_char_code 47 // 3210 +#define end_line_char_code 48 // 3211 +#define new_line_char_code 49 // 3212 +#define language_code 50 // 3213 +#define left_hyphen_min_code 51 // 3214 +#define right_hyphen_min_code 52 // 3215 +#define holding_inserts_code 53 // 3216 +#define error_context_lines_code 54 // 3217 +#define int_pars 55 #define count_base (int_base + int_pars) // 3218 #define del_code_base (count_base + 256) // 3474 #define dimen_base (del_code_base + 256) // 3730 @@ -643,7 +618,6 @@ enum #define floating_penalty int_par(floating_penalty_code) #define global_defs int_par(global_defs_code) #define cur_fam int_par(cur_fam_code) -#define cur_jfam int_par(cur_jfam_code) #define escape_char int_par(escape_char_code) #define default_hyphen_char int_par(default_hyphen_char_code) #define default_skew_char int_par(default_skew_char_code) @@ -654,7 +628,6 @@ enum #define right_hyphen_min int_par(right_hyphen_min_code) #define holding_inserts int_par(holding_inserts_code) #define error_context_lines int_par(error_context_lines_code) -#define jchr_widow_penalty int_par(jchr_widow_penalty_code) /* sec 0247 */ #define par_indent_code 0 // 3730 #define math_surround_code 1 // 3731 @@ -677,16 +650,12 @@ enum #define h_offset_code 18 // 3748 #define v_offset_code 19 // 3749 #define emergency_stretch_code 20 // 3750 -#define t_baseline_shift_code 21 -#define y_baseline_shift_code 22 -#define dimen_pars 23 //21 +#define dimen_pars 21 #define scaled_base (dimen_base + dimen_pars) // 3751 -#define kinsoku_penalty_base (scaled_base + 256) -#define eqtb_size (kinsoku_penalty_base + 255) //(scaled_base + 255) // 4006 +#define eqtb_size (scaled_base + 255) // 4006 // # #define dimen(a) eqtb[scaled_base + a].cint #define dimen_par(a) eqtb[dimen_base + a].cint -#define kinsoku_penalty(a) eqtb[kinsoku_penalty_base + a].cint #define par_indent dimen_par(par_indent_code) #define math_surround dimen_par(math_surround_code) #define line_skip_limit dimen_par(line_skip_limit_code) @@ -707,8 +676,6 @@ enum #define hang_indent dimen_par(hang_indent_code) #define h_offset dimen_par(h_offset_code) #define v_offset dimen_par(v_offset_code) -#define t_baseline_shift dimen_par(t_baseline_shift_code) -#define y_baseline_shift dimen_par(y_baseline_shift_code) #define emergency_stretch dimen_par(emergency_stretch_code) /* sec 0256 */ #define text(a) hash[a].rh @@ -758,6 +725,12 @@ enum #define other_token 06000 // 3072 = 2^8 * other_char #define match_token 06400 // 3328 = 2^8 * match #define end_match_token 07000 // 3584 = 2^8 * end_match +/* sec 0302 */ +#define state cur_input.state_field +#define index cur_input.index_field +#define start cur_input.start_field +#define limit cur_input.limit_field +//#define name /* sec 0303 */ #define mid_line 1 #define skip_blanks 2 + max_char_code // 17 @@ -770,8 +743,8 @@ enum #define absorbing 5 /* sec 0307 */ #define token_list 0 -#define token_type cur_input.index_field -#define param_start cur_input.limit_field +#define token_type index +#define param_start limit #define parameter 0 #define u_template 1 #define v_template 2 @@ -840,6 +813,14 @@ enum #define mu_val 3 #define ident_val 4 #define tok_val 5 +/* sec 0413 */ +#define scanned_result(va, vb) \ +do \ + { \ + cur_val = va; \ + cur_val_level = vb; \ + } \ +while (0) /* sec 0416 */ #define input_line_no_code (glue_val + 1) #define badness_code (glue_val + 2) @@ -897,21 +878,9 @@ enum #define fi_code 2 #define else_code 3 #define or_code 4 -/* sec 0519 */ -#define append_to_name(s) \ - do \ - { \ - c = s; \ - incr(k); \ - \ - if (k <= PATH_MAX) \ - name_of_file[k] = xchr[c];\ - } \ - while (0) /* sec 0544 */ #define no_tag 0 #define lig_tag 1 -#define gk_tag 1 #define list_tag 2 #define ext_tag 3 /* sec 0545 */ @@ -939,8 +908,6 @@ enum #define non_address 0 /* sec 0554 */ #define char_info(a, b) font_info[char_base[a] + b].qqqq -#define kchar_code(a, b) font_info[ctype_base[a] + b].hh.rh -#define kchar_type(a, b) font_info[ctype_base[a] + b].hh.lh #define char_width(a, b) font_info[width_base[a] + b.b0].cint #define char_exists(a) (a.b0 > min_quarterword) #define char_italic(a, b) font_info[italic_base[a] + (b.b2) / 4].cint @@ -988,40 +955,6 @@ enum val = qw; \ } /* sec 0571 */ -#define store_scaled(s) \ - do \ - { \ - tfm_temp = getc(tfm_file); \ - a = tfm_temp; \ - tfm_temp = getc(tfm_file); \ - b = tfm_temp; \ - tfm_temp = getc(tfm_file); \ - c = tfm_temp; \ - tfm_temp = getc(tfm_file); \ - d = tfm_temp; \ - sw = (((((d * z) / 256) + (c * z)) / 256) + (b * z)) / beta;\ - \ - if (a == 0) \ - s = sw; \ - else if (a == 255) \ - s = sw - alpha; \ - else \ - goto lab11; \ - } \ - while (0) -/* sec 0573 */ -#define check_existence(s) \ - do \ - { \ - if ((s < bc) || (s > ec)) \ - goto lab11; \ - \ - qw = char_info(f, s); \ - \ - if (!(qw.b0 > 0)) \ - goto lab11; \ - } \ - while (0) /* sec 0585 */ #define set1 128 // c[1] #define set2 129 // c[2] @@ -1453,7 +1386,18 @@ enum #define show_box_code 1 #define show_the_code 2 #define show_lists 3 -#define show_mode 4 +/* sec 1306 */ +#define undump(va, vb, vc) \ +do \ + { \ + undump_int(x); \ + \ + if ((x < (va)) || (x > (vb))) \ + goto lab_bad_fmt; \ + else \ + vc = x; \ + } \ +while (0) /* sec 1342 */ #define write_node_size 2 #define open_node_size 3 @@ -1474,14 +1418,4 @@ enum #define immediate_code 4 #define set_language_code 5 /* sec 1371 */ -#define end_write_token (cs_token_flag + end_write) - -/* Appendix: pTeX*/ -// direction -#define dir_default 0 // {direction of the box, default Left to Right} -#define dir_dtou 1 // {direction of the box, Bottom to Top} -#define dir_tate 3 // {direction of the box, Top to Bottom} -#define dir_yoko 4 // {direction of the box, equal default} -// jfm -#define yoko_jfm_id 11 // {for `yoko-kumi' fonts} -#define tate_jfm_id 9 // {for `tate-kumi' fonts} \ No newline at end of file +#define end_write_token (cs_token_flag + end_write) \ No newline at end of file diff --git a/src/texsourc/yandy_pool.c b/src/texsourc/yandy_pool.c index 3309289..f338598 100644 --- a/src/texsourc/yandy_pool.c +++ b/src/texsourc/yandy_pool.c @@ -550,7 +550,7 @@ static const char *pool_file_arr[] = /* 0782 */ "", //"I can't find file `", /* 0783 */ "", //"I can't write on file `", /* 0784 */ "", //"'.", -/* 0785 */ ".tex", +/* 0785 */ "", //".tex", /* 0786 */ "", //"Please type another ", /* 0787 */ "", //"*** (job aborted, file error in nonstop mode)", /* 0788 */ "", //".dvi", diff --git a/src/texsourc/yandytex.c b/src/texsourc/yandytex.c index 1ae7b17..6d52271 100644 --- a/src/texsourc/yandytex.c +++ b/src/texsourc/yandytex.c @@ -28,13 +28,9 @@ #define edit_value tex_edit_value extern char * replacement[]; - -/* The main program, etc. */ -/* What we were invoked as and with. */ - -static char *program_name = NULL; +static char * program_name = NULL; int gargc; /* number of args - set to zero after initialization */ -char **gargv; /* char *gargv[] -- bkph ? */ +char **gargv; /* The entry point: set up for reading the command line, which will happen in `t_open_in', then call the main body. */ @@ -178,9 +174,7 @@ void get_date_and_time (integer *sys_minutes, } if (clock < 0) - { - show_line("Time not available!\n", 1); - } + puts("Time not available!\n"); tmptr = localtime (&clock); @@ -218,9 +212,9 @@ void get_date_and_time (integer *sys_minutes, { if (signal(SIGINT, catch_interrupt) == SIG_ERR) { - show_line(" CTRL-C handler not installed\n", 0); + puts(" CTRL-C handler not installed\n"); #ifndef _WINDOWS - uexit(1); /* do we care when run as DLL ? */ + uexit(EXIT_FAILURE); /* do we care when run as DLL ? */ #endif } } @@ -246,13 +240,12 @@ void complain_line (FILE *output) if (output == stderr) show_line(log_line, 1); + else if (output == stdout) + show_line(log_line, 0); else - if (output == stdout) - show_line(log_line, 0); - else - fputs(log_line, output); // never + fputs(log_line, output); // never - show_line(" (File may have a line termination problem.)", 0); + puts(" (File may have a line termination problem.)"); } void show_bad_line (FILE *output, int first, int last) @@ -544,7 +537,7 @@ boolean input_line (FILE *f) last--; /* just in case */ } else - uexit(1); /* line too long */ + uexit(EXIT_FAILURE); /* line too long */ } return input_line_finish(); @@ -630,7 +623,7 @@ void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, sprintf(log_line, "! `%%d' cannot appear twice in editor command.\n"); show_line(log_line, 1); #endif - uexit(1); + uexit(EXIT_FAILURE); } (void) sprintf (s, "%d", linenumber); @@ -651,7 +644,7 @@ void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, sprintf(log_line, "! `%%s' cannot appear twice in editor command.\n"); show_line(log_line, 1); #endif - uexit(1); + uexit(EXIT_FAILURE); } t = (char *) texfilename; @@ -677,7 +670,7 @@ void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, sprintf(log_line, "! `%%l' cannot appear twice in editor command.\n"); show_line(log_line, 1); #endif - uexit(1); + uexit(EXIT_FAILURE); } t = (char *) log_file_name; @@ -714,7 +707,7 @@ void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, { sprintf(log_line, "Command too long (%d > %d)\n", strlen(command) + 1, commandlen); show_line(log_line, 1); - uexit(1); + uexit(EXIT_FAILURE); } //flushall(); @@ -733,11 +726,11 @@ void call_edit (ASCII_code *stringpool, pool_pointer fnstart, integer fnlength, sprintf(log_line, " (TEXEDIT=%s)\n", edit_value); show_line(log_line, 0); - show_line(" (Editor specified may be missing or path may be wrong)\n", 0); - show_line(" (or there may be missing -- or extraneous -- quotation signs)\n", 0); + puts(" (Editor specified may be missing or path may be wrong)\n"); + puts(" (or there may be missing -- or extraneous -- quotation signs)\n"); } - uexit(1); + uexit(EXIT_FAILURE); } /* Read and write format (for TeX) or base (for Metafont) files. In @@ -810,7 +803,7 @@ static int swap_items (char *p, int nitems, int size) show_line("\n", 0); sprintf(log_line, "! I can't (un)dump a %d byte item.\n", size); show_line(log_line, 1); - uexit(1); + uexit(EXIT_FAILURE); } return 0; } @@ -839,7 +832,7 @@ int do_dump (char *p, int item_size, int nitems, FILE *out_file) sprintf(log_line, "! Could not write %d %d-byte item%s.\n", nitems, item_size, (nitems > 1) ? "s" : ""); show_line(log_line, 1); - uexit(1); + uexit(EXIT_FAILURE); } /* Have to restore the old contents of memory, since some of it might get used again. */ @@ -865,12 +858,13 @@ int do_undump (char *p, int item_size, int nitems, FILE *in_file) 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); + uexit(EXIT_FAILURE); } #if !defined (WORDS_BIGENDIAN) && !defined (NO_FMTBASE_SWAP) swap_items (p, nitems, item_size); #endif + return 0; } @@ -910,3 +904,15 @@ void funny_core_dump (void) } } #endif /* FUNNY_CORE_DUMP */ +/* +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +*/ \ No newline at end of file diff --git a/src/texsourc/yandytex.h b/src/texsourc/yandytex.h index ba03fa6..ee4a955 100644 --- a/src/texsourc/yandytex.h +++ b/src/texsourc/yandytex.h @@ -20,6 +20,7 @@ #define WORDS_BIGENDIAN 0 +//#pragma warning(disable:4032) #pragma warning(disable:4201) #pragma warning(disable:4996) #pragma warning(disable:4701) @@ -45,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -102,9 +102,6 @@ typedef enum #define a_open_out(f) open_output (&(f), FOPEN_W_MODE) #define a_close(f) check_fclose (f) -#define Hi(x) (((x) >> 8) & 0xff) -#define Lo(x) ((x) & 0xff) - #define MAXLINE 256 extern integer zround (double); -- 2.11.0