diff options
author | axel <axel@liljencrantz.se> | 2006-01-21 12:52:06 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-01-21 12:52:06 +1000 |
commit | f3c93c16909e8cf7f8d23e5612cdb2148021bcbf (patch) | |
tree | 17c898b0cbd389eae3371e44c631b5fadf17c89a | |
parent | e55bd063eb41c04292e22e50f3d4ce7cdd994b39 (diff) |
Fix two bugs which together caused descriptions to be interpreted as a part of the completion in some rare cases
darcs-hash:20060121025206-ac50b-2bda82d8a9acdcdc9298e9986fbd38696514249f.gz
-rw-r--r-- | complete.c | 19 | ||||
-rw-r--r-- | wildcard.c | 9 |
2 files changed, 17 insertions, 11 deletions
@@ -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; @@ -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 { |