diff options
Diffstat (limited to 'lua.c')
| -rw-r--r-- | lua.c | 16 |
1 files changed, 6 insertions, 10 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.c,v 1.137 2005/03/22 16:55:35 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.138 2005/03/23 17:50:49 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 | */ |
| @@ -46,8 +46,9 @@ static void print_usage (void) { | |||
| 46 | " - execute stdin as a file\n" | 46 | " - execute stdin as a file\n" |
| 47 | " -e stat execute string `stat'\n" | 47 | " -e stat execute string `stat'\n" |
| 48 | " -i enter interactive mode after executing `script'\n" | 48 | " -i enter interactive mode after executing `script'\n" |
| 49 | " -l name load and run library `name'\n" | 49 | " -l name require library `name'\n" |
| 50 | " -v show version information\n" | 50 | " -v show version information\n" |
| 51 | " -w control access to undefined globals\n" | ||
| 51 | " -- stop handling options\n" , | 52 | " -- stop handling options\n" , |
| 52 | progname); | 53 | progname); |
| 53 | } | 54 | } |
| @@ -130,14 +131,9 @@ static int dostring (lua_State *L, const char *s, const char *name) { | |||
| 130 | 131 | ||
| 131 | 132 | ||
| 132 | static int dolibrary (lua_State *L, const char *name) { | 133 | static int dolibrary (lua_State *L, const char *name) { |
| 133 | luaL_getfield(L, LUA_GLOBALSINDEX, "package.path"); | 134 | lua_getglobal(L, "require"); |
| 134 | if (!lua_isstring(L, -1)) { | 135 | lua_pushstring(L, name); |
| 135 | l_message(progname, "`package.path' must be a string"); | 136 | return report(L, lua_pcall(L, 1, 0, 0)); |
| 136 | return 1; | ||
| 137 | } | ||
| 138 | name = luaL_searchpath(L, name, lua_tostring(L, -1)); | ||
| 139 | if (name == NULL) return report(L, 1); | ||
| 140 | else return dofile(L, name); | ||
| 141 | } | 137 | } |
| 142 | 138 | ||
| 143 | 139 | ||
