src/t_tst_cse.c
int
t_tst_cse_traceback( lua_State *L )
{
	char           *msg = NULL;
	const char     *loc;
	if (LUA_TSTRING == lua_type( L, 1 ))
	{
		lua_newtable( L );
		lua_insert( L, 1 );            // S: tbl msg
		loc = lua_tostring( L, 2 );
		msg = strchr( loc, ':' );      // find separator of filename and line number
		if (msg)
		{
			msg++;
			msg = strchr( msg, ':' ) + 2;  // find separator before message
			if (0==strncmp( T_TST_CSE_SKIPINDICATOR, msg, strlen( T_TST_CSE_SKIPINDICATOR ) ))
			{
				lua_pushstring( L, msg+strlen( T_TST_CSE_SKIPINDICATOR) );
				lua_setfield( L, 1, "skip" );
				lua_pushboolean( L, 1 );
				lua_setfield( L, 1, "pass" );
				lua_pop( L, 1 );    // pop original massage
			}
			else
			{
				lua_pushboolean( L, 0 );
				lua_setfield( L, 1, "pass" );
				lua_pushstring( L, msg );
				lua_setfield( L, 1, "message" );
				lua_pushlstring( L, loc, msg-loc-2 );
				lua_setfield( L, 1, "location" );
				lua_pop( L, 1 );                 // pop original message
				luaL_traceback( L, L, NULL, 1 );
				lua_setfield( L, 1, "traceback" );
			}
		}
		else
		{
			lua_setfield( L, 1, "message" );    // set original message
			luaL_where( L, 2 );
			lua_setfield( L, 1, "location" );
			luaL_traceback( L, L, NULL, 1 );
			lua_setfield( L, 1, "traceback" );
		}
	}
	else
		if (LUA_TTABLE == lua_type( L, 1 ))
		{
			//luaL_where( L, 2 );
			//lua_setfield( L, 1, "location" );
			luaL_traceback( L, L, NULL, 1 );
			lua_setfield( L, 1, "traceback" );
		}

	return 1;
}
/**--------------------------------------------------------------------------
 * Creates a traceback from a function call
 * \param   L      Lua state.
 * \lparam  either assert result table or generic string.
 * \lreturn a t_tst result Failure description table.
 * \return  int    # of values pushed onto the stack.
 * --------------------------------------------------------------------------*/
Creates a traceback from a function call
\param   L      Lua state.
\lparam  either assert result table or generic string.
\lreturn a t_tst result Failure description table.
\return  int    # of values pushed onto the stack.
Creates a traceback from a function call \ param L Lua state . \ lparam either assert result table or generic string . \ lreturn a t_tst result Failure description table . \ return int # of values pushed onto the stack .
int
t_tst_cse_traceback( lua_State *L )
{
	char           *msg = NULL;
	const char     *loc;
	if (LUA_TSTRING == lua_type( L, 1 ))
	{
		lua_newtable( L );
		lua_insert( L, 1 );            
		loc = lua_tostring( L, 2 );
		msg = strchr( loc, ':' );      
		if (msg)
		{
			msg++;
			msg = strchr( msg, ':' ) + 2;  
			if (0==strncmp( T_TST_CSE_SKIPINDICATOR, msg, strlen( T_TST_CSE_SKIPINDICATOR ) ))
			{
				lua_pushstring( L, msg+strlen( T_TST_CSE_SKIPINDICATOR) );
				lua_setfield( L, 1, "skip" );
				lua_pushboolean( L, 1 );
				lua_setfield( L, 1, "pass" );
				lua_pop( L, 1 );    
			}
			else
			{
				lua_pushboolean( L, 0 );
				lua_setfield( L, 1, "pass" );
				lua_pushstring( L, msg );
				lua_setfield( L, 1, "message" );
				lua_pushlstring( L, loc, msg-loc-2 );
				lua_setfield( L, 1, "location" );
				lua_pop( L, 1 );                 
				luaL_traceback( L, L, NULL, 1 );
				lua_setfield( L, 1, "traceback" );
			}
		}
		else
		{
			lua_setfield( L, 1, "message" );    
			luaL_where( L, 2 );
			lua_setfield( L, 1, "location" );
			luaL_traceback( L, L, NULL, 1 );
			lua_setfield( L, 1, "traceback" );
		}
	}
	else
		if (LUA_TTABLE == lua_type( L, 1 ))
		{
			luaL_traceback( L, L, NULL, 1 );
			lua_setfield( L, 1, "traceback" );
		}
	return 1;
}
int t_tst_cse_traceback ( lua_State * L ) { char * msg = NULL ; const char * loc ; if ( LUA_TSTRING == lua_type ( L , 1 ) ) { lua_newtable ( L ) ; lua_insert ( L , 1 ) ; loc = lua_tostring ( L , 2 ) ; msg = strchr ( loc , ' ' ) ; if ( msg ) { msg ++ ; msg = strchr ( msg , ' ' ) + 2 ; if ( 0 == strncmp ( T_TST_CSE_SKIPINDICATOR , msg , strlen ( T_TST_CSE_SKIPINDICATOR ) ) ) { lua_pushstring ( L , msg + strlen ( T_TST_CSE_SKIPINDICATOR ) ) ; lua_setfield ( L , 1 , " " ) ; lua_pushboolean ( L , 1 ) ; lua_setfield ( L , 1 , " " ) ; lua_pop ( L , 1 ) ; } else { lua_pushboolean ( L , 0 ) ; lua_setfield ( L , 1 , " " ) ; lua_pushstring ( L , msg ) ; lua_setfield ( L , 1 , " " ) ; lua_pushlstring ( L , loc , msg - loc - 2 ) ; lua_setfield ( L , 1 , " " ) ; lua_pop ( L , 1 ) ; luaL_traceback ( L , L , NULL , 1 ) ; lua_setfield ( L , 1 , " " ) ; } } else { lua_setfield ( L , 1 , " " ) ; luaL_where ( L , 2 ) ; lua_setfield ( L , 1 , " " ) ; luaL_traceback ( L , L , NULL , 1 ) ; lua_setfield ( L , 1 , " " ) ; } } else if ( LUA_TTABLE == lua_type ( L , 1 ) ) { luaL_traceback ( L , L , NULL , 1 ) ; lua_setfield ( L , 1 , " " ) ; } return 1 ; }
Creates a traceback from a function call
 \param   L      Lua state.
Creates a traceback from a function call \ param L Lua state .
// S: tbl msg // find separator of filename and line number // find separator before message // pop original massage // pop original message // set original message //luaL_where( L, 2 ); //lua_setfield( L, 1, "location" );