LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Joseph Wright <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Sat, 29 Jul 2023 08:15:19 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (65 lines)
On 29/07/2023 07:36, LARONDE Thierry wrote:
> On Fri, Jul 28, 2023 at 07:53:19PM +0100, David Carlisle wrote:
>> On 28/07/2023 18:57, LARONDE Thierry wrote:
>>
>> but if \filesize{README} and \mdfivesum{README} refer to a different
>> file than \input{README} then they are not reliably useful for their
>> main use cases.
> 
> It shall be noted that as long as a filename is subject to different
> behavior (adding an extension or not; I'm unclear now about the fact
> that \input could try to input README without the ".tex" extension if
> not found, deviating from m.537---and even \openin is adding
> inconditionnally a ".tex" if no extension: see m.1275).
> 
> But at the LaTeX (macro) level (but even at the binary level: no
> atomicity; but the time gap is increased at macro level), if the
> behavior is not definite, you have a race condition. The first
> \filesize{README} could first fail to read a README.tex then succeed
> to read a README (without extension) but the \input following,
> because something in the system has created a README.tex in the
> meantime, would be opening _not the same file_.

Same with \openin, which as already noted has been used since the 1980s 
in LaTeX. \input provides no way of checking for a file and no control 
over error status, so LaTeX has always used a 'check then \input' 
approach. That is even more important if you are dealing with 
user-defined paths, most obviously \graphicspath but used more widely.

> 1) Is LaTeX expecting to be able to "\input" a file without extension?
> For me, "\input" could only be a tex file; so the extension was
> mandatory...

No. \input is the only way to read a file 'here'. Most obviously, many 
users reserve .tex for plain TeX files and use .ltx for LaTeX sources. 
But to have systematic file naming you need different extensions, e.g. 
LaTeX packages are .sty, classes are .cls, etc., all of which are 
ultimately used with the \input primitive.

> 2) What is done to ensure that the same file, at least by its absolute
> pathname, is opened when opening it several times?

Once the file is found, the same path is reused (it is cached internally 
to avoid the cost of repeated file lookups). But of course a user might 
have a structure such as

     thesis/chapter1/content.tex
     thesis/chapter1/appendix.tex
     thesis/chapter2/content.tex
     thesis/chapter2/appendix.tex

and set up a macro-level path to swap where is used so they can have

   % I've made this command up but the idea is used in e.g. the import
   % package
   \setpath{thesis/chapter1}
   \input{content}
   \input{appendix}
   \setpath{thesis/chapter2}
   \input{content}
   \input{appendix}

so the absolute path does have to account for the current relative one.

Joseph

ATOM RSS1 RSS2