Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit Fix filename autocompletion for strings like a\)b



details:   https://anonhg.NetBSD.org/src/rev/8e6fc60484cc
branches:  trunk
changeset: 363427:8e6fc60484cc
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Mar 12 15:29:17 2022 +0000

description:
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:

 lib/libedit/filecomplete.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (47 lines):

diff -r 2740e5a92461 -r 8e6fc60484cc lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Sat Mar 12 09:16:05 2022 +0000
+++ b/lib/libedit/filecomplete.c        Sat Mar 12 15:29:17 2022 +0000
@@ -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 @@
 }
 
 static int
-needs_escaping(char c)
+needs_escaping(wchar_t c)
 {
        switch (c) {
        case '\'':
@@ -612,13 +612,13 @@
        for (;;) {
                if (ctemp <= buffer)
                        break;
-               if (wcschr(word_break, ctemp[-1])) {
-                       if (ctemp - buffer >= 2 && ctemp[-2] == '\\') {
-                               ctemp -= 2;
-                               continue;
-                       }
+               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--;



Home | Main Index | Thread Index | Old Index