Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Flattery is all right -- if you don't inhale." -- Adlai Stevenson


computers / comp.text.tex / \scantokens after \endinput

SubjectAuthor
* \scantokens after \endinputjfbu
`- Re: \scantokens after \endinputUlrich Diez

1
\scantokens after \endinput

<60c46072$0$21614$426a74cc@news.free.fr>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=3682&group=comp.text.tex#3682

  copy link   Newsgroups: comp.text.tex
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Newsgroups: comp.text.tex
X-Mozilla-News-Host: news://news.free.fr:119
From: jfREMOVEbu@free.fr (jfbu)
Subject: \scantokens after \endinput
Date: Sat, 12 Jun 2021 09:21:22 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:78.0)
Gecko/20100101 Thunderbird/78.11.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: fr
Content-Transfer-Encoding: 8bit
Lines: 57
Message-ID: <60c46072$0$21614$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 12 Jun 2021 09:21:22 CEST
NNTP-Posting-Host: 88.122.168.98
X-Trace: 1623482482 news-3.free.fr 21614 88.122.168.98:4948
X-Complaints-To: abuse@proxad.net
 by: jfbu - Sat, 12 Jun 2021 07:21 UTC

Hi,

I raised this on the TeXLive list but it is probably wrong list
for such topic. So cross-posting here.

I have encountered a phenomenon with \scantokens executed after \endinput:

---
% execute this file testscan.tex with etex on command line
\def\test{%
\begingroup
\endlinechar-1\everyeof{\noexpand}%
\edef\foo{\scantokens{}}%
\endgroup
}%
\test % ok
% \test\endinput % would be ok
\endinput\test % not ok
---

executing "etex testscan" (or pdftex, xetex, luatex, eptex) gives this:

Runaway definition?
->
! File ended while scanning definition of \foo.
<inserted text>
}
\test ...of {\noexpand }\edef \foo {\scantokens {}
}\endgroup
l.12 \endinput\test
% not ok^^M
? X

I would be curious if some expert could elucidate.

It seems the \noexpand which is usual trick to
be able to use \scantokens inside an \edef
fails here,

and this is caused by the \scantokens being executed
after the \endinput token was already encountered.

As a side note, one may execute some \input otherfile.tex
like this in mainfile.tex : \endinput \input otherfile.tex\relax
but only the first line of otherfile.tex will then be included

I am wondering if that has some relation with the
\scantokens issue above. Perhaps some "end of something"
is encountered earlier than where would be the actual
pseudo EOF which \noexpand helps into silencing.

But I have not read the e-TeX extended TeX sources,
perhaps someone here has.

Best,

Jean-François

Re: \scantokens after \endinput

<98f4b7c1-310e-46d3-b5e3-84fb64d3225fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=3720&group=comp.text.tex#3720

  copy link   Newsgroups: comp.text.tex
X-Received: by 2002:ac8:5045:: with SMTP id h5mr10553747qtm.178.1624052796813;
Fri, 18 Jun 2021 14:46:36 -0700 (PDT)
X-Received: by 2002:a0c:ff25:: with SMTP id x5mr8071975qvt.39.1624052796645;
Fri, 18 Jun 2021 14:46:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.text.tex
Date: Fri, 18 Jun 2021 14:46:36 -0700 (PDT)
In-Reply-To: <60c46072$0$21614$426a74cc@news.free.fr>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:c1:1f15:ef79:adb8:fee6:f799:2e42;
posting-account=SqELUwoAAAAC4z0UVxAwBa1lVLdEk1Ux
NNTP-Posting-Host: 2003:c1:1f15:ef79:adb8:fee6:f799:2e42
References: <60c46072$0$21614$426a74cc@news.free.fr>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <98f4b7c1-310e-46d3-b5e3-84fb64d3225fn@googlegroups.com>
Subject: Re: \scantokens after \endinput
From: eu_angelion@web.de (Ulrich Diez)
Injection-Date: Fri, 18 Jun 2021 21:46:36 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ulrich Diez - Fri, 18 Jun 2021 21:46 UTC

Jean-François Burnol wrote:

[...]
> I have encountered a phenomenon with \scantokens executed after \endinput:
>
> ---
> % execute this file testscan.tex with etex on command line
> \def\test{%
> \begingroup
> \endlinechar-1\everyeof{\noexpand}%
> \edef\foo{\scantokens{}}%
> \endgroup
> }%
> \test % ok
> % \test\endinput % would be ok
> \endinput\test % not ok
> ---
>
> executing "etex testscan" (or pdftex, xetex, luatex, eptex) gives this:
>
> Runaway definition?
> ->
> ! File ended while scanning definition of \foo.
> <inserted text>
> }
> \test ...of {\noexpand }\edef \foo {\scantokens {}
> }\endgroup
> l.12 \endinput\test
> % not ok^^M
> ? X
>
> I would be curious if some expert could elucidate.
[...]

I don't know if I can be called an expert, but the man who wrote
the TeXbook surely is. ;-)

Chapter 20: Definitions (also called macros) of the TeXbook
has a very large double-dangerous-bend paragraph which
begins with

| Now let’s consider the control sequences that are expanded whenever
| expansion has not been inhibited. Such control sequences fall into
| several classes:

About \endinput you find:

| - \endinput. The expansion is null. The next time TeX gets to the end
| of an \input line, it will stop reading from the file containing that line.

I *think* expecting *some* error-message does correspond to the
TeXbook's description of what behavior of TeX is triggered by
\endinput -- the reason for this expectation is:

\test expands to an \edef whose <definition text> contains \scantokens.

With \endinput\test the next time TeX gets to the end of an
\input line is "inside the \edef" while processing \scantokens which
emulates unexpanded writing tokens to external text file and then
processing that external text file via \input outgoing from current
catcode-régime .

Due to the previously encountered \endinput \scantokens' emulating
of processing that external text file via \input is stopped at the end
of the very first line of that "scantokens-file", i.e., at a moment in time
before the \edef-assignment is complete, and also at a moment in time
where the end of the "scantokens-file" is not reached yet and therefore
\everyeof is not carried out.

This in turn implies that TeX doesn't look at the "scantokens-file"
any more but at the previous input-file while an \edef-assignment
is in progress. Changing to previous input-file without having
\everyeof doing its\noexpand-trick while an \edef-assignment is
in progress yields the runaway-definition-error.

I *think* the error-message encountered by you is misleading:

You find the phrase "> ! File ended while scanning definition of \foo. "

This is not correct. The file did not end while scanning definition of \foo. "

Correct would be: "Reading the file was ceased after reading its first
line due to pending \endinput while scanning definition of \foo. "

Sincerely

Ulrich


computers / comp.text.tex / \scantokens after \endinput

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor