Make braces expand right-to-left, to make syntax more consistent

darcs-hash:20060617142652-ac50b-3c6ca24e37ae723fea6e74d1e4a9c66fd2f60c50.gz
This commit is contained in:
axel 2006-06-18 00:26:52 +10:00
parent e007a5c203
commit 43b6b703ff

View file

@ -987,14 +987,13 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
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_count++;
@ -1004,8 +1003,10 @@ 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 )
{
@ -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
{
@ -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 );
}
}