Hans Hagen
David Kastrup wrote:
in the following code, the callback is never reached when called with luatex -ini bug
------------------------------------------------------------------------
\catcode`{=1 \catcode`}=2 \directlua0{callback.register("open_read_file",function(filename) print "opening file name";return end)} \input plain.tex
hm, works ok here
I don't see that.
opening file name ! I can't find file `plain.tex'. l.13 \input plain.tex
So you don't even get to the stage where the callback open_read_file would get called, regardless of whether the callback works or not. Try it with an existing file (according to LuaTeX's notion of "existing").
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.
(btw, the return format is mentioned in the manual)
I am aware of that. My actual code is quite more complex, but I did not want to burden the list with a complicated example they need to figure out. This was a minimal example demonstrating that the callback is never reached. That it does not return anything useful is irrelevant since it never gets to returning anything in the first place. Once the callback actually gets called, the above program will likely break in some manner. That is expected. See Taco's answer. -- David Kastrup