summaryrefslogtreecommitdiff
path: root/pico/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'pico/file.c')
-rw-r--r--pico/file.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pico/file.c b/pico/file.c
index 149971f0..1b41f181 100644
--- a/pico/file.c
+++ b/pico/file.c
@@ -1016,7 +1016,7 @@ int
pico_fncomplete(char *dirarg, char *fn, size_t fnlen)
{
char *p, *dlist, tmp[NLINE], dir[NLINE];
- int n, i, match = -1;
+ int n, i, match = -1, orign;
#ifdef DOS
#define FILECMP(x, y) (toupper((unsigned char)(x))\
== toupper((unsigned char)(y)))
@@ -1027,9 +1027,16 @@ pico_fncomplete(char *dirarg, char *fn, size_t fnlen)
strncpy(dir, dirarg, sizeof(dir));
dir[sizeof(dir)-1] = '\0';
pfnexpand(dir, sizeof(dir));
- if(*fn && (dlist = p = getfnames(dir, fn, &n, NULL, 0))){
+ if((dlist = p = getfnames(dir, fn, &n, NULL, 0))){
+ orign = n;
memset(tmp, 0, sizeof(tmp));
while(n--){ /* any names in it */
+ if(strcmp(p, ".") == 0 || strcmp(p, "..") == 0){
+ p += strlen(p) + 1;
+ orign--;
+ continue;
+ }
+
for(i = 0; i < sizeof(tmp)-1 && fn[i] && FILECMP(p[i], fn[i]); i++)
;
@@ -1054,6 +1061,9 @@ pico_fncomplete(char *dirarg, char *fn, size_t fnlen)
free(dlist);
}
+ if(fn[0] == '\0' && orign != 1)
+ match = -1;
+
if(match >= 0){
strncpy(fn, tmp, fnlen);
fn[fnlen-1] = '\0';