<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8583">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">main/sounds: Use ast_cli_completion_add.<br><br>Change-Id: I140e1137906bbfcdb61c0c6304159be459ad873e<br>---<br>M main/sounds.c<br>1 file changed, 19 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/sounds.c b/main/sounds.c<br>index c792c1b..6fec48e 100644<br>--- a/main/sounds.c<br>+++ b/main/sounds.c<br>@@ -219,6 +219,11 @@<br> /*! \brief Show details about a sound available in the system */<br> static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br> {<br>+     int length;<br>+  struct ao2_iterator it_sounds;<br>+       char *filename;<br>+      struct ao2_container *sound_files;<br>+<br>         switch (cmd) {<br>        case CLI_INIT:<br>                e->command = "core show sound";<br>@@ -227,29 +232,30 @@<br>                   "       Shows information about the specified sound.\n";<br>            return NULL;<br>  case CLI_GENERATE:<br>-   {<br>-            int length = strlen(a->word);<br>-             int which = 0;<br>-               struct ao2_iterator it_sounds;<br>-               char *match = NULL;<br>-          char *filename;<br>-              RAII_VAR(struct ao2_container *, sound_files, ast_media_get_media(sounds_index), ao2_cleanup);<br>+               if (a->pos != 3) {<br>+                        return NULL;<br>+         }<br>+<br>+         sound_files = ast_media_get_media(sounds_index);<br>              if (!sound_files) {<br>                   return NULL;<br>          }<br> <br>+         length = strlen(a->word);<br>          it_sounds = ao2_iterator_init(sound_files, 0);<br>                while ((filename = ao2_iterator_next(&it_sounds))) {<br>-                     if (!strncasecmp(a->word, filename, length) && ++which > a->n) {<br>-                            match = ast_strdup(filename);<br>-                                ao2_ref(filename, -1);<br>-                               break;<br>+                       if (!strncasecmp(a->word, filename, length)) {<br>+                            if (ast_cli_completion_add(ast_strdup(filename))) {<br>+                                  ao2_ref(filename, -1);<br>+                                       break;<br>+                               }<br>                     }<br>                     ao2_ref(filename, -1);<br>                }<br>             ao2_iterator_destroy(&it_sounds);<br>-                return match;<br>-        }<br>+            ao2_ref(sound_files, -1);<br>+<br>+         return NULL;<br>  }<br> <br>  if (a->argc == 4) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8583">change 8583</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/8583"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I140e1137906bbfcdb61c0c6304159be459ad873e </div>
<div style="display:none"> Gerrit-Change-Number: 8583 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>