comments
This commit is contained in:
11
lua.c
11
lua.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.215 2014/10/17 16:28:21 roberto Exp roberto $
|
** $Id: lua.c,v 1.216 2014/10/20 18:19:26 roberto Exp roberto $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -158,7 +158,8 @@ static void l_message (const char *pname, const char *msg) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Check whether 'status' is not OK and, if so, prints the error
|
** Check whether 'status' is not OK and, if so, prints the error
|
||||||
** message on the top of the stack.
|
** message on the top of the stack. It assumes that the error object
|
||||||
|
** is a string, as it was either generated by Lua or by 'msghandler'.
|
||||||
*/
|
*/
|
||||||
static int report (lua_State *L, int status) {
|
static int report (lua_State *L, int status) {
|
||||||
if (status != LUA_OK) {
|
if (status != LUA_OK) {
|
||||||
@@ -176,15 +177,15 @@ static int report (lua_State *L, int status) {
|
|||||||
static int msghandler (lua_State *L) {
|
static int msghandler (lua_State *L) {
|
||||||
const char *msg = lua_tostring(L, 1);
|
const char *msg = lua_tostring(L, 1);
|
||||||
if (msg == NULL) { /* is error object not a string? */
|
if (msg == NULL) { /* is error object not a string? */
|
||||||
if (luaL_callmeta(L, 1, "__tostring") && /* did have a metamethod */
|
if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */
|
||||||
lua_type(L, -1) == LUA_TSTRING) /* and it produce a string? */
|
lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */
|
||||||
return 1; /* that is the message */
|
return 1; /* that is the message */
|
||||||
else
|
else
|
||||||
msg = lua_pushfstring(L, "(error object is a %s value)",
|
msg = lua_pushfstring(L, "(error object is a %s value)",
|
||||||
luaL_typename(L, 1));
|
luaL_typename(L, 1));
|
||||||
}
|
}
|
||||||
luaL_traceback(L, L, msg, 1); /* append a standard traceback */
|
luaL_traceback(L, L, msg, 1); /* append a standard traceback */
|
||||||
return 1;
|
return 1; /* return the traceback */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user