summaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/ldblib.c b/ldblib.c
index 8fe60179..da0a90f5 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.50 2002/05/06 19:05:10 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.51 2002/05/07 17:36:56 roberto Exp roberto $
3** Interface from Lua to its debug API 3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -54,8 +54,7 @@ static int getinfo (lua_State *L) {
54 switch (*options) { 54 switch (*options) {
55 case 'S': 55 case 'S':
56 settabss(L, "source", ar.source); 56 settabss(L, "source", ar.source);
57 if (ar.source) 57 settabss(L, "short_src", ar.short_src);
58 settabss(L, "short_src", ar.short_src);
59 settabsi(L, "linedefined", ar.linedefined); 58 settabsi(L, "linedefined", ar.linedefined);
60 settabss(L, "what", ar.what); 59 settabss(L, "what", ar.what);
61 break; 60 break;
@@ -205,31 +204,28 @@ static int errorfb (lua_State *L) {
205 firstpart = 0; 204 firstpart = 0;
206 continue; 205 continue;
207 } 206 }
208 sprintf(buff, "%4d: ", level-1); 207 sprintf(buff, "%4d- ", level-1);
209 lua_pushstring(L, buff); 208 lua_pushstring(L, buff);
210 lua_getinfo(L, "Snl", &ar); 209 lua_getinfo(L, "Snl", &ar);
210 luaL_vstr(L, "%s:", ar.short_src);
211 if (ar.currentline > 0)
212 luaL_vstr(L, "%d:", ar.currentline);
211 switch (*ar.namewhat) { 213 switch (*ar.namewhat) {
212 case 'g': case 'l': /* global, local */ 214 case 'g': /* global */
213 luaL_vstr(L, "function `%s'", ar.name); 215 case 'l': /* local */
214 break;
215 case 'f': /* field */ 216 case 'f': /* field */
216 case 'm': /* method */ 217 case 'm': /* method */
217 luaL_vstr(L, "method `%s'", ar.name); 218 luaL_vstr(L, " in function `%s'", ar.name);
218 break; 219 break;
219 default: { 220 default: {
220 if (*ar.what == 'm') /* main? */ 221 if (*ar.what == 'm') /* main? */
221 luaL_vstr(L, "main of %s", ar.short_src); 222 luaL_vstr(L, " in main chunk");
222 else if (*ar.what == 'C') /* C function? */ 223 else if (*ar.what == 'C') /* C function? */
223 luaL_vstr(L, "%s", ar.short_src); 224 luaL_vstr(L, "%s", ar.short_src);
224 else 225 else
225 luaL_vstr(L, "function <%d:%s>", ar.linedefined, ar.short_src); 226 luaL_vstr(L, " in function <%s:%d>", ar.short_src, ar.linedefined);
226 ar.source = NULL; /* do not print source again */
227 } 227 }
228 } 228 }
229 if (ar.currentline > 0)
230 luaL_vstr(L, " at line %d", ar.currentline);
231 if (ar.source)
232 luaL_vstr(L, " [%s]", ar.short_src);
233 lua_pushliteral(L, "\n"); 229 lua_pushliteral(L, "\n");
234 lua_concat(L, lua_gettop(L)); 230 lua_concat(L, lua_gettop(L));
235 } 231 }