summaryrefslogtreecommitdiff
path: root/lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'lua.c')
-rw-r--r--lua.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/lua.c b/lua.c
index 112a20cc..d57db025 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.126 2004/05/31 18:51:50 roberto Exp roberto $ 2** $Id: lua.c,v 1.127 2004/06/16 20:22:43 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*/
@@ -251,6 +251,14 @@ static void manual_input (void) {
251} 251}
252 252
253 253
254static int checkvar (lua_State *l) {
255 const char *name = lua_tostring(l, 2);
256 if (name)
257 luaL_error(l, "attempt to access undefined variable `%s'", name);
258 return 0;
259}
260
261
254#define clearinteractive(i) (*i &= 2) 262#define clearinteractive(i) (*i &= 2)
255 263
256static int handle_argv (char *argv[], int *interactive) { 264static int handle_argv (char *argv[], int *interactive) {
@@ -290,6 +298,13 @@ static int handle_argv (char *argv[], int *interactive) {
290 print_version(); 298 print_version();
291 break; 299 break;
292 } 300 }
301 case 'w': {
302 if (lua_getmetatable(L, LUA_GLOBALSINDEX)) {
303 lua_pushcfunction(L, checkvar);
304 lua_setfield(L, -2, "__index");
305 }
306 break;
307 }
293 case 'e': { 308 case 'e': {
294 const char *chunk = argv[i] + 2; 309 const char *chunk = argv[i] + 2;
295 clearinteractive(interactive); 310 clearinteractive(interactive);
@@ -313,14 +328,6 @@ static int handle_argv (char *argv[], int *interactive) {
313 return 1; /* stop if file fails */ 328 return 1; /* stop if file fails */
314 break; 329 break;
315 } 330 }
316 case 'c': {
317 l_message(progname, "option `-c' is deprecated");
318 break;
319 }
320 case 's': {
321 l_message(progname, "option `-s' is deprecated");
322 break;
323 }
324 default: { 331 default: {
325 clearinteractive(interactive); 332 clearinteractive(interactive);
326 print_usage(); 333 print_usage();