<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7336">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">CLI: Refactor ast_cli_display_match_list.<br><br>* Stop estimating line count, just print until we run out of matches.<br>* Stop freeing entries, the caller does that anyways.<br>* Stop calculating / returning numoutput, it was ignored.<br><br>Change-Id: I7f92afa8bea92241a95227587367424c8c32a5cb<br>---<br>M main/asterisk.c<br>1 file changed, 15 insertions(+), 29 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/asterisk.c b/main/asterisk.c<br>index c4ed909..fbb2e77 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -3079,51 +3079,37 @@<br> return strcasecmp(s1, s2);<br> }<br> <br>-static int ast_cli_display_match_list(char **matches, int len, int max)<br>+static void ast_cli_display_match_list(char **matches, int len, int max)<br> {<br>- int i, idx, limit, count;<br>- int screenwidth = 0;<br>- int numoutput = 0, numoutputline = 0;<br>-<br>- screenwidth = ast_get_termcols(STDOUT_FILENO);<br>-<br>+ int idx = 1;<br> /* find out how many entries can be put on one line, with two spaces between strings */<br>- limit = screenwidth / (max + 2);<br>- if (limit == 0)<br>+ int limit = ast_get_termcols(STDOUT_FILENO) / (max + 2);<br>+<br>+ if (limit == 0) {<br> limit = 1;<br>-<br>- /* how many lines of output */<br>- count = len / limit;<br>- if (count * limit < len)<br>- count++;<br>-<br>- idx = 1;<br>+ }<br> <br> qsort(&matches[0], (size_t)(len), sizeof(char *), ast_el_sort_compare);<br> <br>- for (; count > 0; count--) {<br>- numoutputline = 0;<br>- for (i = 0; i < limit && matches[idx]; i++, idx++) {<br>+ for (;;) {<br>+ int numoutputline;<br> <br>+ for (numoutputline = 0; numoutputline < limit && matches[idx]; idx++) {<br> /* Don't print dupes */<br> if ( (matches[idx+1] != NULL && strcmp(matches[idx], matches[idx+1]) == 0 ) ) {<br>- i--;<br>- ast_free(matches[idx]);<br>- matches[idx] = NULL;<br> continue;<br> }<br> <br>- numoutput++;<br> numoutputline++;<br> fprintf(stdout, "%-*s ", max, matches[idx]);<br>- ast_free(matches[idx]);<br>- matches[idx] = NULL;<br> }<br>- if (numoutputline > 0)<br>- fprintf(stdout, "\n");<br>- }<br> <br>- return numoutput;<br>+ if (!numoutputline) {<br>+ break;<br>+ }<br>+<br>+ fprintf(stdout, "\n");<br>+ }<br> }<br> <br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7336">change 7336</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/7336"/><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: merged </div>
<div style="display:none"> Gerrit-Change-Id: I7f92afa8bea92241a95227587367424c8c32a5cb </div>
<div style="display:none"> Gerrit-Change-Number: 7336 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </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: Kevin Harwell <kharwell@digium.com> </div>