mirror of
https://github.com/lua/lua
synced 2025-04-01 18:42:52 +03:00
give preference to global names in tracebacks
This commit is contained in:
parent
741ad97e92
commit
6f54b07663
20
lauxlib.c
20
lauxlib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.275 2014/11/21 12:17:58 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.276 2014/12/08 15:26:09 roberto Exp $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -83,20 +83,18 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
|
|||||||
|
|
||||||
|
|
||||||
static void pushfuncname (lua_State *L, lua_Debug *ar) {
|
static void pushfuncname (lua_State *L, lua_Debug *ar) {
|
||||||
if (*ar->namewhat != '\0') /* is there a name? */
|
if (pushglobalfuncname(L, ar)) { /* try first a global name */
|
||||||
lua_pushfstring(L, "%s '%s'", ar->namewhat, ar->name);
|
|
||||||
else if (*ar->what == 'm') /* main? */
|
|
||||||
lua_pushliteral(L, "main chunk");
|
|
||||||
else if (*ar->what == 'C') {
|
|
||||||
if (pushglobalfuncname(L, ar)) {
|
|
||||||
lua_pushfstring(L, "function '%s'", lua_tostring(L, -1));
|
lua_pushfstring(L, "function '%s'", lua_tostring(L, -1));
|
||||||
lua_remove(L, -2); /* remove name */
|
lua_remove(L, -2); /* remove name */
|
||||||
}
|
}
|
||||||
else
|
else if (*ar->namewhat != '\0') /* is there a name from code? */
|
||||||
lua_pushliteral(L, "?");
|
lua_pushfstring(L, "%s '%s'", ar->namewhat, ar->name); /* use it */
|
||||||
}
|
else if (*ar->what == 'm') /* main? */
|
||||||
else
|
lua_pushliteral(L, "main chunk");
|
||||||
|
else if (*ar->what != 'C') /* for Lua functions, use <file:line> */
|
||||||
lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined);
|
lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined);
|
||||||
|
else /* nothing left... */
|
||||||
|
lua_pushliteral(L, "?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user