aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--complete.c33
-rw-r--r--wildcard.c30
2 files changed, 23 insertions, 40 deletions
diff --git a/complete.c b/complete.c
index 028cf86d..caaabf3b 100644
--- a/complete.c
+++ b/complete.c
@@ -1389,8 +1389,6 @@ static void complete_cmd( const wchar_t *cmd,
nxt_path != 0;
nxt_path = wcstok( 0, ARRAY_SEP_STR, &state) )
{
- int i;
- array_list_t tmp;
wchar_t *nxt_completion=
wcsdupcat2( nxt_path,
(nxt_path[wcslen(nxt_path)-1]==L'/'?L"":L"/"),
@@ -1401,36 +1399,15 @@ static void complete_cmd( const wchar_t *cmd,
continue;
}
- al_init( &tmp );
-
if( expand_string( 0,
- nxt_completion,
- &tmp,
+ nxt_completion,
+ comp,
ACCEPT_INCOMPLETE | DIRECTORIES_ONLY ) != EXPAND_ERROR )
{
-
- for( i=0; i<al_get_count(&tmp); i++ )
- {
- wchar_t *nxt = (wchar_t *)al_get( &tmp, i );
-
- wchar_t *desc = wcsrchr( nxt, COMPLETE_SEP );
- if( desc )
- {
- int is_valid = desc && (wcscmp(desc+1,
- COMPLETE_DIRECTORY_DESC)==0);
- if( is_valid )
- {
- al_push( comp, nxt );
- }
- else
- {
- free(nxt);
- }
- }
- }
+ /*
+ Don't care if we fail - completions are just hints
+ */
}
-
- al_destroy( &tmp );
}
}
diff --git a/wildcard.c b/wildcard.c
index 2b0e2ca8..ffce9803 100644
--- a/wildcard.c
+++ b/wildcard.c
@@ -391,22 +391,28 @@ static void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd )
static int test_flags( wchar_t *filename,
int flags )
{
- if( !(flags & EXECUTABLES_ONLY) && !(flags & DIRECTORIES_ONLY) )
- return 1;
-
- struct stat buf;
- if( wstat( filename, &buf ) == -1 )
+ if( flags & DIRECTORIES_ONLY )
{
- return 0;
+ struct stat buf;
+ if( wstat( filename, &buf ) == -1 )
+ {
+ return 0;
+ }
+
+ if( !S_ISDIR( buf.st_mode ) )
+ {
+ return 0;
+ }
}
-
- if( S_ISDIR( buf.st_mode ) )
- return 1;
+
if( flags & EXECUTABLES_ONLY )
- return ( waccess( filename, X_OK ) == 0);
-
- return 0;
+ {
+ if ( waccess( filename, X_OK ) != 0)
+ return 0;
+ }
+
+ return 1;
}