Fix a number of bugs found using the warnings generated by earlier patch

darcs-hash:20061019153603-ac50b-4efb1ad1fe2cbe693a921648a0616a3d258d7933.gz
This commit is contained in:
axel 2006-10-20 01:36:03 +10:00
parent ae16397e1c
commit 4683f4c989
8 changed files with 188 additions and 155 deletions

View File

@ -909,8 +909,8 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig )
array_list_t l; array_list_t l;
al_init( &l ); al_init( &l );
exec_subshell( cmd, &l ); if( exec_subshell( cmd, &l ) != -1 )
free(cmd); {
if( al_get_count( &l )>0 ) if( al_get_count( &l )>0 )
{ {
@ -926,7 +926,9 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig )
desc[0]=towupper(desc[0]); desc[0]=towupper(desc[0]);
} }
} }
}
free(cmd);
al_foreach( &l, &free ); al_foreach( &l, &free );
al_destroy( &l ); al_destroy( &l );
} }
@ -1155,7 +1157,9 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp )
systems with a large set of manuals, but it should be ok systems with a large set of manuals, but it should be ok
since apropos is only called once. since apropos is only called once.
*/ */
exec_subshell( lookup_cmd, &list ); if( exec_subshell( lookup_cmd, &list ) != -1 )
{
/* /*
Then discard anything that is not a possible completion and put Then discard anything that is not a possible completion and put
@ -1227,6 +1231,7 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp )
*cmd_end = COMPLETE_SEP; *cmd_end = COMPLETE_SEP;
} }
} }
}
hash_destroy( &lookup ); hash_destroy( &lookup );
al_foreach( &list, al_foreach( &list,
@ -1798,16 +1803,18 @@ static void complete_param_expand( wchar_t *str,
{ {
comp_str = str; comp_str = str;
} }
/*
debug( 3, if( expand_string( 0,
L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | %ls );",
comp_str,
do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
*/
expand_string( 0,
wcsdup(comp_str), wcsdup(comp_str),
comp_out, comp_out,
EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) ); EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) ) )
{
/*
Ignore errors - completions may fail, and that's ok
*/
}
} }
/** /**
@ -1974,7 +1981,7 @@ static int try_complete_user( const wchar_t *cmd,
L"/", L"/",
COMPLETE_SEP_STR, COMPLETE_SEP_STR,
COMPLETE_USER_DESC, COMPLETE_USER_DESC,
0 ); (void *)0 );
if( blarg != 0 ) if( blarg != 0 )
{ {
al_push( comp, blarg ); al_push( comp, blarg );

12
exec.c
View File

@ -1344,7 +1344,7 @@ int exec_subshell( const wchar_t *cmd,
debug( 1, debug( 1,
_( L"Sent null command to subshell. This is a fish bug. If it can be reproduced, please send a bug report to %s." ), _( L"Sent null command to subshell. This is a fish bug. If it can be reproduced, please send a bug report to %s." ),
PACKAGE_BUGREPORT ); PACKAGE_BUGREPORT );
return 0; return -1;
} }
is_subshell=1; is_subshell=1;
@ -1352,11 +1352,17 @@ int exec_subshell( const wchar_t *cmd,
prev_status = proc_get_last_status(); prev_status = proc_get_last_status();
eval( cmd, io_buffer, SUBST ); if( eval( cmd, io_buffer, SUBST ) )
{
status = -1;
}
else
{
status = proc_get_last_status();
}
io_buffer_read( io_buffer ); io_buffer_read( io_buffer );
status = proc_get_last_status();
proc_set_last_status( prev_status ); proc_set_last_status( prev_status );
is_subshell = prev_subshell; is_subshell = prev_subshell;

View File

@ -1265,7 +1265,12 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
wcslcpy( subcmd, paran_begin+1, paran_end-paran_begin ); wcslcpy( subcmd, paran_begin+1, paran_end-paran_begin );
subcmd[ paran_end-paran_begin-1]=0; subcmd[ paran_end-paran_begin-1]=0;
exec_subshell( subcmd, sub_res); if( exec_subshell( subcmd, sub_res) == -1 )
{
halloc_free( context );
error( CMDSUBST_ERROR, -1, L"Unknown error while evaulating command substitution" );
return 0;
}
tail_begin = paran_end + 1; tail_begin = paran_end + 1;
if( *tail_begin == L'[' ) if( *tail_begin == L'[' )

View File

@ -1297,6 +1297,7 @@ static void add_common_bindings()
add_escaped_mapping( name[i], (L"\\C-y"), L"Control-y", L"yank" ); add_escaped_mapping( name[i], (L"\\C-y"), L"Control-y", L"yank" );
add_mapping( name[i], L"", L"Any key", L"self-insert" ); add_mapping( name[i], L"", L"Any key", L"self-insert" );
} }
} }
/** /**

12
kill.c
View File

@ -97,7 +97,13 @@ void kill_add( wchar_t *str )
{ {
wchar_t *escaped_str = escape( str, 1 ); wchar_t *escaped_str = escape( str, 1 );
wchar_t *cmd = wcsdupcat2(L"echo ", escaped_str, L"|xsel -b",(void *)0); wchar_t *cmd = wcsdupcat2(L"echo ", escaped_str, L"|xsel -b",(void *)0);
exec_subshell( cmd, 0 ); if( exec_subshell( cmd, 0 ) == -1 )
{
/*
Do nothing on failiure
*/
}
free( cut_buffer ); free( cut_buffer );
free( cmd ); free( cmd );
@ -192,7 +198,8 @@ static void kill_check_x_buffer()
wchar_t *new_cut_buffer=0; wchar_t *new_cut_buffer=0;
array_list_t list; array_list_t list;
al_init( &list ); al_init( &list );
exec_subshell( cmd, &list ); if( exec_subshell( cmd, &list ) != -1 )
{
for( i=0; i<al_get_count( &list ); i++ ) for( i=0; i<al_get_count( &list ); i++ )
{ {
@ -237,6 +244,7 @@ static void kill_check_x_buffer()
kill_add_internal( cut_buffer ); kill_add_internal( cut_buffer );
} }
} }
}
al_foreach( &list, &free ); al_foreach( &list, &free );
al_destroy( &list ); al_destroy( &list );

View File

@ -878,7 +878,13 @@ static int parse_util_load_internal( const wchar_t *cmd,
/* /*
Source the completion file for the specified completion Source the completion file for the specified completion
*/ */
exec_subshell( src_cmd, 0 ); if( exec_subshell( src_cmd, 0 ) == -1 )
{
/*
Do nothing on failiure
*/
}
free(src_cmd); free(src_cmd);
reloaded = 1; reloaded = 1;
} }

View File

@ -2910,7 +2910,7 @@ int parser_test( const wchar_t * buff,
*/ */
if( contains_str( cmd, if( contains_str( cmd,
L"end", L"end",
0 ) ) (void *)0 ) )
{ {
err=1; err=1;
if( out ) if( out )
@ -2985,7 +2985,7 @@ int parser_test( const wchar_t * buff,
if( contains_str( cmd, if( contains_str( cmd,
L"or", L"or",
L"and", L"and",
0 ) ) (void *)0 ) )
{ {
/* /*
'or' and 'and' can not be used inside pipelines 'or' and 'and' can not be used inside pipelines