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 */
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)) ) {
/* 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);