History

Lua 5.1-work5

Lua Team committed 21 years ago

Commit e684a4d1 parent 930912737 files · +938 −717Browse files

Showing the changes to src/lua.c (1 of 37 files). Show all

Unified · Split

src/lua.c+16−4
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lua.c,v 1.133 2004/11/18 19:53:49 roberto Exp $
2+** $Id: lua.c,v 1.135 2005/01/10 17:21:10 roberto Exp $
33 ** Lua stand-alone interpreter
44 ** See Copyright Notice in lua.h
55 */
@@ -79,11 +79,23 @@ static int report (lua_State *L, int status) { · 73 unmodified lines
7979 }
8080
8181
82+static int traceback (lua_State *L) {
83+ luaL_getfield(L, LUA_GLOBALSINDEX, "debug.traceback");
84+ if (!lua_isfunction(L, -1))
85+ lua_pop(L, 1);
86+ else {
87+ lua_pushvalue(L, 1); /* pass error message */
88+ lua_pushinteger(L, 2); /* skip this function and traceback */
89+ lua_call(L, 2, 1); /* call debug.traceback */
90+ }
91+ return 1;
92+}
93+
94+
8295 static int docall (lua_State *L, int narg, int clear) {
8396 int status;
8497 int base = lua_gettop(L) - narg; /* function index */
85− lua_pushliteral(L, "_TRACEBACK");
86− lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */
98+ lua_pushcfunction(L, traceback); /* push traceback function */
8799 lua_insert(L, base); /* put it under chunk and args */
88100 signal(SIGINT, laction);
89101 status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
@@ -359,7 +371,7 @@ static int pmain (lua_State *L) { · 269 unmodified lines
359371 int interactive = 1;
360372 if (s->argv[0] && s->argv[0][0]) progname = s->argv[0];
361373 globalL = L;
362− lua_userinit(L); /* open libraries */
374+ luaopen_stdlibs(L); /* open libraries */
363375 status = handle_luainit(L);
364376 if (status == 0) {
365377 status = handle_argv(L, s->argv, &interactive);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t