diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-12 15:41:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-12 15:41:55 -0300 |
commit | 5d033f33ebe1887ea19853b5158fba48d452ba0f (patch) | |
tree | 6478462fdd8d8855202b311d6205d59133ac7267 | |
parent | e143fed484a758a48bac742bf4b60b7510a9bd65 (diff) | |
download | lua-5d033f33ebe1887ea19853b5158fba48d452ba0f.tar.gz lua-5d033f33ebe1887ea19853b5158fba48d452ba0f.tar.bz2 lua-5d033f33ebe1887ea19853b5158fba48d452ba0f.zip |
details in ERRORMESSAGE
-rw-r--r-- | liolib.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.80 2000/09/12 13:48:34 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.81 2000/09/12 13:58:37 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -597,10 +597,12 @@ static int errorfb (lua_State *L) { | |||
597 | luaL_buffinit(L, &b); | 597 | luaL_buffinit(L, &b); |
598 | luaL_addstring(&b, "error: "); | 598 | luaL_addstring(&b, "error: "); |
599 | luaL_addstring(&b, luaL_check_string(L, 1)); | 599 | luaL_addstring(&b, luaL_check_string(L, 1)); |
600 | luaL_addstring(&b, "\nstack traceback:\n"); | 600 | luaL_addstring(&b, "\n"); |
601 | while (lua_getstack(L, level++, &ar)) { | 601 | while (lua_getstack(L, level++, &ar)) { |
602 | char buff[120]; /* enough to fit following `sprintf's */ | 602 | char buff[120]; /* enough to fit following `sprintf's */ |
603 | if (level > LEVELS1 && firstpart) { | 603 | if (level == 2) |
604 | luaL_addstring(&b, "stack traceback:\n"); | ||
605 | else if (level > LEVELS1 && firstpart) { | ||
604 | /* no more than `LEVELS2' more levels? */ | 606 | /* no more than `LEVELS2' more levels? */ |
605 | if (!lua_getstack(L, level+LEVELS2, &ar)) | 607 | if (!lua_getstack(L, level+LEVELS2, &ar)) |
606 | level--; /* keep going */ | 608 | level--; /* keep going */ |
@@ -627,11 +629,11 @@ static int errorfb (lua_State *L) { | |||
627 | break; | 629 | break; |
628 | default: { | 630 | default: { |
629 | if (*ar.what == 'm') /* main? */ | 631 | if (*ar.what == 'm') /* main? */ |
630 | sprintf(buff, "main of %.70s", ar.source_id); | 632 | sprintf(buff, "main of %.70s", ar.short_src); |
631 | else if (*ar.what == 'C') /* C function? */ | 633 | else if (*ar.what == 'C') /* C function? */ |
632 | sprintf(buff, "%.70s", ar.source_id); | 634 | sprintf(buff, "%.70s", ar.short_src); |
633 | else | 635 | else |
634 | sprintf(buff, "function <%d:%.70s>", ar.linedefined, ar.source_id); | 636 | sprintf(buff, "function <%d:%.70s>", ar.linedefined, ar.short_src); |
635 | ar.source = NULL; /* do not print source again */ | 637 | ar.source = NULL; /* do not print source again */ |
636 | } | 638 | } |
637 | } | 639 | } |
@@ -641,17 +643,15 @@ static int errorfb (lua_State *L) { | |||
641 | luaL_addstring(&b, buff); | 643 | luaL_addstring(&b, buff); |
642 | } | 644 | } |
643 | if (ar.source) { | 645 | if (ar.source) { |
644 | sprintf(buff, " [%.70s]", ar.source_id); | 646 | sprintf(buff, " [%.70s]", ar.short_src); |
645 | luaL_addstring(&b, buff); | 647 | luaL_addstring(&b, buff); |
646 | } | 648 | } |
647 | luaL_addstring(&b, "\n"); | 649 | luaL_addstring(&b, "\n"); |
648 | } | 650 | } |
649 | luaL_pushresult(&b); | 651 | luaL_pushresult(&b); |
650 | lua_getglobals(L); | 652 | lua_getglobal(L, LUA_ALERT); |
651 | lua_pushstring(L, LUA_ALERT); | ||
652 | lua_rawget(L, -2); | ||
653 | if (lua_isfunction(L, -1)) { /* avoid loop if _ALERT is not defined */ | 653 | if (lua_isfunction(L, -1)) { /* avoid loop if _ALERT is not defined */ |
654 | lua_pushvalue(L, -3); /* error message */ | 654 | lua_pushvalue(L, -2); /* error message */ |
655 | lua_call(L, 1, 0); | 655 | lua_call(L, 1, 0); |
656 | } | 656 | } |
657 | return 0; | 657 | return 0; |