From a85ebb2e479786844868f0fe8cdf5c27a4033d7a Mon Sep 17 00:00:00 2001 From: maqiyuan Date: Thu, 12 Jun 2014 08:35:05 +0800 Subject: [PATCH] pause_for_instructions(). main_control()'s label. pop_input(). --- src/texsourc/itex.c | 280 +++++++-------------------- src/texsourc/local.c | 13 +- src/texsourc/tex2.c | 28 +-- src/texsourc/tex6.c | 22 +-- src/texsourc/tex8.c | 178 +++++++---------- src/texsourc/tex9.c | 2 - src/texsourc/texmf.h | 3 +- src/texsourc/yandy_kanji.c | 456 -------------------------------------------- src/texsourc/yandy_macros.h | 35 ++++ 9 files changed, 191 insertions(+), 826 deletions(-) delete mode 100644 src/texsourc/yandy_kanji.c diff --git a/src/texsourc/itex.c b/src/texsourc/itex.c index d4797a2..3f1a49e 100644 --- a/src/texsourc/itex.c +++ b/src/texsourc/itex.c @@ -114,10 +114,7 @@ void initialize (void) for (k = 0; k < 256; k++) { if (xord[k] != 127) - { - sprintf(log_line, "%d => %d\n", k, xord[k]); - show_line(log_line, 0); - } + printf("%d => %d\n", k, xord[k]); } } } @@ -287,7 +284,7 @@ void initialize_aux (void) mode = 1; head = contrib_head; tail = contrib_head; - cur_list.aux_field.cint = ignore_depth; + prev_depth = ignore_depth; mode_line = 0; prev_graf = 0; /* shown_mode = 0; */ @@ -307,7 +304,6 @@ void line_break_ (integer final_widow_penalty) int j; /* 95/Jan/7 */ /* unsigned char c; */ unsigned int c; /* 95/Jan/7 */ -/* savedbadness = 0; */ /* 96/Feb/9 */ pack_begin_line = mode_line; link(temp_head) = link(head); @@ -332,14 +328,10 @@ void line_break_ (integer final_widow_penalty) no_shrink_error_yet = true; if ((shrink_order(left_skip) != normal) && (shrink(left_skip) != 0)) - { left_skip = finite_shrink(left_skip); - } if ((shrink_order(right_skip) != normal) && (shrink(right_skip) != 0)) - { right_skip = finite_shrink(right_skip); - } q = left_skip; r = right_skip; @@ -351,7 +343,6 @@ void line_break_ (integer final_widow_penalty) background[2 + stretch_order(q)] = stretch(q); background[2 + stretch_order(r)] = background[2 + stretch_order(r)] + stretch(r); background[6] = shrink(q) + shrink(r); - minimum_demerits = 1073741823L; /* 2^30 - 1 *//* 40000000 hex - 1 */ minimal_demerits[tight_fit] = 1073741823L; minimal_demerits[decent_fit] = 1073741823L; @@ -409,14 +400,13 @@ void line_break_ (integer final_widow_penalty) if (threshold >= 0) { - #ifdef STAT if (tracing_paragraphs > 0) { begin_diagnostic(); print_nl("@firstpass"); } -#endif /* STAT */ +#endif second_pass = false; final_pass = false; @@ -431,7 +421,7 @@ void line_break_ (integer final_widow_penalty) #ifdef STAT if (tracing_paragraphs > 0) begin_diagnostic(); -#endif /* STAT */ +#endif } while (true) @@ -500,6 +490,7 @@ void line_break_ (integer final_widow_penalty) case rule_node: active_width[1] = active_width[1] + width(cur_p); break; + case whatsit_node: if (subtype(cur_p) == language_node) { @@ -508,6 +499,7 @@ void line_break_ (integer final_widow_penalty) rhyf = what_rhm(cur_p); } break; + case glue_node: { if (auto_breaking) @@ -945,15 +937,15 @@ lab35:; #ifdef STAT if (tracing_paragraphs > 0) print_nl("@emergencypass"); -#endif /* STAT */ -/* can only get here is \emergencystretch has been set positive */ +#endif + background[2] = background[2] + emergency_stretch; final_pass = true; ++final_pass_count; /* 96 Feb 9 */ - } /* end of if second_pass */ - } /* end of while (true)do */ -/* cannot drop through from above loop */ -lab30: /* common exit point */ + } + } + +lab30: if (best_line == 2) single_line++; @@ -963,7 +955,7 @@ lab30: /* common exit point */ end_diagnostic(true); normalize_selector(); } -#endif /* STAT */ +#endif post_line_break(final_widow_penalty); q = link(active); @@ -1054,10 +1046,7 @@ void prefixed_command (void) switch (cur_cmd) { case set_font: - if ((a >= 4)) - geq_define(cur_font_loc, data, cur_chr); - else - eq_define(cur_font_loc, data, cur_chr); + define(cur_font_loc, data, cur_chr); break; case def: @@ -1069,11 +1058,7 @@ void prefixed_command (void) get_r_token(); p = cur_cs; q = scan_toks(true, e); - - if ((a >= 4)) - geq_define(p, call + (a % 4), def_ref); - else - eq_define(p, call + (a % 4), def_ref); + define(p, call + (a % 4), def_ref); } break; @@ -1110,12 +1095,9 @@ void prefixed_command (void) } if (cur_cmd >= call) - incr(mem[cur_chr].hh.lh); + add_token_ref(cur_chr); - if ((a >= 4)) - geq_define(p, cur_cmd, cur_chr); - else - eq_define(p, cur_cmd, cur_chr); + define(p, cur_cmd, cur_chr); } break; @@ -1124,12 +1106,7 @@ void prefixed_command (void) n = cur_chr; get_r_token(); p = cur_cs; - - if ((a >= 4)) - geq_define(p, relax, 256); - else - eq_define(p, relax, 256); - + define(p, relax, 256); scan_optional_equals(); switch (n) @@ -1137,22 +1114,14 @@ void prefixed_command (void) case char_def_code: { scan_char_num(); - - if ((a >= 4)) - geq_define(p, char_given, cur_val); - else - eq_define(p, char_given, cur_val); + define(p, char_given, cur_val); } break; case math_char_def_code: { scan_fifteen_bit_int(); - - if ((a >= 4)) - geq_define(p, math_given, cur_val); - else - eq_define(p, math_given, cur_val); + define(p, math_given, cur_val); } break; @@ -1163,38 +1132,23 @@ void prefixed_command (void) switch (n) { case count_def_code: - if ((a >= 4)) - geq_define(p, assign_int, count_base + cur_val); - else - eq_define(p, assign_int, count_base + cur_val); + define(p, assign_int, count_base + cur_val); break; case dimen_def_code: - if ((a >= 4)) - geq_define(p, assign_dimen, scaled_base + cur_val); - else - eq_define(p, assign_dimen, scaled_base + cur_val); + define(p, assign_dimen, scaled_base + cur_val); break; case skip_def_code: - if ((a >= 4)) - geq_define(p, assign_glue, skip_base + cur_val); - else - eq_define(p, assign_glue, skip_base + cur_val); + define(p, assign_glue, skip_base + cur_val); break; case mu_skip_def_code: - if ((a >= 4)) - geq_define(p, assign_mu_glue, mu_skip_base + cur_val); - else - eq_define(p, assign_mu_glue, mu_skip_base + cur_val); + define(p, assign_mu_glue, mu_skip_base + cur_val); break; case toks_def_code: - if ((a >= 4)) - geq_define(p, assign_toks, toks_base + cur_val); - else - eq_define(p, assign_toks, toks_base + cur_val); + define(p, assign_toks, toks_base + cur_val); break; } } @@ -1208,7 +1162,7 @@ void prefixed_command (void) scan_int(); n = cur_val; - if (! scan_keyword("to")) + if (!scan_keyword("to")) { print_err("Missing `to' inserted"); help2("You should have said `\\read to \\cs'.", @@ -1219,11 +1173,7 @@ void prefixed_command (void) get_r_token(); p = cur_cs; read_toks(n, p); - - if ((a >= 4)) - geq_define(p, call, cur_val); - else - eq_define(p, call, cur_val); + define(p, call, cur_val); } break; @@ -1262,18 +1212,11 @@ void prefixed_command (void) q = equiv(cur_chr); if (q == 0) - if ((a >= 4)) - geq_define(p, undefined_cs, 0); - else - eq_define(p, undefined_cs, 0); + define(p, undefined_cs, 0); else { - incr(mem[q].hh.lh); - - if ((a >= 4)) - geq_define(p, call, q); - else - eq_define(p, call, q); + add_token_ref(q); + define(p, call, q); } goto lab30; } @@ -1285,11 +1228,7 @@ void prefixed_command (void) if (link(def_ref) == 0) { - if ((a >= 4)) - geq_define(p, undefined_cs, 0); - else - eq_define(p, undefined_cs, 0); - + define(p, undefined_cs, 0); free_avail(def_ref); } else @@ -1305,10 +1244,7 @@ void prefixed_command (void) link(def_ref) = q; } - if ((a >= 4)) - geq_define(p, call, def_ref); - else - eq_define(p, call, def_ref); + define(p, call, def_ref); } } break; @@ -1318,11 +1254,7 @@ void prefixed_command (void) p = cur_chr; scan_optional_equals(); scan_int(); - - if ((a >= 4)) - geq_word_define(p, cur_val); - else - eq_word_define(p, cur_val); + word_define(p, cur_val); } break; @@ -1331,11 +1263,7 @@ void prefixed_command (void) p = cur_chr; scan_optional_equals(); scan_dimen(false, false, false); - - if ((a >= 4)) - geq_word_define(p, cur_val); - else - eq_word_define(p, cur_val); + word_define(p, cur_val); } break; @@ -1352,11 +1280,7 @@ void prefixed_command (void) scan_glue(glue_val); trap_zero_glue(); - - if ((a >= 4)) - geq_define(p, glue_ref, cur_val); - else - eq_define(p, glue_ref, cur_val); + define(p, glue_ref, cur_val); } break; @@ -1371,7 +1295,7 @@ void prefixed_command (void) else if (cur_chr == del_code_base) n = 16777215L; /* 2^24 - 1 */ else - n = 255; /* 2^8 - 1 */ + n = 255; p = cur_chr; scan_char_num(); @@ -1396,20 +1320,11 @@ void prefixed_command (void) } if (p < math_code_base) - if ((a >= 4)) - geq_define(p, data, cur_val); - else - eq_define(p, data, cur_val); + define(p, data, cur_val); else if (p < del_code_base) - if ((a >= 4)) - geq_define(p, data, cur_val); - else - eq_define(p, data, cur_val); + define(p, data, cur_val); else - if ((a >= 4)) - geq_word_define(p, cur_val); - else - eq_word_define(p, cur_val); + word_define(p, cur_val); } break; @@ -1420,11 +1335,7 @@ void prefixed_command (void) p = p + cur_val; scan_optional_equals(); scan_font_ident(); - - if ((a >= 4)) - geq_define(p, data, cur_val); - else - eq_define(p, data, cur_val); + define(p, data, cur_val); } break; @@ -1447,9 +1358,7 @@ void prefixed_command (void) scan_optional_equals(); if (set_box_allowed) - { scan_box(box_flag + n); - } else { print_err("Improper "); @@ -1503,10 +1412,7 @@ void prefixed_command (void) } } - if ((a >= 4)) - geq_define(par_shape_loc, shape_ref, p); - else - eq_define(par_shape_loc, shape_ref, p); + define(par_shape_loc, shape_ref, p); } break; @@ -1519,7 +1425,7 @@ void prefixed_command (void) new_patterns(); goto lab30; } -#endif /* INITEX */ +#endif print_err("Patterns can be loaded only by INITEX"); help_ptr = 0; error(); @@ -1610,10 +1516,7 @@ boolean load_fmt_file (void) #ifdef ALLOCATEMAIN /* we already read this once earlier to grab mem_top */ if (trace_flag) - { - sprintf(log_line, "Read from fmt file mem_top = %d TeX words\n", x); - show_line(log_line, 0); - } + printf("Read from fmt file mem_top = %d TeX words\n", x); mem = allocate_main_memory(x); /* allocate main memory at this point */ @@ -1628,7 +1531,7 @@ boolean load_fmt_file (void) undump_int(x); /* eqtb_size */ - if (x != (eqtb_size)) + if (x != eqtb_size) goto lab_bad_fmt; undump_int(x); /* hash_prime */ @@ -1640,7 +1543,7 @@ boolean load_fmt_file (void) #ifdef ALLOCATEHYPHEN /* allow format files dumped with arbitrary (prime) hyphenation exceptions */ - realloc_hyphen(x); /* reset_hyphen(); */ + realloc_hyphen(x); hyphen_prime = x; #endif @@ -1657,21 +1560,17 @@ boolean load_fmt_file (void) if (x > current_pool_size) { if (trace_flag) - { - sprintf(log_line, "undump string pool reallocation (%d > %d)\n", x, current_pool_size); - show_line(log_line, 0); - } + printf("undump string pool reallocation (%d > %d)\n", x, current_pool_size); str_pool = realloc_str_pool (x - current_pool_size + increment_pool_size); } - if (x > current_pool_size) /* 94/Jan/24 */ + if (x > current_pool_size) #else if (x > pool_size) #endif { - sprintf(log_line, "%s%s\n", "---! Must increase the ", "string pool size"); - show_line(log_line, 0); + printf("%s%s\n", "---! Must increase the ", "string pool size"); goto lab_bad_fmt; } else @@ -1688,10 +1587,7 @@ boolean load_fmt_file (void) if (x > current_max_strings) { if (trace_flag) - { - sprintf(log_line, "undump string pointer reallocation (%d > %d)\n", x, current_max_strings); - show_line(log_line, 0); - } + printf("undump string pointer reallocation (%d > %d)\n", x, current_max_strings); str_start = realloc_str_start(x - current_max_strings + increment_max_strings); } @@ -1701,8 +1597,7 @@ boolean load_fmt_file (void) if (x > max_strings) #endif { - sprintf(log_line, "%s%s\n", "---! Must increase the ", "max strings"); - show_line(log_line, 0); + printf("%s%s\n", "---! Must increase the ", "max strings"); goto lab_bad_fmt; } else @@ -1812,42 +1707,32 @@ boolean load_fmt_file (void) undump_int(cs_count); if (trace_flag) - { - sprintf(log_line, "itex undump cs_count %d ", cs_count); - show_line(log_line, 0); - } + printf("itex undump cs_count %d ", cs_count); { - undump_int(x); /* font_mem_size */ + undump_int(x); /* font_mem_size */ if (x < 7) goto lab_bad_fmt; #ifdef ALLOCATEFONT if (trace_flag) - { - sprintf(log_line, "Read from fmt fmem_ptr = %d\n", x); - show_line(log_line, 0); - } + printf("Read from fmt fmem_ptr = %d\n", x); - if (x > current_font_mem_size) /* 93/Nov/28 dynamic allocate font_info */ + if (x > current_font_mem_size) { if (trace_flag) - { - sprintf(log_line, "Undump realloc font_info (%d > %d)\n", x, current_font_mem_size); - show_line(log_line, 0); - } + printf("Undump realloc font_info (%d > %d)\n", x, current_font_mem_size); font_info = realloc_font_info (x - current_font_mem_size + increment_font_mem_size); } - if (x > current_font_mem_size) /* in case allocation failed 94/Jan/24 */ + if (x > current_font_mem_size) #else if (x > font_mem_size) #endif { - sprintf(log_line, "%s%s\n", "---! Must increase the ", "font mem size"); - show_line(log_line, 0); + puts("---! Must increase the font mem size\n"); goto lab_bad_fmt; } else @@ -1866,15 +1751,14 @@ boolean load_fmt_file (void) if (x > font_max) { - sprintf(log_line, "%s%s\n", "---! Must increase the ", "font max"); - show_line(log_line, 0); + puts("---! Must increase the font max\n"); goto lab_bad_fmt; } else font_ptr = x; } - frozen_font_ptr = font_ptr; /* remember number of fonts frozen into format */ + frozen_font_ptr = font_ptr; if (undumpthings(font_check[0], font_ptr + 1)) return -1; @@ -1951,7 +1835,6 @@ boolean load_fmt_file (void) /* non_address from font_mem_size to 0 96/Jan/15 ??? */ #ifdef ALLOCATEFONT -/* deal with fmt files dumped with *different* font_mem_size 93/Nov/29 */ { int count = 0, oldfont_mem_size = 0; @@ -1960,26 +1843,21 @@ boolean load_fmt_file (void) if (bchar_label[x] > oldfont_mem_size) oldfont_mem_size = bchar_label[x]; } - - /* somewhat arbitrary sanity check ... */ - if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) /* 96/Jan/16 */ + + if (oldfont_mem_size != non_address && oldfont_mem_size > font_max) { for (x = 0; x <= font_ptr; x++) { if (bchar_label[x] == oldfont_mem_size) { - /* bchar_label[x] = font_mem_size; */ - bchar_label[x] = non_address; /* 96/Jan/16 */ + bchar_label[x] = non_address; count++; } } if (trace_flag) - { - sprintf(log_line, "oldfont_mem_size is %d --- hit %d times. Using non_address %d\n", + printf("oldfont_mem_size is %d --- hit %d times. Using non_address %d\n", oldfont_mem_size, count, non_address); - show_line(log_line, 0); - } } } #endif @@ -2022,8 +1900,7 @@ boolean load_fmt_file (void) if (x > trie_size) { - sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie size"); - show_line(log_line, 0); + puts("---! Must increase the trie size\n"); goto lab_bad_fmt; } else @@ -2052,8 +1929,7 @@ boolean load_fmt_file (void) if (x > trie_op_size) { - sprintf(log_line, "%s%s\n", "---! Must increase the ", "trie op size"); - show_line(log_line, 0); + puts("---! Must increase the trie op size\n"); goto lab_bad_fmt; } else @@ -2113,8 +1989,7 @@ boolean load_fmt_file (void) return true; lab_bad_fmt:; - sprintf(log_line, "(Fatal format file error; I'm stymied)\n"); - show_line(log_line, 1); + puts("(Fatal format file error; I'm stymied)\n"); return false; } @@ -2317,9 +2192,8 @@ int main_program (void) if (bad > 0) { - sprintf(log_line, "%s%s%ld\n", "Ouch---my internal constants have been clobbered!", + printf("%s%s%ld\n", "Ouch---my internal constants have been clobbered!", "---case ", (long) bad); - show_line(log_line, 1); goto lab9999; } @@ -2348,19 +2222,15 @@ lab1: file_offset = 0; show_line(tex_version, 0); - { #ifdef _WIN32 #ifdef _WIN64 - sprintf(log_line, " (%s %s/Windows 64bit)", application, yandyversion); + printf(log_line, " (%s %s/Windows 64bit)", application, yandyversion); #else - sprintf(log_line, " (%s %s/Windows 32bit)", application, yandyversion); + printf(log_line, " (%s %s/Windows 32bit)", application, yandyversion); #endif #else - sprintf(log_line, " (%s %s/Linux)", application, yandyversion); + printf(log_line, " (%s %s/Linux)", application, yandyversion); #endif - } - - show_line(log_line, 0); if (format_ident > 0) slow_print(format_ident); @@ -3619,11 +3489,8 @@ lab32: cs_count = frozen_control_sequence - 1 - hash_used; if (trace_flag) - { - sprintf(log_line, "itex cs_count %d hash_size %d hash_extra %d hash_used %d", + printf("itex cs_count %d hash_size %d hash_extra %d hash_used %d", cs_count, hash_size, hash_extra, hash_used); - show_line(log_line, 0); - } for (p = hash_base; p <= hash_used; p++) { @@ -3634,10 +3501,7 @@ lab32: incr(cs_count); if (trace_flag) - { - sprintf(log_line, "itex cs_count++ "); - show_line(log_line, 0); - } + puts("itex cs_count++ "); } } diff --git a/src/texsourc/local.c b/src/texsourc/local.c index 801ea83..e0189c2 100644 --- a/src/texsourc/local.c +++ b/src/texsourc/local.c @@ -87,9 +87,7 @@ unsigned char wintodos[128] = void show_usage (void) { - char * s = log_line; - - sprintf (s, "\n" + printf("\n" " Useage: yanytex [OPTION]... [+format_file] [tex_file]\n\n" " --help -?\n" " show this usage summary\n" @@ -122,7 +120,6 @@ void show_usage (void) " write LOG file in specified directory (default current directory)\n" " --aux-dir -a\n" " write AUX file in specified directory (default current directory)\n"); - show_line(log_line, 1); #ifndef _WINDOWS uexit(EXIT_FAILURE); // has this been setup yet ??? @@ -135,8 +132,6 @@ void show_usage (void) /* \t\t(applies to file name and format file name, if present)\n\ */ /* \t-r\tallow Mac style line termination - i.e. convert \\r to \\n \n\ */ -/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ - // Sep 27 1990 => 1990 Sep 27 // 012456789 0123456789 void scivilize (char * date) @@ -198,8 +193,6 @@ void stampcopy (char *s) } } -/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ - #define MAXCHRS 256 #define NOTDEF 127 @@ -209,8 +202,8 @@ void read_xchr_sub (FILE * xchr_input) int k, from, to, count = 0; char *s; - memset (xchr, NOTDEF, MAXCHRS); - memset (xord, NOTDEF, MAXCHRS); + memset(xchr, NOTDEF, MAXCHRS); + memset(xord, NOTDEF, MAXCHRS); #ifdef ALLOCATEBUFFER while (fgets(buffer, current_buf_size, xchr_input) != NULL) diff --git a/src/texsourc/tex2.c b/src/texsourc/tex2.c index 0e46590..242242d 100644 --- a/src/texsourc/tex2.c +++ b/src/texsourc/tex2.c @@ -537,17 +537,8 @@ void end_token_list (void) return; // abort_flag set } - { - decr(input_ptr); - cur_input = input_stack[input_ptr]; - } - - { - if (interrupt != 0) - { - pause_for_instructions(); - } - } + pop_input(); + check_interrupt(); } /* sec 0325 */ void back_input (void) @@ -679,12 +670,9 @@ void end_file_reading (void) line = line_stack[index]; if (cur_input.name_field > 17) - (void) a_close(input_file[index]); + a_close(input_file[index]); - { - decr(input_ptr); - cur_input = input_stack[input_ptr]; - } + pop_input(); decr(in_open); } /* called only form tex0.c */ @@ -2369,13 +2357,7 @@ lab40: } } - { - if (interrupt != 0) - { - pause_for_instructions(); - } - } - + check_interrupt(); goto lab25; } } diff --git a/src/texsourc/tex6.c b/src/texsourc/tex6.c index 1aafbea..1faa571 100644 --- a/src/texsourc/tex6.c +++ b/src/texsourc/tex6.c @@ -92,7 +92,7 @@ void try_break_ (integer pi, small_number break_type) boolean node_r_stays_active; scaled line_width; char fit_class; - halfword b; /* current badness */ + halfword b; integer d; boolean artificial_demerits; halfword save_link; @@ -171,7 +171,7 @@ lab22: default: { confusion("disc1"); - return; // abort_flag set + return; } break; } @@ -294,7 +294,7 @@ lab30:; #ifdef STAT incr(pass_number); serial(q) = pass_number; -#endif /* STAT */ +#endif prev_break(q) = best_place[fit_class]; q = get_node(active_node_size); break_node(q) = passive; @@ -910,12 +910,7 @@ lab22: if (lig_stack == 0) rt_hit = true; - { - if (interrupt != 0) - { - pause_for_instructions(); - } - } + check_interrupt(); switch (op_byte(q)) { @@ -972,11 +967,7 @@ lab22: mem[p].hh.b1 = 2; lft_hit = false; } -/* if (false) - if (lig_stack == 0){ - incr(mem[p].hh.b1); - rt_hit = false; - } */ /* removed 99/Jan/6 */ + mem[cur_q].hh.rh = p; t = p; ligature_present = false; @@ -1498,8 +1489,7 @@ lab21: if (hyph_count == hyphen_prime) { overflow("exception dictionary", hyphen_prime); /* exception dictionary - NOT DYNAMIC */ - /* not dynamic ---- but can be set -e=... from command line in ini-TeX */ - return; // abort_flag set + return; } incr(hyph_count); diff --git a/src/texsourc/tex8.c b/src/texsourc/tex8.c index 1595304..eb8f2f7 100644 --- a/src/texsourc/tex8.c +++ b/src/texsourc/tex8.c @@ -98,9 +98,7 @@ void math_left_right (void) error(); } else - { off_save(); - } } else { @@ -175,7 +173,7 @@ void after_math (void) l = false; p = fin_mlist(0); - if (mode == - (integer) m) + if (mode == -m) { { get_x_token(); @@ -397,7 +395,7 @@ void resume_after_display (void) if (cur_group != math_shift_group) { confusion("display"); - return; // abort_flag set + return; } unsave(); @@ -417,9 +415,7 @@ void resume_after_display (void) } if (nest_ptr == 1) - { build_page(); - } } /* sec 1215 */ void get_r_token (void) @@ -614,20 +610,11 @@ lab40: } if (p < glue_val) - { - if ((a >= 4)) - geq_word_define(l, cur_val); - else - eq_word_define(l, cur_val); - } + word_define(l, cur_val); else { trap_zero_glue(); - - if ((a >= 4)) - geq_define(l, glue_ref, cur_val); - else - eq_define(l, glue_ref, cur_val); + define(l, glue_ref, cur_val); } } /* sec 1243 */ @@ -636,9 +623,7 @@ void alter_aux (void) halfword c; if (cur_chr != abs(mode)) - { report_illegal_case(); - } else { c = cur_chr; @@ -764,11 +749,7 @@ void new_font_(small_number a) t = make_string(); } - if ((a >= 4)) - geq_define(u, set_font, 0); - else - eq_define(u, set_font, 0); - + define(u, set_font, null_font); scan_optional_equals(); scan_file_name(); @@ -793,7 +774,7 @@ void new_font_(small_number a) else if (scan_keyword("scaled")) { scan_int(); - s = - (integer) cur_val; + s = -cur_val; if ((cur_val <= 0) || (cur_val > 32768L)) { @@ -945,7 +926,7 @@ void open_or_close_in (void) if (read_open[n] != closed) { - (void) a_close(read_file[n]); + a_close(read_file[n]); read_open[n] = closed; } @@ -1144,19 +1125,15 @@ lab50: decr(error_count); } else if (tracing_online > 0) - { help3("This isn't an error message; I'm just \\showing something.", "Type `I\\show...' to show more (e.g., \\show\\cs,", "\\showthe\\count10, \\showbox255, \\showlists)."); - } else - { help5("This isn't an error message; I'm just \\showing something.", "Type `I\\show...' to show more (e.g., \\show\\cs,", "\\showthe\\count10, \\showbox255, \\showlists).", "And type `I\\tracingonline=1\\show...' to show boxes and", "lists on your terminal as well as in the transcript file."); - } error(); } @@ -1281,7 +1258,7 @@ void do_extension (void) default: { confusion("ext1"); - return; // abort_flag set + return; } break; } @@ -1290,7 +1267,7 @@ void do_extension (void) void fix_language (void) { /* ASCII_code l; */ - int l; /* 95/Jan/7 */ + int l; if (language <= 0) l = 0; @@ -1395,11 +1372,10 @@ void handle_right_brace (void) free_node(p, box_node_size); if (nest_ptr == 0) - { build_page(); - } } break; + case output_group: { if ((loc != 0) || ((token_type != output_text) && (token_type != backed_up))) @@ -1449,6 +1425,7 @@ void handle_right_brace (void) link(page_head) = 0; page_tail = page_head; } + pop_nest(); build_page(); } @@ -1533,7 +1510,7 @@ void handle_right_brace (void) default: { confusion("rightbrace"); - return; // abort_flag set + return; } break; } @@ -1547,21 +1524,16 @@ void main_control (void) if (every_job != 0) begin_token_list(every_job, every_job_text); -lab60: +big_switch: get_x_token(); /* big_switch */ -lab21: +reswitch: if (interrupt != 0) if (OK_to_interrupt) { back_input(); - { - if (interrupt != 0) - { - pause_for_instructions(); - } - } - goto lab60; + check_interrupt(); + goto big_switch; } #ifdef DEBUG @@ -1572,20 +1544,19 @@ lab21: if (tracing_commands > 0) show_cur_cmd_chr(); -/* the big switch --- don't bother to test abort_flag ??? */ switch(abs(mode) + cur_cmd) { case hmode + letter: case hmode + other_char: case hmode + char_given: - goto lab70; + goto main_loop; break; case hmode + char_num: { scan_char_num(); cur_chr = cur_val; - goto lab70; + goto main_loop; } break; @@ -1596,20 +1567,20 @@ lab21: if ((cur_cmd == letter) || (cur_cmd == other_char) || (cur_cmd == char_given) || (cur_cmd == char_num)) cancel_boundary = true; - goto lab21; + goto reswitch; } break; case hmode + spacer: if (space_factor == 1000) - goto lab120; + goto append_normal_space; else app_space(); break; case hmode + ex_space: case mmode + ex_space: - goto lab120; + goto append_normal_space; break; case any_mode(relax): @@ -1626,7 +1597,7 @@ lab21: get_x_token(); } while (!(cur_cmd != spacer)); - goto lab21; + goto reswitch; } break; @@ -2059,10 +2030,11 @@ lab21: case any_mode(extension): do_extension(); break; - } /* end of big switch */ - goto lab60; /* main_loop */ + } + + goto big_switch; -lab70: +main_loop: adjust_space_factor(); main_f = cur_font; bchar = font_bchar[main_f]; @@ -2087,33 +2059,32 @@ lab70: main_k = bchar_label[main_f]; if (main_k == non_address) - goto lab92; + goto main_loop_move_2; cur_r = cur_l; cur_l = non_char; - goto lab111; + goto main_lig_loop_1; -lab80: +main_loop_wrapup: wrapup(rt_hit); -/* main_loop_move */ -lab90: +main_loop_move: if (lig_stack == 0) - goto lab21; + goto reswitch; cur_q = tail; cur_l = character(lig_stack); -lab91: +main_loop_move_1: if (!is_char_node(lig_stack)) - goto lab95; + goto main_loop_move_lig; -lab92: +main_loop_move_2: if ((cur_chr < font_bc[main_f]) || (cur_chr > font_ec[main_f])) { char_warning(main_f, cur_chr); free_avail(lig_stack); - goto lab60; + goto big_switch; } main_i = char_info(main_f, cur_l); @@ -2122,38 +2093,37 @@ lab92: { char_warning(main_f, cur_chr); free_avail(lig_stack); - goto lab60; + goto big_switch; } { link(tail) = lig_stack; tail = lig_stack; } -/* main_loop_lookahead */ -lab100: +main_loop_lookahead: get_next(); if (cur_cmd == letter) - goto lab101; + goto main_loop_lookahead_1; if (cur_cmd == other_char) - goto lab101; + goto main_loop_lookahead_1; if (cur_cmd == char_given) - goto lab101; + goto main_loop_lookahead_1; x_token(); if (cur_cmd == letter) - goto lab101; + goto main_loop_lookahead_1; if (cur_cmd == other_char) - goto lab101; + goto main_loop_lookahead_1; if (cur_cmd == char_given) - goto lab101; + goto main_loop_lookahead_1; if (cur_cmd == char_num) { scan_char_num(); cur_chr = cur_val; - goto lab101; + goto main_loop_lookahead_1; } if (cur_cmd == no_boundary) @@ -2161,9 +2131,9 @@ lab100: cur_r = bchar; lig_stack = 0; - goto lab110; + goto main_lig_loop; -lab101: +main_loop_lookahead_1: adjust_space_factor(); fast_get_avail(lig_stack); font(lig_stack) = main_f; @@ -2173,30 +2143,25 @@ lab101: if (cur_r == false_bchar) cur_r = non_char; -// main_lig_loop:@; -lab110: - +main_lig_loop: if (char_tag(main_i) != lig_tag) - goto lab80; + goto main_loop_wrapup; if (cur_r == non_char) - goto lab80; + goto main_loop_wrapup; main_k = lig_kern_start(main_f, main_i); main_j = font_info[main_k].qqqq; if (skip_byte(main_j) <= stop_flag) - goto lab112; + goto main_lig_loop_2; main_k = lig_kern_restart(main_f, main_j); -/* main_lig_loop+1:main_j:=font_info[main_k].qqqq; */ -lab111: +main_lig_loop_1: main_j = font_info[main_k].qqqq; -lab112: -/* provide for suppression of f-ligatures 99/Jan/5 */ +main_lig_loop_2: bSuppress = 0; if (suppress_f_ligs && next_char(main_j) == cur_r && op_byte(main_j) == no_tag) @@ -2212,7 +2177,7 @@ lab112: { wrapup(rt_hit); tail_append(new_kern(char_kern(main_f, main_j))); - goto lab90; + goto main_loop_move; } if (cur_l == non_char) @@ -2220,12 +2185,7 @@ lab112: else if (lig_stack == 0) rt_hit = true; - { - if (interrupt != 0) - { - pause_for_instructions(); - } - } + check_interrupt(); switch (op_byte(main_j)) { @@ -2281,22 +2241,22 @@ lab112: ligature_present = true; if (lig_stack == 0) - goto lab80; + goto main_loop_wrapup; else - goto lab91; + goto main_loop_move_1; } break; } if (op_byte(main_j) > 4) if (op_byte(main_j) != 7) - goto lab80; + goto main_loop_wrapup; if (cur_l < non_char) - goto lab110; + goto main_lig_loop; main_k = bchar_label[main_f]; - goto lab111; + goto main_lig_loop_1; } if (skip_byte(main_j) == 0) @@ -2304,15 +2264,14 @@ lab112: else { if (skip_byte(main_j) >= stop_flag) - goto lab80; + goto main_loop_wrapup; main_k = main_k + skip_byte(main_j) + 1; } - goto lab111; + goto main_lig_loop_1; -/* main_move_log */ -lab95: +main_loop_move_lig: main_p = lig_ptr(lig_stack); if (main_p != 0) /* BUG FIX */ @@ -2326,16 +2285,15 @@ lab95: if (lig_stack == 0) if (main_p != 0) /* BUG FIX */ - goto lab100; + goto main_loop_lookahead; else cur_r = bchar; else cur_r = character(lig_stack); - goto lab110; + goto main_lig_loop; -/* append_normal_space */ -lab120: +append_normal_space: if (space_skip == 0) { { @@ -2358,6 +2316,6 @@ lab120: link(tail) = temp_ptr; tail = temp_ptr; - goto lab60; -} -/* give_err_help etc followed here in the old tex8.c */ \ No newline at end of file + + goto big_switch; +} \ No newline at end of file diff --git a/src/texsourc/tex9.c b/src/texsourc/tex9.c index e43d925..2502069 100644 --- a/src/texsourc/tex9.c +++ b/src/texsourc/tex9.c @@ -442,9 +442,7 @@ void close_files_and_terminate (void) print_ln(); if ((edit_name_start != 0) && (interaction > 0)) - { call_edit(str_pool, edit_name_start, edit_name_length, edit_line); - } } #ifdef DEBUG /* sec 1338 */ diff --git a/src/texsourc/texmf.h b/src/texsourc/texmf.h index d4d108b..a21da7b 100644 --- a/src/texsourc/texmf.h +++ b/src/texsourc/texmf.h @@ -23,7 +23,8 @@ #include "yandytex.h" -enum { +enum +{ out_dvi_flag = (1 << 0), out_pdf_flag = (1 << 1), out_xdv_flag = (1 << 2), diff --git a/src/texsourc/yandy_kanji.c b/src/texsourc/yandy_kanji.c deleted file mode 100644 index c2eafd6..0000000 --- a/src/texsourc/yandy_kanji.c +++ /dev/null @@ -1,456 +0,0 @@ -/* 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. */ - -#define EXTERN extern - -#include "texd.h" - -boolean check_kanji(integer c) -{ - return is_char_kanji(c); -} - -boolean is_char_ascii(integer c) -{ - return (0 <= c && c < 0x100); -} - -boolean is_char_kanji(integer c) -{ - return (iskanji1(Hi(c)) && iskanji2(Lo(c))); -} - -boolean ismultiprn(integer c) -{ - if (iskanji1(c) || iskanji2(c)) - return true; - - return false; -} - -integer calc_pos(integer c) -{ - unsigned char c1, c2; - - if(c>=0 && c<=255) - return(c); - - c1 = (c >> 8) & 0xff; - c2 = c & 0xff; - - if(iskanji1(c1)) - { - if (is_internalSJIS()) - { - c1 = ((c1 - 0x81) % 4) * 64; /* c1 = 0, 64, 128, 192 */ - c2 = c2 % 64; /* c2 = 0..63 */ - } - else - { - c1 = ((c1 - 0xa1) % 4) * 64; /* c1 = 0, 64, 128, 192 */ - c2 = c2 % 64; /* c2 = 0..63 */ - } - - return(c1 + c2); /* ret = 0..255 */ - } else - return(c2); -} - -integer kcatcodekey(integer c) -{ - return Hi(toDVI(c)); -} - -void init_default_kanji (const_string file_str, const_string internal_str) -{ - char *p; - - enable_UPTEX (false); /* disable */ - - if (!set_enc_string (file_str, internal_str)) - { - fprintf (stderr, "Bad kanji encoding \"%s\" or \"%s\".\n", - file_str ? file_str : "NULL", - internal_str ? internal_str : "NULL"); - uexit(1); - } - - p = getenv ("PTEX_KANJI_ENC"); - - if (p) - { - if (!set_enc_string (p, NULL)) - fprintf (stderr, "Ignoring bad kanji encoding \"%s\".\n", p); - } - -#ifdef WIN32 - p = kpse_var_value ("guess_input_kanji_encoding"); - - if (p) - { - if (*p == '1' || *p == 'y' || *p == 't') - infile_enc_auto = 1; - - free(p); - } -#endif -} -/* Routines needed by pTeX */ -/* -void print_kanji(KANJI_code s) -{ - if (s > 255) - { - print_char(Hi(s)); - print_char(Lo(s)); - } - else - print_char(s); -} - -void print_kansuji(integer n) -{ - int k; - KANJI_code cx; - - k = 0; - - if (n < 0) - return; - - do - { - dig[k] = n % 10; - n = n / 10; - incr(k); - } - while (!(n = 0)); - - while (k > 0) - { - decr(k); - cx = kansuji_char(dig[k]); - print_kanji(fromDVI(cx)); - } -} - -void print_dir(eight_bits dir) -{ - if (dir == dir_yoko) - print_char('Y'); - else if (dir == dir_tate) - print_char('T'); - else if (dir == dir_dtou) - print_char('D'); -} - -void print_direction(integer d) -{ - switch (d) - { - case dir_yoko: - print_string("yoko"); - break; - - case dir_tate: - print_string("tate"); - break; - - case dir_dtou: - print_string("dtou"); - break; - } - - if (d < 0) - print_string("(math)"); - else - print_string(" direction"); -} - -eight_bits get_jfm_pos(KANJI_code kcode, internal_font_number f) -{ - KANJI_code jc; - pointer sp, mp, ep; - - if (f == null_font) - { - return kchar_type(null_font, 0); - } - - jc = toDVI(kcode); - sp = 1; - ep = font_num_ext[f] - 1; - - if (ep >= 1 && kchar_code(f, sp) <= jc && jc <= kchar_code(f, ep)) - { - while (sp <= ep) - { - mp = sp + (ep - sp) / 2; - - if (jc < kchar_code(f, mp)) - ep = mp - 1; - else if (jc > kchar_code(f, mp)) - sp = mp + 1; - else - { - return kchar_typ(f, mp); - } - } - } - - return kchar_type(f, 0); -} - -pointer get_inhibit_pos(KANJI_code c, small_number n) -{ - pointer p, s; - - s = calc_pos(c); - p = s; - - if (n == new_pos) - { - do - { - if (inhibit_xsp_code(p) == 0 || inhibit_xsp_code(p) == c) - goto done; - - incr(p); - - if (p > 255) - p = 0; - } - while (!(s == p)); - - p = no_entry; - } - else - { - do - { - if (inhibit_xsp_code(p) == 0) - goto done1; - - if (inhibit_xsp_code(p) == c) - goto done; - - incr(p); - - if (p > 255) - p = 0; - } - while (!(s == p)); - -done1: - p = no_entry; - } - -done: - return p; -} - -void set_math_kchar(integer c) -{ - pointer p; - - p = new_noad(); - math_type(nucleus(p)) = math_jchar; - inhibit_glue_flag = false; - character(nucleus(p)) = 0; - math_kcode(p) = c; - fam(nucleus) = cur_jfam; - - if (font_dir[fam_fnt(fam(nucleus(p)) + cur_size)] == dir_default) - { - print_err("Not two-byte family"); - help1("IGNORE."); - error(); - } - - type(p) = ord_noad; - link(tail) = p; - tail = p; -} - -void synch_dir(void) -{ - scaled tmp; - - switch (cur_dir_hv) - { - case dir_yoko: - if (dvi_dir != cur_dir_hv) - { - synch_h(); - synch_v(); - dvi_out(dir_chg); - dvi_out(dvi_yoko); - dir_used = true; - - switch () - { - case dir_tate: - tmp = cur_h; - cur_h = -cur_v; - cur_v = tmp; - break; - - case dir_dtou: - tmp = cur_h; - cur_h = cur_v; - cur_v = -tmp; - break - } - - dvi_h = cur_h; - dvi_v = cur_v; - dvi_dir = cur_dir_hv; - } - break; - - case dir_tate: - if (dvi_dir != cur_dir_hv) - { - synch_h(); - synch_v(); - dvi_out(dirchg); - dvi_out(dvi_tate); - dir_used = true; - - switch (dvi_dir) - { - case dir_yoko: - tmp = cur_h; - cur_h = cur_v; - cur_v = -tmp; - break; - - case dir_dtou: - cur_v = -cur_v; - cur_h = -cur_h; - break; - } - - dvi_h = cur_h; - dvi_v = cur_v; - dvi_dir = cur_dir_hv; - } - break; - - case dir_dtou: - if (dvi_dir != cur_dir_hv) - { - synch_h(); - synch_v(); - dvi_out(dir_chg); - dvi_out(dvi_dtou); - dir_used = true; - - switch (dvi_dir) - { - case dir_yoko: - tmp = cur_h; - cur_h = -cur_v; - cur_v = tmp; - break; - - case dir_tate: - cur_v = -cur_v; - cur_h = -cur_h; - break; - } - - dvi_h = cur_h; - dvi_v = cur_v; - dvi_dir = cur_dir_hv; - } - break; - - default: - confusion("synch_dir"); - break; - } -} - -void dir_out(void) -{ - pointer this_box; - - this_box = temp_ptr; - temp_ptr = list_ptr(this_box); - - if (type(temp_ptr) != hlist_node && type(temp_ptr) != vlist_out) - confusion("dir_out"); - - switch (box_dir(this_box)) - { - case dir_yoko: - switch (box_dir(temp_ptr)) - { - case dir_tate: - cur_v = cur_v - height(this_box); - cur_h = cur_h + depth(temp_ptr); - break; - - case dir_dtou: - cur_v = cur_v + depth(this_box); - cur_h = cur_h + height(temp_ptr); - break; - } - break; - - case dir_tate: - switch (box_dir(temp_ptr)) - { - case dir_yoko: - cur_v = cur_v + depth(this_box); - cur_h = cur_h + height(temp_ptr); - break; - - case dir_dtou: - cur_v = cur_v + depth(this_box) - height(temp_ptr); - cur_h = cur_h + width(temp_ptr); - break; - } - break; - - case dir_dtou: - switch (box_dir(temp_ptr)) - { - case dir_yoko: - cur_v = cur_v - height(this_box); - cur_h = cur_h + depth(temp_ptr); - break; - - case dir_tate: - cur_v = cur_v + depth(this_box) - height(temp_ptr); - cur_h = cur_h + width(temp_ptr); - break; - } - break; - } - - cur_dir_hv = box_dir(temp_ptr); - - if (type(temp_ptr) == vlist_node) - vlist_out(); - else - hlist_out(); -} -*/ \ No newline at end of file diff --git a/src/texsourc/yandy_macros.h b/src/texsourc/yandy_macros.h index faf1017..a4f5b0c 100644 --- a/src/texsourc/yandy_macros.h +++ b/src/texsourc/yandy_macros.h @@ -53,6 +53,14 @@ enum error_message_issued = 2, fatal_error_stop = 3, }; +/* sec 0096 */ +#define check_interrupt() \ +do \ +{ \ + if (interrupt != 0) \ + pause_for_instructions(); \ +} \ +while (0) /* sec 0105 */ #define nx_plux_y(...) mult_and_add(..., 07777777777L) #define mult_integers(a) mult_and_add(a,0,017777777777L) @@ -761,6 +769,14 @@ enum #define every_cr_text 13 #define mark_text 14 #define write_text 15 +/* sec 0322 */ +#define pop_input() \ +do \ +{ \ + decr(input_ptr); \ + cur_input = input_stack[input_ptr]; \ +} \ +while (0) /* sec 0323 */ #define back_list(a) begin_token_list(a, backed_up) #define ins_list(a) begin_token_list(a, inserted) @@ -1373,6 +1389,25 @@ while (0) #define over_code 1 #define atop_code 2 #define delimited_code 3 +/* sec 1214 */ +#define define(p, t, e) \ +do \ +{ \ + if (a >= 4) \ + geq_define(p, t, e);\ + else \ + eq_define(p, t, e); \ +} \ +while (0) +#define word_define(p, w) \ +do \ +{ \ + if (a >= 4) \ + geq_word_define(p, w);\ + else \ + eq_word_define(p, w); \ +} \ +while (0) /* sec 1222 */ #define char_def_code 0 #define math_char_def_code 1 -- 2.11.0