diff --git a/complete.c b/complete.c index 15e545058..d3fa45299 100644 --- a/complete.c +++ b/complete.c @@ -895,6 +895,7 @@ static const wchar_t *complete_get_desc_suffix( const wchar_t *suff_orig ) const wchar_t *complete_get_desc( const wchar_t *filename ) { struct stat buf; + if( !get_desc_buff ) { get_desc_buff = malloc(sizeof(string_buffer_t) ); @@ -971,21 +972,21 @@ const wchar_t *complete_get_desc( const wchar_t *filename ) if( wcslen((wchar_t *)get_desc_buff->buff) == 0 ) { wchar_t *suffix = wcsrchr( filename, L'.' ); - if( suffix != 0 ) + if( suffix != 0 && !wcsrchr( suffix, L'/' ) ) { - if( !wcsrchr( suffix, L'/' ) ) - { - sb_printf( get_desc_buff, - L"%lc%ls", - COMPLETE_SEP, - complete_get_desc_suffix( suffix ) ); - } + sb_printf( get_desc_buff, + L"%lc%ls", + COMPLETE_SEP, + complete_get_desc_suffix( suffix ) ); } else + { sb_printf( get_desc_buff, L"%lc%ls", COMPLETE_SEP, - COMPLETE_FILE_DESC ); + COMPLETE_FILE_DESC ); + } + } return (wchar_t *)get_desc_buff->buff; diff --git a/wildcard.c b/wildcard.c index 4a519e975..e76eeeebb 100644 --- a/wildcard.c +++ b/wildcard.c @@ -278,10 +278,15 @@ void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd ) } desc = complete_get_desc( fn ); - + + if( wcschr( desc, COMPLETE_SEP )==0 ) + { + sb_append( sb, COMPLETE_SEP_STR ); + } + if( sz >= 0 && S_ISDIR(buf.st_mode) ) { - sb_append2( sb, desc, (void *)0 ); + sb_append( sb, desc ); } else {