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
This commit is contained in:
axel 2006-01-21 12:52:06 +10:00
parent e55bd063eb
commit f3c93c1690
2 changed files with 17 additions and 11 deletions

View file

@ -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;

View file

@ -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
{