diff options
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.190 2010/04/14 15:14:21 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.191 2010/07/02 17:36:32 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -31,10 +31,13 @@ | |||
31 | #define LUA_MAXINPUT 512 | 31 | #define LUA_MAXINPUT 512 |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #if !defined(LUA_INIT_VAR) | 34 | #if !defined(LUA_INIT) |
35 | #define LUA_INIT_VAR "LUA_INIT" | 35 | #define LUA_INIT "LUA_INIT" |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #define LUA_INITVERSION \ | ||
39 | LUA_INIT "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR | ||
40 | |||
38 | 41 | ||
39 | /* | 42 | /* |
40 | ** lua_stdin_is_tty detects whether the standard input is a 'tty' (that | 43 | ** 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) { | |||
409 | 412 | ||
410 | 413 | ||
411 | static int handle_luainit (lua_State *L) { | 414 | static int handle_luainit (lua_State *L) { |
412 | const char *init = getenv(LUA_INIT_VAR); | 415 | const char *name = "=" LUA_INITVERSION; |
416 | const char *init = getenv(name + 1); | ||
417 | if (init == NULL) { | ||
418 | name = "=" LUA_INIT; | ||
419 | init = getenv(name + 1); /* try alternative name */ | ||
420 | } | ||
413 | if (init == NULL) return LUA_OK; | 421 | if (init == NULL) return LUA_OK; |
414 | else if (init[0] == '@') | 422 | else if (init[0] == '@') |
415 | return dofile(L, init+1); | 423 | return dofile(L, init+1); |
416 | else | 424 | else |
417 | return dostring(L, init, "=" LUA_INIT_VAR); | 425 | return dostring(L, init, name); |
418 | } | 426 | } |
419 | 427 | ||
420 | 428 | ||