From d8958375d945820cf77d96f3bcf1b7c96e07a12e Mon Sep 17 00:00:00 2001 From: maqiyuan Date: Sat, 7 Jun 2014 21:41:03 +0800 Subject: [PATCH] pTeX's primitives. --- src/texsourc/coerce.h | 2 +- src/texsourc/itex.c | 37 ++++- src/texsourc/tex0.c | 227 +++++---------------------- src/texsourc/tex1.c | 375 ++++++++++++++++++++++++-------------------- src/texsourc/tex2.c | 17 +- src/texsourc/tex3.c | 181 +++------------------ src/texsourc/texd.h | 25 ++- src/texsourc/yandy_macros.h | 84 +++++++--- src/texsourc/yandy_pool.c | 2 +- 9 files changed, 377 insertions(+), 573 deletions(-) diff --git a/src/texsourc/coerce.h b/src/texsourc/coerce.h index 379db83..d52795e 100644 --- a/src/texsourc/coerce.h +++ b/src/texsourc/coerce.h @@ -67,7 +67,7 @@ void print_hex_(integer); void print_roman_int_(integer); #define print_roman_int(n) print_roman_int_((integer) (n)) void print_current_string(void); -void term_input(char *, int); +void term_input(void); void int_error_(integer); #define int_error(n) int_error_((integer) (n)) void normalize_selector(void); diff --git a/src/texsourc/itex.c b/src/texsourc/itex.c index 34c98f1..be411dd 100644 --- a/src/texsourc/itex.c +++ b/src/texsourc/itex.c @@ -1383,7 +1383,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); @@ -2792,6 +2792,12 @@ 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]; @@ -2803,11 +2809,20 @@ 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; @@ -3986,6 +4001,8 @@ 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); @@ -4048,6 +4065,8 @@ 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); @@ -4073,6 +4092,8 @@ 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); @@ -4091,6 +4112,8 @@ 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); @@ -4289,10 +4312,10 @@ void init_prim (void) primitive("lccode", def_code, lc_code_base); primitive("uccode", def_code, uc_code_base); primitive("sfcode", def_code, sf_code_base); - primitive("delcode", def_code, (hash_size + 3474)); - primitive("textfont", def_family, (hash_size + 1835)); - primitive("scriptfont", def_family, (hash_size + 1851)); - primitive("scriptscriptfont", def_family, (hash_size + 1867)); + 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("hyphenation", hyph_data, 0); primitive("patterns", hyph_data, 1); primitive("hyphenchar", assign_font_int, 0); @@ -4305,8 +4328,8 @@ void init_prim (void) primitive("closein", in_stream, 0); primitive("message", message, 0); primitive("errmessage", message, 1); - primitive("lowercase", case_shift, (hash_size + 2139)); - primitive("uppercase", case_shift, (hash_size + 2395)); + primitive("lowercase", case_shift, lc_code_base); + primitive("uppercase", case_shift, uc_code_base); primitive("show", xray, 0); primitive("showbox", xray, 1); primitive("showthe", xray, 2); diff --git a/src/texsourc/tex0.c b/src/texsourc/tex0.c index dadb7b4..aed2ea1 100644 --- a/src/texsourc/tex0.c +++ b/src/texsourc/tex0.c @@ -20,6 +20,15 @@ #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) +{ + print_string(s); + term_input(); +} INLINE void synch_h(void) { if (cur_h != dvi_h) @@ -61,7 +70,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; @@ -79,30 +88,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; @@ -118,7 +127,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) @@ -135,7 +144,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); @@ -573,11 +582,7 @@ void error (void) { lab22: clear_for_error_prompt(); - - { /* prompt_input */ - print_string("? "); - term_input("? ", help_ptr); - } + prompt_input("? "); if (last == first) return; // no input @@ -687,10 +692,7 @@ lab22: } else { - { /* prompt_input */ - print_string("insert>"); - term_input("insert>", 0); - } + prompt_input("insert>"); cur_input.loc_field = first; } first = last; @@ -1047,190 +1049,31 @@ 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) -void term_input (char * term_str, int term_help_lines) +void term_input(void) { integer k; - int flag; - char * helpstring = NULL; -#ifdef _WINDOWS - char * querystring = NULL; -#endif -// if (nhelplines != 0) { -// helpstring = make_up_help_string (nhelplines); -// printf(helpstring); -// free(helpstring); -// } - show_line("\n", 0); // force it to show what may be buffered up ??? - helpstring = NULL; - -#ifdef _WINDOWS - if (term_str != NULL) - querystring = term_str; - if (term_help_lines != NULL) - helpstring = make_up_help_string(term_help_lines); + if (!knuth_flag) + show_line("\n", 0); // force it to show what may be buffered up ??? - if (helpstring == NULL && querystring != NULL) - { - if (strcmp(querystring, ": ") == 0) - helpstring = xstrdup("Please type another file name (or ^z to exit):"); - else if (strcmp(querystring, "=>") == 0) // from firm_up_the_line - helpstring = xstrdup("Please type to accept this line\r\nor type a replacement line"); - else if (strcmp(querystring, "insert>") == 0) // from error() after "I" - helpstring = xstrdup("Please type something to insert here"); - else if (strcmp(querystring, "") == 0) // from read_toks - helpstring = xstrdup("Please type a control sequence"); - else if (strcmp(querystring, "= ") == 0) // from read_toks - helpstring = xstrdup("Please type a token"); - else if (strcmp(querystring, "*") == 0) // get_next - helpstring = xstrdup("Please type a control sequence\r\n(or ^z to exit)"); - } - - flag = ConsoleInput(querystring, helpstring, (char *) &buffer[first]); // ??? -// flag == 0 means trouble --- EOF on terminal - if (querystring != NULL) - free(querystring); - - if (helpstring != NULL) - free(helpstring); - - helpstring = querystring = NULL; - - last = first + strlen((char *) &buffer[first]); /* -1 ? */ -// flag = (last > first); -// may need to be more elaborate see input_line in texmf.c ??? -// sprintf(log_line, "first %d last %d flag %d - %s", -// first, last, flag, (char *) &buffer[first]); -// winerror(log_line); -#else fflush(stdout); - flag = input_ln(stdin, true); -#endif - if (!flag) + + if (!input_ln(stdin, true)) { fatal_error("End of file on the terminal!"); - return; // abort_flag set + return; } + term_offset = 0; -#ifdef _WINDOWS -// echo what was typed into Console buffer also - if (last != first) - for (k = first; k <= last - 1; k++) - print(buffer[k]); - print_ln(); -#else - decr(selector); // shut off echo + decr(selector); if (last != first) for (k = first; k <= last - 1; k++) print(buffer[k]); print_ln(); - incr(selector); // reset selector again -#endif + incr(selector); } /* sec 0091 */ void int_error_ (integer n) @@ -2476,6 +2319,16 @@ 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; @@ -2488,6 +2341,10 @@ 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; diff --git a/src/texsourc/tex1.c b/src/texsourc/tex1.c index d9b1723..7193b3e 100644 --- a/src/texsourc/tex1.c +++ b/src/texsourc/tex1.c @@ -831,6 +831,14 @@ 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; @@ -964,6 +972,14 @@ 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; @@ -2065,193 +2081,204 @@ void show_eqtb_(halfword n) { if (n < active_base) print_char('?'); - else - if (n < glue_base) + 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) { - sprint_cs(n); + print_skip_param(n - glue_base); 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); - } + + 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 - 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"); - } + { + 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 - 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('='); + 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 (equiv(n) != 0) + show_token_list(link(equiv(n)), 0, 32); + } + else if (n < cur_font_loc) { - if (n < count_base) - print_param(n - int_base); + print_esc("box"); + print_int(n - box_base); + print_char('='); + + if (equiv(n) == 0) + print_string("void"); else - if (n < del_code_base) - { - print_esc("count"); - print_int(n - count_base); - } - else - { - print_esc("delcode"); - print_int(n - del_code_base); - } - + { + 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_int(eqtb[n].cint); + print_esc(""); + print(hash[font_id_base + equiv(n)].rh); } - else - if (n <= eqtb_size) + else if (n < math_code_base) + { + if (n < kcat_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"); + 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) + { + print_esc("uccode"); + print_int(n - uc_code_base); } else - print_char('?'); + { + 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('?'); } #endif /* STAT */ /* sec 0259 */ diff --git a/src/texsourc/tex2.c b/src/texsourc/tex2.c index 6471d8f..04f41ce 100644 --- a/src/texsourc/tex2.c +++ b/src/texsourc/tex2.c @@ -494,7 +494,7 @@ void begin_token_list_ (halfword p, quarterword t) break; default: - print_cmd_chr(assign_toks, t + (hash_size + 1307)); + print_cmd_chr(assign_toks, t - output_text + output_routine_loc); break; } @@ -814,12 +814,7 @@ void firm_up_the_line (void) print(buffer[k]); first = cur_input.limit_field; - - { - ; - print_string("=>"); - term_input("=>", 0); - } + prompt_input("=>"); if (last > first) { @@ -2424,13 +2419,7 @@ lab40: print_ln(); first = cur_input.start_field; - - { - ; - print_string("*"); - term_input("*", 0); - } - + prompt_input("*"); cur_input.limit_field = last; if ((end_line_char < 0) || (end_line_char > 255)) diff --git a/src/texsourc/tex3.c b/src/texsourc/tex3.c index 9820d75..3bbb95d 100644 --- a/src/texsourc/tex3.c +++ b/src/texsourc/tex3.c @@ -961,18 +961,12 @@ void read_toks_(integer n, halfword r) if (read_open[m] == closed) if (interaction > nonstop_mode) if (n < 0) - { - print_string(""); - term_input("", 0); - } + prompt_input(""); else { print_ln(); sprint_cs(r); - { - print_string("="); - term_input("=", 0); - } + prompt_input("="); n = -1; } else @@ -1459,7 +1453,6 @@ boolean more_name_(ASCII_code c) return true; } } -/******************************** 2000 August 15th start ***********************/ // The following code is to save string space used by TeX for filenames // Not really critical in a system that has dynamic memory allocation @@ -1525,16 +1518,12 @@ void remove_string (int start, int end) int nlen = pool_ptr - end; // how many bytes to move down char *s; -// int trace_flag=1; // debugging only -// if (end < start) show_line("\nEND < START", 1); -// if (pool_ptr < end) show_line("\nPOOLPTR < END", 1); - 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); + strncpy(s, (const char *) str_pool + start, n); strcpy(s + n, "\n"); show_line(log_line, 0); } @@ -1542,7 +1531,7 @@ void remove_string (int start, int end) if (nlen > 0) memcpy(str_pool + start, str_pool + end, nlen); - pool_ptr = start + nlen; // poolprt - (end-start); + pool_ptr = start + nlen; } void show_string (int k) @@ -1576,13 +1565,13 @@ void end_name (void) if (str_ptr + 3 > current_max_strings) { overflow("number of strings", current_max_strings - init_str_ptr); - return; // abort_flag set + return; } #else if (str_ptr + 3 > max_strings) { overflow("number of strings", max_strings - init_str_ptr); - return; // abort_flag set + return; } #endif @@ -1597,9 +1586,6 @@ void end_name (void) if (ext_delimiter != 0) ext_delimiter = ext_delimiter - area_delimiter; - -// str_start[str_ptr + 1]= str_start[str_ptr]+ area_delimiter; // test only -// incr(str_ptr); // test only } else // carve out string for "cur_area" { @@ -1616,7 +1602,6 @@ void end_name (void) if (save_strings_flag && (cur_name = find_string(str_start[str_ptr], pool_ptr)) > 0) { remove_string(str_start[str_ptr], pool_ptr); -// (void) make_string(); // test only } else // Make string from str_start[str_ptr]to pool_ptr cur_name = make_string(); @@ -1627,8 +1612,6 @@ void end_name (void) (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); -// str_start[str_ptr + 1]= str_start[str_ptr]+ ext_delimiter - area_delimiter - 1; // test only -// incr(str_ptr); // test only } else // carve out string for "cur_name" { @@ -1640,7 +1623,6 @@ void end_name (void) if (save_strings_flag && (cur_ext = find_string(str_start[str_ptr], pool_ptr)) > 0) { remove_string(str_start[str_ptr], pool_ptr); -// (void) make_string(); // test only } else // Make string from str_start[str_ptr]to pool_ptr cur_ext = make_string(); @@ -1659,31 +1641,13 @@ 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++) - { - c = str_pool[j]; - incr(k); - - if (k <= PATH_MAX) - name_of_file[k] = xchr[c]; - } + append_to_name(str_pool[j]); for (j = str_start[n]; j <= str_start[n + 1] - 1; j++) - { - c = str_pool[j]; - incr(k); - - if (k <= PATH_MAX) - name_of_file[k] = xchr[c]; - } + append_to_name(str_pool[j]); for (j = str_start[e]; j <= str_start[e + 1] - 1; j++) - { - c = str_pool[j]; - incr(k); - - if (k <= PATH_MAX) - name_of_file[k] = xchr[c]; - } + append_to_name(str_pool[j]); if (k < PATH_MAX) name_length = k; @@ -1694,7 +1658,7 @@ void pack_file_name_(str_number n, str_number a, str_number e) for (k = name_length + 1; k <= PATH_MAX; k++) name_of_file[k] = ' '; - name_of_file[PATH_MAX] = '\0'; /* paranoia 94/Mar/24 */ + name_of_file[PATH_MAX] = '\0'; { name_of_file [name_length+1] = '\0'; @@ -1885,19 +1849,14 @@ void prompt_file_name_(char * s, str_number e) if (interaction < 2) { fatal_error("*** (job aborted, file error in nonstop mode)"); - return; // abort_flag set + return; } if (!knuth_flag) -#ifdef _WINDOWS - show_line(" (or ^z to exit)", 0); -#else show_line(" (or Ctrl-Z to exit)", 0); -#endif - { - print_string(": "); - term_input(": ", 0); - } + + prompt_input(": "); + /* should we deal with tilde and space in file name here ??? */ { begin_name(); @@ -1973,14 +1932,14 @@ void open_log_file (void) { stamp_it(log_line); strcat(log_line, "\n"); - (void) fputs(log_line, log_file); + fputs(log_line, log_file); stampcopy(log_line); strcat(log_line, "\n"); - (void) fputs(log_line, log_file); + fputs(log_line, log_file); } - (void) fputs(tex_version, log_file); - (void) fprintf(log_file, " (%s %s)", application, yandyversion); + fputs(tex_version, log_file); + fprintf(log_file, " (%s %s)", application, yandyversion); if (format_ident > 0) slow_print(format_ident); @@ -1996,7 +1955,7 @@ void open_log_file (void) months = " JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"; for (k = 3 * month - 2; k <= 3 * month; k++) - (void) putc(months[k], log_file); + putc(months[k], log_file); print_char(' '); @@ -2035,76 +1994,6 @@ void open_log_file (void) selector = old_setting + 2; } - -/**************************** start of insertion 98/Feb/7 **************/ -// 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(); -} - -/**************************** end of insertion 98/Feb/7 **************/ /* sec 0537 */ void start_input(void) { @@ -2116,31 +2005,9 @@ void start_input(void) while (true) { added_extension = false; - begin_file_reading(); - - if ((cur_ext != 335) && a_open_in(input_file[cur_input.index_field], TEXINPUTPATH)) - goto lab30; - - if ((cur_ext != 785) && (name_length + 5 < PATH_MAX)) - { - name_of_file[name_length + 1] = '.'; - name_of_file[name_length + 2] = 't'; - name_of_file[name_length + 3] = 'e'; - name_of_file[name_length + 4] = 'x'; - name_of_file[name_length + 5] = ' '; - name_length = name_length + 4; - - added_extension = true; - - if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH)) - goto lab30; - - name_length = name_length - 4; - name_of_file[name_length + 1] = ' '; - added_extension = false; - } - - if ((cur_ext == 335) && a_open_in(input_file[cur_input.index_field], TEXINPUTPATH)) + begin_file_reading(); + + if (a_open_in(input_file[cur_input.index_field], TEXINPUTPATH)) goto lab30; end_file_reading(); @@ -2153,10 +2020,6 @@ lab30: if (job_name == 0) { job_name = cur_name; - - if (cur_ext != 335 && added_extension) - job_name_append(); - open_log_file(); } diff --git a/src/texsourc/texd.h b/src/texsourc/texd.h index fb7be91..61c2b77 100644 --- a/src/texsourc/texd.h +++ b/src/texsourc/texd.h @@ -23,6 +23,7 @@ #define STAT #include "texmf.h" +#include "yandy_macros.h" // #define max_halfword 65535L /* for 32 bit memory word */ #define min_halfword -2147483647L /* for 64 bit memory word (signed) */ @@ -244,12 +245,10 @@ EXTERN halfword temp_ptr; /* sec 0116 */ #ifdef ALLOCATEMAIN - EXTERN memory_word * main_memory; /* remembered so can be free() later */ + EXTERN memory_word * main_memory; 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 @@ -310,12 +309,12 @@ EXTERN int old_setting; #endif #ifdef ALLOCATEZEQTB - EXTERN memory_word * zeqtb; + EXTERN memory_word * eqtb; #else #ifdef INCREASEFONTS - EXTERN memory_word eqtb[(hash_size + 4007) + eqtb_extra]; + EXTERN memory_word eqtb[eqtb_size + 1]; #else - EXTERN memory_word zeqtb[(hash_size + 4007)]; + EXTERN memory_word eqtb[eqtb_size + 1]; #endif #endif @@ -493,9 +492,7 @@ 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 width_base[font_max + 1]; EXTERN integer height_base[font_max + 1]; @@ -671,13 +668,12 @@ EXTERN trie_op_code max_op_used; EXTERN trie_pointer trie_min[256]; EXTERN trie_pointer trie_max; EXTERN boolean trie_not_ready; -#endif /* INITEX */ +#endif 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) @@ -875,15 +871,18 @@ void call_edit (ASCII_code *filename, pool_pointer fnstart, void add_variable_space(int); -void get_date_and_time (integer *minutes, integer *day, - integer *month, integer *year); +void get_date_and_time (integer *, integer *, integer *, integer *); + +//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 */ +extern INLINE void prompt_input(const char *s); extern INLINE void synch_h(void); extern INLINE void synch_v(void); extern INLINE void set_cur_lang(void); diff --git a/src/texsourc/yandy_macros.h b/src/texsourc/yandy_macros.h index a43d83f..ec33ba9 100644 --- a/src/texsourc/yandy_macros.h +++ b/src/texsourc/yandy_macros.h @@ -434,10 +434,13 @@ enum #define space_skip_code 12 // 794 #define xspace_skip_code 13 // 795 #define par_fill_skip_code 14 // 796 -#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 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 skip_base (glue_base + glue_pars) // 800 #define mu_skip_base (skip_base + 256) // 1056 #define local_base (mu_skip_base + 256) // 1312 @@ -460,6 +463,8 @@ 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) @@ -478,8 +483,17 @@ 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 cat_code_base (math_font_base + 48) // 1883 -#define lc_code_base (cat_code_base + 256) // 2139 +#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 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 @@ -499,7 +513,18 @@ 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) @@ -553,17 +578,19 @@ enum #define floating_penalty_code 42 // 3205 #define global_defs_code 43 // 3206 #define cur_fam_code 44 // 3207 -#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 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 count_base (int_base + int_pars) // 3218 #define del_code_base (count_base + 256) // 3474 #define dimen_base (del_code_base + 256) // 3730 @@ -616,6 +643,7 @@ 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) @@ -626,6 +654,7 @@ 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 @@ -648,12 +677,16 @@ enum #define h_offset_code 18 // 3748 #define v_offset_code 19 // 3749 #define emergency_stretch_code 20 // 3750 -#define dimen_pars 21 +#define t_baseline_shift_code 21 +#define y_baseline_shift_code 22 +#define dimen_pars 23 //21 #define scaled_base (dimen_base + dimen_pars) // 3751 -#define eqtb_size (scaled_base + 255) // 4006 +#define kinsoku_penalty_base (scaled_base + 256) +#define eqtb_size (kinsoku_penalty_base + 255) //(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) @@ -674,6 +707,8 @@ 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 @@ -862,6 +897,17 @@ 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 diff --git a/src/texsourc/yandy_pool.c b/src/texsourc/yandy_pool.c index f338598..3309289 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", -- 2.11.0