[Asterisk-code-review] main/taskprocessor: Use ast cli completion add. (asterisk[13])

Corey Farrell asteriskteam at digium.com
Sun Mar 18 21:36:10 CDT 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8598


Change subject: main/taskprocessor: Use ast_cli_completion_add.
......................................................................

main/taskprocessor: Use ast_cli_completion_add.

Change-Id: Ie5f812a988ed811fd11967151932de62bc131b48
---
M main/taskprocessor.c
1 file changed, 9 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/98/8598/1

diff --git a/main/taskprocessor.c b/main/taskprocessor.c
index a464ada..7577715 100644
--- a/main/taskprocessor.c
+++ b/main/taskprocessor.c
@@ -343,26 +343,27 @@
 static char *tps_taskprocessor_tab_complete(struct ast_cli_args *a)
 {
 	int tklen;
-	int wordnum = 0;
 	struct ast_taskprocessor *p;
-	char *name = NULL;
 	struct ao2_iterator i;
 
-	if (a->pos != 3)
+	if (a->pos != 3) {
 		return NULL;
+	}
 
 	tklen = strlen(a->word);
 	i = ao2_iterator_init(tps_singletons, 0);
 	while ((p = ao2_iterator_next(&i))) {
-		if (!strncasecmp(a->word, p->name, tklen) && ++wordnum > a->n) {
-			name = ast_strdup(p->name);
-			ast_taskprocessor_unreference(p);
-			break;
+		if (!strncasecmp(a->word, p->name, tklen)) {
+			if (ast_cli_completion_add(ast_strdup(p->name))) {
+				ast_taskprocessor_unreference(p);
+				break;
+			}
 		}
 		ast_taskprocessor_unreference(p);
 	}
 	ao2_iterator_destroy(&i);
-	return name;
+
+	return NULL;
 }
 
 /* ping task handling function */

-- 
To view, visit https://gerrit.asterisk.org/8598
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5f812a988ed811fd11967151932de62bc131b48
Gerrit-Change-Number: 8598
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180318/e3717638/attachment.html>


More information about the asterisk-code-review mailing list