diff options
author | George Joseph <gjoseph@digium.com> | 2017-11-27 11:31:24 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-11-27 11:31:24 -0600 |
commit | c34223c958fbdd049917596826c64f4e5cc82e9e (patch) | |
tree | 236782e2337e4b2e8266cdfb19f6ee33fc431030 /main | |
parent | 570ce8206eccebeb5f0b5256baa03dbe7ac6c889 (diff) | |
parent | 369e77d68b2239dd6d791642c4dae8a0a8cf7ddc (diff) |
Merge "CLI: Remove calls to ast_cli_generator." into 15
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; } |