texlive[59027] Build/source/texk/web2c/lib: (calledit): ignore token
commits+karl at tug.org
commits+karl at tug.org
Fri Apr 30 00:09:17 CEST 2021
Revision: 59027
http://tug.org/svn/texlive?view=revision&revision=59027
Author: karl
Date: 2021-04-30 00:09:17 +0200 (Fri, 30 Apr 2021)
Log Message:
-----------
(calledit): ignore token lists and any string <256 when looking for the filename to edit
Modified Paths:
--------------
trunk/Build/source/texk/web2c/lib/ChangeLog
trunk/Build/source/texk/web2c/lib/texmfmp.c
Modified: trunk/Build/source/texk/web2c/lib/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/lib/ChangeLog 2021-04-29 22:05:32 UTC (rev 59026)
+++ trunk/Build/source/texk/web2c/lib/ChangeLog 2021-04-29 22:09:17 UTC (rev 59027)
@@ -1,3 +1,19 @@
+2021-04-28 Marcel Fabian Krueger <tex at 2krueger.de>
+ Hironori KITAGAWA <h_kitagawa2001 at yahoo.co.jp>
+ Karl Berry <karl at freefriends.org>
+
+ * texmfmp.c (calledit): When looking for the filename to edit,
+ skip \scantokens pseudo-files (streams 18 and 19) and indeed all
+ name_field values <=255 (following tex.web), and token lists
+ (state_field==0).
+
+ Original reports from Don Hosek,
+ https://tex.stackexchange.com/questions/594702
+ and Hironori (plus patch),
+ https://tug.org/pipermail/tex-k/2021-April/003542.html
+ and Marcel (plus patch) for \scantokens,
+ https://tug.org/pipermail/tex-live/2021-April/046846.html.
+
2021-03-23 Karl Berry <karl at tug.org>
* TL'21.
Modified: trunk/Build/source/texk/web2c/lib/texmfmp.c
===================================================================
--- trunk/Build/source/texk/web2c/lib/texmfmp.c 2021-04-29 22:05:32 UTC (rev 59026)
+++ trunk/Build/source/texk/web2c/lib/texmfmp.c 2021-04-29 22:09:17 UTC (rev 59027)
@@ -2624,29 +2624,49 @@
and a non-file for the insert. https://tex.stackexchange.com/q/552113
Therefore, we have to traverse down input_stack (not input_file),
- looking for name_field values >17, which correspond to open
- files, and then the index_field value of that entry tells us the
+ looking for large enough name_field values corresponding to open
+ files. Then the index_field value of that entry tells us the
corresponding element of input_file, which is what we need to close.
+ Additionally we have to skip all entries with state_field 0 since these
+ correspond to token lists and not input files.
- We test for >17 because name_field=0 means the terminal,
+ We test for name_field<=255, following tex.web, because the first
+ 256 strings are static, initialized by TeX. (Well, many more
+ strings are initialized, but we'll follow tex.web.)
+
+ For the record, name_field=0 means the terminal,
name_field=1..16 means \openin stream n - 1,
- name_field=17 means an invalid stream number (for read_toks).
- Although ... seems like we should close any opened \openin files also.
- Whoever is reading this, please implement that? Sigh.
+ name_field=17 means an invalid stream number (for read_toks),
+ name_field=18..19 means \scantokens pseudo-files (except for
+ original TeX of course). But 255 suffices for us.
- Description in modules 300--304 of tex.web: "Input stacks and states."
-
Here, we do not have to look at cur_input, the global variable
which is effectively the top of input_stack, because it will always
be a terminal (non-file) interaction -- the one where the user
- typed "e" to start the edit. */
+ typed "e" to start the edit.
+
+ In addition, state_field will be zero for token lists. Skip those too.
+ (Does not apply to Metafont.)
+
+ Description in modules 300--304 of tex.web: "Input stacks and states".
+
+ We should close any opened \openin files also. Whoever is reading
+ this, please implement that? */
{
int is_ptr; /* element of input_stack, 0 < input_ptr */
for (is_ptr = 0; is_ptr < inputptr; is_ptr++) {
- if (inputstack[is_ptr].namefield <= 17) {
+#ifdef TeX
+ if (inputstack[is_ptr].statefield == 0 /* token list */
+ || inputstack[is_ptr].namefield <= 255) { /* can't be filename */
+#elif defined(MF)
+ if (inputstack[is_ptr].namefield <= 255) {
+#else
+#error "Unable to identify program" /* MetaPost doesn't use this file */
+#endif
; /* fprintf (stderr, "calledit: skipped input_stack[%d], ", is_ptr);
- fprintf (stderr, "namefield=%d <= 17\n",
- inputstack[is_ptr].namefield); */
+ fprintf (stderr, "namefield=%d <= 255 or statefield=%d == 0\n",
+ inputstack[is_ptr].namefield,
+ inputstack[is_ptr].statefield); */
} else {
FILE *f;
/* when name_field > 17, index_field specifies the element of
More information about the tex-live-commits
mailing list.