Skip to content

Commit

Permalink
Fix bug in parser, on incomplete blocks. This bug was handled correct…
Browse files Browse the repository at this point in the history
…ly by the error handler, so it was non-critical.

darcs-hash:20070422094847-ac50b-f8aff4c2939725e256b2f6d020f98240d2658d50.gz
  • Loading branch information
liljencrantz committed Apr 22, 2007
1 parent 8ab1d02 commit e9790db
Showing 1 changed file with 53 additions and 50 deletions.
103 changes: 53 additions & 50 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2161,73 +2161,76 @@ static int parse_job( process_t *p,
BLOCK_END_ERR_MSG );

}

if( !make_sub_block )
else
{
int done=0;

for( tok_init( &subtok, end, 0 );
!done && tok_has_next( &subtok );
tok_next( &subtok ) )
if( !make_sub_block )
{

switch( tok_last_type( &subtok ) )
int done=0;

for( tok_init( &subtok, end, 0 );
!done && tok_has_next( &subtok );
tok_next( &subtok ) )
{
case TOK_END:
done = 1;
break;

case TOK_REDIRECT_OUT:
case TOK_REDIRECT_APPEND:
case TOK_REDIRECT_IN:
case TOK_REDIRECT_FD:
case TOK_PIPE:

switch( tok_last_type( &subtok ) )
{
done = 1;
make_sub_block = 1;
break;
}
case TOK_END:
done = 1;
break;

case TOK_REDIRECT_OUT:
case TOK_REDIRECT_APPEND:
case TOK_REDIRECT_IN:
case TOK_REDIRECT_FD:
case TOK_PIPE:
{
done = 1;
make_sub_block = 1;
break;
}

case TOK_STRING:
{
break;
}
case TOK_STRING:
{
break;
}

default:
{
done = 1;
error( SYNTAX_ERROR,
current_tokenizer_pos,
BLOCK_END_ERR_MSG );
default:
{
done = 1;
error( SYNTAX_ERROR,
current_tokenizer_pos,
BLOCK_END_ERR_MSG );
}
}
}
}

tok_destroy( &subtok );
}
tok_destroy( &subtok );
}

if( make_sub_block )
{
if( make_sub_block )
{

int end_pos = end-tok_string( tok );
wchar_t *sub_block= halloc_wcsndup( j,
tok_string( tok ) + current_tokenizer_pos,
end_pos - current_tokenizer_pos);
int end_pos = end-tok_string( tok );
wchar_t *sub_block= halloc_wcsndup( j,
tok_string( tok ) + current_tokenizer_pos,
end_pos - current_tokenizer_pos);

p->type = INTERNAL_BLOCK;
al_set( args, 0, sub_block );
p->type = INTERNAL_BLOCK;
al_set( args, 0, sub_block );

tok_set_pos( tok,
end_pos );
tok_set_pos( tok,
end_pos );

while( prev_block != current_block )
{
parser_pop_block();
}
while( prev_block != current_block )
{
parser_pop_block();
}

}
else tok_next( tok );
}
else tok_next( tok );


}
else tok_next( tok );

Expand Down

0 comments on commit e9790db

Please sign in to comment.