summaryrefslogtreecommitdiffstats
path: root/lib/libedit
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-06-15 21:00:53 +0000
committerjilles <jilles@FreeBSD.org>2010-06-15 21:00:53 +0000
commitfcd7dd670620b7d2f3e6982da2c43fe888b879f0 (patch)
treeaf8997dc5ee1ce66bb29df34d222142c5bc4e84c /lib/libedit
parent14f08fd6272b6042eef9e52239ed552feb9c126c (diff)
downloadFreeBSD-src-fcd7dd670620b7d2f3e6982da2c43fe888b879f0.zip
FreeBSD-src-fcd7dd670620b7d2f3e6982da2c43fe888b879f0.tar.gz
libedit: Fix a bug that could make completion listings incomplete.
The element matches[0] is the common prefix and is not counted in len, so subtracting 1 is not needed. A counter for the number of matches per line was incremented twice. Submitted by: Guy Yur
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/filecomplete.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c
index 25d681f..ce0db10 100644
--- a/lib/libedit/filecomplete.c
+++ b/lib/libedit/filecomplete.c
@@ -347,13 +347,12 @@ fn_display_match_list(EditLine *el, char **matches, size_t len, size_t max)
count++;
/* Sort the items if they are not already sorted. */
- qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
- _fn_qsort_string_compare);
+ qsort(&matches[1], len, sizeof(char *), _fn_qsort_string_compare);
idx = 1;
for(; count > 0; count--) {
int more = limit > 0 && matches[0];
- for(i = 0; more; i++, idx++) {
+ for(i = 0; more; idx++) {
more = ++i < limit && matches[idx + 1];
(void)fprintf(el->el_outfile, "%-*s%s", (int)max,
matches[idx], more ? " " : "");
OpenPOWER on IntegriCloud