| 1 |
% $Id: outerdel.tex 73679 2025-02-01 22:56:43Z karl $ |
| 2 |
% Public domain, from Udo Wermuth. |
| 3 |
% |
| 4 |
% Running TeX on this will provoke an error. |
| 5 |
% Deleting 3 tokens at the interactive prompt should result in |
| 6 |
% ! File ended while scanning definition of \one. |
| 7 |
% and not delete tokens through eof. |
| 8 |
% Full message from Udo below (files are renamed for inclusion web2c). |
| 9 |
% |
| 10 |
% BTW, there are no \outer tokens involved in this test, but the original |
| 11 |
% change involved deleting \outer tokens. |
| 12 |
% https://tug.org/pipermail/tex-k/2024-March/004021.html |
| 13 |
|
| 14 |
\catcode`\{=1 \catcode`\}=2 \let\ea=\expandafter |
| 15 |
\def\zero{z} |
| 16 |
\ea\edef\ea\one\ea{\input outerdelsub.tex\relax\zero} |
| 17 |
\show\one\end |
| 18 |
|
| 19 |
%Date: Fri, 7 Jun 2024 18:04:21 +0200 |
| 20 |
%From: Udo Wermuth |
| 21 |
%To: Karl Berry <[email protected]> |
| 22 |
%Subject: Re: skipping tokens through the end of an input file |
| 23 |
% |
| 24 |
%I think now I know what you want me to do; I saw the error |
| 25 |
%report about \outer in an \edef on tex-k. |
| 26 |
% |
| 27 |
%Lets create two files: |
| 28 |
%1) sub.tex (1 line): |
| 29 |
%x\error y\noexpand |
| 30 |
% |
| 31 |
%2) main.tex (4 lines): |
| 32 |
%\let\ea=\expandafter |
| 33 |
%\def\zero{z} |
| 34 |
%\ea\edef\ea\one\ea{\input sub.tex\relax\zero} |
| 35 |
%\show\one\bye |
| 36 |
% |
| 37 |
% |
| 38 |
%tex sub gives an error |
| 39 |
% |
| 40 |
%! Undefined control sequence. |
| 41 |
%l.1 x\error |
| 42 |
% y\noexpand |
| 43 |
%? |
| 44 |
% |
| 45 |
%When you delete 1, 2, or 3 tokens at the ?-prompt it works as |
| 46 |
%expected. With 2 you get the *-prompt and you can say \bye. |
| 47 |
%With 3 you get the *-prompt too but now a \bye is deleted as |
| 48 |
%one delete operation is still waiting. At the next *-prompt |
| 49 |
%you can enter a valid \bye. |
| 50 |
%With 1 a \bye at the *-prompt is not expanded and thus doesn't |
| 51 |
%work. Again the next *-prompt accepts the \bye. |
| 52 |
% |
| 53 |
% |
| 54 |
%With tex main you get the error as above. |
| 55 |
% |
| 56 |
%With <return> or 1 the definition is finished as the outerness of the |
| 57 |
%eof is canceled by the \noexpand. With 2 the \noexpand is deleted too |
| 58 |
%and a <return> at the next ?-prompt gives a runaway error: |
| 59 |
% |
| 60 |
%Runaway definition? |
| 61 |
%->x |
| 62 |
%! File ended while scanning definition of \one. |
| 63 |
%<inserted text> |
| 64 |
% } |
| 65 |
%<to be read again> |
| 66 |
% \relax |
| 67 |
%l.4 \ea\edef\ea\one\ea{\input sub.tex\relax |
| 68 |
% \zero} |
| 69 |
%? |
| 70 |
% |
| 71 |
%Another <return> reports |
| 72 |
% |
| 73 |
%! Too many }'s. |
| 74 |
%l.4 \ea\edef\ea\one\ea{\input sub.tex\relax\zero} |
| 75 |
% |
| 76 |
%? |
| 77 |
% |
| 78 |
%before the run ends with another <return>. \one is what I expect and a |
| 79 |
%dvi is produced that shows `z' as expected. |
| 80 |
% |
| 81 |
%But with 2 and then a 1 (not a <return>) we get the runaway and with |
| 82 |
%a <return> |
| 83 |
% |
| 84 |
%<inserted text> } |
| 85 |
% |
| 86 |
%<to be read again> |
| 87 |
% \relax |
| 88 |
%l.4 \ea\edef\ea\one\ea{\input sub.tex\relax |
| 89 |
% \zero} |
| 90 |
%? |
| 91 |
% |
| 92 |
%so that the definition can be finished. With 3 instead of 2 the same |
| 93 |
%happens. |
| 94 |
% |
| 95 |
% |
| 96 |
% |
| 97 |
%With the change that inserts OK_to_interrupt things change. When |
| 98 |
%you enter now 2 and 1 or directly 3 you get |
| 99 |
% |
| 100 |
%) |
| 101 |
%<recently read> \relax |
| 102 |
% |
| 103 |
%l.4 \ea\edef\ea\one\ea{\input sub.tex\relax |
| 104 |
% \zero} |
| 105 |
%? |
| 106 |
% |
| 107 |
%That is y, \noexpand, and \relax are deleted. The outerness of the eof |
| 108 |
%doesn't count now and there is no inserted } anymore. |
| 109 |
% |
| 110 |
%I would consider this wrong. Somewhere the file ended and this end should |
| 111 |
%be treated as \outer. One could say in the last case the file ended with |
| 112 |
%the x. |