<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8579">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">main/test: Use ast_cli_completion_add.<br><br>Change-Id: I5133ff2ba4e030f9733fb3d050c863d72a22ae6b<br>---<br>M main/test.c<br>1 file changed, 24 insertions(+), 24 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/79/8579/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/test.c b/main/test.c<br>index f45ad9b..0528baf 100644<br>--- a/main/test.c<br>+++ b/main/test.c<br>@@ -691,40 +691,40 @@<br> return test;<br> }<br> <br>-static char *complete_test_category(const char *line, const char *word, int pos, int state)<br>+static char *complete_test_category(const char *word, int pos)<br> {<br>- int which = 0;<br> int wordlen = strlen(word);<br>- char *ret = NULL;<br> struct ast_test *test;<br> <br> AST_LIST_LOCK(&tests);<br> AST_LIST_TRAVERSE(&tests, test, entry) {<br>- if (!strncasecmp(word, test->info.category, wordlen) && ++which > state) {<br>- ret = ast_strdup(test->info.category);<br>- break;<br>+ if (!strncasecmp(word, test->info.category, wordlen)) {<br>+ if (ast_cli_completion_add(ast_strdup(test->info.category))) {<br>+ break;<br>+ }<br> }<br> }<br> AST_LIST_UNLOCK(&tests);<br>- return ret;<br>+<br>+ return NULL;<br> }<br> <br>-static char *complete_test_name(const char *line, const char *word, int pos, int state, const char *category)<br>+static char *complete_test_name(const char *word, const char *category)<br> {<br>- int which = 0;<br> int wordlen = strlen(word);<br>- char *ret = NULL;<br> struct ast_test *test;<br> <br> AST_LIST_LOCK(&tests);<br> AST_LIST_TRAVERSE(&tests, test, entry) {<br>- if (!test_cat_cmp(test->info.category, category) && (!strncasecmp(word, test->info.name, wordlen) && ++which > state)) {<br>- ret = ast_strdup(test->info.name);<br>- break;<br>+ if (!test_cat_cmp(test->info.category, category) && !strncasecmp(word, test->info.name, wordlen)) {<br>+ if (ast_cli_completion_add(ast_strdup(test->info.name))) {<br>+ break;<br>+ }<br> }<br> }<br> AST_LIST_UNLOCK(&tests);<br>- return ret;<br>+<br>+ return NULL;<br> }<br> <br> /* CLI commands */<br>@@ -749,16 +749,16 @@<br> return NULL;<br> case CLI_GENERATE:<br> if (a->pos == 3) {<br>- return ast_cli_complete(a->word, option1, a->n);<br>+ return ast_cli_complete(a->word, option1, -1);<br> }<br> if (a->pos == 4) {<br>- return complete_test_category(a->line, a->word, a->pos, a->n);<br>+ return complete_test_category(a->word, a->pos);<br> }<br> if (a->pos == 5) {<br>- return ast_cli_complete(a->word, option2, a->n);<br>+ return ast_cli_complete(a->word, option2, -1);<br> }<br> if (a->pos == 6) {<br>- return complete_test_name(a->line, a->word, a->pos, a->n, a->argv[3]);<br>+ return complete_test_name(a->word, a->argv[3]);<br> }<br> return NULL;<br> case CLI_HANDLER:<br>@@ -808,16 +808,16 @@<br> return NULL;<br> case CLI_GENERATE:<br> if (a->pos == 2) {<br>- return ast_cli_complete(a->word, option1, a->n);<br>+ return ast_cli_complete(a->word, option1, -1);<br> }<br> if (a->pos == 3) {<br>- return complete_test_category(a->line, a->word, a->pos, a->n);<br>+ return complete_test_category(a->word, a->pos);<br> }<br> if (a->pos == 4) {<br>- return ast_cli_complete(a->word, option2, a->n);<br>+ return ast_cli_complete(a->word, option2, -1);<br> }<br> if (a->pos == 5) {<br>- return complete_test_name(a->line, a->word, a->pos, a->n, a->argv[3]);<br>+ return complete_test_name(a->word, a->argv[3]);<br> }<br> return NULL;<br> case CLI_HANDLER:<br>@@ -877,7 +877,7 @@<br> return NULL;<br> case CLI_GENERATE:<br> if (a->pos == 3) {<br>- return ast_cli_complete(a->word, option1, a->n);<br>+ return ast_cli_complete(a->word, option1, -1);<br> }<br> return NULL;<br> case CLI_HANDLER:<br>@@ -950,7 +950,7 @@<br> return NULL;<br> case CLI_GENERATE:<br> if (a->pos == 3) {<br>- return ast_cli_complete(a->word, option, a->n);<br>+ return ast_cli_complete(a->word, option, -1);<br> }<br> return NULL;<br> case CLI_HANDLER:<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8579">change 8579</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8579"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I5133ff2ba4e030f9733fb3d050c863d72a22ae6b </div>
<div style="display:none"> Gerrit-Change-Number: 8579 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>