From 73b0a3451d0bd59f1540271aa3b8d8de36b36580 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Sun, 25 Jul 2010 12:03:37 -0300 Subject: environment variables consulted by Lua may be version-specific --- lua.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lua.c') diff --git a/lua.c b/lua.c index 6f80550b..5f68dd55 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.190 2010/04/14 15:14:21 roberto Exp roberto $ +** $Id: lua.c,v 1.191 2010/07/02 17:36:32 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -31,10 +31,13 @@ #define LUA_MAXINPUT 512 #endif -#if !defined(LUA_INIT_VAR) -#define LUA_INIT_VAR "LUA_INIT" +#if !defined(LUA_INIT) +#define LUA_INIT "LUA_INIT" #endif +#define LUA_INITVERSION \ + LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + /* ** lua_stdin_is_tty detects whether the standard input is a 'tty' (that @@ -409,12 +412,17 @@ static int runargs (lua_State *L, char **argv, int n) { static int handle_luainit (lua_State *L) { - const char *init = getenv(LUA_INIT_VAR); + const char *name = "=" LUA_INITVERSION; + const char *init = getenv(name + 1); + if (init == NULL) { + name = "=" LUA_INIT; + init = getenv(name + 1); /* try alternative name */ + } if (init == NULL) return LUA_OK; else if (init[0] == '@') return dofile(L, init+1); else - return dostring(L, init, "=" LUA_INIT_VAR); + return dostring(L, init, name); } -- cgit v1.2.3-55-g6feb