aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-05-22 14:45:56 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-05-22 14:45:56 -0300
commit6142e663e4d3180d2afaea50bd0978a040f518a4 (patch)
tree55d789eb4fa54dba3bf936b7f9ea5751ad4742fa /ldebug.c
parent6dc20ff293239efd59ec8be7d14a31af084e28d5 (diff)
downloadlua-6142e663e4d3180d2afaea50bd0978a040f518a4.tar.gz
lua-6142e663e4d3180d2afaea50bd0978a040f518a4.tar.bz2
lua-6142e663e4d3180d2afaea50bd0978a040f518a4.zip
reuse of 'addinfo' by lexical errors
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/ldebug.c b/ldebug.c
index 6e4cdb35..91c3e5b7 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.113 2015/03/11 16:10:41 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.114 2015/03/28 19:14:47 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*/
@@ -599,19 +599,16 @@ l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
599} 599}
600 600
601 601
602static void addinfo (lua_State *L, const char *msg) { 602/* add src:line information to 'msg' */
603 CallInfo *ci = L->ci; 603const char *luaG_addinfo (lua_State *L, const char *msg, TString *src,
604 if (isLua(ci)) { /* is Lua code? */ 604 int line) {
605 char buff[LUA_IDSIZE]; /* add file:line information */ 605 char buff[LUA_IDSIZE];
606 int line = currentline(ci); 606 if (src)
607 TString *src = ci_func(ci)->p->source; 607 luaO_chunkid(buff, getstr(src), LUA_IDSIZE);
608 if (src) 608 else { /* no source available; use "?" instead */
609 luaO_chunkid(buff, getstr(src), LUA_IDSIZE); 609 buff[0] = '?'; buff[1] = '\0';
610 else { /* no source available; use "?" instead */
611 buff[0] = '?'; buff[1] = '\0';
612 }
613 luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
614 } 610 }
611 return luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
615} 612}
616 613
617 614
@@ -628,10 +625,14 @@ l_noret luaG_errormsg (lua_State *L) {
628 625
629 626
630l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { 627l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
628 CallInfo *ci = L->ci;
629 const char *msg;
631 va_list argp; 630 va_list argp;
632 va_start(argp, fmt); 631 va_start(argp, fmt);
633 addinfo(L, luaO_pushvfstring(L, fmt, argp)); 632 msg = luaO_pushvfstring(L, fmt, argp); /* format message */
634 va_end(argp); 633 va_end(argp);
634 if (isLua(ci)) /* if Lua function, add source:line information */
635 luaG_addinfo(L, msg, ci_func(ci)->p->source, currentline(ci));
635 luaG_errormsg(L); 636 luaG_errormsg(L);
636} 637}
637 638