[Dev-luatex] \input does not look at open_read_file callback?

David Kastrup dak at gnu.org
Tue Apr 24 13:49:35 CEST 2007

David Kastrup <dak at gnu.org> writes:

> Hans Hagen <pragma at wxs.nl> writes:
>> David Kastrup wrote:
>>> in the following code, the callback is never reached when called
>>> with luatex -ini bug
>> you return nothing, while you need to return a table with at least a
>> reader function that luatex can call for each line it wants
> I am aware of that.  The above code is not intended to work, but
> rather to produce a noticeable message (of course, this is a minimal
> example: the actual use case did something more useful), possibly
> bombing out afterwards.
> It does not do that: the callback is never reached in the first
> place.

For what it is worth: here is the actual code I use.  Adding the
callback for find_read_file (as Taco suggested as a workaround) makes
this work as expected.  Without adding the callback, it does not work,
contrary to the documentation.

\catcode `\{1
\catcode `\}2
\catcode `\@11
\catcode `\#=6
\catcode `\%=14
inputenc={auto = function(line) return line end;
  bytes = function(line) return unicode.utf8.char(unicode.latin1.byte(line,0,-1))
          end };
callback.register("find_read_file", function(id,filename) return kpse.find_file(filename, "tex", true) end);
    local file = io.open(filename, "rb");
    return {file = file; inputenc = defaultinputenc;
           reader = function(table)
             if localinputenc then
               table.inputenc = localinputenc;
	       localinputenc = nil
             local line = table.file:read();
	     if line then
               return table.inputenc(line)
	       return nil
	   close = function(table)
  \expandafter{\the\everyjob \lu@@inpencsetup\XeTeXdefaultencoding "bytes"}
\XeTeXdefaultencoding "bytes"
\input latex.ltx

David Kastrup

More information about the dev-luatex mailing list