Update code formatting

This commit is contained in:
ridiculousfish 2013-03-21 17:44:51 -07:00
parent 1ed8af2ee8
commit e0e0bcdc1e
6 changed files with 153 additions and 138 deletions

View file

@ -54,16 +54,17 @@
#include "common.h" #include "common.h"
struct builtin_printf_state_t { struct builtin_printf_state_t
{
int exit_code; int exit_code;
void verify_numeric(const wchar_t *s, const wchar_t *end); void verify_numeric(const wchar_t *s, const wchar_t *end);
void print_direc(const wchar_t *start, size_t length, wchar_t conversion, void print_direc(const wchar_t *start, size_t length, wchar_t conversion,
bool have_field_width, int field_width, bool have_field_width, int field_width,
bool have_precision, int precision, bool have_precision, int precision,
wchar_t const *argument); wchar_t const *argument);
int print_formatted(const wchar_t *format, int argc, wchar_t **argv); int print_formatted(const wchar_t *format, int argc, wchar_t **argv);
}; };
@ -111,7 +112,7 @@ static int hextobin(const wchar_t &c)
default: default:
append_format(stderr_buffer, L"Invalid hex number : %lc", c); append_format(stderr_buffer, L"Invalid hex number : %lc", c);
return -1; return -1;
} }
} }
static int octtobin(const wchar_t &c) 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 /* This message appears in N_() here rather than just in _() below because
the sole use would have been in a #define. */ the sole use would have been in a #define. */
static wchar_t const *const cfcc_msg = 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) 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; T val;
if (*s == L'\"' || *s == L'\'') if (*s == L'\"' || *s == L'\'')
{ {
unsigned wchar_t ch = *++s; unsigned wchar_t ch = *++s;
val = ch; val = ch;
} }
else else
{ {
wchar_t *end = NULL; wchar_t *end = NULL;
errno = 0; errno = 0;
@ -235,33 +236,33 @@ static void print_esc_char(wchar_t c)
{ {
switch (c) switch (c)
{ {
case L'a': /* Alert. */ case L'a': /* Alert. */
append_format(stdout_buffer, L"%lc", L'\a'); append_format(stdout_buffer, L"%lc", L'\a');
break; break;
case L'b': /* Backspace. */ case L'b': /* Backspace. */
append_format(stdout_buffer, L"%lc", L'\b'); append_format(stdout_buffer, L"%lc", L'\b');
break; break;
case L'c': /* Cancel the rest of the output. */ case L'c': /* Cancel the rest of the output. */
return; return;
break; break;
case L'f': /* Form feed. */ case L'f': /* Form feed. */
append_format(stdout_buffer, L"%lc", L'\f'); append_format(stdout_buffer, L"%lc", L'\f');
break; break;
case L'n': /* New line. */ case L'n': /* New line. */
append_format(stdout_buffer, L"%lc", L'\n'); append_format(stdout_buffer, L"%lc", L'\n');
break; break;
case L'r': /* Carriage retturn. */ case L'r': /* Carriage retturn. */
append_format(stdout_buffer, L"%lc", L'\r'); append_format(stdout_buffer, L"%lc", L'\r');
break; break;
case L't': /* Horizontal tab. */ case L't': /* Horizontal tab. */
append_format(stdout_buffer, L"%lc", L'\t'); append_format(stdout_buffer, L"%lc", L'\t');
break; break;
case L'v': /* Vertical tab. */ case L'v': /* Vertical tab. */
append_format(stdout_buffer, L"%lc", L'\v'); append_format(stdout_buffer, L"%lc", L'\v');
break; break;
default: default:
append_format(stdout_buffer, L"%lc", c); append_format(stdout_buffer, L"%lc", c);
break; 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. */ /* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits. */
for (esc_length = 0, ++p; for (esc_length = 0, ++p;
esc_length < 2 && isxdigit(to_uwchar_t(*p)); esc_length < 2 && isxdigit(to_uwchar_t(*p));
++esc_length, ++p) ++esc_length, ++p)
esc_value = esc_value * 16 + hextobin(*p); esc_value = esc_value * 16 + hextobin(*p);
if (esc_length == 0) if (esc_length == 0)
append_format(stderr_buffer, _(L"missing hexadecimal number in escape")); append_format(stderr_buffer, _(L"missing hexadecimal number in escape"));
append_format(stdout_buffer, L"%lc", esc_value); 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 Allow \ooo if octal_0 && *p != L'0'; this is an undocumented
extension to POSIX that is compatible with Bash 2.05b. */ extension to POSIX that is compatible with Bash 2.05b. */
for (esc_length = 0, p += octal_0 && *p == L'0'; for (esc_length = 0, p += octal_0 && *p == L'0';
esc_length < 3 && isodigit(*p); esc_length < 3 && isodigit(*p);
++esc_length, ++p) ++esc_length, ++p)
esc_value = esc_value * 8 + octtobin(*p); esc_value = esc_value * 8 + octtobin(*p);
append_format(stdout_buffer, L"%c", esc_value); append_format(stdout_buffer, L"%c", esc_value);
} }
else if (*p && wcschr(L"\"\\abcfnrtv", *p)) else if (*p && wcschr(L"\"\\abcfnrtv", *p))
print_esc_char(*p++); print_esc_char(*p++);
else if (*p == L'u' || *p == L'U') 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; uni_value = 0;
for (esc_length = (esc_char == L'u' ? 4 : 8), ++p; for (esc_length = (esc_char == L'u' ? 4 : 8), ++p;
esc_length > 0; esc_length > 0;
--esc_length, ++p) --esc_length, ++p)
{ {
if (! isxdigit(to_uwchar_t(*p))) if (! isxdigit(to_uwchar_t(*p)))
append_format(stderr_buffer, _(L"missing hexadecimal number in escape")); 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 name shall not designate a character in the required
character set. */ character set. */
if ((uni_value <= 0x9f if ((uni_value <= 0x9f
&& uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60) && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60)
|| (uni_value >= 0xd800 && uni_value <= 0xdfff)) || (uni_value >= 0xd800 && uni_value <= 0xdfff))
append_format(stderr_buffer, _(L"invalid universal character name \\%c%0*x"), append_format(stderr_buffer, _(L"invalid universal character name \\%c%0*x"),
esc_char, (esc_char == L'u' ? 4 : 8), uni_value); esc_char, (esc_char == L'u' ? 4 : 8), uni_value);
append_format(stdout_buffer, L"%lc", uni_value); append_format(stdout_buffer, L"%lc", uni_value);
} }
else else
{ {
@ -360,9 +361,9 @@ print_esc_string(const wchar_t *str)
be formatted. */ be formatted. */
void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wchar_t conversion, 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_field_width, int field_width,
bool have_precision, int precision, bool have_precision, int precision,
wchar_t const *argument) wchar_t const *argument)
{ {
wcstring fmt; wcstring fmt;
@ -376,16 +377,24 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
switch (conversion) switch (conversion)
{ {
case L'd': case L'i': case L'd':
case L'i':
length_modifier = L"lld"; length_modifier = L"lld";
length_modifier_len = sizeof L"lld" - 2; length_modifier_len = sizeof L"lld" - 2;
break; break;
case L'a': case L'e': case L'f': case L'g': case L'a':
case L'A': case L'E': case L'F': case L'G': 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 = L"L";
length_modifier_len = 1; length_modifier_len = 1;
break; break;
case L's': case L'u': case L's':
case L'u':
length_modifier = L"l"; length_modifier = L"l";
length_modifier_len = 1; length_modifier_len = 1;
break; break;
@ -478,15 +487,17 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
case L'c': case L'c':
if (!have_field_width) if (!have_field_width)
append_format(stdout_buffer, fmt.c_str(), *argument); append_format(stdout_buffer, fmt.c_str(), *argument);
else else
append_format(stdout_buffer, fmt.c_str(), field_width, *argument); append_format(stdout_buffer, fmt.c_str(), field_width, *argument);
break; break;
case L's': case L's':
if (!have_field_width) if (!have_field_width)
{ {
if (!have_precision){ if (!have_precision)
append_format(stdout_buffer, fmt.c_str(), argument);} {
append_format(stdout_buffer, fmt.c_str(), argument);
}
else else
append_format(stdout_buffer, fmt.c_str(), precision, argument); 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. arguments to any `%' directives.
Return the number of elements of ARGV used. */ 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. */ int save_argc = argc; /* Preserve original value. */
const wchar_t *f; /* Pointer into `format'. */ const wchar_t *f; /* Pointer into `format'. */
const wchar_t *direc_start; /* Start of % directive. */ 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['a'] = ok['A'] = ok['c'] = ok['d'] = ok['e'] = ok['E'] =
ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] = ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] =
ok['s'] = ok['u'] = ok['x'] = ok['X'] = true; ok['s'] = ok['u'] = ok['x'] = ok['X'] = true;
for (;; f++, direc_length++) 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': case L'I':
#endif #endif
case L'\'': case L'\'':
ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] = ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] =
ok['o'] = ok['s'] = ok['x'] = ok['X'] = false; ok['o'] = ok['s'] = ok['x'] = ok['X'] = false;
break; break;
case '-': case '+': case ' ': case '-':
break; case '+':
case ' ':
break;
case L'#': case L'#':
ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = false; ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = false;
break; break;
case '0': case '0':
ok['c'] = ok['s'] = false; ok['c'] = ok['s'] = false;
break; break;
default: default:
goto no_more_flag_characters; goto no_more_flag_characters;
} }
} }
no_more_flag_characters:; no_more_flag_characters:
;
if (*f == L'*') 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); intmax_t prec = string_to_scalar_type<intmax_t>(*argv, this);
if (prec < 0) if (prec < 0)
{ {
/* A negative precision is taken as if the /* A negative precision is taken as if the
precision were omitted, so -1 is safe precision were omitted, so -1 is safe
here even if prec < INT_MIN. */ here even if prec < INT_MIN. */
precision = -1; precision = -1;
} }
else if (INT_MAX < prec) else if (INT_MAX < prec)
append_format(stderr_buffer, _(L"invalid precision: %ls"), *argv); 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; ++argv;
--argc; --argc;
} }
else
{
precision = 0;
}
have_precision = true;
}
else 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)) unsigned wchar_t conversion = *f;
{ if (! ok[conversion])
++f; append_format(stderr_buffer,
++direc_length; _("%.*ls: invalid conversion specification"),
} (int)(f + 1 - direc_start), direc_start);
} }
}
while (*f == L'l' || *f == L'L' || *f == L'h' print_direc(direc_start, direc_length, *f,
|| *f == L'j' || *f == L't' || *f == L'z') have_field_width, field_width,
++f; have_precision, precision,
{ (argc <= 0 ? L"" : (argc--, *argv++)));
unsigned wchar_t conversion = *f; break;
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;
case L'\\': case L'\\':
f += print_esc(f, false); f += print_esc(f, false);
@ -666,8 +681,8 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
default: default:
append_format(stdout_buffer, L"%lc", *f); append_format(stdout_buffer, L"%lc", *f);
}
} }
}
return save_argc - argc; return save_argc - argc;
} }
@ -675,7 +690,7 @@ static int builtin_printf(parser_t &parser, wchar_t **argv)
{ {
builtin_printf_state_t state; builtin_printf_state_t state;
state.exit_code = STATUS_BUILTIN_OK; state.exit_code = STATUS_BUILTIN_OK;
wchar_t *format; wchar_t *format;
int args_used; int args_used;
int argc = builtin_count_args(argv); int argc = builtin_count_args(argv);
@ -697,5 +712,5 @@ static int builtin_printf(parser_t &parser, wchar_t **argv)
argv += args_used; argv += args_used;
} }
while (args_used > 0 && argc > 0); while (args_used > 0 && argc > 0);
return state.exit_code; return state.exit_code;
} }

View file

@ -546,7 +546,7 @@ expression *test_parser::parse_3_arg_expression(unsigned int start, unsigned int
{ {
assert(end - start == 3); assert(end - start == 3);
expression *result = NULL; expression *result = NULL;
const token_info_t *center_token = token_for_string(arg(start + 1)); const token_info_t *center_token = token_for_string(arg(start + 1));
if (center_token->flags & BINARY_PRIMARY) 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); assert(end - start == 4);
expression *result = NULL; expression *result = NULL;
token_t first_token = token_for_string(arg(start))->tok; token_t first_token = token_for_string(arg(start))->tok;
if (first_token == test_bang) 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); return error(L"Missing argument at index %u", start);
} }
unsigned int argc = end - start; unsigned int argc = end - start;
switch (argc) switch (argc)
{ {
case 0: case 0:
assert(0); //should have been caught by the above test assert(0); //should have been caught by the above test
return NULL; return NULL;
case 1: case 1:
{ {
return error(L"Missing argument at index %u", start + 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); return parse_unary_expression(start, end);
} }
case 3: case 3:
{ {
return parse_3_arg_expression(start, end); return parse_3_arg_expression(start, end);
} }
case 4: case 4:
{ {
return parse_4_arg_expression(start, end); return parse_4_arg_expression(start, end);
} }
default: default:
{ {
return parse_combining_expression(start, end); 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) int builtin_test(parser_t &parser, wchar_t **argv)
{ {
using namespace test_expressions; using namespace test_expressions;
/* The first argument should be the name of the command ('test') */ /* The first argument should be the name of the command ('test') */
if (! argv[0]) if (! argv[0])
return BUILTIN_TEST_FAIL; return BUILTIN_TEST_FAIL;
/* Whether we are invoked with bracket '[' or not */ /* Whether we are invoked with bracket '[' or not */
const bool is_bracket = ! wcscmp(argv[0], L"["); const bool is_bracket = ! wcscmp(argv[0], L"[");
size_t argc = 0; size_t argc = 0;
while (argv[argc + 1]) while (argv[argc + 1])
argc++; 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 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) 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"); builtin_show_error(L"[: the last argument must be ']'\n");
return BUILTIN_TEST_FAIL; return BUILTIN_TEST_FAIL;
} }
} }
/* Collect the arguments into a list */ /* Collect the arguments into a list */
const wcstring_list_t args(argv + 1, argv + 1 + argc); const wcstring_list_t args(argv + 1, argv + 1 + argc);
switch (argc) switch (argc)
{ {
case 0: case 0:

View file

@ -345,26 +345,26 @@ class completer_t
/** Table of completions conditions that have already been tested and the corresponding test results */ /** Table of completions conditions that have already been tested and the corresponding test results */
typedef std::map<wcstring, bool> condition_cache_t; typedef std::map<wcstring, bool> condition_cache_t;
condition_cache_t condition_cache; condition_cache_t condition_cache;
enum complete_type_t enum complete_type_t
{ {
COMPLETE_DEFAULT, COMPLETE_DEFAULT,
COMPLETE_AUTOSUGGEST COMPLETE_AUTOSUGGEST
}; };
complete_type_t type() const complete_type_t type() const
{ {
return (flags & COMPLETION_REQUEST_AUTOSUGGESTION) ? COMPLETE_AUTOSUGGEST : COMPLETE_DEFAULT; return (flags & COMPLETION_REQUEST_AUTOSUGGESTION) ? COMPLETE_AUTOSUGGEST : COMPLETE_DEFAULT;
} }
bool wants_descriptions() const bool wants_descriptions() const
{ {
return !! (flags & COMPLETION_REQUEST_DESCRIPTIONS); return !!(flags & COMPLETION_REQUEST_DESCRIPTIONS);
} }
bool fuzzy() const 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 */ /* Make our completer */
completer_t completer(cmd, flags); 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; const wchar_t *tok_begin, *tok_end, *cmdsubst_begin, *cmdsubst_end, *prev_begin, *prev_end;
wcstring current_token, prev_token; wcstring current_token, prev_token;
wcstring current_command; wcstring current_command;

View file

@ -77,7 +77,7 @@ enum
/** This completion is case insensitive. */ /** This completion is case insensitive. */
COMPLETE_CASE_INSENSITIVE = 1 << 1, COMPLETE_CASE_INSENSITIVE = 1 << 1,
/** This is not the suffix of a token, but replaces it entirely */ /** This is not the suffix of a token, but replaces it entirely */
COMPLETE_REPLACES_TOKEN = 1 << 2, COMPLETE_REPLACES_TOKEN = 1 << 2,
@ -139,7 +139,8 @@ public:
bool operator != (const completion_t& rhs) const; bool operator != (const completion_t& rhs) const;
}; };
enum { enum
{
COMPLETION_REQUEST_DEFAULT = 0, COMPLETION_REQUEST_DEFAULT = 0,
COMPLETION_REQUEST_AUTOSUGGESTION = 1 << 0, // indicates the completion is for an autosuggestion COMPLETION_REQUEST_AUTOSUGGESTION = 1 << 0, // indicates the completion is for an autosuggestion
COMPLETION_REQUEST_DESCRIPTIONS = 1 << 1, // indicates that we want descriptions COMPLETION_REQUEST_DESCRIPTIONS = 1 << 1, // indicates that we want descriptions

View file

@ -936,7 +936,7 @@ static void test_test()
/* This crashed */ /* This crashed */
assert(run_test_test(1, L"1 = 1 -a = 1")); 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 */ /* 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(0, L"-S = -S"));
assert(run_test_test(1, L"! ! ! A")); 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"}; 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; size_t count = sizeof name_strs / sizeof *name_strs;
const wcstring_list_t names(name_strs, name_strs + count); const wcstring_list_t names(name_strs, name_strs + count);
complete_set_variable_names(&names); complete_set_variable_names(&names);
std::vector<completion_t> completions; std::vector<completion_t> completions;
complete(L"$F", completions, COMPLETION_REQUEST_DEFAULT); complete(L"$F", completions, COMPLETION_REQUEST_DEFAULT);
assert(completions.size() == 3); assert(completions.size() == 3);
assert(completions.at(0).completion == L"oo1"); assert(completions.at(0).completion == L"oo1");
assert(completions.at(1).completion == L"oo2"); assert(completions.at(1).completion == L"oo2");
assert(completions.at(2).completion == L"oo3"); assert(completions.at(2).completion == L"oo3");
complete_set_variable_names(NULL); complete_set_variable_names(NULL);
} }
@ -1714,7 +1714,7 @@ int main(int argc, char **argv)
builtin_init(); builtin_init();
reader_init(); reader_init();
env_init(); env_init();
test_format(); test_format();
test_escape(); test_escape();
test_convert(); test_convert();

View file

@ -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++) for (size_t i=0; i< comp.size(); i++)
{ {
const completion_t &el = comp.at(i); const completion_t &el = comp.at(i);
if (! (el.flags & COMPLETE_CASE_INSENSITIVE)) if (!(el.flags & COMPLETE_CASE_INSENSITIVE))
{ {
has_case_sensitive = true; has_case_sensitive = true;
break; 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 */ /* 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); const wcstring buffcpy = wcstring(cmdsub_begin, token_end);
//fprintf(stderr, "Complete (%ls)\n", buffcpy.c_str()); //fprintf(stderr, "Complete (%ls)\n", buffcpy.c_str());
data->complete_func(buffcpy, comp, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_DESCRIPTIONS, NULL); data->complete_func(buffcpy, comp, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_DESCRIPTIONS, NULL);