aboutsummaryrefslogtreecommitdiffhomepage
path: root/expand.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-10-28 01:21:48 +1000
committerGravatar axel <axel@liljencrantz.se>2005-10-28 01:21:48 +1000
commitb78fba810cc0dde84ff68b408c96aa8be502e0d4 (patch)
tree38af12f2ffdca8de62824d4a82f1017f1b8c8658 /expand.c
parent43213ee45858486e95adcdbe2a9e3452a97e9f53 (diff)
Fix crash bug when pasting long text
darcs-hash:20051027152148-ac50b-b47b96bc8acae760ce53a2e42d23dc2d07bf2302.gz
Diffstat (limited to 'expand.c')
-rw-r--r--expand.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/expand.c b/expand.c
index cadea78e..3a56e050 100644
--- a/expand.c
+++ b/expand.c
@@ -1121,9 +1121,7 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
break;
- }
-
-
+ }
len1 = (paran_begin-in);
len2 = wcslen(paran_end)-1;
@@ -1147,10 +1145,10 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
free( subcmd );
return 0;
}
-
+
al_init( &tail_expand );
expand_subshell( wcsdup(paran_end+1), &tail_expand );
-
+
for( i=0; i<al_get_count( &sub_res ); i++ )
{
wchar_t *sub_item, *sub_item2;
@@ -1158,20 +1156,20 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
sub_item2 = expand_escape( sub_item, 1 );
free(sub_item);
int item_len = wcslen( sub_item2 );
-
+
for( j=0; j<al_get_count( &tail_expand ); j++ )
{
string_buffer_t whole_item;
wchar_t *tail_item = (wchar_t *)al_get( &tail_expand, j );
-
+
sb_init( &whole_item );
-
+
sb_append_substring( &whole_item, in, len1 );
sb_append_char( &whole_item, INTERNAL_SEPARATOR );
sb_append_substring( &whole_item, sub_item2, item_len );
sb_append_char( &whole_item, INTERNAL_SEPARATOR );
sb_append( &whole_item, tail_item );
-
+
al_push( out, whole_item.buff );
}
@@ -1183,7 +1181,7 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
al_foreach( &tail_expand, (void (*)(const void *))&free );
al_destroy( &tail_expand );
-
+
free( subcmd );
return 1;
}
@@ -1246,7 +1244,7 @@ static int tilde_expand( wchar_t **ptr )
old_in = name_end;
char *name_str = wcs2str( name );
-
+
struct passwd *userinfo =
getpwnam( name_str );
@@ -1397,7 +1395,7 @@ int expand_string( wchar_t *str,
for( i=0; i<al_get_count( in ); i++ )
{
wchar_t *next;
-
+
next = expand_unescape( (wchar_t *)al_get( in, i ),
1);