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 @@
1/*1/*
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 $
3** Lua stand-alone interpreter3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -79,11 +79,23 @@ static int report (lua_State *L, int status) { · 73 unmodified lines
79}79}
80 80
81 81
82static 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
82static int docall (lua_State *L, int narg, int clear) {95static int docall (lua_State *L, int narg, int clear) {
83 int status;96 int status;
84 int base = lua_gettop(L) - narg; /* function index */97 int base = lua_gettop(L) - narg; /* function index */
85 lua_pushliteral(L, "_TRACEBACK");98 lua_pushcfunction(L, traceback); /* push traceback function */
86 lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */
87 lua_insert(L, base); /* put it under chunk and args */99 lua_insert(L, base); /* put it under chunk and args */
88 signal(SIGINT, laction);100 signal(SIGINT, laction);
89 status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);101 status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
@@ -359,7 +371,7 @@ static int pmain (lua_State *L) { · 269 unmodified lines
359 int interactive = 1;371 int interactive = 1;
360 if (s->argv[0] && s->argv[0][0]) progname = s->argv[0];372 if (s->argv[0] && s->argv[0][0]) progname = s->argv[0];
361 globalL = L;373 globalL = L;
362 lua_userinit(L); /* open libraries */374 luaopen_stdlibs(L); /* open libraries */
363 status = handle_luainit(L);375 status = handle_luainit(L);
364 if (status == 0) {376 if (status == 0) {
365 status = handle_argv(L, s->argv, &interactive);377 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