Fixed bug in traceback code.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <cstring>
|
||||
#include "traceback.hpp"
|
||||
|
||||
#define TRACEBACK_LEVELS1 12
|
||||
@@ -26,6 +27,7 @@ int traceback_coroutine(lua_State *L) {
|
||||
// Append the traceback.
|
||||
lua_Debug ar;
|
||||
int firstpart = 1;
|
||||
bool any = false;
|
||||
for (int level = 0; lua_getstack(L, level, &ar); level++) {
|
||||
if (level > TRACEBACK_LEVELS1 && firstpart) {
|
||||
/* no more than `LEVELS2' more levels? */
|
||||
@@ -40,10 +42,11 @@ int traceback_coroutine(lua_State *L) {
|
||||
continue;
|
||||
}
|
||||
lua_getinfo(L, "Snl", &ar);
|
||||
if ((level == 0) && (*ar.what == 'C') && (std::string(ar.name) == "__newindex")) {
|
||||
continue;
|
||||
if ((!any) && (*ar.what == 'C') && (ar.name != 0)) {
|
||||
if (strcmp(ar.name, "__newindex") == 0) continue;
|
||||
}
|
||||
if ((ar.currentline > 0) || (*ar.namewhat != 0) || (*ar.what != 'C')) {
|
||||
any = true;
|
||||
lua_pushliteral(L, "\n\t");
|
||||
lua_pushfstring(L, "%s:", ar.short_src);
|
||||
if (ar.currentline > 0)
|
||||
|
||||
Reference in New Issue
Block a user