@@ -153,29 +153,26 @@ static int pcall_error_traceback_handler(lua_State *lua_state)
153153 assert (lua_state);
154154
155155 char const *msg = lua_tostring (lua_state, 1 );
156- if (msg == nullptr ) { // is error object not a string?
157- if (luaL_callmeta (lua_state, 1 ,
158- " __tostring" ) && // does it have a metamethod
159- lua_type (lua_state, -1 ) == LUA_TSTRING) { // that produces a string?
160- return 1 ; // that is the message
161- } else {
162- msg = lua_pushfstring (lua_state, " (error object is a %s value)" ,
163- luaL_typename (lua_state, 1 ));
156+ if (msg == nullptr ) {
157+ if (luaL_callmeta (lua_state, 1 , " __tostring" ) &&
158+ lua_type (lua_state, -1 ) == LUA_TSTRING) {
159+ return 1 ;
164160 }
161+ msg = lua_pushfstring (lua_state, " (error object is a %s value)" ,
162+ luaL_typename (lua_state, 1 ));
165163 }
166- luaL_traceback (lua_state, lua_state, msg, 1 ); // append a standard traceback
167- return 1 ; // return the traceback
164+ luaL_traceback (lua_state, lua_state, msg, 1 );
165+ return 1 ;
168166}
169167
170- // wrapper function for lua_pcall to include a stack traceback
168+ // / Wrapper function for lua_pcall() showing a stack trace on error.
171169int luaX_pcall (lua_State *lua_state, int narg, int nres)
172170{
173- int const base = lua_gettop (lua_state) - narg; // function index
174- lua_pushcfunction (lua_state,
175- pcall_error_traceback_handler); // push message handler
176- lua_insert (lua_state, base); // put it under function and args
171+ int const base = lua_gettop (lua_state) - narg;
172+ lua_pushcfunction (lua_state, pcall_error_traceback_handler);
173+ lua_insert (lua_state, base);
177174 int const status = lua_pcall (lua_state, narg, nres, base);
178- lua_remove (lua_state, base); // remove message handler from the stack
175+ lua_remove (lua_state, base);
179176 return status;
180177}
181178
0 commit comments