Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Perform quoting of filename completions when the...
details: https://anonhg.NetBSD.org/src/rev/20dc3dcacbcf
branches: trunk
changeset: 449975:20dc3dcacbcf
user: abhinav <abhinav%NetBSD.org@localhost>
date: Sun Mar 31 03:04:57 2019 +0000
description:
Perform quoting of filename completions when there are multiple matches as well
Quoting of special characters in filename completion was implemented for single match
case, this enables it for multiple matches as well. For example:
$ touch 'foo bar'
$ touch 'foo baz'
$ ls fo<TAB>
autocompletes to =>
$ ls foo\ ba
hitting <TAB> again shows:
foo bar foo baz
This required unescaping escape sequences generated during last completion
in order to find the word to complete.
While there, also update the test to include cases for multiple matches.
Reviewed by christos
diffstat:
lib/libedit/TEST/test_filecompletion.c | 161 ++++++++++++++++++--------------
lib/libedit/filecomplete.c | 83 ++++++++++------
2 files changed, 141 insertions(+), 103 deletions(-)
diffs (truncated from 716 to 300 lines):
diff -r c75aa370ec9b -r 20dc3dcacbcf lib/libedit/TEST/test_filecompletion.c
--- a/lib/libedit/TEST/test_filecompletion.c Sun Mar 31 02:24:47 2019 +0000
+++ b/lib/libedit/TEST/test_filecompletion.c Sun Mar 31 03:04:57 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: test_filecompletion.c,v 1.3 2018/05/04 16:39:15 abhinav Exp $ */
+/* $NetBSD: test_filecompletion.c,v 1.4 2019/03/31 03:04:57 abhinav Exp $ */
/*-
* Copyright (c) 2017 Abhinav Upadhyay <abhinav%NetBSD.org@localhost>
@@ -45,7 +45,7 @@
typedef struct {
const wchar_t *user_typed_text; /* The actual text typed by the user on the terminal */
const char *completion_function_input ; /*the text received by fn_filename_completion_function */
- const char *expanded_text; /* the value to which completion_function_input should be expanded */
+ const char *expanded_text[2]; /* the value to which completion_function_input should be expanded */
const wchar_t *escaped_output; /* expected escaped value of expanded_text */
} test_input;
@@ -54,446 +54,463 @@
/* simple test for escaping angular brackets */
L"ls ang",
"ang",
- "ang<ular>test",
+ {"ang<ular>test", NULL},
L"ls ang\\<ular\\>test "
},
{
/* test angular bracket inside double quotes: ls "dq_ang */
L"ls \"dq_ang",
"dq_ang",
- "dq_ang<ular>test",
+ {"dq_ang<ular>test", NULL},
L"ls \"dq_ang<ular>test\" "
},
{
/* test angular bracket inside singlq quotes: ls "sq_ang */
L"ls 'sq_ang",
"sq_ang",
- "sq_ang<ular>test",
+ {"sq_ang<ular>test", NULL},
L"ls 'sq_ang<ular>test' "
},
{
/* simple test for backslash */
L"ls back",
"back",
- "backslash\\test",
+ {"backslash\\test", NULL},
L"ls backslash\\\\test "
},
{
/* backslash inside single quotes */
L"ls 'sback",
"sback",
- "sbackslash\\test",
+ {"sbackslash\\test", NULL},
L"ls 'sbackslash\\test' "
},
{
/* backslash inside double quotes */
L"ls \"dback",
"dback",
- "dbackslash\\test",
+ {"dbackslash\\test", NULL},
L"ls \"dbackslash\\\\test\" "
},
{
/* test braces */
L"ls br",
"br",
- "braces{test}",
+ {"braces{test}", NULL},
L"ls braces\\{test\\} "
},
{
/* test braces inside single quotes */
L"ls 'sbr",
"sbr",
- "sbraces{test}",
+ {"sbraces{test}", NULL},
L"ls 'sbraces{test}' "
},
{
/* test braces inside double quotes */
L"ls \"dbr",
"dbr",
- "dbraces{test}",
+ {"dbraces{test}", NULL},
L"ls \"dbraces{test}\" "
},
{
/* test dollar */
L"ls doll",
"doll",
- "doll$artest",
+ {"doll$artest", NULL},
L"ls doll\\$artest "
},
{
/* test dollar inside single quotes */
L"ls 'sdoll",
"sdoll",
- "sdoll$artest",
+ {"sdoll$artest", NULL},
L"ls 'sdoll$artest' "
},
{
/* test dollar inside double quotes */
L"ls \"ddoll",
"ddoll",
- "ddoll$artest",
+ {"ddoll$artest", NULL},
L"ls \"ddoll\\$artest\" "
},
{
/* test equals */
L"ls eq",
"eq",
- "equals==test",
+ {"equals==test", NULL},
L"ls equals\\=\\=test "
},
{
/* test equals inside sinqle quotes */
L"ls 'seq",
"seq",
- "sequals==test",
+ {"sequals==test", NULL},
L"ls 'sequals==test' "
},
{
/* test equals inside double quotes */
L"ls \"deq",
"deq",
- "dequals==test",
+ {"dequals==test", NULL},
L"ls \"dequals==test\" "
},
{
/* test \n */
L"ls new",
"new",
- "new\\nline",
+ {"new\\nline", NULL},
L"ls new\\\\nline "
},
{
/* test \n inside single quotes */
L"ls 'snew",
"snew",
- "snew\nline",
+ {"snew\nline", NULL},
L"ls 'snew\nline' "
},
{
/* test \n inside double quotes */
L"ls \"dnew",
"dnew",
- "dnew\nline",
+ {"dnew\nline", NULL},
L"ls \"dnew\nline\" "
},
{
/* test single space */
L"ls spac",
"spac",
- "space test",
+ {"space test", NULL},
L"ls space\\ test "
},
{
/* test single space inside singlq quotes */
L"ls 's_spac",
"s_spac",
- "s_space test",
+ {"s_space test", NULL},
L"ls 's_space test' "
},
{
/* test single space inside double quotes */
L"ls \"d_spac",
"d_spac",
- "d_space test",
+ {"d_space test", NULL},
L"ls \"d_space test\" "
},
{
/* test multiple spaces */
L"ls multi",
"multi",
- "multi space test",
+ {"multi space test", NULL},
L"ls multi\\ space\\ \\ test "
},
{
/* test multiple spaces inside single quotes */
L"ls 's_multi",
"s_multi",
- "s_multi space test",
+ {"s_multi space test", NULL},
L"ls 's_multi space test' "
},
{
/* test multiple spaces inside double quotes */
L"ls \"d_multi",
"d_multi",
- "d_multi space test",
+ {"d_multi space test", NULL},
L"ls \"d_multi space test\" "
},
{
/* test double quotes */
L"ls doub",
"doub",
- "doub\"quotes",
+ {"doub\"quotes", NULL},
L"ls doub\\\"quotes "
},
{
/* test double quotes inside single quotes */
L"ls 's_doub",
"s_doub",
- "s_doub\"quotes",
+ {"s_doub\"quotes", NULL},
L"ls 's_doub\"quotes' "
},
{
/* test double quotes inside double quotes */
L"ls \"d_doub",
"d_doub",
- "d_doub\"quotes",
+ {"d_doub\"quotes", NULL},
L"ls \"d_doub\\\"quotes\" "
},
{
/* test multiple double quotes */
L"ls mud",
"mud",
- "mud\"qu\"otes\"",
+ {"mud\"qu\"otes\"", NULL},
L"ls mud\\\"qu\\\"otes\\\" "
},
{
/* test multiple double quotes inside single quotes */
L"ls 'smud",
"smud",
- "smud\"qu\"otes\"",
+ {"smud\"qu\"otes\"", NULL},
L"ls 'smud\"qu\"otes\"' "
},
{
/* test multiple double quotes inside double quotes */
L"ls \"dmud",
"dmud",
- "dmud\"qu\"otes\"",
+ {"dmud\"qu\"otes\"", NULL},
L"ls \"dmud\\\"qu\\\"otes\\\"\" "
},
{
/* test one single quote */
L"ls sing",
"sing",
- "single'quote",
+ {"single'quote", NULL},
L"ls single\\'quote "
},
{
/* test one single quote inside single quote */
L"ls 'ssing",
"ssing",
- "ssingle'quote",
+ {"ssingle'quote", NULL},
L"ls 'ssingle'\\''quote' "
},
{
/* test one single quote inside double quote */
L"ls \"dsing",
"dsing",
- "dsingle'quote",
+ {"dsingle'quote", NULL},
L"ls \"dsingle'quote\" "
},
{
/* test multiple single quotes */
L"ls mu_sing",
"mu_sing",
- "mu_single''quotes''",
+ {"mu_single''quotes''", NULL},
L"ls mu_single\\'\\'quotes\\'\\' "
},
{
/* test multiple single quotes inside single quote */
L"ls 'smu_sing",
"smu_sing",
- "smu_single''quotes''",
+ {"smu_single''quotes''", NULL},
L"ls 'smu_single'\\'''\\''quotes'\\\'''\\''' "
},
{
/* test multiple single quotes inside double quote */
Home |
Main Index |
Thread Index |
Old Index