Module Name: src Committed By: abhinav Date: Fri Apr 21 05:38:03 UTC 2017
Modified Files: src/lib/libedit: filecomplete.c filecomplete.h readline.c Log Message: When doing filename autocompletion, append a trailing slash at the end of directory names. We already do this when there is only one completion option but in case of of multiple completion options, it wasn't being done. ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/lib/libedit/filecomplete.c cvs rdiff -u -r1.10 -r1.11 src/lib/libedit/filecomplete.h cvs rdiff -u -r1.140 -r1.141 src/lib/libedit/readline.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.44 src/lib/libedit/filecomplete.c:1.45 --- src/lib/libedit/filecomplete.c:1.44 Mon Oct 31 17:46:32 2016 +++ src/lib/libedit/filecomplete.c Fri Apr 21 05:38:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $ */ +/* $NetBSD: filecomplete.c,v 1.45 2017/04/21 05:38:03 abhinav 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.44 2016/10/31 17:46:32 abhinav Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.45 2017/04/21 05:38:03 abhinav Exp $"); #endif /* not lint && not SCCSID */ #include <sys/types.h> @@ -354,10 +354,13 @@ _fn_qsort_string_compare(const void *i1, * 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) +fn_display_match_list(EditLine * el, char **matches, size_t num, size_t width, + const char *(*app_func) (const char *)) { size_t line, lines, col, cols, thisguy; int screenwidth = el->el_terminal.t_size.h; + if (app_func == NULL) + app_func = append_char_function; /* Ignore matches[0]. Avoid 1-based array logic below. */ matches++; @@ -385,8 +388,11 @@ fn_display_match_list (EditLine *el, cha thisguy = line + col * lines; if (thisguy >= num) break; - (void)fprintf(el->el_outfile, "%s%-*s", - col == 0 ? "" : " ", (int)width, matches[thisguy]); + (void)fprintf(el->el_outfile, "%s%s%s", + col == 0 ? "" : " ", matches[thisguy], + append_char_function(matches[thisguy])); + (void)fprintf(el->el_outfile, "%-*s", + (int) (width - strlen(matches[thisguy])), ""); } (void)fprintf(el->el_outfile, "\n"); } @@ -533,7 +539,7 @@ fn_complete(EditLine *el, * add 1 to matches_num for the call. */ fn_display_match_list(el, matches, - matches_num+1, maxlen); + matches_num+1, maxlen, app_func); } retval = CC_REDISPLAY; } else if (matches[0][0]) { Index: src/lib/libedit/filecomplete.h diff -u src/lib/libedit/filecomplete.h:1.10 src/lib/libedit/filecomplete.h:1.11 --- src/lib/libedit/filecomplete.h:1.10 Mon Apr 11 00:50:13 2016 +++ src/lib/libedit/filecomplete.h Fri Apr 21 05:38:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.h,v 1.10 2016/04/11 00:50:13 christos Exp $ */ +/* $NetBSD: filecomplete.h,v 1.11 2017/04/21 05:38:03 abhinav Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -37,7 +37,8 @@ int fn_complete(EditLine *, const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t, int *, int *, int *, int *); -void fn_display_match_list(EditLine *, char **, size_t, size_t); +void fn_display_match_list(EditLine *, char **, size_t, size_t, + const char *(*)(const char *)); char *fn_tilde_expand(const char *); char *fn_filename_completion_function(const char *, int); Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.140 src/lib/libedit/readline.c:1.141 --- src/lib/libedit/readline.c:1.140 Mon Jan 9 03:09:05 2017 +++ src/lib/libedit/readline.c Fri Apr 21 05:38:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.140 2017/01/09 03:09:05 christos Exp $ */ +/* $NetBSD: readline.c,v 1.141 2017/04/21 05:38:03 abhinav Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.140 2017/01/09 03:09:05 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.141 2017/04/21 05:38:03 abhinav Exp $"); #endif /* not lint && not SCCSID */ #include <sys/types.h> @@ -1812,18 +1812,6 @@ _el_rl_tstp(EditLine *el __attribute__(( return CC_NORM; } -/* - * Display list of strings in columnar format on readline's output stream. - * 'matches' is list of strings, 'len' is number of strings in 'matches', - * 'max' is maximum length of string in 'matches'. - */ -void -rl_display_match_list(char **matches, int len, int max) -{ - - fn_display_match_list(e, matches, (size_t)len, (size_t)max); -} - static const char * /*ARGSUSED*/ _rl_completion_append_character_function(const char *dummy @@ -1837,6 +1825,19 @@ _rl_completion_append_character_function /* + * Display list of strings in columnar format on readline's output stream. + * 'matches' is list of strings, 'len' is number of strings in 'matches', + * 'max' is maximum length of string in 'matches'. + */ +void +rl_display_match_list(char **matches, int len, int max) +{ + + fn_display_match_list(e, matches, (size_t)len, (size_t)max, + _rl_completion_append_character_function); +} + +/* * complete word at current point */ /* ARGSUSED */