From b7a0503c1d72603b8f7e480f2abecbc05348cb69 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 15 May 2002 15:57:44 -0300 Subject: new format for error messages --- ldblib.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'ldblib.c') diff --git a/ldblib.c b/ldblib.c index 8fe60179..da0a90f5 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.50 2002/05/06 19:05:10 roberto Exp roberto $ +** $Id: ldblib.c,v 1.51 2002/05/07 17:36:56 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -54,8 +54,7 @@ static int getinfo (lua_State *L) { switch (*options) { case 'S': settabss(L, "source", ar.source); - if (ar.source) - settabss(L, "short_src", ar.short_src); + settabss(L, "short_src", ar.short_src); settabsi(L, "linedefined", ar.linedefined); settabss(L, "what", ar.what); break; @@ -205,31 +204,28 @@ static int errorfb (lua_State *L) { firstpart = 0; continue; } - sprintf(buff, "%4d: ", level-1); + sprintf(buff, "%4d- ", level-1); lua_pushstring(L, buff); lua_getinfo(L, "Snl", &ar); + luaL_vstr(L, "%s:", ar.short_src); + if (ar.currentline > 0) + luaL_vstr(L, "%d:", ar.currentline); switch (*ar.namewhat) { - case 'g': case 'l': /* global, local */ - luaL_vstr(L, "function `%s'", ar.name); - break; + case 'g': /* global */ + case 'l': /* local */ case 'f': /* field */ case 'm': /* method */ - luaL_vstr(L, "method `%s'", ar.name); + luaL_vstr(L, " in function `%s'", ar.name); break; default: { if (*ar.what == 'm') /* main? */ - luaL_vstr(L, "main of %s", ar.short_src); + luaL_vstr(L, " in main chunk"); else if (*ar.what == 'C') /* C function? */ luaL_vstr(L, "%s", ar.short_src); else - luaL_vstr(L, "function <%d:%s>", ar.linedefined, ar.short_src); - ar.source = NULL; /* do not print source again */ + luaL_vstr(L, " in function <%s:%d>", ar.short_src, ar.linedefined); } } - if (ar.currentline > 0) - luaL_vstr(L, " at line %d", ar.currentline); - if (ar.source) - luaL_vstr(L, " [%s]", ar.short_src); lua_pushliteral(L, "\n"); lua_concat(L, lua_gettop(L)); } -- cgit v1.2.3-55-g6feb