mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix glitches in stack trace
darcs-hash:20060126154722-ac50b-0d44e98b6d98e3b42f60f66f5bfa2c5f97ea2bd8.gz
This commit is contained in:
parent
db0eccdc86
commit
7cd98a670b
3 changed files with 19 additions and 3 deletions
5
exec.c
5
exec.c
|
@ -815,13 +815,18 @@ void exec( job_t *j )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
These two lines must be called before the new block is pushed
|
||||||
|
*/
|
||||||
int lineno = parser_get_lineno();
|
int lineno = parser_get_lineno();
|
||||||
|
wchar_t *file = parser_current_filename()?wcsdup(parser_current_filename()):0;
|
||||||
|
|
||||||
parser_push_block( FUNCTION_CALL );
|
parser_push_block( FUNCTION_CALL );
|
||||||
|
|
||||||
al_init( ¤t_block->param2.function_vars );
|
al_init( ¤t_block->param2.function_vars );
|
||||||
current_block->param1.function_name = wcsdup( p->argv[0] );
|
current_block->param1.function_name = wcsdup( p->argv[0] );
|
||||||
current_block->param3.function_lineno = lineno;
|
current_block->param3.function_lineno = lineno;
|
||||||
|
current_block->param4.function_filename = file;
|
||||||
|
|
||||||
if( builtin_count_args(p->argv)>1 )
|
if( builtin_count_args(p->argv)>1 )
|
||||||
{
|
{
|
||||||
|
|
8
parser.c
8
parser.c
|
@ -401,6 +401,7 @@ void parser_pop_block()
|
||||||
case FUNCTION_CALL:
|
case FUNCTION_CALL:
|
||||||
{
|
{
|
||||||
free( current_block->param1.function_name );
|
free( current_block->param1.function_name );
|
||||||
|
free( current_block->param4.function_filename );
|
||||||
al_foreach( ¤t_block->param2.function_vars,
|
al_foreach( ¤t_block->param2.function_vars,
|
||||||
(void (*)(const void *))&free );
|
(void (*)(const void *))&free );
|
||||||
al_destroy( ¤t_block->param2.function_vars );
|
al_destroy( ¤t_block->param2.function_vars );
|
||||||
|
@ -1023,7 +1024,8 @@ static void parser_stack_trace( block_t *b, string_buffer_t *buff)
|
||||||
|
|
||||||
sb_printf( buff, _(L"in function '%ls',\n"), b->param1.function_name );
|
sb_printf( buff, _(L"in function '%ls',\n"), b->param1.function_name );
|
||||||
|
|
||||||
const wchar_t *file = function_get_definition_file( b->param1.function_name );
|
const wchar_t *file = b->param4.function_filename;
|
||||||
|
|
||||||
if( file )
|
if( file )
|
||||||
sb_printf( buff,
|
sb_printf( buff,
|
||||||
_(L"\tcalled on line %d of file '%ls',\n"),
|
_(L"\tcalled on line %d of file '%ls',\n"),
|
||||||
|
@ -1094,7 +1096,7 @@ int parser_get_lineno()
|
||||||
return lineno;
|
return lineno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const wchar_t *parser_current_filename()
|
const wchar_t *parser_current_filename()
|
||||||
{
|
{
|
||||||
block_t *b = current_block;
|
block_t *b = current_block;
|
||||||
|
|
||||||
|
@ -1188,7 +1190,7 @@ wchar_t *parser_current_line()
|
||||||
/**
|
/**
|
||||||
If we are not going to print a stack trace, at least print the line number and filename
|
If we are not going to print a stack trace, at least print the line number and filename
|
||||||
*/
|
*/
|
||||||
if( !is_interactive )
|
if( !is_interactive || is_function() )
|
||||||
{
|
{
|
||||||
int prev_width = my_wcswidth( (wchar_t *)lineinfo->buff );
|
int prev_width = my_wcswidth( (wchar_t *)lineinfo->buff );
|
||||||
if( file )
|
if( file )
|
||||||
|
|
9
parser.h
9
parser.h
|
@ -92,6 +92,7 @@ typedef struct block
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
array_list_t *function_events;
|
array_list_t *function_events;
|
||||||
|
wchar_t *function_filename;
|
||||||
} param4;
|
} param4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -338,4 +339,12 @@ void parser_destroy();
|
||||||
*/
|
*/
|
||||||
int parser_is_help( wchar_t *s, int min_match );
|
int parser_is_help( wchar_t *s, int min_match );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the file currently evaluated by the parser. This can be
|
||||||
|
different than reader_current_filename, e.g. if we are evaulating a
|
||||||
|
function defined in a different file than the one curently read.
|
||||||
|
*/
|
||||||
|
const wchar_t *parser_current_filename();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue