From b76ab76c1e3ebf249317bae666dca768163bea0f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 11 Jan 2022 23:13:18 +0000 Subject: \showstream fix from Marcel git-svn-id: svn://tug.org/texlive/trunk@61577 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ChangeLog | 12 +++++ Build/source/texk/web2c/showstream.ch | 88 +++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 24 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index daa75a421de..7fddce9c88c 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,3 +1,15 @@ +2022-01-11 Marcel Kr\"uger + + * showstream.ch: adjust selector for show_stream. + Bug report from Hironobu Yamashita, 8 Dec 2021: +\newwrite\IO +\immediate\openout\IO=io.tex +\showstream=\IO +\showtokens A \end + +This should throw an error "! Missing { inserted." but for now +it just stops silently and if I press [Enter] it crashes. + 2022-01-10 Karl Berry * tangle-sh.in, diff --git a/Build/source/texk/web2c/showstream.ch b/Build/source/texk/web2c/showstream.ch index ba319209644..d250523dc38 100644 --- a/Build/source/texk/web2c/showstream.ch +++ b/Build/source/texk/web2c/showstream.ch @@ -1,3 +1,7 @@ +% $Id$ +% Implementation of |\showstream|. +% Public domain. Originally written by Marcel Kr\"uger, 2021. + Since we redirect content which is normally written to the terminal/log to a write stream, print_nl will sometimes get called while selector is a write stream. Therefore we adapt print_nl to handle that case properly. @@ -57,36 +61,24 @@ del_code("."):=0; {this null delimiter is used in error recovery} show_stream:=-1; @z -Then do the actual change: In |show_whatever| we save the old selector -and then replace it based on |show_stream|. We don't need any changes +Then do the actual change: In all cases of |show_whatever| we adjust the selector +if |show_stream| is set. We don't need any changes to |begin/end_diagnostic| since they don't do anything interesting if |selector| isn't |term_and_log|. + +For |show_lists_code| this is done directly in |show_whatever|: @x -procedure show_whatever; -label common_ending; -var p:pointer; {tail of a token list to show} -@!t:small_number; {type of conditional being shown} -@!m:normal..or_code; {upper bound on |fi_or_else| codes} -@!l:integer; {line where that conditional began} -@!n:integer; {level of \.{\\if...\\fi} nesting} -begin case cur_chr of +show_lists_code: begin begin_diagnostic; show_activities; + end; @y -procedure show_whatever; -label common_ending; -var p:pointer; {tail of a token list to show} -@!t:small_number; {type of conditional being shown} -@!m:normal..or_code; {upper bound on |fi_or_else| codes} -@!l:integer; {line where that conditional began} -@!n:integer; {level of \.{\\if...\\fi} nesting} -@!saved_selector:0..max_selector; {previous selector, separate from the global |old_setting|} -begin saved_selector:=selector; -if (show_stream>=0) and (show_stream + begin_diagnostic; show_activities; + end; @z The ending gets skipped if we changed the selector, -but we have to restore |selector|. +but we have to reset the |selector| based on the current interaction setting. @x @; common_ending: if interaction; common_ending: if selector; + if log_opened then selector:=selector+2; end else begin if interaction= +begin get_token; +@y +@ @= +if (show_stream>=0) and (show_stream= +begin get_token; + @ +@z + +@x +@ @= +begin scan_register_num; fetch_box(p); begin_diagnostic; +@y +@ @= +begin scan_register_num; fetch_box(p); +@ +begin_diagnostic; +@z + +@x +@ @= +begin p:=the_toks; +@y +@ @= +begin p:=the_toks; +@ +@z + +@x +show_groups: begin begin_diagnostic; show_save_groups; +@y +show_groups: begin @ + begin_diagnostic; show_save_groups; +@z + +@x +show_ifs: begin begin_diagnostic; print_nl(""); print_ln; +@y +show_ifs: begin @ + begin_diagnostic; print_nl(""); print_ln; +@z -- cgit v1.2.3