Module Name: src Committed By: dholland Date: Mon Dec 6 00:05:39 UTC 2010
Modified Files: src/lib/libedit: filecomplete.c Log Message: Improve previous to avoid changing the interface of an externally exposed function. (But note that this function is neither documented nor declared in any installed header file, and it probably should not be externally exposed.) Related to PR 44183, closes PR 44186. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libedit/filecomplete.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libedit/filecomplete.c diff -u src/lib/libedit/filecomplete.c:1.22 src/lib/libedit/filecomplete.c:1.23 --- src/lib/libedit/filecomplete.c:1.22 Thu Dec 2 04:42:46 2010 +++ src/lib/libedit/filecomplete.c Mon Dec 6 00:05:38 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.22 2010/12/02 04:42:46 dholland Exp $ */ +/* $NetBSD: filecomplete.c,v 1.23 2010/12/06 00:05:38 dholland Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: filecomplete.c,v 1.22 2010/12/02 04:42:46 dholland Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.23 2010/12/06 00:05:38 dholland Exp $"); #endif /* not lint && not SCCSID */ #include <sys/types.h> @@ -341,8 +341,8 @@ * 'matches' is list of strings, 'num' is number of strings in 'matches', * 'width' is maximum length of string in 'matches'. * - * matches[0] is not one of the match strings, so the strings are - * matches[1] *through* matches[num]. + * matches[0] is not one of the match strings, but it is counted in + * num, so the strings are matches[1] *through* matches[num-1]. */ void fn_display_match_list (EditLine *el, char **matches, size_t num, size_t width) @@ -352,6 +352,7 @@ /* Ignore matches[0]. Avoid 1-based array logic below. */ matches++; + num--; /* * Find out how many entries can be put on one line; count @@ -518,9 +519,17 @@ (void)fprintf(el->el_outfile, "\n"); } - if (match_display) - fn_display_match_list(el, matches, matches_num, - maxlen); + if (match_display) { + /* + * Interface of this function requires the + * strings be matches[1..num-1] for compat. + * We have matches_num strings not counting + * the prefix in matches[0], so we need to + * add 1 to matches_num for the call. + */ + fn_display_match_list(el, matches, + matches_num+1, maxlen); + } retval = CC_REDISPLAY; } else if (matches[0][0]) { /*