8

What is the precise syntax for file names in various common distributions?

This is relevant for three primitives:

  • \input<filename> (renamed \@@input in LaTeX)
  • \openin<4-bit number><equals><filename>
  • \openout<4-bit number><equals><filename>

where <4-bit number> is an integer between 0 and 15, and is any number of spaces, followed by an optional explicit catcode-other = token.

Testing with TeX Live 2011, I find the following: tokens are fully expanded one by one (just as everywhere else in TeX, with the get_x_token procedure). If the token found is an explicit or implicit character token, then the catcode is ignored, and the character is appended to the filename being built. A space with any catcode ends the filename and is gobbled. Any non-expandable non-character token ends the filename and remains.

Examples:

\makeatletter
\def\test{test}
\tracingall        % To see when spaces occur.
\openin4=\test     % Opens "test.tex"
\openin4=\bgroup \test \space \space % Opens "{test.tex", one space left.
\openin4=test\@sptoken \space        % Opens "test.tex", one space left.
\openin4="test \space test"          % Opens "test test.tex" in some distributions.

A remaining subtlety is that since \input is expandable and \openin and \openout are not, they behave slightly differently when appearing as the first token of a tabular cell. But that's another story.

1 Answer 1

2

It seems unlikely that there is any TeX distribution anywhere that behaves differently because even though Knuth writes somewhere that this bit of code is system dependent, what you describe above is the 'sane' thing to do, far better than alternative, system-dependent options.

That does not necessarily mean that what this procedure produces is a valid file name according to the operating system, but that is a different question, I think.

1
  • Since you're probably more aware of these things than many TeX.sx users, I'll accept that answer, but it would be great if you have any references, or pointers to how I could test that (I only have access to TeXLive). Commented Aug 9, 2011 at 6:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .