aboutsummaryrefslogtreecommitdiffhomepage
path: root/wildcard.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-04-17 07:06:05 +1000
committerGravatar axel <axel@liljencrantz.se>2007-04-17 07:06:05 +1000
commit87223c68f4df8aa4de7256be398569bc957fed2f (patch)
tree07bccec4bb3ab651ef4738e3da85c78a5c3d484c /wildcard.c
parent5c9570eb56126dda8f5319f94924a0b1b9e498ce (diff)
Fix bug where case insensitive completions would miss the leading slash in file completions. This bug was reported by Claes Nästén.
darcs-hash:20070416210605-ac50b-eb1bc315ec360f8ccd5f37194c274796be97c607.gz
Diffstat (limited to 'wildcard.c')
-rw-r--r--wildcard.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/wildcard.c b/wildcard.c
index 150fce39..41f8f1b6 100644
--- a/wildcard.c
+++ b/wildcard.c
@@ -1189,35 +1189,36 @@ int wildcard_expand( const wchar_t *wc,
if( flags & ACCEPT_INCOMPLETE )
{
- wchar_t *wc_base;
+ wchar_t *wc_base=L"";
wchar_t *wc_base_ptr = wcsrchr( wc, L'/' );
+ string_buffer_t sb;
+
if( wc_base_ptr )
{
- string_buffer_t sb;
-
- sb_init( &sb );
wc_base = wcsndup( wc, (wc_base_ptr-wc)+1 );
+ }
+
+ sb_init( &sb );
+
+ for( i=c; i<al_get_count( out ); i++ )
+ {
+ completion_t *c = al_get( out, i );
- for( i=c; i<al_get_count( out ); i++ )
+ if( c->flags & COMPLETE_NO_CASE )
{
- completion_t *c = al_get( out, i );
-
- if( c->flags & COMPLETE_NO_CASE )
- {
- sb_clear( &sb );
- sb_printf( &sb, L"%ls%ls", wc_base, c->completion );
-
- c->completion = halloc_wcsdup( out, (wchar_t *)sb.buff );
- }
+ sb_clear( &sb );
+ sb_printf( &sb, L"%ls%ls%ls", base_dir, wc_base, c->completion );
+
+ c->completion = halloc_wcsdup( out, (wchar_t *)sb.buff );
}
-
- sb_destroy( &sb );
- free( wc_base );
-
}
+ sb_destroy( &sb );
+
+ if( wc_base_ptr )
+ free( wc_base );
+
}
-
return res;
}