diff options
Diffstat (limited to '')
-rw-r--r-- | ldebug.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -817,16 +817,15 @@ l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { | |||
817 | /* add src:line information to 'msg' */ | 817 | /* add src:line information to 'msg' */ |
818 | const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, | 818 | const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, |
819 | int line) { | 819 | int line) { |
820 | char buff[LUA_IDSIZE]; | 820 | if (src == NULL) /* no debug information? */ |
821 | if (src) { | 821 | return luaO_pushfstring(L, "?:?: %s", msg); |
822 | else { | ||
823 | char buff[LUA_IDSIZE]; | ||
822 | size_t idlen; | 824 | size_t idlen; |
823 | const char *id = getlstr(src, idlen); | 825 | const char *id = getlstr(src, idlen); |
824 | luaO_chunkid(buff, id, idlen); | 826 | luaO_chunkid(buff, id, idlen); |
827 | return luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); | ||
825 | } | 828 | } |
826 | else { /* no source available; use "?" instead */ | ||
827 | buff[0] = '?'; buff[1] = '\0'; | ||
828 | } | ||
829 | return luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); | ||
830 | } | 829 | } |
831 | 830 | ||
832 | 831 | ||
@@ -852,12 +851,8 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { | |||
852 | const char *msg; | 851 | const char *msg; |
853 | va_list argp; | 852 | va_list argp; |
854 | luaC_checkGC(L); /* error message uses memory */ | 853 | luaC_checkGC(L); /* error message uses memory */ |
855 | va_start(argp, fmt); | 854 | pushvfstring(L, argp, fmt, msg); |
856 | msg = luaO_pushvfstring(L, fmt, argp); /* format message */ | 855 | if (isLua(ci)) { /* Lua function? */ |
857 | va_end(argp); | ||
858 | if (msg == NULL) /* no memory to format message? */ | ||
859 | luaD_throw(L, LUA_ERRMEM); | ||
860 | else if (isLua(ci)) { /* Lua function? */ | ||
861 | /* add source:line information */ | 856 | /* add source:line information */ |
862 | luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); | 857 | luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); |
863 | setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ | 858 | setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ |