mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Merge "CLI: Fix remote console completion." into 13
This commit is contained in:
@@ -3133,19 +3133,26 @@ static char *cli_prompt(EditLine *editline)
|
||||
static struct ast_vector_string *ast_el_strtoarr(char *buf)
|
||||
{
|
||||
char *retstr;
|
||||
char *bestmatch;
|
||||
struct ast_vector_string *vec = ast_calloc(1, sizeof(*vec));
|
||||
|
||||
if (!vec) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* bestmatch must not be deduplicated */
|
||||
bestmatch = strsep(&buf, " ");
|
||||
if (!bestmatch || !strcmp(bestmatch, AST_CLI_COMPLETE_EOF)) {
|
||||
goto vector_cleanup;
|
||||
}
|
||||
|
||||
while ((retstr = strsep(&buf, " "))) {
|
||||
if (!strcmp(retstr, AST_CLI_COMPLETE_EOF)) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Older daemons sent duplicates. */
|
||||
if (AST_VECTOR_GET_CMP(vec, retstr, strcasecmp)) {
|
||||
if (AST_VECTOR_GET_CMP(vec, retstr, !strcasecmp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3157,7 +3164,9 @@ static struct ast_vector_string *ast_el_strtoarr(char *buf)
|
||||
}
|
||||
}
|
||||
|
||||
if (!AST_VECTOR_SIZE(vec)) {
|
||||
bestmatch = ast_strdup(bestmatch);
|
||||
if (!bestmatch || AST_VECTOR_INSERT_AT(vec, 0, bestmatch)) {
|
||||
ast_free(bestmatch);
|
||||
goto vector_cleanup;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user