Fix CLI breakage
authorMark Spencer <markster@digium.com>
Sat, 7 Jan 2006 15:17:10 +0000 (15:17 +0000)
committerMark Spencer <markster@digium.com>
Sat, 7 Jan 2006 15:17:10 +0000 (15:17 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7851 65c4cc65-6c06-0410-ace0-fbb531ad65f3

asterisk.c

index 11363c8..2e47563 100644 (file)
@@ -1511,7 +1511,7 @@ static int ast_cli_display_match_list(char **matches, int len, int max)
 
        idx = 1;
 
-       qsort(&matches[0], (size_t)(len + 1), sizeof(char *), ast_el_sort_compare);
+       qsort(&matches[0], (size_t)(len), sizeof(char *), ast_el_sort_compare);
 
        for (; count > 0; count--) {
                numoutputline = 0;
@@ -1603,12 +1603,14 @@ static char *cli_complete(EditLine *el, int ch)
                } else
                        matches = (char **) NULL;
        } else {
-               char **p;
-               int count = 0;
+               char **p, *oldbuf=NULL;
+               nummatches = 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 ? */
+               for (p = matches; p && *p; p++) {
+                       if (!oldbuf || strcmp(*p,oldbuf))
+                               nummatches++;
+                       oldbuf = *p;
+               }
        }
 
        if (matches) {