lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 27/07/2011 18.50, Sean Conner wrote:
It was thus said that the Great Lorenzo Donati once stated:
For example, if I wanted to avoid Lua from running the initialization
code specified by LUA_INIT, would it be enough to modify luaconf.h so
that the line:

#define LUA_INIT	"LUA_INIT"

is removed? Or should I define that macro as an empty string:

#define LUA_INIT	""

   I'm not sure if that's a good idea; you'd have to check the code around
the calls to getenv() to see if that would cause more bugs (at first blush,
I don't see how it could, but better to be safe than sorry).

or neither will do and I should mess more deeply with the source code to
achieve what I want.

   Your best bet is to comment out the body of the handle_luainit() function
(in lua.c) and comment out the two calls to setpath() in loadlib.c.

Thank you for the pointer. Actually I've already been using (for about a year) a slightly modified lua.c in which handle_luainit() is disabled and as a (non-portable) way to initialize the interpreter looks for a file named lua_init.lua in the same dir of the executable (it uses GetModuleFileName - I'm on Windows).

I asked that question because I'm always a bit skeptical of my C code (although my modified lua.c never gave problem), and by chance I discovered only lately those #defines and I wondered whether they could be used to skip LUA_INIT (& Co.) processing.

The suggestion about setpath() is new to me. Thanks!


   -spc





-- Lorenzo