diff --git a/luprex/core/cpp/traceback.cpp b/luprex/core/cpp/traceback.cpp index 453d8e5c..dea509c3 100644 --- a/luprex/core/cpp/traceback.cpp +++ b/luprex/core/cpp/traceback.cpp @@ -1,3 +1,4 @@ +#include #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)