mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
Fix bug causing inconsistent state and shutdown when the begin command was used in a function definition
darcs-hash:20051212155104-ac50b-bb942f22d1eaef8cdc07ddf04fb9230bbfb165f6.gz
This commit is contained in:
parent
0a8284c981
commit
00bdd2cb48
1 changed files with 16 additions and 3 deletions
19
parser.c
19
parser.c
|
@ -198,7 +198,8 @@ void parser_push_block( int type )
|
||||||
{
|
{
|
||||||
block_t *new = calloc( 1, sizeof( block_t ));
|
block_t *new = calloc( 1, sizeof( block_t ));
|
||||||
|
|
||||||
// debug( 2, L"Block push %ls %d\n", bl[type], block_count( current_block)+1 );
|
debug( 3, L"Block push %ls %d\n", parser_get_block_desc(type), block_count( current_block)+1 );
|
||||||
|
|
||||||
new->outer = current_block;
|
new->outer = current_block;
|
||||||
new->type = (current_block && current_block->skip)?FAKE:type;
|
new->type = (current_block && current_block->skip)?FAKE:type;
|
||||||
|
|
||||||
|
@ -231,7 +232,8 @@ void parser_push_block( int type )
|
||||||
|
|
||||||
void parser_pop_block()
|
void parser_pop_block()
|
||||||
{
|
{
|
||||||
// debug( 2, L"Block pop %ls %d\n", bl[current_block->type], block_count(current_block)-1 );
|
|
||||||
|
debug( 3, L"Block pop %ls %d\n", parser_get_block_desc(current_block->type), block_count(current_block)-1 );
|
||||||
event_block_t *eb, *eb_next;
|
event_block_t *eb, *eb_next;
|
||||||
|
|
||||||
if( (current_block->type != FUNCTION_DEF ) &&
|
if( (current_block->type != FUNCTION_DEF ) &&
|
||||||
|
@ -301,7 +303,7 @@ wchar_t *parser_get_block_desc( int block )
|
||||||
return L"function definition block";
|
return L"function definition block";
|
||||||
|
|
||||||
case FUNCTION_CALL:
|
case FUNCTION_CALL:
|
||||||
return L"fuction invocation block";
|
return L"function invocation block";
|
||||||
|
|
||||||
case SWITCH:
|
case SWITCH:
|
||||||
return L"switch block";
|
return L"switch block";
|
||||||
|
@ -1687,7 +1689,10 @@ static int parse_job( process_t *p,
|
||||||
end_pos );
|
end_pos );
|
||||||
|
|
||||||
while( prev_block != current_block )
|
while( prev_block != current_block )
|
||||||
|
{
|
||||||
parser_pop_block();
|
parser_pop_block();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else tok_next( tok );
|
else tok_next( tok );
|
||||||
|
|
||||||
|
@ -1721,7 +1726,10 @@ static int parse_job( process_t *p,
|
||||||
Make sure the block stack is consistent
|
Make sure the block stack is consistent
|
||||||
*/
|
*/
|
||||||
while( prev_block != current_block )
|
while( prev_block != current_block )
|
||||||
|
{
|
||||||
parser_pop_block();
|
parser_pop_block();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
al_destroy( &args );
|
al_destroy( &args );
|
||||||
|
|
||||||
|
@ -1747,6 +1755,7 @@ static void skipped_exec( job_t * j )
|
||||||
{
|
{
|
||||||
if(( wcscmp( p->argv[0], L"for" )==0) ||
|
if(( wcscmp( p->argv[0], L"for" )==0) ||
|
||||||
( wcscmp( p->argv[0], L"switch" )==0) ||
|
( wcscmp( p->argv[0], L"switch" )==0) ||
|
||||||
|
( wcscmp( p->argv[0], L"begin" )==0) ||
|
||||||
( wcscmp( p->argv[0], L"function" )==0))
|
( wcscmp( p->argv[0], L"function" )==0))
|
||||||
{
|
{
|
||||||
parser_push_block( FAKE );
|
parser_push_block( FAKE );
|
||||||
|
@ -1980,6 +1989,9 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
|
||||||
block_io = io;
|
block_io = io;
|
||||||
|
|
||||||
job_reap( 0 );
|
job_reap( 0 );
|
||||||
|
|
||||||
|
debug( 4, L"eval: %ls", cmd );
|
||||||
|
|
||||||
|
|
||||||
if( !cmd )
|
if( !cmd )
|
||||||
{
|
{
|
||||||
|
@ -2022,6 +2034,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
|
||||||
}
|
}
|
||||||
|
|
||||||
int prev_block_type = current_block->type;
|
int prev_block_type = current_block->type;
|
||||||
|
|
||||||
parser_pop_block();
|
parser_pop_block();
|
||||||
|
|
||||||
while( start_current_block != current_block )
|
while( start_current_block != current_block )
|
||||||
|
|
Loading…
Reference in a new issue