[Asterisk-cvs] asterisk cli.c,1.53.2.10,1.53.2.11
russell
russell
Sun Sep 25 13:29:52 CDT 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv13469
Modified Files:
Tag: v1-0
cli.c
Log Message:
fix incorrect CLI tab completion (issue #5041)
Index: cli.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cli.c,v
retrieving revision 1.53.2.10
retrieving revision 1.53.2.11
diff -u -d -r1.53.2.10 -r1.53.2.11
--- cli.c 24 Sep 2005 21:19:42 -0000 1.53.2.10
+++ cli.c 25 Sep 2005 17:26:52 -0000 1.53.2.11
@@ -756,7 +756,7 @@
return e;
}
-static void join(char *dest, size_t destsize, char *w[])
+static void join(char *dest, size_t destsize, char *w[], int tws)
{
int x;
/* Join words into a string */
@@ -769,6 +769,8 @@
strncat(dest, " ", destsize - strlen(dest) - 1);
strncat(dest, w[x], destsize - strlen(dest) - 1);
}
+ if (tws)
+ strncat(dest, " ", destsize - strlen(dest) - 1);
}
static void join2(char *dest, size_t destsize, char *w[])
@@ -797,7 +799,7 @@
if (!find_cli(myargv, -1))
break;
}
- join(cmdline, sizeof(cmdline), myargv);
+ join(cmdline, sizeof(cmdline), myargv, 0);
return cmdline;
}
@@ -879,12 +881,12 @@
e1 = builtins;
e2 = helpers;
if (match)
- join(matchstr, sizeof(matchstr), match);
+ join(matchstr, sizeof(matchstr), match, 0);
while(e1->cmda[0] || e2) {
if (e2)
- join(fullcmd2, sizeof(fullcmd2), e2->cmda);
+ join(fullcmd2, sizeof(fullcmd2), e2->cmda, 0);
if (e1->cmda[0])
- join(fullcmd1, sizeof(fullcmd1), e1->cmda);
+ join(fullcmd1, sizeof(fullcmd1), e1->cmda, 0);
if (!e1->cmda[0] ||
(e2 && (strcmp(fullcmd2, fullcmd1) < 0))) {
/* Use e2 */
@@ -922,14 +924,14 @@
if (e->usage)
ast_cli(fd, "%s", e->usage);
else {
- join(fullcmd, sizeof(fullcmd), argv+1);
+ join(fullcmd, sizeof(fullcmd), argv+1, 0);
ast_cli(fd, "No help text available for '%s'.\n", fullcmd);
}
} else {
if (find_cli(argv + 1, -1)) {
return help_workhorse(fd, argv + 1);
} else {
- join(fullcmd, sizeof(fullcmd), argv+1);
+ join(fullcmd, sizeof(fullcmd), argv+1, 0);
ast_cli(fd, "No such command '%s'.\n", fullcmd);
}
}
@@ -939,7 +941,7 @@
return RESULT_SUCCESS;
}
-static char *parse_args(char *s, int *argc, char *argv[], int max)
+static char *parse_args(char *s, int *argc, char *argv[], int max, int *trailingwhitespace)
{
char *dup, *cur;
int x = 0;
@@ -947,6 +949,7 @@
int escaped = 0;
int whitespace = 1;
+ *trailingwhitespace = 0;
if (!(dup = strdup(s)))
return NULL;
@@ -994,7 +997,7 @@
*(cur++) = '\0';
argv[x] = NULL;
*argc = x;
-
+ *trailingwhitespace = whitespace;
return dup;
}
@@ -1066,18 +1069,19 @@
char fullcmd2[80] = "";
char matchstr[80];
char *fullcmd = NULL;
+ int tws;
- if ((dup = parse_args(text, &x, argv, sizeof(argv) / sizeof(argv[0])))) {
- join(matchstr, sizeof(matchstr), argv);
+ if ((dup = parse_args(text, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws))) {
+ join(matchstr, sizeof(matchstr), argv, tws);
if (lock)
ast_mutex_lock(&clilock);
e1 = builtins;
e2 = helpers;
while(e1->cmda[0] || e2) {
if (e2)
- join(fullcmd2, sizeof(fullcmd2), e2->cmda);
+ join(fullcmd2, sizeof(fullcmd2), e2->cmda, tws);
if (e1->cmda[0])
- join(fullcmd1, sizeof(fullcmd1), e1->cmda);
+ join(fullcmd1, sizeof(fullcmd1), e1->cmda, tws);
if (!e1->cmda[0] ||
(e2 && (strcmp(fullcmd2, fullcmd1) < 0))) {
/* Use e2 */
@@ -1138,8 +1142,9 @@
struct ast_cli_entry *e;
int x;
char *dup;
+ int tws;
- if ((dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0])))) {
+ if ((dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws))) {
/* We need at least one entry, or ignore */
if (x > 0) {
ast_mutex_lock(&clilock);
More information about the svn-commits
mailing list