mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 04:13:08 +00:00
Update code formatting
This commit is contained in:
parent
1ed8af2ee8
commit
e0e0bcdc1e
6 changed files with 153 additions and 138 deletions
|
@ -54,16 +54,17 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
struct builtin_printf_state_t {
|
||||
struct builtin_printf_state_t
|
||||
{
|
||||
int exit_code;
|
||||
|
||||
|
||||
void verify_numeric(const wchar_t *s, const wchar_t *end);
|
||||
|
||||
|
||||
void print_direc(const wchar_t *start, size_t length, wchar_t conversion,
|
||||
bool have_field_width, int field_width,
|
||||
bool have_precision, int precision,
|
||||
wchar_t const *argument);
|
||||
|
||||
bool have_field_width, int field_width,
|
||||
bool have_precision, int precision,
|
||||
wchar_t const *argument);
|
||||
|
||||
int print_formatted(const wchar_t *format, int argc, wchar_t **argv);
|
||||
};
|
||||
|
||||
|
@ -111,7 +112,7 @@ static int hextobin(const wchar_t &c)
|
|||
default:
|
||||
append_format(stderr_buffer, L"Invalid hex number : %lc", c);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int octtobin(const wchar_t &c)
|
||||
|
@ -143,7 +144,7 @@ static int octtobin(const wchar_t &c)
|
|||
/* This message appears in N_() here rather than just in _() below because
|
||||
the sole use would have been in a #define. */
|
||||
static wchar_t const *const cfcc_msg =
|
||||
N_(L"warning: %ls: character(s) following character constant have been ignored");
|
||||
N_(L"warning: %ls: character(s) following character constant have been ignored");
|
||||
|
||||
double C_STRTOD(wchar_t const *nptr, wchar_t **endptr)
|
||||
{
|
||||
|
@ -215,11 +216,11 @@ T string_to_scalar_type(const wchar_t *s, builtin_printf_state_t *state)
|
|||
{
|
||||
T val;
|
||||
if (*s == L'\"' || *s == L'\'')
|
||||
{
|
||||
{
|
||||
unsigned wchar_t ch = *++s;
|
||||
val = ch;
|
||||
}
|
||||
else
|
||||
val = ch;
|
||||
}
|
||||
else
|
||||
{
|
||||
wchar_t *end = NULL;
|
||||
errno = 0;
|
||||
|
@ -235,33 +236,33 @@ static void print_esc_char(wchar_t c)
|
|||
{
|
||||
switch (c)
|
||||
{
|
||||
case L'a': /* Alert. */
|
||||
append_format(stdout_buffer, L"%lc", L'\a');
|
||||
break;
|
||||
case L'a': /* Alert. */
|
||||
append_format(stdout_buffer, L"%lc", L'\a');
|
||||
break;
|
||||
case L'b': /* Backspace. */
|
||||
append_format(stdout_buffer, L"%lc", L'\b');
|
||||
break;
|
||||
case L'c': /* Cancel the rest of the output. */
|
||||
return;
|
||||
break;
|
||||
case L'f': /* Form feed. */
|
||||
append_format(stdout_buffer, L"%lc", L'\f');
|
||||
break;
|
||||
case L'n': /* New line. */
|
||||
append_format(stdout_buffer, L"%lc", L'\n');
|
||||
break;
|
||||
case L'r': /* Carriage retturn. */
|
||||
append_format(stdout_buffer, L"%lc", L'\r');
|
||||
break;
|
||||
case L't': /* Horizontal tab. */
|
||||
append_format(stdout_buffer, L"%lc", L'\t');
|
||||
break;
|
||||
case L'v': /* Vertical tab. */
|
||||
append_format(stdout_buffer, L"%lc", L'\v');
|
||||
break;
|
||||
default:
|
||||
append_format(stdout_buffer, L"%lc", c);
|
||||
break;
|
||||
append_format(stdout_buffer, L"%lc", L'\b');
|
||||
break;
|
||||
case L'c': /* Cancel the rest of the output. */
|
||||
return;
|
||||
break;
|
||||
case L'f': /* Form feed. */
|
||||
append_format(stdout_buffer, L"%lc", L'\f');
|
||||
break;
|
||||
case L'n': /* New line. */
|
||||
append_format(stdout_buffer, L"%lc", L'\n');
|
||||
break;
|
||||
case L'r': /* Carriage retturn. */
|
||||
append_format(stdout_buffer, L"%lc", L'\r');
|
||||
break;
|
||||
case L't': /* Horizontal tab. */
|
||||
append_format(stdout_buffer, L"%lc", L'\t');
|
||||
break;
|
||||
case L'v': /* Vertical tab. */
|
||||
append_format(stdout_buffer, L"%lc", L'\v');
|
||||
break;
|
||||
default:
|
||||
append_format(stdout_buffer, L"%lc", c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,9 +281,9 @@ static long print_esc(const wchar_t *escstart, bool octal_0)
|
|||
{
|
||||
/* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits. */
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 2 && isxdigit(to_uwchar_t(*p));
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin(*p);
|
||||
esc_length < 2 && isxdigit(to_uwchar_t(*p));
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin(*p);
|
||||
if (esc_length == 0)
|
||||
append_format(stderr_buffer, _(L"missing hexadecimal number in escape"));
|
||||
append_format(stdout_buffer, L"%lc", esc_value);
|
||||
|
@ -293,11 +294,11 @@ static long print_esc(const wchar_t *escstart, bool octal_0)
|
|||
Allow \ooo if octal_0 && *p != L'0'; this is an undocumented
|
||||
extension to POSIX that is compatible with Bash 2.05b. */
|
||||
for (esc_length = 0, p += octal_0 && *p == L'0';
|
||||
esc_length < 3 && isodigit(*p);
|
||||
++esc_length, ++p)
|
||||
esc_length < 3 && isodigit(*p);
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 8 + octtobin(*p);
|
||||
append_format(stdout_buffer, L"%c", esc_value);
|
||||
}
|
||||
}
|
||||
else if (*p && wcschr(L"\"\\abcfnrtv", *p))
|
||||
print_esc_char(*p++);
|
||||
else if (*p == L'u' || *p == L'U')
|
||||
|
@ -307,8 +308,8 @@ static long print_esc(const wchar_t *escstart, bool octal_0)
|
|||
|
||||
uni_value = 0;
|
||||
for (esc_length = (esc_char == L'u' ? 4 : 8), ++p;
|
||||
esc_length > 0;
|
||||
--esc_length, ++p)
|
||||
esc_length > 0;
|
||||
--esc_length, ++p)
|
||||
{
|
||||
if (! isxdigit(to_uwchar_t(*p)))
|
||||
append_format(stderr_buffer, _(L"missing hexadecimal number in escape"));
|
||||
|
@ -321,11 +322,11 @@ static long print_esc(const wchar_t *escstart, bool octal_0)
|
|||
character name shall not designate a character in the required
|
||||
character set. */
|
||||
if ((uni_value <= 0x9f
|
||||
&& uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60)
|
||||
|| (uni_value >= 0xd800 && uni_value <= 0xdfff))
|
||||
&& uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60)
|
||||
|| (uni_value >= 0xd800 && uni_value <= 0xdfff))
|
||||
append_format(stderr_buffer, _(L"invalid universal character name \\%c%0*x"),
|
||||
esc_char, (esc_char == L'u' ? 4 : 8), uni_value);
|
||||
append_format(stdout_buffer, L"%lc", uni_value);
|
||||
esc_char, (esc_char == L'u' ? 4 : 8), uni_value);
|
||||
append_format(stdout_buffer, L"%lc", uni_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -360,9 +361,9 @@ print_esc_string(const wchar_t *str)
|
|||
be formatted. */
|
||||
|
||||
void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wchar_t conversion,
|
||||
bool have_field_width, int field_width,
|
||||
bool have_precision, int precision,
|
||||
wchar_t const *argument)
|
||||
bool have_field_width, int field_width,
|
||||
bool have_precision, int precision,
|
||||
wchar_t const *argument)
|
||||
{
|
||||
wcstring fmt;
|
||||
|
||||
|
@ -376,16 +377,24 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
|
|||
|
||||
switch (conversion)
|
||||
{
|
||||
case L'd': case L'i':
|
||||
case L'd':
|
||||
case L'i':
|
||||
length_modifier = L"lld";
|
||||
length_modifier_len = sizeof L"lld" - 2;
|
||||
break;
|
||||
case L'a': case L'e': case L'f': case L'g':
|
||||
case L'A': case L'E': case L'F': case L'G':
|
||||
case L'a':
|
||||
case L'e':
|
||||
case L'f':
|
||||
case L'g':
|
||||
case L'A':
|
||||
case L'E':
|
||||
case L'F':
|
||||
case L'G':
|
||||
length_modifier = L"L";
|
||||
length_modifier_len = 1;
|
||||
break;
|
||||
case L's': case L'u':
|
||||
case L's':
|
||||
case L'u':
|
||||
length_modifier = L"l";
|
||||
length_modifier_len = 1;
|
||||
break;
|
||||
|
@ -478,15 +487,17 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
|
|||
|
||||
case L'c':
|
||||
if (!have_field_width)
|
||||
append_format(stdout_buffer, fmt.c_str(), *argument);
|
||||
append_format(stdout_buffer, fmt.c_str(), *argument);
|
||||
else
|
||||
append_format(stdout_buffer, fmt.c_str(), field_width, *argument);
|
||||
append_format(stdout_buffer, fmt.c_str(), field_width, *argument);
|
||||
break;
|
||||
case L's':
|
||||
if (!have_field_width)
|
||||
{
|
||||
if (!have_precision){
|
||||
append_format(stdout_buffer, fmt.c_str(), argument);}
|
||||
if (!have_precision)
|
||||
{
|
||||
append_format(stdout_buffer, fmt.c_str(), argument);
|
||||
}
|
||||
else
|
||||
append_format(stdout_buffer, fmt.c_str(), precision, argument);
|
||||
}
|
||||
|
@ -505,7 +516,8 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
|
|||
arguments to any `%' directives.
|
||||
Return the number of elements of ARGV used. */
|
||||
|
||||
int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wchar_t **argv) {
|
||||
int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wchar_t **argv)
|
||||
{
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
const wchar_t *f; /* Pointer into `format'. */
|
||||
const wchar_t *direc_start; /* Start of % directive. */
|
||||
|
@ -543,8 +555,8 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
|||
}
|
||||
|
||||
ok['a'] = ok['A'] = ok['c'] = ok['d'] = ok['e'] = ok['E'] =
|
||||
ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] =
|
||||
ok['s'] = ok['u'] = ok['x'] = ok['X'] = true;
|
||||
ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] =
|
||||
ok['s'] = ok['u'] = ok['x'] = ok['X'] = true;
|
||||
|
||||
for (;; f++, direc_length++)
|
||||
{
|
||||
|
@ -554,22 +566,25 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
|||
case L'I':
|
||||
#endif
|
||||
case L'\'':
|
||||
ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] =
|
||||
ok['o'] = ok['s'] = ok['x'] = ok['X'] = false;
|
||||
break;
|
||||
case '-': case '+': case ' ':
|
||||
break;
|
||||
ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] =
|
||||
ok['o'] = ok['s'] = ok['x'] = ok['X'] = false;
|
||||
break;
|
||||
case '-':
|
||||
case '+':
|
||||
case ' ':
|
||||
break;
|
||||
case L'#':
|
||||
ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = false;
|
||||
break;
|
||||
ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = false;
|
||||
break;
|
||||
case '0':
|
||||
ok['c'] = ok['s'] = false;
|
||||
break;
|
||||
ok['c'] = ok['s'] = false;
|
||||
break;
|
||||
default:
|
||||
goto no_more_flag_characters;
|
||||
goto no_more_flag_characters;
|
||||
}
|
||||
}
|
||||
no_more_flag_characters:;
|
||||
no_more_flag_characters:
|
||||
;
|
||||
|
||||
if (*f == L'*')
|
||||
{
|
||||
|
@ -613,10 +628,10 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
|||
intmax_t prec = string_to_scalar_type<intmax_t>(*argv, this);
|
||||
if (prec < 0)
|
||||
{
|
||||
/* A negative precision is taken as if the
|
||||
precision were omitted, so -1 is safe
|
||||
here even if prec < INT_MIN. */
|
||||
precision = -1;
|
||||
/* A negative precision is taken as if the
|
||||
precision were omitted, so -1 is safe
|
||||
here even if prec < INT_MIN. */
|
||||
precision = -1;
|
||||
}
|
||||
else if (INT_MAX < prec)
|
||||
append_format(stderr_buffer, _(L"invalid precision: %ls"), *argv);
|
||||
|
@ -627,38 +642,38 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
|||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
{
|
||||
precision = 0;
|
||||
}
|
||||
have_precision = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
precision = 0;
|
||||
while (iswdigit(*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
have_precision = true;
|
||||
}
|
||||
else
|
||||
|
||||
while (*f == L'l' || *f == L'L' || *f == L'h'
|
||||
|| *f == L'j' || *f == L't' || *f == L'z')
|
||||
++f;
|
||||
{
|
||||
while (iswdigit(*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
unsigned wchar_t conversion = *f;
|
||||
if (! ok[conversion])
|
||||
append_format(stderr_buffer,
|
||||
_("%.*ls: invalid conversion specification"),
|
||||
(int)(f + 1 - direc_start), direc_start);
|
||||
}
|
||||
}
|
||||
|
||||
while (*f == L'l' || *f == L'L' || *f == L'h'
|
||||
|| *f == L'j' || *f == L't' || *f == L'z')
|
||||
++f;
|
||||
{
|
||||
unsigned wchar_t conversion = *f;
|
||||
if (! ok[conversion])
|
||||
append_format(stderr_buffer,
|
||||
_("%.*ls: invalid conversion specification"),
|
||||
(int) (f + 1 - direc_start), direc_start);
|
||||
}
|
||||
|
||||
print_direc(direc_start, direc_length, *f,
|
||||
have_field_width, field_width,
|
||||
have_precision, precision,
|
||||
(argc <= 0 ? L"" : (argc--, *argv++)));
|
||||
break;
|
||||
print_direc(direc_start, direc_length, *f,
|
||||
have_field_width, field_width,
|
||||
have_precision, precision,
|
||||
(argc <= 0 ? L"" : (argc--, *argv++)));
|
||||
break;
|
||||
|
||||
case L'\\':
|
||||
f += print_esc(f, false);
|
||||
|
@ -666,8 +681,8 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
|||
|
||||
default:
|
||||
append_format(stdout_buffer, L"%lc", *f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return save_argc - argc;
|
||||
}
|
||||
|
||||
|
@ -675,7 +690,7 @@ static int builtin_printf(parser_t &parser, wchar_t **argv)
|
|||
{
|
||||
builtin_printf_state_t state;
|
||||
state.exit_code = STATUS_BUILTIN_OK;
|
||||
|
||||
|
||||
wchar_t *format;
|
||||
int args_used;
|
||||
int argc = builtin_count_args(argv);
|
||||
|
@ -697,5 +712,5 @@ static int builtin_printf(parser_t &parser, wchar_t **argv)
|
|||
argv += args_used;
|
||||
}
|
||||
while (args_used > 0 && argc > 0);
|
||||
return state.exit_code;
|
||||
return state.exit_code;
|
||||
}
|
||||
|
|
|
@ -546,7 +546,7 @@ expression *test_parser::parse_3_arg_expression(unsigned int start, unsigned int
|
|||
{
|
||||
assert(end - start == 3);
|
||||
expression *result = NULL;
|
||||
|
||||
|
||||
const token_info_t *center_token = token_for_string(arg(start + 1));
|
||||
if (center_token->flags & BINARY_PRIMARY)
|
||||
{
|
||||
|
@ -577,7 +577,7 @@ expression *test_parser::parse_4_arg_expression(unsigned int start, unsigned int
|
|||
{
|
||||
assert(end - start == 4);
|
||||
expression *result = NULL;
|
||||
|
||||
|
||||
token_t first_token = token_for_string(arg(start))->tok;
|
||||
if (first_token == test_bang)
|
||||
{
|
||||
|
@ -605,14 +605,14 @@ expression *test_parser::parse_expression(unsigned int start, unsigned int end)
|
|||
{
|
||||
return error(L"Missing argument at index %u", start);
|
||||
}
|
||||
|
||||
|
||||
unsigned int argc = end - start;
|
||||
switch (argc)
|
||||
{
|
||||
case 0:
|
||||
assert(0); //should have been caught by the above test
|
||||
return NULL;
|
||||
|
||||
|
||||
case 1:
|
||||
{
|
||||
return error(L"Missing argument at index %u", start + 1);
|
||||
|
@ -621,17 +621,17 @@ expression *test_parser::parse_expression(unsigned int start, unsigned int end)
|
|||
{
|
||||
return parse_unary_expression(start, end);
|
||||
}
|
||||
|
||||
|
||||
case 3:
|
||||
{
|
||||
return parse_3_arg_expression(start, end);
|
||||
}
|
||||
|
||||
|
||||
case 4:
|
||||
{
|
||||
return parse_4_arg_expression(start, end);
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
return parse_combining_expression(start, end);
|
||||
|
@ -888,18 +888,18 @@ static bool unary_primary_evaluate(test_expressions::token_t token, const wcstri
|
|||
int builtin_test(parser_t &parser, wchar_t **argv)
|
||||
{
|
||||
using namespace test_expressions;
|
||||
|
||||
|
||||
/* The first argument should be the name of the command ('test') */
|
||||
if (! argv[0])
|
||||
return BUILTIN_TEST_FAIL;
|
||||
|
||||
|
||||
/* Whether we are invoked with bracket '[' or not */
|
||||
const bool is_bracket = ! wcscmp(argv[0], L"[");
|
||||
|
||||
|
||||
size_t argc = 0;
|
||||
while (argv[argc + 1])
|
||||
argc++;
|
||||
|
||||
|
||||
/* If we're bracket, the last argument ought to be ]; we ignore it. Note that argc is the number of arguments after the command name; thus argv[argc] is the last argument. */
|
||||
if (is_bracket)
|
||||
{
|
||||
|
@ -913,12 +913,12 @@ int builtin_test(parser_t &parser, wchar_t **argv)
|
|||
builtin_show_error(L"[: the last argument must be ']'\n");
|
||||
return BUILTIN_TEST_FAIL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Collect the arguments into a list */
|
||||
const wcstring_list_t args(argv + 1, argv + 1 + argc);
|
||||
|
||||
|
||||
switch (argc)
|
||||
{
|
||||
case 0:
|
||||
|
|
13
complete.cpp
13
complete.cpp
|
@ -345,26 +345,26 @@ class completer_t
|
|||
/** Table of completions conditions that have already been tested and the corresponding test results */
|
||||
typedef std::map<wcstring, bool> condition_cache_t;
|
||||
condition_cache_t condition_cache;
|
||||
|
||||
|
||||
enum complete_type_t
|
||||
{
|
||||
COMPLETE_DEFAULT,
|
||||
COMPLETE_AUTOSUGGEST
|
||||
};
|
||||
|
||||
|
||||
complete_type_t type() const
|
||||
{
|
||||
return (flags & COMPLETION_REQUEST_AUTOSUGGESTION) ? COMPLETE_AUTOSUGGEST : COMPLETE_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
bool wants_descriptions() const
|
||||
{
|
||||
return !! (flags & COMPLETION_REQUEST_DESCRIPTIONS);
|
||||
return !!(flags & COMPLETION_REQUEST_DESCRIPTIONS);
|
||||
}
|
||||
|
||||
|
||||
bool fuzzy() const
|
||||
{
|
||||
return !! (flags & COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
return !!(flags & COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1794,7 +1794,6 @@ void complete(const wcstring &cmd, std::vector<completion_t> &comps, completion_
|
|||
/* Make our completer */
|
||||
completer_t completer(cmd, flags);
|
||||
|
||||
const bool fuzzy = !! (flags & COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
const wchar_t *tok_begin, *tok_end, *cmdsubst_begin, *cmdsubst_end, *prev_begin, *prev_end;
|
||||
wcstring current_token, prev_token;
|
||||
wcstring current_command;
|
||||
|
|
|
@ -77,7 +77,7 @@ enum
|
|||
|
||||
/** This completion is case insensitive. */
|
||||
COMPLETE_CASE_INSENSITIVE = 1 << 1,
|
||||
|
||||
|
||||
/** This is not the suffix of a token, but replaces it entirely */
|
||||
COMPLETE_REPLACES_TOKEN = 1 << 2,
|
||||
|
||||
|
@ -139,7 +139,8 @@ public:
|
|||
bool operator != (const completion_t& rhs) const;
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
COMPLETION_REQUEST_DEFAULT = 0,
|
||||
COMPLETION_REQUEST_AUTOSUGGESTION = 1 << 0, // indicates the completion is for an autosuggestion
|
||||
COMPLETION_REQUEST_DESCRIPTIONS = 1 << 1, // indicates that we want descriptions
|
||||
|
|
|
@ -936,7 +936,7 @@ static void test_test()
|
|||
|
||||
/* This crashed */
|
||||
assert(run_test_test(1, L"1 = 1 -a = 1"));
|
||||
|
||||
|
||||
/* Make sure we can treat -S as a parameter instead of an operator. https://github.com/fish-shell/fish-shell/issues/601 */
|
||||
assert(run_test_test(0, L"-S = -S"));
|
||||
assert(run_test_test(1, L"! ! ! A"));
|
||||
|
@ -965,16 +965,16 @@ static void test_complete(void)
|
|||
const wchar_t *name_strs[] = {L"Foo1", L"Foo2", L"Foo3", L"Bar1", L"Bar2", L"Bar3"};
|
||||
size_t count = sizeof name_strs / sizeof *name_strs;
|
||||
const wcstring_list_t names(name_strs, name_strs + count);
|
||||
|
||||
|
||||
complete_set_variable_names(&names);
|
||||
|
||||
|
||||
std::vector<completion_t> completions;
|
||||
complete(L"$F", completions, COMPLETION_REQUEST_DEFAULT);
|
||||
assert(completions.size() == 3);
|
||||
assert(completions.at(0).completion == L"oo1");
|
||||
assert(completions.at(1).completion == L"oo2");
|
||||
assert(completions.at(2).completion == L"oo3");
|
||||
|
||||
|
||||
complete_set_variable_names(NULL);
|
||||
}
|
||||
|
||||
|
@ -1714,7 +1714,7 @@ int main(int argc, char **argv)
|
|||
builtin_init();
|
||||
reader_init();
|
||||
env_init();
|
||||
|
||||
|
||||
test_format();
|
||||
test_escape();
|
||||
test_convert();
|
||||
|
|
|
@ -1158,7 +1158,7 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector<c
|
|||
for (size_t i=0; i< comp.size(); i++)
|
||||
{
|
||||
const completion_t &el = comp.at(i);
|
||||
if (! (el.flags & COMPLETE_CASE_INSENSITIVE))
|
||||
if (!(el.flags & COMPLETE_CASE_INSENSITIVE))
|
||||
{
|
||||
has_case_sensitive = true;
|
||||
break;
|
||||
|
@ -3061,7 +3061,7 @@ const wchar_t *reader_readline()
|
|||
|
||||
/* Construct a copy of the string from the beginning of the command substitution up to the end of the token we're completing */
|
||||
const wcstring buffcpy = wcstring(cmdsub_begin, token_end);
|
||||
|
||||
|
||||
//fprintf(stderr, "Complete (%ls)\n", buffcpy.c_str());
|
||||
data->complete_func(buffcpy, comp, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_DESCRIPTIONS, NULL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue