[luatex] \openin with extensionless files.

Henri Menke henrimenke at gmail.com
Wed Jan 22 22:29:36 CET 2020


I might have found the bug.  Compare this bit in open_or_close_in(void)

    if (cur_cmd != left_brace_cmd) {
        /*tex Set |cur_name| to desired file name. */
        scan_file_name();
        if (cur_ext == get_nullstr())
            cur_ext = maketexstring(".tex");
    } else {
        scan_file_name_toks();
    }

with this bit in start_input(void)

    if (cur_cmd != left_brace_cmd) {
        /*tex Set |cur_name| to desired file name. */
        scan_file_name();
    } else {
        scan_file_name_toks();
    }

In the former the extra branch

    if (cur_ext == get_nullstr())
        cur_ext = maketexstring(".tex");

does not make any sense actually because start_file_name does not set
cur_ext, which is therefore either going to be NULL or still set to the
last value.  I think it this branch were removed, the code would behave
correctly.

Cheers, Henri

On 1/23/20 10:08 AM, David Carlisle wrote:
> With a file with no extension in the same directory (say  "test") then
> 
> \input test
> 
> and
> 
> \input{test}
> 
> both work but
> 
> \openin test
> 
> and
> 
> \openin{test}
> 
> do not work the same way, it only sees the file if the luatex-specific
> braced form is used.
> 
> That means for example the LaTeX \IfFileExists macro reports the file
> as not existing with luatex and existing with pdftex and xetex.
> 
> We could (and probably will) have a luatex-specific code branch here
> to add the braces, but is this difference from pdftex  intentional? It
> has been this way since at least texlive 2017, but still seems strange
> and not what one would expect from the documentation
> 
> 
> This causes some problems in end-user documents, for example
> 
> https://tex.stackexchange.com/questions/511684/inputting-extension-less-files-with-luatex-fails-after-recent-latex-update/511688?noredirect=1#comment1293990_511688
> 
> 
> 
> 
> This test file:
> 
> \openin0 test
> 
> \ifeof0
> \immediate\write20{NO FILE test}
> \else
> \immediate\write20{FILE test}
> \fi
> 
> \ifx\directlua\undefined\else
> 
> \openin2{test}
> 
> \ifeof2
> \immediate\write20{NO FILE test}
> \else
> \immediate\write20{FILE test}
> \fi
> 
> \fi
> 
> \end
> 
> 
> Produces the terminal output below
> 
> 
> $ cat test
> hello
> 
> $ luatex noext
> This is LuaTeX, Version 1.10.0 (TeX Live 2019)
>  restricted system commands enabled.
> (./noext.tex
> NO FILE test
> FILE test
> )
> 
> and with pdftex
> 
> $ pdftex noext
> This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020)
> (preloaded format=pdftex)
>  restricted \write18 enabled.
> entering extended mode
> (./noext.tex
> FILE test
> 
> 
> David
> 


More information about the luatex mailing list