aboutsummaryrefslogtreecommitdiffhomepage
path: root/expand.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-06-18 00:26:52 +1000
committerGravatar axel <axel@liljencrantz.se>2006-06-18 00:26:52 +1000
commit43b6b703ff56ed4a4194d26811823a6c4e545a87 (patch)
treeacdf7849fbe9b532d543cb3ae3c850b05e08ef7c /expand.c
parente007a5c203c9b506cc9c5262cf30b67617ef7743 (diff)
Make braces expand right-to-left, to make syntax more consistent
darcs-hash:20060617142652-ac50b-3c6ca24e37ae723fea6e74d1e4a9c66fd2f60c50.gz
Diffstat (limited to 'expand.c')
-rw-r--r--expand.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/expand.c b/expand.c
index 67a6b813..61b31210 100644
--- a/expand.c
+++ b/expand.c
@@ -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;
@@ -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;
@@ -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 );
}
}