[tex-k] In TeX: The Program, section 88, interactively deleting outer macros can cause confusing errors
Karl Berry
karl at freefriends.org
Tue Jun 4 16:06:25 CEST 2024
Hi Tyge - back on your report in
https://tug.org/pipermail/tex-k/2024-March/004021.html:
Interactively deleting a control sequence token corresponding to an
outer macro while in a state that forbids outer macros, such as the
replacement text of a macro definition, can cause a confusing error
message. See for example the following run:
This is TeX, Version 3.141592653
**\outer\def\someoutermacro{}
*\edef\a{\undefinedmacro\someoutermacro}
! Undefined control sequence.
<*> \edef\a{\undefinedmacro
\someoutermacro}
? 1
Runaway definition?
Agreed. Added at https://tug.org/texmfbug/newbug.html#B142outer.
Copying the text I wrote there: The simplest fix DRF found was take
advantage of the fact that OK_to_interrupt has been set to
false during the critical moment and omit the \outer check (this is
in the check_outer_validity procedure):
@x [24.336] l.7152 - allow interactive deletion of \outer token
begin if scanner_status<>normal then
@y
begin if OK_to_interrupt and(scanner_status<>normal) then
@z
This is applied in Web2c tex.ch now (so, for all engines except LuaTeX,
which will probably follow).
You had written:
A possible fix would be to temporarily set `scanner_status` to
`normal` in section 88 before deleting tokens and restoring it
afterwards as is similarly done for `align_state`.
DRF looked into this too, copied below. But the above fix is a lot
simpler. Let me know if you see problems ... --thanks, karl.
From: DRF
Yes, you can do the suggested scanner_status save/restore, but it
requires a little bit of a hack, as normal hasn't been defined yet:
@x 1881
@!s1,@!s2,@!s3,@!s4:integer;
@y
@!s1,@!s2,@!s3,@!s4,@!s5:integer;
@z
@x 1990
begin s1:=cur_tok; s2:=cur_cmd; s3:=cur_chr; s4:=align_state;
align_state:=1000000; OK_to_interrupt:=false;
@y
begin s1:=cur_tok; s2:=cur_cmd; s3:=cur_chr; s4:=align_state;
s5:=scanner_status;
align_state:=1000000; scanner_status:=0; {|normal|} OK_to_interrupt:=false;
@z
@x 1999
cur_tok:=s1; cur_cmd:=s2; cur_chr:=s3; align_state:=s4; OK_to_interrupt:=true;
@y
cur_tok:=s1; cur_cmd:=s2; cur_chr:=s3; align_state:=s4; scanner_status:=s5;
OK_to_interrupt:=true;
@z
More information about the tex-k
mailing list.