diff options
author | axel <axel@liljencrantz.se> | 2006-01-13 00:49:03 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-01-13 00:49:03 +1000 |
commit | 16cb9dfa052a261b76840702cd979c04bc4b0a4b (patch) | |
tree | e7f603ecb098b73805450a9f555ca534f13b6169 /complete.c | |
parent | 10fec8abb609cf2d554de89584089917019980ad (diff) |
Improve description handling - handle symbolic link loops, handle description functions returning strings without a separator, and handle testing of un-stat:able files
darcs-hash:20060112144903-ac50b-9766abfa212b2eaf61509a65499df0018562b5d9.gz
Diffstat (limited to 'complete.c')
-rw-r--r-- | complete.c | 51 |
1 files changed, 26 insertions, 25 deletions
@@ -90,6 +90,10 @@ */ #define COMPLETE_ROTTEN_SYMLINK_DESC _( L"Rotten symbolic link" ) /** + Description for symlink loop +*/ +#define COMPLETE_LOOP_SYMLINK_DESC _( L"Symbolic link loop" ) +/** Description for socket */ #define COMPLETE_SOCKET_DESC _( L"Socket" ) @@ -938,7 +942,16 @@ const wchar_t *complete_get_desc( const wchar_t *filename ) break; default: - wperror( L"stat" ); + if( errno == ELOOP ) + { + sb_printf( get_desc_buff, L"%lc%ls", COMPLETE_SEP, COMPLETE_LOOP_SYMLINK_DESC ); + } + + /* + Some kind of broken symlink. We ignore it + here, and it will get a 'file' description, + or one based on suffix. + */ break; } } @@ -954,21 +967,6 @@ const wchar_t *complete_get_desc( const wchar_t *filename ) } } -/* else - { - - switch( errno ) - { - case EACCES: - break; - - default: - fprintf( stderr, L"The following error happened on file %ls\n", filename ); - wperror( L"lstat" ); - break; - } - } -*/ if( wcslen((wchar_t *)get_desc_buff->buff) == 0 ) { @@ -1332,16 +1330,19 @@ static void complete_cmd( const wchar_t *cmd, { wchar_t *nxt = (wchar_t *)al_get( &tmp, i ); - wchar_t *desc = wcsrchr( nxt, COMPLETE_SEP )+1; - int is_valid = (desc && (wcscmp(desc, - COMPLETE_DIRECTORY_DESC)==0)); - if( is_valid ) + wchar_t *desc = wcsrchr( nxt, COMPLETE_SEP ); + if( desc ) { - al_push( comp, nxt ); - } - else - { - free(nxt); + int is_valid = desc && (wcscmp(desc+1, + COMPLETE_DIRECTORY_DESC)==0); + if( is_valid ) + { + al_push( comp, nxt ); + } + else + { + free(nxt); + } } } } |