[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaL_loadfilex returns LUA_ERRSYNTAX when file has wrong mode
- From: Daurnimator <quae@...>
- Date: Tue, 6 Dec 2016 13:31:37 +1100
On 6 December 2016 at 13:07, Gabríel Arthúr Pétursson <gabriel@system.is> wrote:
> Hello,
>
> The documentation for luaL_loadfilex specifies that it'll return
> LUA_ERRFILE when the file has the wrong mode:
>
> "This function returns the same results as lua_load, but it has an
> extra error code LUA_ERRFILE if it cannot open/read the file or the
> file has a wrong mode."
>
> Sadly, this does not seem to be the case as the error code
> LUA_ERRSYNTAX is returned instead.
>
> Here we attempt to load the empty file 'test.lua' in binary mode:
>
> int status = luaL_loadfilex(L, "test.lua", "b");
>
> Since 'test.lua' is not a valid Lua bytecode binary file, I would've
> expected the status code to be LUA_ERRFILE as documented. Is this a
> documentation error by any chance?
>
> I've attached a sample program that demonstrates this behaviour.
>
> Thanks!
I think the 'mode' referred to is the actual 'mode' of the file on the
disk (like what is returned by `stat`).
e.g. if you call luaL_loadfilex on a directory, it will return LUA_ERRFILE