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