\pdffilesize and spaces
Bruno Le Floch
blflatex at gmail.com
Sun Oct 20 12:15:59 CEST 2019
On 10/20/19 10:41 AM, Chris Rowley wrote:
> Hi Bruno,
> Not quite clear which “expansion” you refer to hear: that of the primitive itself, or that when scanning the file name? Also, what are these small differences?
I don't understand what difference you are referring to: when reading
its argument in the input stream the primitive expands.
>> Expansion is a little different for sure between the Knuth TeX
>> primitives and the pdfTeX ones
I'm writing this from memory of a few years back. It is not very
important to the question at hand.
For \input, \openin and \openout it expands until getting a
non-expandable token. If that's a character the character is appended
to a buffer building the file name, unless it is a double quote (in
which case it flips some boolean denoting whether we're inside or
outside quotes) or a space, which stops the file name if we are outside
quotes. Any other nonexpandable token stops the expansion. There are
details (perhaps different between \input and \openin/\openout) about
spaces at the start of the file name but they can be worked around by
using spaces with strange catcodes.
I also remember minor differences in LuaTeX for either \openin or
\openout, at least some time back.
For pdfTeX primitives dealing with files, the primitive reads an
argument exactly like \message, using the same internal routine which
expands tokens (except \protected ones) then appends them to a list of
tokens found, then upon finding the closing (explicit) end-group
character token the whole list of tokens is turned into a string used as
a file name.
The main differences are
- quotes, maybe, unless the pdfTeX primitives or something down the line
- nonexpandable tokens, which just get turned to a string using the same
routine as \detokenize at the end.
For instance the second point can suggest making active characters into
\protected macros, as they would then automatically remain as they are
in pdfTeX primitives. However, \input expands even protected macros.
More information about the tex-live