mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Apply clang-format 10 and selected lints from "make lint-all"
This commit is contained in:
parent
25fe353187
commit
76e0875c8f
10 changed files with 81 additions and 91 deletions
|
@ -559,7 +559,7 @@ unique_ptr<expression> test_parser::parse_args(const wcstring_list_t &args, wcst
|
||||||
int narg = 0;
|
int narg = 0;
|
||||||
int len_to_err = 0;
|
int len_to_err = 0;
|
||||||
wcstring commandline;
|
wcstring commandline;
|
||||||
for (auto arg : args) {
|
for (const wcstring &arg : args) {
|
||||||
if (narg > 0) {
|
if (narg > 0) {
|
||||||
commandline.append(L" ");
|
commandline.append(L" ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -637,7 +637,7 @@ std::shared_ptr<const null_terminated_array_t<char>> env_scoped_impl_t::create_e
|
||||||
// which we depend on here.
|
// which we depend on here.
|
||||||
// Note: Using std::move around make_pair prevents the compiler from implementing
|
// Note: Using std::move around make_pair prevents the compiler from implementing
|
||||||
// copy elision.
|
// copy elision.
|
||||||
vals.insert(std::make_pair(std::move(key), std::move(*var)));
|
vals.insert(std::make_pair(key, std::move(*var)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,7 +442,9 @@ std::string env_universal_t::serialize_with_vars(const var_table_t &vars) {
|
||||||
contents.append("# VERSION: " UVARS_VERSION_3_0 "\n");
|
contents.append("# VERSION: " UVARS_VERSION_3_0 "\n");
|
||||||
|
|
||||||
// Preserve legacy behavior by sorting the values first
|
// Preserve legacy behavior by sorting the values first
|
||||||
typedef std::pair<std::reference_wrapper<const wcstring>, std::reference_wrapper<const env_var_t>> env_pair_t;
|
typedef std::pair<std::reference_wrapper<const wcstring>,
|
||||||
|
std::reference_wrapper<const env_var_t>>
|
||||||
|
env_pair_t;
|
||||||
std::vector<env_pair_t> cloned(vars.begin(), vars.end());
|
std::vector<env_pair_t> cloned(vars.begin(), vars.end());
|
||||||
std::sort(cloned.begin(), cloned.end(), [](const env_pair_t &p1, const env_pair_t &p2) {
|
std::sort(cloned.begin(), cloned.end(), [](const env_pair_t &p1, const env_pair_t &p2) {
|
||||||
return p1.first.get() < p2.first.get();
|
return p1.first.get() < p2.first.get();
|
||||||
|
|
|
@ -645,7 +645,7 @@ static expand_result_t expand_cmdsubst(wcstring input, const operation_context_t
|
||||||
if (*tail_begin == L'[') {
|
if (*tail_begin == L'[') {
|
||||||
std::vector<long> slice_idx;
|
std::vector<long> slice_idx;
|
||||||
const wchar_t *const slice_begin = tail_begin;
|
const wchar_t *const slice_begin = tail_begin;
|
||||||
wchar_t *slice_end;
|
wchar_t *slice_end = nullptr;
|
||||||
size_t bad_pos;
|
size_t bad_pos;
|
||||||
|
|
||||||
bad_pos = parse_slice(slice_begin, &slice_end, slice_idx, sub_res.size());
|
bad_pos = parse_slice(slice_begin, &slice_end, slice_idx, sub_res.size());
|
||||||
|
|
|
@ -349,13 +349,13 @@ static void test_unescape_sane() {
|
||||||
{L"'\\143'", L"\\143"}, {L"\\n", L"\n"} // \n normally becomes newline
|
{L"'\\143'", L"\\143"}, {L"\\n", L"\n"} // \n normally becomes newline
|
||||||
};
|
};
|
||||||
wcstring output;
|
wcstring output;
|
||||||
for (size_t i = 0; i < sizeof tests / sizeof *tests; i++) {
|
for (const auto &test : tests) {
|
||||||
bool ret = unescape_string(tests[i].input, &output, UNESCAPE_DEFAULT);
|
bool ret = unescape_string(test.input, &output, UNESCAPE_DEFAULT);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
err(L"Failed to unescape '%ls'\n", tests[i].input);
|
err(L"Failed to unescape '%ls'\n", test.input);
|
||||||
} else if (output != tests[i].expected) {
|
} else if (output != test.expected) {
|
||||||
err(L"In unescaping '%ls', expected '%ls' but got '%ls'\n", tests[i].input,
|
err(L"In unescaping '%ls', expected '%ls' but got '%ls'\n", test.input, test.expected,
|
||||||
tests[i].expected, output.c_str());
|
output.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,11 +451,10 @@ static void test_format() {
|
||||||
const char *expected;
|
const char *expected;
|
||||||
} tests[] = {{0, "empty"}, {1, "1B"}, {2, "2B"},
|
} tests[] = {{0, "empty"}, {1, "1B"}, {2, "2B"},
|
||||||
{1024, "1kB"}, {1870, "1.8kB"}, {4322911, "4.1MB"}};
|
{1024, "1kB"}, {1870, "1.8kB"}, {4322911, "4.1MB"}};
|
||||||
size_t i;
|
for (const auto &test : tests) {
|
||||||
for (i = 0; i < sizeof tests / sizeof *tests; i++) {
|
|
||||||
char buff[128];
|
char buff[128];
|
||||||
format_size_safe(buff, tests[i].val);
|
format_size_safe(buff, test.val);
|
||||||
do_test(!std::strcmp(buff, tests[i].expected));
|
do_test(!std::strcmp(buff, test.expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = -129; j <= 129; j++) {
|
for (int j = -129; j <= 129; j++) {
|
||||||
|
@ -1876,12 +1875,11 @@ static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) {
|
||||||
}
|
}
|
||||||
msg += L"], found [";
|
msg += L"], found [";
|
||||||
first = true;
|
first = true;
|
||||||
for (completion_list_t::const_iterator it = output.begin(), end = output.end();
|
for (const auto &completion : output) {
|
||||||
it != end; ++it) {
|
|
||||||
if (!first) msg += L", ";
|
if (!first) msg += L", ";
|
||||||
first = false;
|
first = false;
|
||||||
msg += '"';
|
msg += '"';
|
||||||
msg += it->completion;
|
msg += completion.completion;
|
||||||
msg += '"';
|
msg += '"';
|
||||||
}
|
}
|
||||||
msg += L"]";
|
msg += L"]";
|
||||||
|
@ -2372,8 +2370,7 @@ static void test_1_word_motion(word_motion_t motion, move_word_style_t style,
|
||||||
std::set<size_t> stops;
|
std::set<size_t> stops;
|
||||||
|
|
||||||
// Carets represent stops and should be cut out of the command.
|
// Carets represent stops and should be cut out of the command.
|
||||||
for (size_t i = 0; i < test.size(); i++) {
|
for (wchar_t wc : test) {
|
||||||
wchar_t wc = test.at(i);
|
|
||||||
if (wc == L'^') {
|
if (wc == L'^') {
|
||||||
stops.insert(command.size());
|
stops.insert(command.size());
|
||||||
} else {
|
} else {
|
||||||
|
@ -3330,8 +3327,8 @@ static void test_input() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the desired binding to the queue.
|
// Push the desired binding to the queue.
|
||||||
for (size_t idx = 0; idx < desired_binding.size(); idx++) {
|
for (wchar_t c : desired_binding) {
|
||||||
input.queue_ch(desired_binding.at(idx));
|
input.queue_ch(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now test.
|
// Now test.
|
||||||
|
@ -3963,9 +3960,9 @@ void history_tests_t::test_history_races() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all children.
|
// Wait for all children.
|
||||||
for (size_t i = 0; i < RACE_COUNT; i++) {
|
for (pid_t child : children) {
|
||||||
int stat;
|
int stat;
|
||||||
waitpid(children[i], &stat, WUNTRACED);
|
waitpid(child, &stat, WUNTRACED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the expected lines.
|
// Compute the expected lines.
|
||||||
|
@ -4044,8 +4041,8 @@ void history_tests_t::test_history_merge() {
|
||||||
const wcstring alt_texts[count] = {L"History Alt 1", L"History Alt 2", L"History Alt 3"};
|
const wcstring alt_texts[count] = {L"History Alt 1", L"History Alt 2", L"History Alt 3"};
|
||||||
|
|
||||||
// Make sure history is clear.
|
// Make sure history is clear.
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (auto &hist : hists) {
|
||||||
hists[i]->clear();
|
hist->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we don't add an item in the same second as we created the history.
|
// Make sure we don't add an item in the same second as we created the history.
|
||||||
|
@ -4057,8 +4054,8 @@ void history_tests_t::test_history_merge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save them.
|
// Save them.
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (auto &hist : hists) {
|
||||||
hists[i]->save();
|
hist->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure each history contains what it ought to, but they have not leaked into each other.
|
// Make sure each history contains what it ought to, but they have not leaked into each other.
|
||||||
|
@ -4074,21 +4071,21 @@ void history_tests_t::test_history_merge() {
|
||||||
// is newer, since we only pick up items whose timestamp is before the birth stamp.
|
// is newer, since we only pick up items whose timestamp is before the birth stamp.
|
||||||
time_barrier();
|
time_barrier();
|
||||||
std::unique_ptr<history_t> everything = make_unique<history_t>(name);
|
std::unique_ptr<history_t> everything = make_unique<history_t>(name);
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (const auto &text : texts) {
|
||||||
do_test(history_contains(everything, texts[i]));
|
do_test(history_contains(everything, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell all histories to merge. Now everybody should have everything.
|
// Tell all histories to merge. Now everybody should have everything.
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (auto &hist : hists) {
|
||||||
hists[i]->incorporate_external_changes();
|
hist->incorporate_external_changes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everyone should also have items in the same order (#2312)
|
// Everyone should also have items in the same order (#2312)
|
||||||
wcstring_list_t hist_vals1;
|
wcstring_list_t hist_vals1;
|
||||||
hists[0]->get_history(hist_vals1);
|
hists[0]->get_history(hist_vals1);
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (const auto &hist : hists) {
|
||||||
wcstring_list_t hist_vals2;
|
wcstring_list_t hist_vals2;
|
||||||
hists[i]->get_history(hist_vals2);
|
hist->get_history(hist_vals2);
|
||||||
do_test(hist_vals1 == hist_vals2);
|
do_test(hist_vals1 == hist_vals2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4304,15 +4301,13 @@ static void test_new_parser_correctness() {
|
||||||
{L"true || \n\n false", true},
|
{L"true || \n\n false", true},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof parser_tests / sizeof *parser_tests; i++) {
|
for (const auto &test : parser_tests) {
|
||||||
const parser_test_t *test = &parser_tests[i];
|
|
||||||
|
|
||||||
parse_node_tree_t parse_tree;
|
parse_node_tree_t parse_tree;
|
||||||
bool success = parse_tree_from_string(test->src, parse_flag_none, &parse_tree, NULL);
|
bool success = parse_tree_from_string(test.src, parse_flag_none, &parse_tree, NULL);
|
||||||
if (success && !test->ok) {
|
if (success && !test.ok) {
|
||||||
err(L"\"%ls\" should NOT have parsed, but did", test->src);
|
err(L"\"%ls\" should NOT have parsed, but did", test.src);
|
||||||
} else if (!success && test->ok) {
|
} else if (!success && test.ok) {
|
||||||
err(L"\"%ls\" should have parsed, but failed", test->src);
|
err(L"\"%ls\" should have parsed, but failed", test.src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
say(L"Parse tests complete");
|
say(L"Parse tests complete");
|
||||||
|
@ -4452,21 +4447,20 @@ static void test_new_parser_ll2() {
|
||||||
{L"function", L"function", L"", parse_statement_decoration_none},
|
{L"function", L"function", L"", parse_statement_decoration_none},
|
||||||
{L"function --help", L"function", L"--help", parse_statement_decoration_none}};
|
{L"function --help", L"function", L"--help", parse_statement_decoration_none}};
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof tests / sizeof *tests; i++) {
|
for (const auto &test : tests) {
|
||||||
wcstring cmd, args;
|
wcstring cmd, args;
|
||||||
enum parse_statement_decoration_t deco = parse_statement_decoration_none;
|
enum parse_statement_decoration_t deco = parse_statement_decoration_none;
|
||||||
bool success = test_1_parse_ll2(tests[i].src, &cmd, &args, &deco);
|
bool success = test_1_parse_ll2(test.src, &cmd, &args, &deco);
|
||||||
if (!success)
|
if (!success) err(L"Parse of '%ls' failed on line %ld", test.cmd.c_str(), (long)__LINE__);
|
||||||
err(L"Parse of '%ls' failed on line %ld", tests[i].cmd.c_str(), (long)__LINE__);
|
if (cmd != test.cmd)
|
||||||
if (cmd != tests[i].cmd)
|
|
||||||
err(L"When parsing '%ls', expected command '%ls' but got '%ls' on line %ld",
|
err(L"When parsing '%ls', expected command '%ls' but got '%ls' on line %ld",
|
||||||
tests[i].src.c_str(), tests[i].cmd.c_str(), cmd.c_str(), (long)__LINE__);
|
test.src.c_str(), test.cmd.c_str(), cmd.c_str(), (long)__LINE__);
|
||||||
if (args != tests[i].args)
|
if (args != test.args)
|
||||||
err(L"When parsing '%ls', expected args '%ls' but got '%ls' on line %ld",
|
err(L"When parsing '%ls', expected args '%ls' but got '%ls' on line %ld",
|
||||||
tests[i].src.c_str(), tests[i].args.c_str(), args.c_str(), (long)__LINE__);
|
test.src.c_str(), test.args.c_str(), args.c_str(), (long)__LINE__);
|
||||||
if (deco != tests[i].deco)
|
if (deco != test.deco)
|
||||||
err(L"When parsing '%ls', expected decoration %d but got %d on line %ld",
|
err(L"When parsing '%ls', expected decoration %d but got %d on line %ld",
|
||||||
tests[i].src.c_str(), (int)tests[i].deco, (int)deco, (long)__LINE__);
|
test.src.c_str(), (int)test.deco, (int)deco, (long)__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_function_help<grammar::plain_statement>(L"function -h");
|
check_function_help<grammar::plain_statement>(L"function -h");
|
||||||
|
@ -4516,9 +4510,9 @@ static void test_new_parser_errors() {
|
||||||
{L"if true ; case ; end", parse_error_unbalancing_case},
|
{L"if true ; case ; end", parse_error_unbalancing_case},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof tests / sizeof *tests; i++) {
|
for (const auto &test : tests) {
|
||||||
const wcstring src = tests[i].src;
|
const wcstring src = test.src;
|
||||||
parse_error_code_t expected_code = tests[i].code;
|
parse_error_code_t expected_code = test.code;
|
||||||
|
|
||||||
parse_error_list_t errors;
|
parse_error_list_t errors;
|
||||||
parse_node_tree_t parse_tree;
|
parse_node_tree_t parse_tree;
|
||||||
|
@ -4534,8 +4528,8 @@ static void test_new_parser_errors() {
|
||||||
err(L"Source '%ls' was expected to produce error code %lu, but instead produced error "
|
err(L"Source '%ls' was expected to produce error code %lu, but instead produced error "
|
||||||
L"code %lu",
|
L"code %lu",
|
||||||
src.c_str(), expected_code, (unsigned long)errors.at(0).code);
|
src.c_str(), expected_code, (unsigned long)errors.at(0).code);
|
||||||
for (size_t i = 0; i < errors.size(); i++) {
|
for (const auto &error : errors) {
|
||||||
err(L"\t\t%ls", errors.at(i).describe(src, true).c_str());
|
err(L"\t\t%ls", error.describe(src, true).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4597,8 +4591,7 @@ static bool string_matches_format(const wcstring &string, const wchar_t *format)
|
||||||
bool result = true;
|
bool result = true;
|
||||||
wcstring_list_t components = separate_by_format_specifiers(format);
|
wcstring_list_t components = separate_by_format_specifiers(format);
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
for (size_t i = 0; i < components.size(); i++) {
|
for (const auto &component : components) {
|
||||||
const wcstring &component = components.at(i);
|
|
||||||
size_t where = string.find(component, idx);
|
size_t where = string.find(component, idx);
|
||||||
if (where == wcstring::npos) {
|
if (where == wcstring::npos) {
|
||||||
result = false;
|
result = false;
|
||||||
|
@ -4632,13 +4625,12 @@ static void test_error_messages() {
|
||||||
{L"echo \"foo$(foo)bar\"", ERROR_BAD_VAR_SUBCOMMAND1}};
|
{L"echo \"foo$(foo)bar\"", ERROR_BAD_VAR_SUBCOMMAND1}};
|
||||||
|
|
||||||
parse_error_list_t errors;
|
parse_error_list_t errors;
|
||||||
for (size_t i = 0; i < sizeof error_tests / sizeof *error_tests; i++) {
|
for (const auto &test : error_tests) {
|
||||||
const struct error_test_t *test = &error_tests[i];
|
|
||||||
errors.clear();
|
errors.clear();
|
||||||
parse_util_detect_errors(test->src, &errors, false /* allow_incomplete */);
|
parse_util_detect_errors(test.src, &errors, false /* allow_incomplete */);
|
||||||
do_test(!errors.empty());
|
do_test(!errors.empty());
|
||||||
if (!errors.empty()) {
|
if (!errors.empty()) {
|
||||||
do_test1(string_matches_format(errors.at(0).text, test->error_text_format), test->src);
|
do_test1(string_matches_format(errors.at(0).text, test.error_text_format), test.src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,4 +35,3 @@ ELEM(optional_time)
|
||||||
ELEM(end_command)
|
ELEM(end_command)
|
||||||
ELEM(freestanding_argument_list)
|
ELEM(freestanding_argument_list)
|
||||||
#undef ELEM
|
#undef ELEM
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ class dup2_list_t;
|
||||||
class job_t;
|
class job_t;
|
||||||
class process_t;
|
class process_t;
|
||||||
|
|
||||||
/// Tell the proc \p pid to join process group \p pgrp.
|
/// Tell the proc \p pid to join process group \p pgroup.
|
||||||
/// If \p is_child is true, we are the child process; otherwise we are fish.
|
/// If \p is_child is true, we are the child process; otherwise we are fish.
|
||||||
/// Called by both parent and child; this is an unavoidable race inherent to Unix.
|
/// Called by both parent and child; this is an unavoidable race inherent to Unix.
|
||||||
/// If is_parent is set, then we are the parent process and should swallow EACCESS.
|
/// If is_parent is set, then we are the parent process and should swallow EACCESS.
|
||||||
/// \return 0 on success, an errno error code on failure.
|
/// \return 0 on success, an errno error code on failure.
|
||||||
int execute_setpgid(pid_t pid, pid_t pgrp, bool is_parent);
|
int execute_setpgid(pid_t pid, pid_t pgroup, bool is_parent);
|
||||||
|
|
||||||
/// Report the error code \p err for a failed setpgid call.
|
/// Report the error code \p err for a failed setpgid call.
|
||||||
/// Note not all errors should be reported; in particular EACCESS is expected and benign in the
|
/// Note not all errors should be reported; in particular EACCESS is expected and benign in the
|
||||||
|
|
|
@ -1683,7 +1683,6 @@ bool reader_data_t::handle_completions(const completion_list_t &comp, size_t tok
|
||||||
// No suitable completions found, flash screen and return.
|
// No suitable completions found, flash screen and return.
|
||||||
flash();
|
flash();
|
||||||
done = true;
|
done = true;
|
||||||
success = false;
|
|
||||||
} else if (size == 1) {
|
} else if (size == 1) {
|
||||||
// Exactly one suitable completion found - insert it.
|
// Exactly one suitable completion found - insert it.
|
||||||
const completion_t &c = comp.at(0);
|
const completion_t &c = comp.at(0);
|
||||||
|
@ -1783,7 +1782,6 @@ bool reader_data_t::handle_completions(const completion_list_t &comp, size_t tok
|
||||||
completion_insert(common_prefix.c_str(), token_end, flags);
|
completion_insert(common_prefix.c_str(), token_end, flags);
|
||||||
cycle_command_line = command_line.text();
|
cycle_command_line = command_line.text();
|
||||||
cycle_cursor_pos = command_line.position();
|
cycle_cursor_pos = command_line.position();
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3434,7 +3432,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
||||||
editable_line_t *el = active_edit_line();
|
editable_line_t *el = active_edit_line();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
jump_direction_t original_dir, dir;
|
jump_direction_t original_dir, dir;
|
||||||
original_dir = dir = last_jump_direction;
|
original_dir = last_jump_direction;
|
||||||
|
|
||||||
if (last_jump_direction == jump_direction_t::forward) {
|
if (last_jump_direction == jump_direction_t::forward) {
|
||||||
dir = jump_direction_t::backward;
|
dir = jump_direction_t::backward;
|
||||||
|
|
|
@ -24,7 +24,7 @@ static maybe_t<termsize_t> read_termsize_from_tty() {
|
||||||
// static
|
// static
|
||||||
termsize_container_t &termsize_container_t::shared() {
|
termsize_container_t &termsize_container_t::shared() {
|
||||||
// Heap-allocated to avoid runtime dtor registration.
|
// Heap-allocated to avoid runtime dtor registration.
|
||||||
static termsize_container_t *res = new termsize_container_t(read_termsize_from_tty);
|
static auto *res = new termsize_container_t(read_termsize_from_tty);
|
||||||
return *res;
|
return *res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,12 +207,11 @@ static bool wildcard_complete_internal(const wchar_t * const str, size_t str_len
|
||||||
const wchar_t *const wc, size_t wc_len,
|
const wchar_t *const wc, size_t wc_len,
|
||||||
const wc_complete_pack_t ¶ms, complete_flags_t flags,
|
const wc_complete_pack_t ¶ms, complete_flags_t flags,
|
||||||
completion_list_t *out, bool is_first_call);
|
completion_list_t *out, bool is_first_call);
|
||||||
__attribute__((unused))
|
__attribute__((unused)) static bool wildcard_complete_internal(
|
||||||
static bool wildcard_complete_internal(const wchar_t * const str, const wchar_t * const wc,
|
const wchar_t *const str, const wchar_t *const wc, const wc_complete_pack_t ¶ms,
|
||||||
const wc_complete_pack_t ¶ms, complete_flags_t flags,
|
complete_flags_t flags, completion_list_t *out, bool is_first_call = false) {
|
||||||
completion_list_t *out, bool is_first_call = false) {
|
return wildcard_complete_internal(str, std::wcslen(str), wc, std::wcslen(wc), params, flags,
|
||||||
return wildcard_complete_internal(
|
out, is_first_call);
|
||||||
str, std::wcslen(str), wc, std::wcslen(wc), params, flags, out, is_first_call);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wildcard_complete_internal(const wchar_t *const str, size_t str_len,
|
static bool wildcard_complete_internal(const wchar_t *const str, size_t str_len,
|
||||||
|
@ -300,7 +299,8 @@ static bool wildcard_complete_internal(const wchar_t * const str, size_t str_len
|
||||||
if (str[0] == L'\0') {
|
if (str[0] == L'\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return wildcard_complete_internal(str + 1, str_len - 1, wc + 1, wc_len - 1, params, flags, out);
|
return wildcard_complete_internal(str + 1, str_len - 1, wc + 1, wc_len - 1, params,
|
||||||
|
flags, out);
|
||||||
}
|
}
|
||||||
case ANY_STRING: {
|
case ANY_STRING: {
|
||||||
// Hackish. If this is the last character of the wildcard, then just complete with
|
// Hackish. If this is the last character of the wildcard, then just complete with
|
||||||
|
@ -316,7 +316,8 @@ static bool wildcard_complete_internal(const wchar_t * const str, size_t str_len
|
||||||
bool has_match = false;
|
bool has_match = false;
|
||||||
for (size_t i = 0; str[i] != L'\0'; i++) {
|
for (size_t i = 0; str[i] != L'\0'; i++) {
|
||||||
const size_t before_count = out ? out->size() : 0;
|
const size_t before_count = out ? out->size() : 0;
|
||||||
if (wildcard_complete_internal(str + i, str_len - i, wc + 1, wc_len - 1, params, flags, out)) {
|
if (wildcard_complete_internal(str + i, str_len - i, wc + 1, wc_len - 1, params,
|
||||||
|
flags, out)) {
|
||||||
// We found a match.
|
// We found a match.
|
||||||
has_match = true;
|
has_match = true;
|
||||||
|
|
||||||
|
@ -353,8 +354,7 @@ bool wildcard_complete(const wcstring &str, const wchar_t *wc,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wildcard_match(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match) {
|
bool wildcard_match(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match) {
|
||||||
enum fuzzy_match_type_t match =
|
enum fuzzy_match_type_t match = wildcard_match_internal(str, wc, leading_dots_fail_to_match);
|
||||||
wildcard_match_internal(str, wc, leading_dots_fail_to_match);
|
|
||||||
return match != fuzzy_match_none;
|
return match != fuzzy_match_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,6 @@ static int fast_waccess(const struct stat &stat_buf, uint8_t mode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Obtain a description string for the file specified by the filename.
|
/// Obtain a description string for the file specified by the filename.
|
||||||
///
|
///
|
||||||
/// The returned value is a string constant and should not be free'd.
|
/// The returned value is a string constant and should not be free'd.
|
||||||
|
|
Loading…
Reference in a new issue