diff --git a/complete.cpp b/complete.cpp index 9b745dfcd..019950f0b 100644 --- a/complete.cpp +++ b/complete.cpp @@ -913,9 +913,6 @@ static void complete_cmd_desc( const wchar_t *cmd, std::vector &co { const wchar_t *cmd_start; int cmd_len; - wchar_t *lookup_cmd=0; - array_list_t list; - hash_table_t lookup; wchar_t *esc; int skip; @@ -964,14 +961,10 @@ static void complete_cmd_desc( const wchar_t *cmd, std::vector &co } - esc = escape( cmd_start, 1 ); - - lookup_cmd = wcsdupcat( L"__fish_describe_command ", esc ); - free(esc); - - al_init( &list ); - hash_init( &lookup, &hash_wcs_func, &hash_wcs_cmp ); + wcstring lookup_cmd(L"__fish_describe_command "); + lookup_cmd.append(escape_string(cmd_start, 1)); + std::map lookup; /* First locate a list of possible descriptions using a single @@ -980,7 +973,8 @@ static void complete_cmd_desc( const wchar_t *cmd, std::vector &co systems with a large set of manuals, but it should be ok since apropos is only called once. */ - if( exec_subshell( lookup_cmd, &list ) != -1 ) + wcstring_list_t list; + if( exec_subshell2( lookup_cmd, list ) != -1 ) { /* @@ -990,31 +984,28 @@ static void complete_cmd_desc( const wchar_t *cmd, std::vector &co Should be reasonably fast, since no memory allocations are needed. */ - for( int i=0; i &co */ for( size_t i=0; i::iterator new_desc_iter = lookup.find(el); + if (new_desc_iter != lookup.end()) + completion.description = new_desc_iter->second; } } - hash_destroy( &lookup ); - al_foreach( &list, - &free ); - al_destroy( &list ); - free( lookup_cmd ); } /** @@ -1158,8 +1139,6 @@ static void complete_cmd( const wchar_t *cmd, These return the original strings - don't free them */ -// al_init( &possible_comp ); - if( use_function ) { //function_get_names( &possible_comp, cmd[0] == L'_' ); diff --git a/complete.h b/complete.h index daf95d408..ed1528852 100644 --- a/complete.h +++ b/complete.h @@ -146,8 +146,7 @@ public: bool operator < (const completion_t& rhs) const { return this->completion < rhs.completion; } bool operator == (const completion_t& rhs) const { return this->completion == rhs.completion; } bool operator != (const completion_t& rhs) const { return ! (*this == rhs); } -} -; +}; /**