Hello,
the following PlainTeX document results in an error message about kpse
not
being initialized:
------------------------------------------------------------------------
--
% \directlua0{kpse.set_program_name('tex')} % A
\directlua0{kpse.find_file('foo', 'tex')}
\end
------------------------------------------------------------------------
---
jonathansauer$ luatex kpseTest.tex
This is LuaTeX, Version snapshot-0.22.0-2008021518 (Web2C 7.5.6)
(kpseTest.tex
! LuaTeX error Please call kpse.set_program_name() before using the
library.
l.2 \directlua0{kpse.find_file('foo', 'tex')}
? x
No pages of output.
Transcript written on .
------------------------------------------------------------------------
---
- According to section 4.9 of the manual, kpse's database is
automatically initialized when LuaTeX is used to typeset documents.
- The name of the transcript file is empty (even though the
transcript is written to 'kpseTest.log').
After uncommenting line A above, no error is generated, and the name
of the transcript file printed is not empty anymore:
------------------------------------------------------------------------
---
jonathansauer$ luatex kpseTest.tex
This is LuaTeX, Version snapshot-0.22.0-2008021518 (Web2C 7.5.6)
(kpseTest.tex )
No pages of output.
Transcript written on kpseTest.log.
------------------------------------------------------------------------
---
I looked into the source, and the reason for this behaviour seems to
be that 'init_kpse' ('luainit.c') calls 'kpse_set_program_name', but
does not set 'program_name_set' ('lkpselib.c') to 1. This is only done
by 'set_program_name', which is the C function called by
'kpse.set_program_name'.
My modifications to fix this:
lkpselib.c line 119:
- static int program_name_set = 0;
+ int program_name_set = 0;
luainit.c line 63:
- extern int last_lineno;
+ extern int last_lineno;
+ extern int program_name_set;
line 353:
- kpse_set_program_name(argv[0], user_progname);
+ program_name_set = 1;
+ kpse_set_program_name(argv[0], user_progname);
(BTW: Is there a way to speed up compilation of LuaTeX after making
small changes such as these? The build script seems to always recompile
everything)
I did not find the reason for the missing log file name.
Furthermore, I tried to set the program name using '--progname' and
got:
------------------------------------------------------------------------
---
jonathansauer$ luatex --progname=luatex kpseTest
Abort trap
------------------------------------------------------------------------
---
The reason for this seems to lie in file 'luainit.c', function
'init_kpse', where 'dump_name' is only initialized with the name of
the executable when 'user_progname' has not been set (and if LuaTeX is
not in IniTeX mode) [BTW: The casts to 'string' in the function are
not necessary (anymore?)].
Specifying the format as well using '--fmt' resulted in the message I
got
the first time.
Jonathan