aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-10-20 20:21:05 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-10-20 20:21:05 -0200
commit6d613817d4c94588260484f29e931c46bae1fc28 (patch)
tree22629225ff2343264a39a948ad8d6570db014d7b
parentb8d412aa07278b3c4ef6ebc58d4b72045dffea3a (diff)
downloadlua-6d613817d4c94588260484f29e931c46bae1fc28.tar.gz
lua-6d613817d4c94588260484f29e931c46bae1fc28.tar.bz2
lua-6d613817d4c94588260484f29e931c46bae1fc28.zip
comments
-rw-r--r--lua.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lua.c b/lua.c
index 5c979c5a..d53c7f68 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.215 2014/10/17 16:28:21 roberto Exp roberto $ 2** $Id: lua.c,v 1.216 2014/10/20 18:19:26 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*/
@@ -158,7 +158,8 @@ static void l_message (const char *pname, const char *msg) {
158 158
159/* 159/*
160** Check whether 'status' is not OK and, if so, prints the error 160** Check whether 'status' is not OK and, if so, prints the error
161** message on the top of the stack. 161** message on the top of the stack. It assumes that the error object
162** is a string, as it was either generated by Lua or by 'msghandler'.
162*/ 163*/
163static int report (lua_State *L, int status) { 164static int report (lua_State *L, int status) {
164 if (status != LUA_OK) { 165 if (status != LUA_OK) {
@@ -176,15 +177,15 @@ static int report (lua_State *L, int status) {
176static int msghandler (lua_State *L) { 177static int msghandler (lua_State *L) {
177 const char *msg = lua_tostring(L, 1); 178 const char *msg = lua_tostring(L, 1);
178 if (msg == NULL) { /* is error object not a string? */ 179 if (msg == NULL) { /* is error object not a string? */
179 if (luaL_callmeta(L, 1, "__tostring") && /* did have a metamethod */ 180 if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */
180 lua_type(L, -1) == LUA_TSTRING) /* and it produce a string? */ 181 lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */
181 return 1; /* that is the message */ 182 return 1; /* that is the message */
182 else 183 else
183 msg = lua_pushfstring(L, "(error object is a %s value)", 184 msg = lua_pushfstring(L, "(error object is a %s value)",
184 luaL_typename(L, 1)); 185 luaL_typename(L, 1));
185 } 186 }
186 luaL_traceback(L, L, msg, 1); /* append a standard traceback */ 187 luaL_traceback(L, L, msg, 1); /* append a standard traceback */
187 return 1; 188 return 1; /* return the traceback */
188} 189}
189 190
190 191