aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-13 15:47:58 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-13 15:47:58 -0200
commitc8da3fbc35ea1a7a313f298e98e3829c06a270fb (patch)
treea131c914f2534600cd837c0e988c1ac3c4588c83 /lauxlib.c
parentc96cd1c647f4b34964d403d7c3da826476afbb19 (diff)
downloadlua-c8da3fbc35ea1a7a313f298e98e3829c06a270fb.tar.gz
lua-c8da3fbc35ea1a7a313f298e98e3829c06a270fb.tar.bz2
lua-c8da3fbc35ea1a7a313f298e98e3829c06a270fb.zip
in traceback names, give preference to 'name' over '_G.name'
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 5c982f93..abe57656 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.276 2014/12/08 15:26:09 roberto Exp $ 2** $Id: lauxlib.c,v 1.277 2014/12/10 11:31:32 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -48,7 +48,7 @@ static int findfield (lua_State *L, int objidx, int level) {
48 lua_pushnil(L); /* start 'next' loop */ 48 lua_pushnil(L); /* start 'next' loop */
49 while (lua_next(L, -2)) { /* for each pair in table */ 49 while (lua_next(L, -2)) { /* for each pair in table */
50 if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */ 50 if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */
51 if (lua_rawequal(L, objidx, -1)) { /* found object? */ 51 if (level == 1 && lua_rawequal(L, objidx, -1)) { /* found object? */
52 lua_pop(L, 1); /* remove value (but keep name) */ 52 lua_pop(L, 1); /* remove value (but keep name) */
53 return 1; 53 return 1;
54 } 54 }
@@ -70,7 +70,8 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
70 int top = lua_gettop(L); 70 int top = lua_gettop(L);
71 lua_getinfo(L, "f", ar); /* push function */ 71 lua_getinfo(L, "f", ar); /* push function */
72 lua_pushglobaltable(L); 72 lua_pushglobaltable(L);
73 if (findfield(L, top + 1, 2)) { 73 /* try first global names, and then global.name names */
74 if (findfield(L, top + 1, 1) || findfield(L, top + 1, 2)) {
74 lua_copy(L, -1, top + 1); /* move name to proper place */ 75 lua_copy(L, -1, top + 1); /* move name to proper place */
75 lua_pop(L, 2); /* remove pushed values */ 76 lua_pop(L, 2); /* remove pushed values */
76 return 1; 77 return 1;