diff options
Diffstat (limited to 'ldebug.c')
| -rw-r--r-- | ldebug.c | 17 |
1 files changed, 6 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 1.129 2002/08/07 14:35:55 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.130 2002/08/07 19:22:39 roberto Exp roberto $ |
| 3 | ** Debug Interface | 3 | ** Debug Interface |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -518,13 +518,10 @@ int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { | |||
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | 520 | ||
| 521 | static void addinfo (lua_State *L, int internal) { | 521 | static void addinfo (lua_State *L, const char *msg) { |
| 522 | const char *msg = svalue(L->top - 1); | ||
| 523 | CallInfo *ci = L->ci; | 522 | CallInfo *ci = L->ci; |
| 524 | if (!internal && ci > L->base_ci) ci--; | ||
| 525 | if (strchr(msg, '\n')) return; /* message already `formatted' */ | ||
| 526 | if (!isLua(ci)) { /* no Lua code? */ | 523 | if (!isLua(ci)) { /* no Lua code? */ |
| 527 | luaO_pushfstring(L, "%s\n", msg); /* no extra info */ | 524 | luaO_pushfstring(L, "%s\n", msg); /* no extra info; just add '\n' */ |
| 528 | } | 525 | } |
| 529 | else { /* add file:line information */ | 526 | else { /* add file:line information */ |
| 530 | char buff[LUA_IDSIZE]; | 527 | char buff[LUA_IDSIZE]; |
| @@ -535,9 +532,7 @@ static void addinfo (lua_State *L, int internal) { | |||
| 535 | } | 532 | } |
| 536 | 533 | ||
| 537 | 534 | ||
| 538 | void luaG_errormsg (lua_State *L, int internal) { | 535 | void luaG_errormsg (lua_State *L) { |
| 539 | if (ttisstring(L->top - 1)) | ||
| 540 | addinfo(L, internal); | ||
| 541 | if (L->errfunc != 0) { /* is there an error handling function? */ | 536 | if (L->errfunc != 0) { /* is there an error handling function? */ |
| 542 | StkId errfunc = restorestack(L, L->errfunc); | 537 | StkId errfunc = restorestack(L, L->errfunc); |
| 543 | if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); | 538 | if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); |
| @@ -553,8 +548,8 @@ void luaG_errormsg (lua_State *L, int internal) { | |||
| 553 | void luaG_runerror (lua_State *L, const char *fmt, ...) { | 548 | void luaG_runerror (lua_State *L, const char *fmt, ...) { |
| 554 | va_list argp; | 549 | va_list argp; |
| 555 | va_start(argp, fmt); | 550 | va_start(argp, fmt); |
| 556 | luaO_pushvfstring(L, fmt, argp); | 551 | addinfo(L, luaO_pushvfstring(L, fmt, argp)); |
| 557 | va_end(argp); | 552 | va_end(argp); |
| 558 | luaG_errormsg(L, 1); | 553 | luaG_errormsg(L); |
| 559 | } | 554 | } |
| 560 | 555 | ||
