From 8316f1c459bab0a9894b74d3f86494563293aa22 Mon Sep 17 00:00:00 2001 From: Luigi Scarso Date: Wed, 12 Jan 2022 11:25:59 +0000 Subject: LuaTeX \showstream (M.Krüger) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://tug.org/texlive/trunk@61580 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/luatexdir/ChangeLog | 3 +++ .../source/texk/web2c/luatexdir/luatex_svnversion.h | 2 +- Build/source/texk/web2c/luatexdir/tex/commands.c | 9 +++++++++ Build/source/texk/web2c/luatexdir/tex/equivalents.h | 4 +++- Build/source/texk/web2c/luatexdir/tex/mainbody.c | 1 + Build/source/texk/web2c/luatexdir/tex/maincontrol.c | 20 ++++++++++++++++++-- Build/source/texk/web2c/luatexdir/tex/printing.c | 3 ++- 7 files changed, 37 insertions(+), 5 deletions(-) (limited to 'Build/source/texk/web2c') diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog index d7b5f3bfaac..714392e10ad 100644 --- a/Build/source/texk/web2c/luatexdir/ChangeLog +++ b/Build/source/texk/web2c/luatexdir/ChangeLog @@ -1,3 +1,6 @@ +2022-01-12 Luigi Scarso + * fixed \showstream (M.Krüger) + 2021-12-31 Luigi Scarso * drop (for the moment) \showstream diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h index b44df5aab7c..19c6192eafc 100644 --- a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h +++ b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h @@ -1 +1 @@ -#define luatex_svn_revision 7474 +#define luatex_svn_revision 7478 diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.c b/Build/source/texk/web2c/luatexdir/tex/commands.c index e9c0ad88803..899e84c3bb7 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.c +++ b/Build/source/texk/web2c/luatexdir/tex/commands.c @@ -820,6 +820,15 @@ void initialize_etex_commands(void) primitive_luatex("shapemode", assign_int_cmd, int_base + shape_mode_code, int_base); primitive_luatex("hyphenationbounds", assign_int_cmd, int_base + hyphenation_bounds_code, int_base); + /*tex + + The \.{\\showstream} parameter allows to redirect the output of |xray_cmd| + commands to any write stream. + + */ + + primitive_tex("showstream", assign_int_cmd, int_base + show_stream_code, int_base); + primitive_etex("showgroups", xray_cmd, show_groups, 0); /*tex diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h index e4872f74896..ce9ad1f2aaa 100644 --- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h +++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h @@ -312,8 +312,9 @@ the |number_regs| \.{\\dimen} registers. # define math_defaults_mode_code 119 /* > 0 : latex preferences */ # define discretionary_ligature_mode_code 120 # define partoken_context_code 121 +# define show_stream_code 122 -# define math_option_code 122 +# define math_option_code 123 # define mathoption_int_base_code (math_option_code+1) /* one reserve */ # define mathoption_int_last_code (mathoption_int_base_code+8) @@ -818,6 +819,7 @@ extern halfword last_cs_name; #define discretionary_ligature_mode_par int_par(discretionary_ligature_mode_code) #define partoken_context_code_par int_par(partoken_context_code) +#define show_stream_par int_par(show_stream_code) /* */ diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.c b/Build/source/texk/web2c/luatexdir/tex/mainbody.c index 2f45f9989d2..4fbe62b69bc 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.c +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.c @@ -441,6 +441,7 @@ int main_initialize(void) memset(eqtb, 0, sizeof(memory_word) * (unsigned) (eqtb_top + 1)); init_string_pool_array((unsigned) max_strings); reset_cur_string(); + show_stream_par = -1; } /*tex Check the ``constant'' values... diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.c b/Build/source/texk/web2c/luatexdir/tex/maincontrol.c index f72659c5064..4f91283b9c0 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.c +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.c @@ -4055,12 +4055,16 @@ void show_whatever(void) int n; /* level of \.{\\if...\\fi} nesting */ switch (cur_chr) { case show_lists: + if (file_can_be_written(show_stream_par)) + selector = show_stream_par; begin_diagnostic(); show_activities(); break; case show_box_code: /*tex Show the current contents of a box. */ scan_register_num(); + if (file_can_be_written(show_stream_par)) + selector = show_stream_par; begin_diagnostic(); tprint_nl("> \\box"); print_int(cur_val); @@ -4073,7 +4077,9 @@ void show_whatever(void) case show_code: /*tex Show the current meaning of a token, then |goto common_ending|. */ get_token(); - if (interaction == error_stop_mode) + if (file_can_be_written(show_stream_par)) + selector = show_stream_par; + else if (interaction == error_stop_mode) wake_up_terminal(); tprint_nl("> "); if (cur_cs != 0) { @@ -4085,10 +4091,14 @@ void show_whatever(void) break; /*tex Cases for |show_whatever| */ case show_groups: + if (file_can_be_written(show_stream_par)) + selector = show_stream_par; begin_diagnostic(); show_save_groups(); break; case show_ifs: + if (file_can_be_written(show_stream_par)) + selector = show_stream_par; begin_diagnostic(); tprint_nl(""); print_ln(); @@ -4128,7 +4138,9 @@ void show_whatever(void) common_ending|. */ p = the_toks(); - if (interaction == error_stop_mode) + if (file_can_be_written(show_stream_par)) + selector = show_stream_par; + else if (interaction == error_stop_mode) wake_up_terminal(); tprint_nl("> "); token_show(temp_token_head); @@ -4147,6 +4159,10 @@ void show_whatever(void) } } COMMON_ENDING: + if (valid_write_file(selector)) { + fixup_selector(log_opened_global); + return; + } if (interaction < error_stop_mode) { help0(); decr(error_count); diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.c b/Build/source/texk/web2c/luatexdir/tex/printing.c index 2ee5a110606..02756f5caeb 100644 --- a/Build/source/texk/web2c/luatexdir/tex/printing.c +++ b/Build/source/texk/web2c/luatexdir/tex/printing.c @@ -382,7 +382,8 @@ void print_nlp(void) { if (new_string_line > 0) { print_char(new_string_line); - } else if (((term_offset > 0) && (odd(selector))) || + } else if ((selector < no_print) || + ((term_offset > 0) && (odd(selector))) || ((file_offset > 0) && (selector >= log_only))) { print_ln(); } -- cgit v1.2.3