aboutsummaryrefslogtreecommitdiffhomepage
path: root/wildcard.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-01-13 00:49:03 +1000
committerGravatar axel <axel@liljencrantz.se>2006-01-13 00:49:03 +1000
commit16cb9dfa052a261b76840702cd979c04bc4b0a4b (patch)
treee7f603ecb098b73805450a9f555ca534f13b6169 /wildcard.c
parent10fec8abb609cf2d554de89584089917019980ad (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 'wildcard.c')
-rw-r--r--wildcard.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/wildcard.c b/wildcard.c
index c008d3ab..a6b1d721 100644
--- a/wildcard.c
+++ b/wildcard.c
@@ -150,27 +150,34 @@ static int wildcard_complete_internal( const wchar_t *orig,
sep = wcschr(new, PROG_COMPLETE_SEP );
*sep = COMPLETE_SEP;
}
- else if( desc_func )
- {
- /*
- A descripton generating function is specified, use it
- */
- new = wcsdupcat2( str, COMPLETE_SEP_STR, desc_func( orig ), (void *)0);
- }
else
{
+ wchar_t *this_desc = desc;
+
+ if( desc_func )
+ {
+ /*
+ A descripton generating function is specified, call
+ it. If it returns something, use that as the
+ description.
+ */
+ wchar_t *func_desc = desc_func( orig );
+ if( func_desc )
+ this_desc = func_desc;
+ }
+
/*
- Append generic description to item, if the description exists
+ Append description to item, if a description exists
*/
- if( desc && wcslen(desc) )
+ if( this_desc && wcslen(this_desc) )
{
/*
Check if the description already contains a separator character, if not, prepend it
*/
- if( wcschr( desc, COMPLETE_SEP ) )
- new = wcsdupcat2( str, desc, (void *)0 );
+ if( wcschr( this_desc, COMPLETE_SEP ) )
+ new = wcsdupcat2( str, this_desc, (void *)0 );
else
- new = wcsdupcat2( str, COMPLETE_SEP_STR, desc, (void *)0 );
+ new = wcsdupcat2( str, COMPLETE_SEP_STR, this_desc, (void *)0 );
}
else
new = wcsdup( str );
@@ -328,7 +335,7 @@ static int test_flags( wchar_t *filename,
struct stat buf;
if( wstat( filename, &buf ) == -1 )
{
- return 1;
+ return 0;
}
if( S_IFDIR & buf.st_mode )