11/*
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 $
33** Lua stand-alone interpreter
44** See Copyright Notice in lua.h
55*/
@@ -164,9 +164,9 @@ static void l_message (const char *pname, const char *msg) {
164164*/
165165static int report (lua_State * L , int status ) {
166166 if (status != LUA_OK ) {
167- const char * msg = (lua_type (L , -1 ) == LUA_TSTRING ) ? lua_tostring ( L , -1 )
168- : NULL ;
169- if ( msg == NULL ) msg = "(error object is not a string)" ;
167+ const char * msg = (lua_type (L , -1 ) == LUA_TSTRING )
168+ ? lua_tostring ( L , -1 )
169+ : "(error object is not a string)" ;
170170 l_message (progname , msg );
171171 lua_pop (L , 1 );
172172 }
@@ -181,10 +181,9 @@ static int msghandler (lua_State *L) {
181181 const char * msg = lua_tostring (L , 1 );
182182 if (msg ) /* is error object a string? */
183183 luaL_traceback (L , L , msg , 1 ); /* use standard traceback */
184- else if (!lua_isnoneornil (L , 1 )) { /* non-string error object? */
185- if (!luaL_callmeta (L , 1 , "__tostring" )) /* try its 'tostring' metamethod */
186- lua_pushliteral (L , "(no error message)" );
187- } /* else no error object, does nothing */
184+ else /* non-string error object */
185+ luaL_callmeta (L , 1 , "__tostring" ); /* try its 'tostring' metamethod */
186+ /* if no metamethod, original object still is in the stack */
188187 return 1 ;
189188}
190189
0 commit comments