aboutsummaryrefslogtreecommitdiffhomepage
path: root/tokenizer.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-10-08 07:30:08 +1000
committerGravatar axel <axel@liljencrantz.se>2005-10-08 07:30:08 +1000
commitb867fc2b71941368faf544708e02ff28ea99255c (patch)
treed9f6c0ccf857cc00d599d0754c0fc7a42b4e675c /tokenizer.c
parentc84d360ae7936bd10ce0237218b78bee2ea01060 (diff)
Allow redirection to filedescriptors with higher number than 9
darcs-hash:20051007213008-ac50b-2e8cfb44de481d6e7a2e0104ed8ae6bc9a776ff6.gz
Diffstat (limited to 'tokenizer.c')
-rw-r--r--tokenizer.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/tokenizer.c b/tokenizer.c
index 01442a7d..021c428f 100644
--- a/tokenizer.c
+++ b/tokenizer.c
@@ -511,7 +511,7 @@ void tok_next( tokenizer *tok )
break;
case L'|':
- check_size( tok, 16 );
+ check_size( tok, 2 );
tok->last[0]=L'1';
tok->last[1]=L'\0';
@@ -527,11 +527,17 @@ void tok_next( tokenizer *tok )
return read_redirect( tok, 2 );
default:
+ {
+
if( iswdigit( *tok->buff ) )
{
- int fd = *tok->buff - L'0';
- check_size( tok, 16 );
- switch( *(tok->buff+1))
+
+ wchar_t *orig = tok->buff;
+ int fd = 0;
+ while( iswdigit( *tok->buff ) )
+ fd = (fd*10) + (*(tok->buff++) - L'0');
+
+ switch( *(tok->buff))
{
case L'|':
{
@@ -540,24 +546,24 @@ void tok_next( tokenizer *tok )
tok_error( tok, PIPE_ERROR );
return;
}
-
- tok->buff+=2;
- tok->last[0]=L'0'+fd;
- tok->last[1]=L'\0';
+ check_size( tok, 16 );
+ tok->buff++;
+ swprintf( tok->buff, 16, L"%d", fd );
tok->last_type = TOK_PIPE;
return;
}
-
+
case L'>':
case L'<':
- {
- tok->buff++;
read_redirect( tok, fd );
return;
- }
+
}
+ tok->buff = orig;
}
read_string( tok );
+ }
+
}
}