Re: [NTG-context] How to Determine the Current File Name and Line Number in the ConTeXt Source?
Hans Hagen wrote:
Tad Ashlock wrote:
Is there a convenient way within a Lua block to determine the current file name and line number of the source file being processed by ConTeXt?
[snip]
i have no time now to figure out while filenames are not known but here's a (wikifyable) hack: [snip] line = status.linenumber, file = status.filename
From the luatex 0.40.6 sources (luatex/source/texk/web2c/luatexdir/lua/lstatslib.c): ---------------------------------------------------------- /* hack, I really should implement the makecstring */ char *getfilename(void) { integer t; t = get_current_name(); if (t > (1 << 21)) return makecstring(t); else return xstrdup(""); } ---------------------------------------------------------- Looks like we're always getting the xstrdup() branch of the conditional. Hans, would you like me to submit this as a luatex bug? Tad
Tad Ashlock wrote:
Hans Hagen wrote:
Tad Ashlock wrote:
Is there a convenient way within a Lua block to determine the current file name and line number of the source file being processed by ConTeXt?
[snip]
i have no time now to figure out while filenames are not known but here's a (wikifyable) hack: [snip] line = status.linenumber, file = status.filename
From the luatex 0.40.6 sources (luatex/source/texk/web2c/luatexdir/lua/lstatslib.c): ---------------------------------------------------------- /* hack, I really should implement the makecstring */ char *getfilename(void) { integer t; t = get_current_name(); if (t > (1 << 21)) return makecstring(t); else return xstrdup(""); } ----------------------------------------------------------
Looks like we're always getting the xstrdup() branch of the conditional.
Hans, would you like me to submit this as a luatex bug?
taco reads this mail anyway so this suits as bug report Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Tad Ashlock wrote:
Looks like we're always getting the xstrdup() branch of the conditional.
Probably because you are not reading from a file at that level, but from a token list. Do you want filename to be a file even if the current input is not directly from a file at all (doable, but less meaningful)? Best wishes, Taco
participants (3)
-
Hans Hagen
-
Taco Hoekwater
-
Tad Ashlock