From: Russell Bryant Date: Tue, 27 Dec 2005 17:24:54 +0000 (+0000) Subject: when doing tab completion, iterate the list of matches to count how many there X-Git-Tag: 1.4.0-beta1~3125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f737171889d78806140a343c8ef47a340d18d3e;p=thirdparty%2Fasterisk.git when doing tab completion, iterate the list of matches to count how many there are instead of having the list of matches generated twice (issue #6066) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7655 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/asterisk.c b/asterisk.c index 54c9405fbf..11363c8514 100644 --- a/asterisk.c +++ b/asterisk.c @@ -1602,12 +1602,13 @@ static char *cli_complete(EditLine *el, int ch) free(mbuf); } else matches = (char **) NULL; - - } else { - - nummatches = ast_cli_generatornummatches((char *)lf->buffer,ptr); + char **p; + int count = 0; matches = ast_cli_completion_matches((char *)lf->buffer,ptr); + for (p = matches; p && *p; p++) + count++; + nummatches = count - 1; /* XXX apparently there is one dup ? */ } if (matches) { @@ -1641,7 +1642,7 @@ static char *cli_complete(EditLine *el, int ch) retval = CC_REFRESH; } } - free(matches); + free(matches); } return (char *)(long)retval;