error message always shows file names.

This commit is contained in:
Roberto Ierusalimschy 1997-06-18 14:33:30 -03:00
parent 70160320b1
commit e931c7c0f6
1 changed files with 6 additions and 3 deletions

View File

@ -242,6 +242,9 @@ static void lua_printstack (FILE *f)
while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) {
char *name;
int currentline;
char *filename;
int linedefined;
lua_funcinfo(func, &filename, &linedefined);
fprintf(f, (level==2) ? "Active Stack:\n\t" : "\t");
switch (*lua_getobjname(func, &name)) {
case 'g':
@ -251,19 +254,19 @@ static void lua_printstack (FILE *f)
fprintf(f, "`%s' tag method", name);
break;
default: {
char *filename;
int linedefined;
lua_funcinfo(func, &filename, &linedefined);
if (linedefined == 0)
fprintf(f, "main of %s", filename);
else if (linedefined < 0)
fprintf(f, "%s", filename);
else
fprintf(f, "function (%s:%d)", filename, linedefined);
filename = NULL;
}
}
if ((currentline = lua_currentline(func)) > 0)
fprintf(f, " at line %d", currentline);
if (filename)
fprintf(f, " [in file %s]", filename);
fprintf(f, "\n");
}
}