aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lua.c b/lua.c
index d994925b..806be9fb 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.212 2014/06/26 17:08:52 roberto Exp roberto $ 2** $Id: lua.c,v 1.213 2014/06/30 19:48:08 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -164,9 +164,9 @@ static void l_message (const char *pname, const char *msg) {
164*/ 164*/
165static int report (lua_State *L, int status) { 165static int report (lua_State *L, int status) {
166 if (status != LUA_OK) { 166 if (status != LUA_OK) {
167 const char *msg = (lua_type(L, -1) == LUA_TSTRING) ? lua_tostring(L, -1) 167 const char *msg = (lua_type(L, -1) == LUA_TSTRING)
168 : NULL; 168 ? lua_tostring(L, -1)
169 if (msg == NULL) msg = "(error object is not a string)"; 169 : "(error object is not a string)";
170 l_message(progname, msg); 170 l_message(progname, msg);
171 lua_pop(L, 1); 171 lua_pop(L, 1);
172 } 172 }
@@ -181,10 +181,9 @@ static int msghandler (lua_State *L) {
181 const char *msg = lua_tostring(L, 1); 181 const char *msg = lua_tostring(L, 1);
182 if (msg) /* is error object a string? */ 182 if (msg) /* is error object a string? */
183 luaL_traceback(L, L, msg, 1); /* use standard traceback */ 183 luaL_traceback(L, L, msg, 1); /* use standard traceback */
184 else if (!lua_isnoneornil(L, 1)) { /* non-string error object? */ 184 else /* non-string error object */
185 if (!luaL_callmeta(L, 1, "__tostring")) /* try its 'tostring' metamethod */ 185 luaL_callmeta(L, 1, "__tostring"); /* try its 'tostring' metamethod */
186 lua_pushliteral(L, "(no error message)"); 186 /* if no metamethod, original object still is in the stack */
187 } /* else no error object, does nothing */
188 return 1; 187 return 1;
189} 188}
190 189