Skip to content

Commit

Permalink
Make braces expand right-to-left, to make syntax more consistent
Browse files Browse the repository at this point in the history
darcs-hash:20060617142652-ac50b-3c6ca24e37ae723fea6e74d1e4a9c66fd2f60c50.gz
  • Loading branch information
liljencrantz committed Jun 17, 2006
1 parent e007a5c commit 43b6b70
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,17 +985,16 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )

wchar_t *item_begin;
int len1, len2, tot_len;

for( pos=in;
(!bracket_end) && (*pos) && !syntax_error;
(*pos) && !syntax_error;
pos++ )
{
switch( *pos )
{
case BRACKET_BEGIN:
{
if(( bracket_count == 0)&&(bracket_begin==0))
bracket_begin = pos;
bracket_begin = pos;

bracket_count++;
break;
Expand All @@ -1004,9 +1003,11 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
case BRACKET_END:
{
bracket_count--;
if( (bracket_count == 0) && (bracket_end == 0) )
if( bracket_end < bracket_begin )
{
bracket_end = pos;

}

if( bracket_count < 0 )
{
syntax_error = 1;
Expand All @@ -1024,7 +1025,9 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
if( bracket_count > 0 )
{
if( !(flags & ACCEPT_INCOMPLETE) )
{
syntax_error = 1;
}
else
{

Expand All @@ -1042,9 +1045,6 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
sb_append_char( &mod, BRACKET_END );
}




return expand_brackets( (wchar_t*)mod.buff, 1, out );
}
}
Expand Down

0 comments on commit 43b6b70

Please sign in to comment.