From owner-dev-commits-src-all@freebsd.org Mon Mar 29 08:04:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8887B5C02C9 for ; Mon, 29 Mar 2021 08:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F84q43VtNz4lXr; Mon, 29 Mar 2021 08:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 607327B34; Mon, 29 Mar 2021 08:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12T84GxO054110; Mon, 29 Mar 2021 08:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12T84GBE054109; Mon, 29 Mar 2021 08:04:16 GMT (envelope-from git) Date: Mon, 29 Mar 2021 08:04:16 GMT Message-Id: <202103290804.12T84GBE054109@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org From: Baptiste Daroussin Subject: git: 31595a7c3a4a - vendor/NetBSD/libedit - libedit: vendor import snapshot 2021-03-28 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/vendor/NetBSD/libedit X-Git-Reftype: branch X-Git-Commit: 31595a7c3a4afa330555de5f58b1a23ad88a8bc5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2021 08:04:16 -0000 The branch vendor/NetBSD/libedit has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=31595a7c3a4afa330555de5f58b1a23ad88a8bc5 commit 31595a7c3a4afa330555de5f58b1a23ad88a8bc5 Author: Baptiste Daroussin AuthorDate: 2021-03-29 08:01:41 +0000 Commit: Baptiste Daroussin CommitDate: 2021-03-29 08:02:12 +0000 libedit: vendor import snapshot 2021-03-28 --- filecomplete.c | 47 ++++++++++++++++++++++++++++++++--------------- filecomplete.h | 8 +++++++- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/filecomplete.c b/filecomplete.c index ba887e0e4180..963a73fc8322 100644 --- a/filecomplete.c +++ b/filecomplete.c @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.c,v 1.64 2020/01/05 07:12:05 abhinav Exp $ */ +/* $NetBSD: filecomplete.c,v 1.67 2021/03/28 13:39:39 christos 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.64 2020/01/05 07:12:05 abhinav Exp $"); +__RCSID("$NetBSD: filecomplete.c,v 1.67 2021/03/28 13:39:39 christos Exp $"); #endif /* not lint && not SCCSID */ #include @@ -291,7 +291,7 @@ escape_filename(EditLine * el, const char *filename, int single_match, if (single_match && app_func) { escaped_str[offset] = 0; - append_char = app_func(escaped_str); + append_char = app_func(filename); /* we want to append space only if we are not inside quotes */ if (append_char[0] == ' ') { if (!s_quoted && !d_quoted) @@ -652,12 +652,13 @@ find_word_to_complete(const wchar_t * cursor, const wchar_t * buffer, * '!' could never be invoked */ int -fn_complete(EditLine *el, - char *(*complet_func)(const char *, int), - char **(*attempted_completion_function)(const char *, int, int), - const wchar_t *word_break, const wchar_t *special_prefixes, - const char *(*app_func)(const char *), size_t query_items, - int *completion_type, int *over, int *point, int *end) +fn_complete2(EditLine *el, + char *(*complete_func)(const char *, int), + char **(*attempted_completion_function)(const char *, int, int), + const wchar_t *word_break, const wchar_t *special_prefixes, + const char *(*app_func)(const char *), size_t query_items, + int *completion_type, int *over, int *point, int *end, + unsigned int flags) { const LineInfoW *li; wchar_t *temp; @@ -666,7 +667,7 @@ fn_complete(EditLine *el, size_t len; int what_to_do = '\t'; int retval = CC_NORM; - int do_unescape = attempted_completion_function == NULL? 1: 0; + int do_unescape = flags & FN_QUOTE_MATCH; if (el->el_state.lastcmd == el->el_state.thiscmd) what_to_do = '?'; @@ -675,8 +676,8 @@ fn_complete(EditLine *el, if (completion_type != NULL) *completion_type = what_to_do; - if (!complet_func) - complet_func = fn_filename_completion_function; + if (!complete_func) + complete_func = fn_filename_completion_function; if (!app_func) app_func = append_char_function; @@ -703,7 +704,7 @@ fn_complete(EditLine *el, if (!attempted_completion_function || (over != NULL && !*over && !matches)) matches = completion_matches( - ct_encode_string(temp, &el->el_scratch), complet_func); + ct_encode_string(temp, &el->el_scratch), complete_func); if (over != NULL) *over = 0; @@ -720,7 +721,7 @@ fn_complete(EditLine *el, if (matches[0][0] != '\0') { el_deletestr(el, (int)len); - if (!attempted_completion_function) + if (flags & FN_QUOTE_MATCH) completion = escape_filename(el, matches[0], single_match, app_func); else @@ -735,7 +736,9 @@ fn_complete(EditLine *el, el_winsertstr(el, ct_decode_string(completion, &el->el_scratch)); - if (single_match && attempted_completion_function) { + if (single_match && attempted_completion_function && + !(flags & FN_QUOTE_MATCH)) + { /* * We found an exact match. Add a space after * it, unless we do filename completion and the @@ -817,6 +820,20 @@ out: return retval; } +int +fn_complete(EditLine *el, + char *(*complete_func)(const char *, int), + char **(*attempted_completion_function)(const char *, int, int), + const wchar_t *word_break, const wchar_t *special_prefixes, + const char *(*app_func)(const char *), size_t query_items, + int *completion_type, int *over, int *point, int *end) +{ + return fn_complete2(el, complete_func, attempted_completion_function, + word_break, special_prefixes, app_func, query_items, + completion_type, over, point, end, + attempted_completion_function ? 0 : FN_QUOTE_MATCH); +} + /* * el-compatible wrapper around rl_complete; needed for key binding */ diff --git a/filecomplete.h b/filecomplete.h index 61d81389a0f7..60ea4894414b 100644 --- a/filecomplete.h +++ b/filecomplete.h @@ -1,4 +1,4 @@ -/* $NetBSD: filecomplete.h,v 1.11 2017/04/21 05:38:03 abhinav Exp $ */ +/* $NetBSD: filecomplete.h,v 1.13 2021/03/28 13:38:10 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -36,6 +36,12 @@ int fn_complete(EditLine *, char **(*)(const char *, int, int), const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t, int *, int *, int *, int *); +int fn_complete2(EditLine *, + char *(*)(const char *, int), + char **(*)(const char *, int, int), + const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t, + int *, int *, int *, int *, unsigned int); +#define FN_QUOTE_MATCH 1 /* Quote the returned match */ void fn_display_match_list(EditLine *, char **, size_t, size_t, const char *(*)(const char *));