diff options
author | George Joseph <gjoseph@digium.com> | 2017-11-27 12:11:18 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-11-27 12:11:18 -0600 |
commit | 93dba6f39670d3b39e05831fa685698227b8c7f3 (patch) | |
tree | 5aae634ca53c0ab09e5ae4e5fbc9319d096abdd6 /main | |
parent | 2e4a8f00362b2c0df3a9d811a97e7649f5fa1b10 (diff) | |
parent | a02cbc2ef3903c68737fddee79d8db1d66623ab4 (diff) |
Merge "CLI: Remove calls to ast_cli_generator."
Diffstat (limited to 'main')
-rw-r--r-- | main/cli.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/main/cli.c b/main/cli.c index eae14adc4..1653838ea 100644 --- a/main/cli.c +++ b/main/cli.c @@ -2475,18 +2475,17 @@ static char *parse_args(const char *s, int *argc, const char *argv[], int max, i /*! \brief Return the number of unique matches for the generator */ int ast_cli_generatornummatches(const char *text, const char *word) { - int matches = 0, i = 0; - char *buf = NULL, *oldbuf = NULL; - - while ((buf = ast_cli_generator(text, word, i++))) { - if (!oldbuf || strcmp(buf,oldbuf)) - matches++; - if (oldbuf) - ast_free(oldbuf); - oldbuf = buf; - } - if (oldbuf) - ast_free(oldbuf); + int matches; + struct ast_vector_string *vec = ast_cli_completion_vector(text, word); + + if (!vec) { + return 0; + } + + matches = AST_VECTOR_SIZE(vec) - 1; + AST_VECTOR_CALLBACK_VOID(vec, ast_free); + AST_VECTOR_PTR_FREE(vec); + return matches; } |