diff options
author | Volker Lendecke <vl@samba.org> | 2010-02-18 22:52:41 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-02-20 18:59:30 +0100 |
commit | 2beaa190295bc6e4c9e7f8a3768c74ad0a4359fe (patch) | |
tree | 3be8bffc16f48d61cc6f2a83720df9ed86496174 /source3/client | |
parent | 48d6ed7cac1e948b604ff44eee3528c396d5ecef (diff) | |
download | samba-2beaa190295bc6e4c9e7f8a3768c74ad0a4359fe.tar.gz samba-2beaa190295bc6e4c9e7f8a3768c74ad0a4359fe.tar.bz2 samba-2beaa190295bc6e4c9e7f8a3768c74ad0a4359fe.zip |
s3: Slightly simplify the logic of completion_remote_filter
Diffstat (limited to 'source3/client')
-rw-r--r-- | source3/client/client.c | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 9245428c5e..f275dddd8b 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -4176,53 +4176,59 @@ static void completion_remote_filter(const char *mnt, { struct completion_remote *info = (struct completion_remote *)state; - if ((info->count < MAX_COMPLETIONS - 1) && - (strncmp(info->text, f->name, info->len) == 0) && - (strcmp(f->name, ".") != 0) && - (strcmp(f->name, "..") != 0)) { - if ((info->dirmask[0] == 0) && !(f->mode & aDIR)) - info->matches[info->count] = SMB_STRDUP(f->name); - else { - TALLOC_CTX *ctx = talloc_stackframe(); - char *tmp; - - tmp = talloc_strdup(ctx,info->dirmask); - if (!tmp) { - TALLOC_FREE(ctx); - return; - } - tmp = talloc_asprintf_append(tmp, "%s", f->name); - if (!tmp) { - TALLOC_FREE(ctx); - return; - } - if (f->mode & aDIR) { - tmp = talloc_asprintf_append(tmp, "%s", CLI_DIRSEP_STR); - } - if (!tmp) { - TALLOC_FREE(ctx); - return; - } - info->matches[info->count] = SMB_STRDUP(tmp); + if (info->count >= MAX_COMPLETIONS - 1) { + return; + } + if (strncmp(info->text, f->name, info->len) != 0) { + return; + } + if (ISDOT(f->name) || ISDOTDOT(f->name)) { + return; + } + + if ((info->dirmask[0] == 0) && !(f->mode & aDIR)) + info->matches[info->count] = SMB_STRDUP(f->name); + else { + TALLOC_CTX *ctx = talloc_stackframe(); + char *tmp; + + tmp = talloc_strdup(ctx,info->dirmask); + if (!tmp) { TALLOC_FREE(ctx); + return; } - if (info->matches[info->count] == NULL) { + tmp = talloc_asprintf_append(tmp, "%s", f->name); + if (!tmp) { + TALLOC_FREE(ctx); return; } if (f->mode & aDIR) { - smb_readline_ca_char(0); + tmp = talloc_asprintf_append(tmp, "%s", + CLI_DIRSEP_STR); } - if (info->count == 1) { - info->samelen = strlen(info->matches[info->count]); - } else { - while (strncmp(info->matches[info->count], - info->matches[info->count-1], - info->samelen) != 0) { - info->samelen--; - } + if (!tmp) { + TALLOC_FREE(ctx); + return; + } + info->matches[info->count] = SMB_STRDUP(tmp); + TALLOC_FREE(ctx); + } + if (info->matches[info->count] == NULL) { + return; + } + if (f->mode & aDIR) { + smb_readline_ca_char(0); + } + if (info->count == 1) { + info->samelen = strlen(info->matches[info->count]); + } else { + while (strncmp(info->matches[info->count], + info->matches[info->count-1], + info->samelen) != 0) { + info->samelen--; } - info->count++; } + info->count++; } static char **remote_completion(const char *text, int len) |