From 4683f4c989e90bf49fc8199d7f22c925aee836cd Mon Sep 17 00:00:00 2001 From: axel Date: Fri, 20 Oct 2006 01:36:03 +1000 Subject: [PATCH] Fix a number of bugs found using the warnings generated by earlier patch darcs-hash:20061019153603-ac50b-4efb1ad1fe2cbe693a921648a0616a3d258d7933.gz --- complete.c | 229 ++++++++++++++++++++++++++------------------------- exec.c | 12 ++- expand.c | 7 +- history.c | 2 +- input.c | 3 +- kill.c | 78 ++++++++++-------- parse_util.c | 8 +- parser.c | 4 +- 8 files changed, 188 insertions(+), 155 deletions(-) diff --git a/complete.c b/complete.c index 69c7748f0..eb8e3ac6e 100644 --- a/complete.c +++ b/complete.c @@ -909,24 +909,26 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig ) array_list_t l; al_init( &l ); - exec_subshell( cmd, &l ); - free(cmd); - - if( al_get_count( &l )>0 ) + if( exec_subshell( cmd, &l ) != -1 ) { - wchar_t *ln = (wchar_t *)al_get(&l, 0 ); - if( wcscmp( ln, L"unknown" ) != 0 ) + + if( al_get_count( &l )>0 ) { - desc = wcsdup( ln); - /* - I have decided I prefer to have the description - begin in uppercase and the whole universe will just - have to accept it. Hah! - */ - desc[0]=towupper(desc[0]); + wchar_t *ln = (wchar_t *)al_get(&l, 0 ); + if( wcscmp( ln, L"unknown" ) != 0 ) + { + desc = wcsdup( ln); + /* + I have decided I prefer to have the description + begin in uppercase and the whole universe will just + have to accept it. Hah! + */ + desc[0]=towupper(desc[0]); + } } } - + + free(cmd); al_foreach( &l, &free ); al_destroy( &l ); } @@ -1155,79 +1157,82 @@ 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 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 - the result into a hashtable with the completion as key and the - description as value. - - Should be reasonably fast, since no memory allocations are needed. - */ - for( i=0; i