src/t_tst_cse.c
static size_t
t_tst_cse_getFuncSource( lua_State *L, int pos )
{
	lua_Debug  ar;
	FILE      *f;
	int        r      = 0; ///< current line count
	char       b[ LUAL_BUFFERSIZE ];
	size_t     w;
	size_t     concat = 0;

	lua_getfield( L, pos, "function" );
	lua_getinfo( L, ">S", &ar );

	lua_pushstring( L, "\n    source:" );
	concat++;
	f = fopen( ar.short_src, "r" );
	while (r < ar.lastlinedefined)
	{
		w = sprintf( &(b[0]), "\n        %d: ", r+1 );
		if (NULL == fgets( &(b[0])+w, LUAL_BUFFERSIZE-w, f ))
			break;  // eof?
		//TODO: reasonable line end check
		if (++r < ar.linedefined)
			continue;
		lua_pushlstring( L, &(b[0]), strlen( &(b[0]) )-1 );
		concat++;
	}
	fclose (f);
	lua_concat( L, concat );
	return 1;
}
/**----------------------------------------------------------------------------
 * Put source of function onto stack
 * Use lua debug facilities to determine lines of code and read the code from
 * the source files
 * \param   L        Lua state.
 * \param   int      position of Test.Case on stack.
 * \lparam  table    T.Test.Case Lua table instance.
 * \lreturn string   Source of function.
 * --------------------------------------------------------------------------*/
Put source of function onto stack
Use lua debug facilities to determine lines of code and read the code from
the source files
\param   L        Lua state.
\param   int      position of Test.Case on stack.
\lparam  table    T.Test.Case Lua table instance.
\lreturn string   Source of function.
Put source of function onto stack Use lua debug facilities to determine lines of code and read the code from the source files \ param L Lua state . \ param int position of Test . Case on stack . \ lparam table T . Test . Case Lua table instance . \ lreturn string Source of function .
static size_t
t_tst_cse_getFuncSource( lua_State *L, int pos )
{
	lua_Debug  ar;
	FILE      *f;
	int        r      = 0; 
	char       b[ LUAL_BUFFERSIZE ];
	size_t     w;
	size_t     concat = 0;
	lua_getfield( L, pos, "function" );
	lua_getinfo( L, ">S", &ar );
	lua_pushstring( L, "\n    source:" );
	concat++;
	f = fopen( ar.short_src, "r" );
	while (r < ar.lastlinedefined)
	{
		w = sprintf( &(b[0]), "\n        %d: ", r+1 );
		if (NULL == fgets( &(b[0])+w, LUAL_BUFFERSIZE-w, f ))
			break;  
		if (++r < ar.linedefined)
			continue;
		lua_pushlstring( L, &(b[0]), strlen( &(b[0]) )-1 );
		concat++;
	}
	fclose (f);
	lua_concat( L, concat );
	return 1;
}
static size_t t_tst_cse_getFuncSource ( lua_State * L , int pos ) { lua_Debug ar ; FILE * f ; int r = 0 ; char b [ LUAL_BUFFERSIZE ] ; size_t w ; size_t concat = 0 ; lua_getfield ( L , pos , " " ) ; lua_getinfo ( L , " " , & ar ) ; lua_pushstring ( L , " \n " ) ; concat ++ ; f = fopen ( ar . short_src , " " ) ; while ( r < ar . lastlinedefined ) { w = sprintf ( & ( b [ 0 ] ) , " \n " , r + 1 ) ; if ( NULL == fgets ( & ( b [ 0 ] ) + w , LUAL_BUFFERSIZE - w , f ) ) break ; if ( ++ r < ar . linedefined ) continue ; lua_pushlstring ( L , & ( b [ 0 ] ) , strlen ( & ( b [ 0 ] ) ) - 1 ) ; concat ++ ; } fclose ( f ) ; lua_concat ( L , concat ) ; return 1 ; }
Put source of function onto stack
 Use lua debug facilities to determine lines of code and read the code from
 the source files
 \param   L        Lua state.
Put source of function onto stack Use lua debug facilities to determine lines of code and read the code from the source files \ param L Lua state .
///< current line count // eof? //TODO: reasonable line end check