aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-19 19:35:16 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-19 19:35:16 +0000
commitb474b62f4a076678653839da4c72075407d5430d (patch)
tree3ac0ff04c689b5d5a53bdf77aca20ab8861280d8
parent52c9e41ded7768d4050c2500b2022f01c7c9fa98 (diff)
Fix tab completion when you just do a plain tab without entering anything, and also fix show application tab completion. (issue #7089 reported by blitzrage)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@28792 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--cli.c9
-rw-r--r--pbx.c4
2 files changed, 9 insertions, 4 deletions
diff --git a/cli.c b/cli.c
index 0c5e84088..491472231 100644
--- a/cli.c
+++ b/cli.c
@@ -1313,7 +1313,7 @@ static char *__ast_cli_generator(const char *text, const char *word, int state,
int matchnum=0;
char *ret = NULL;
char matchstr[80] = "";
- int tws;
+ int tws = 0;
char *dup = parse_args(text, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws);
if (!dup) /* error */
@@ -1321,9 +1321,12 @@ static char *__ast_cli_generator(const char *text, const char *word, int state,
argindex = (!ast_strlen_zero(word) && x>0) ? x-1 : x;
/* rebuild the command, ignore tws */
ast_join(matchstr, sizeof(matchstr)-1, argv);
- if (tws)
- strcat(matchstr, " "); /* XXX */
matchlen = strlen(matchstr);
+ if (tws) {
+ strcat(matchstr, " "); /* XXX */
+ if (matchlen)
+ matchlen++;
+ }
if (lock)
AST_LIST_LOCK(&helpers);
while( !ret && (e = cli_next(&i)) ) {
diff --git a/pbx.c b/pbx.c
index 1a5f6f4c4..d1e202866 100644
--- a/pbx.c
+++ b/pbx.c
@@ -2864,8 +2864,10 @@ static char *complete_show_application(const char *line, const char *word, int p
/* return the n-th [partial] matching entry */
AST_LIST_LOCK(&apps);
AST_LIST_TRAVERSE(&apps, a, list) {
- if (!strncasecmp(word, a->name, wordlen) && ++which > state)
+ if (!strncasecmp(word, a->name, wordlen) && ++which > state) {
ret = strdup(a->name);
+ break;
+ }
}
AST_LIST_UNLOCK(&apps);