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

Jenkins2 asteriskteam at digium.com
Tue Mar 20 07:58:00 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8599 )

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

main/translate: Use ast_cli_completion_add.

Change-Id: I0e2402660e54d91f74ab0804c62a5b1925577413
---
M main/translate.c
1 file changed, 10 insertions(+), 8 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/translate.c b/main/translate.c
index 226d098..396c552 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -900,9 +900,9 @@
 	return ast_str_buffer(*str);
 }
 
-static char *complete_trans_path_choice(const char *line, const char *word, int pos, int state)
+static char *complete_trans_path_choice(const char *word)
 {
-	int i = 1, which = 0;
+	int i = 1;
 	int wordlen = strlen(word);
 	struct ast_codec *codec;
 
@@ -912,13 +912,15 @@
 			ao2_ref(codec, -1);
 			continue;
 		}
-		if (!strncasecmp(word, codec->name, wordlen) && ++which > state) {
-			char *res = ast_strdup(codec->name);
-			ao2_ref(codec, -1);
-			return res;
+		if (!strncasecmp(word, codec->name, wordlen)) {
+			if (ast_cli_completion_add(ast_strdup(codec->name))) {
+				ao2_ref(codec, -1);
+				break;
+			}
 		}
 		ao2_ref(codec, -1);
 	}
+
 	return NULL;
 }
 
@@ -1138,10 +1140,10 @@
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 3) {
-			return ast_cli_complete(a->word, option, a->n);
+			return ast_cli_complete(a->word, option, -1);
 		}
 		if (a->pos == 4 && !strcasecmp(a->argv[3], option[1])) {
-			return complete_trans_path_choice(a->line, a->word, a->pos, a->n);
+			return complete_trans_path_choice(a->word);
 		}
 		/* BUGBUG - add tab completion for sample rates */
 		return NULL;

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0e2402660e54d91f74ab0804c62a5b1925577413
Gerrit-Change-Number: 8599
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180320/4b8d2bb8/attachment.html>


More information about the asterisk-code-review mailing list