diff options
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.182 2009/12/22 16:47:12 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.183 2010/01/21 16:31:06 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 | */ |
@@ -445,7 +445,6 @@ static int pmain (lua_State *L) { | |||
445 | 445 | ||
446 | 446 | ||
447 | int main (int argc, char **argv) { | 447 | int main (int argc, char **argv) { |
448 | static lua_CFunction ppmain = &pmain; | ||
449 | int status, result; | 448 | int status, result; |
450 | lua_State *L = luaL_newstate(); /* create state */ | 449 | lua_State *L = luaL_newstate(); /* create state */ |
451 | if (L == NULL) { | 450 | if (L == NULL) { |
@@ -453,11 +452,9 @@ int main (int argc, char **argv) { | |||
453 | return EXIT_FAILURE; | 452 | return EXIT_FAILURE; |
454 | } | 453 | } |
455 | /* call 'pmain' in protected mode */ | 454 | /* call 'pmain' in protected mode */ |
456 | lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_CPCALL); /* calling function */ | 455 | lua_pushinteger(L, argc); /* 1st argument */ |
457 | lua_pushlightuserdata(L, &ppmain); | 456 | lua_pushlightuserdata(L, argv); /* 2nd argument */ |
458 | lua_pushinteger(L, argc); | 457 | status = luaL_cpcall(L, &pmain, 2, 1); |
459 | lua_pushlightuserdata(L, argv); | ||
460 | status = lua_pcall(L, 3, 1, 0); | ||
461 | result = lua_toboolean(L, -1); /* get result */ | 458 | result = lua_toboolean(L, -1); /* get result */ |
462 | finalreport(L, status); | 459 | finalreport(L, status); |
463 | lua_close(L); | 460 | lua_close(L); |