summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2022-03-12 15:29:17 +0000
committerchristos <christos@NetBSD.org>2022-03-12 15:29:17 +0000
commit344e92e9fe7bec6b506f255cb608fcb05d9f43ce (patch)
treec6846f49f465a1085e1e9b5d93c1a1c2ea6729ea /lib/libedit
parent467b380360961cf7c1d34c761af451f3a9935dcb (diff)
Fix filename autocompletion for strings like a\)b
An escaped character should unconditionally be skipped together with the character that does the escaping. For example, in "a\)b" only the ")b" part was skipped but then the loop stopped at the "\" since it's one of the characters listed in word_break. (Piotr P. Stefaniak)
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/filecomplete.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c
index dff36939cdb..f1ed03f72cf 100644
--- a/lib/libedit/filecomplete.c
+++ b/lib/libedit/filecomplete.c
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.69 2021/09/26 13:45:37 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 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.69 2021/09/26 13:45:37 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -127,7 +127,7 @@ fn_tilde_expand(const char *txt)
}
static int
-needs_escaping(char c)
+needs_escaping(wchar_t c)
{
switch (c) {
case '\'':
@@ -612,13 +612,13 @@ find_word_to_complete(const wchar_t * cursor, const wchar_t * buffer,
for (;;) {
if (ctemp <= buffer)
break;
- if (wcschr(word_break, ctemp[-1])) {
- if (ctemp - buffer >= 2 && ctemp[-2] == '\\') {
- ctemp -= 2;
- continue;
- }
- break;
+ if (ctemp - buffer >= 2 && ctemp[-2] == '\\' &&
+ needs_escaping(ctemp[-1])) {
+ ctemp -= 2;
+ continue;
}
+ if (wcschr(word_break, ctemp[-1]))
+ break;
if (special_prefixes && wcschr(special_prefixes, ctemp[-1]))
break;
ctemp--;