ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Bug in Luatex file handling?
@ 2021-06-15 12:38 Hans van der Meer
  2021-06-15 13:37 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Hans van der Meer @ 2021-06-15 12:38 UTC (permalink / raw)
  To: NTG ConTeXt


[-- Attachment #1.1: Type: text/plain, Size: 1313 bytes --]

This I cannot explain. Opening a file directly from its full name in a string succeeds. But doing the same from a parameter transferred from ConteXt to Lua succeeds if the file is in one directory deeper but fails if the file is two directories deeper.
I suspect there is something not ok in LuaTeX.
The lines with .... and >>>> directly come from print statements inserted in the Lua code.

dr. Hans van der Meer

Open file in directory 1 and 2 levels deep - direct call succeeds
..........io.open("events/hga-0372-345-62.xml","r")=>file (0x7fff97415f88)
..........io.open("events/transcripten/hga-0372-345-62.xml","r")=>file (0x7fff97416020)

Idem but now from parameter filename transferred from ConTeXt into Lua:
Open file one level deeper succeeds (printed filename comes from the call):
>>>>>>>>>>io.open(filename,"r") filename=events/hga-0372-1764-63.xml=>file (0x7fff974160b8)
Open file two levels deeper fails:
>>>>>>>>>>io.open(filename,"r") filename=events/transcripten/hga-0372-1764-63.xml=>nil

Caller:
\def\FileExist#1{\cldcontext{hvdm.existfile([===[#1]===])}}
Lua code:
hvdm.existfile = function (filename)
-- The test code was inserted here --
		local file = io.open(filename, "r")
		if file then
			file:close()
		end
		return file ~= nil and "true" or "false"
	end


[-- Attachment #1.2: Type: text/html, Size: 4113 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in Luatex file handling?
  2021-06-15 12:38 Bug in Luatex file handling? Hans van der Meer
@ 2021-06-15 13:37 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2021-06-15 13:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans van der Meer

On 6/15/2021 2:38 PM, Hans van der Meer wrote:
> This I cannot explain. Opening a file directly from its full name in a 
> string succeeds. But doing the same from a parameter transferred from 
> ConteXt to Lua succeeds if the file is in one directory deeper but fails 
> if the file is two directories deeper.
> I suspect there is something not ok in LuaTeX.
> The lines with .... and >>>> directly come from print statements 
> inserted in the Lua code.
> 
> dr. Hans van der Meer
> 
> Open file in directory 1 and 2 levels deep - direct call succeeds
> ..........io.open("events/hga-0372-345-62.xml","r")=>file (0x7fff97415f88)
> ..........io.open("events/transcripten/hga-0372-345-62.xml","r")=>file 
> (0x7fff97416020)
> 
> Idem but now from parameter filename transferred from ConTeXt into Lua:
> Open file one level deeper succeeds (printed filename comes from the call):
>  >>>>>>>>>>io.open(filename,"r") 
> filename=events/hga-0372-1764-63.xml=>file (0x7fff974160b8)
> Open file two levels deeper fails:
>  >>>>>>>>>>io.open(filename,"r") 
> filename=events/transcripten/hga-0372-1764-63.xml=>nil
> 
> Caller:
> \def\FileExist#1{\cldcontext{hvdm.existfile([===[#1]===])}}
> Lua code:
> hvdm.existfile = function (filename)
> -- The test code was inserted here --
> local file = io.open(filename, "r")
> if file then
> file:close()
> end
> return file ~= nil and "true" or "false"
> end

does lfs.isfile(name) work?

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-15 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 12:38 Bug in Luatex file handling? Hans van der Meer
2021-06-15 13:37 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).