aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-12-13 01:51:04 +1000
committerGravatar axel <axel@liljencrantz.se>2005-12-13 01:51:04 +1000
commit00bdd2cb484e9aa72c557d6d4b9968b79815cb99 (patch)
treed3f6a7ffec13c6dc47ced8b7411221e1e348aa6d /parser.c
parent0a8284c9813c0ed6e667c340cdc451a5d49603d2 (diff)
Fix bug causing inconsistent state and shutdown when the begin command was used in a function definition
darcs-hash:20051212155104-ac50b-bb942f22d1eaef8cdc07ddf04fb9230bbfb165f6.gz
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/parser.c b/parser.c
index 4ae3a86e..001d5caa 100644
--- a/parser.c
+++ b/parser.c
@@ -198,7 +198,8 @@ void parser_push_block( int type )
{
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->type = (current_block && current_block->skip)?FAKE:type;
@@ -231,7 +232,8 @@ void parser_push_block( int type )
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;
if( (current_block->type != FUNCTION_DEF ) &&
@@ -301,7 +303,7 @@ wchar_t *parser_get_block_desc( int block )
return L"function definition block";
case FUNCTION_CALL:
- return L"fuction invocation block";
+ return L"function invocation block";
case SWITCH:
return L"switch block";
@@ -1687,7 +1689,10 @@ static int parse_job( process_t *p,
end_pos );
while( prev_block != current_block )
+ {
parser_pop_block();
+ }
+
}
else tok_next( tok );
@@ -1721,7 +1726,10 @@ static int parse_job( process_t *p,
Make sure the block stack is consistent
*/
while( prev_block != current_block )
+ {
parser_pop_block();
+ }
+
}
al_destroy( &args );
@@ -1747,6 +1755,7 @@ static void skipped_exec( job_t * j )
{
if(( wcscmp( p->argv[0], L"for" )==0) ||
( wcscmp( p->argv[0], L"switch" )==0) ||
+ ( wcscmp( p->argv[0], L"begin" )==0) ||
( wcscmp( p->argv[0], L"function" )==0))
{
parser_push_block( FAKE );
@@ -1980,6 +1989,9 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
block_io = io;
job_reap( 0 );
+
+ debug( 4, L"eval: %ls", 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;
+
parser_pop_block();
while( start_current_block != current_block )