summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-11-09 01:39:13 -0500
committerCorey Farrell <git@cfware.com>2017-11-21 09:47:38 -0500
commit115f53a0fb19138f07ca0c03f06f4a557d663f1f (patch)
tree64f76356762f8da8752789e85ba1f739473007b7 /main
parent0fd8db7ec24abfd84a4d9a87b7e677b06bf83e39 (diff)
CLI: Remove calls to ast_cli_generator.
The ability to add to localized storage cannot be supported by ast_cli_generator. The only calls to ast_cli_generator should be by functions that need to proxy the CLI generator, for example 'cli check permissions' or 'core show help'. * ast_cli_generatornummatches now retrieves the vector of matches and reports the number of elements (not including 'best' match). * test_substitution retrieves and iterates the vector. Change-Id: I8cd6b93905363cf7a33a2d2b0e2a8f8446d9f248
Diffstat (limited to 'main')
-rw-r--r--main/cli.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/main/cli.c b/main/cli.c
index f3411860c..94ea95956 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -2463,18 +2463,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;
}