From 835c6ffa673c6ef7f46986438aa12aa1819ebf7f Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 27 May 2019 19:47:13 -0700 Subject: [PATCH] clang-format all files --- src/common.cpp | 10 ++++--- src/complete.cpp | 6 ++-- src/exec.cpp | 4 +-- src/expand.cpp | 4 ++- src/fish_indent.cpp | 68 ++++++++++++++++++++++----------------------- src/screen.cpp | 14 ++++++---- src/wutil.cpp | 2 +- 7 files changed, 59 insertions(+), 49 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 44091d56a..ccfc0764f 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1535,7 +1535,8 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in if (unescape_special) { brace_count++; to_append_or_none = BRACE_BEGIN; - // We need to store where the brace *ends up* in the output because of NOT_A_WCHAR. + // We need to store where the brace *ends up* in the output because of + // NOT_A_WCHAR. braces.push_back(result.size()); } break; @@ -1563,10 +1564,11 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in to_append_or_none = L'}'; } - // Remove all seps inside the current brace pair, so if we have a surrounding pair - // we only get seps inside *that*. + // Remove all seps inside the current brace pair, so if we have a + // surrounding pair we only get seps inside *that*. if (vars_or_seps.size()) { - while(vars_or_seps.size() && vars_or_seps.back() > braces.back()) vars_or_seps.pop_back(); + while (vars_or_seps.size() && vars_or_seps.back() > braces.back()) + vars_or_seps.pop_back(); } braces.pop_back(); } diff --git a/src/complete.cpp b/src/complete.cpp index 5fb2fb987..750d9dbc6 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -243,7 +243,8 @@ static bool compare_completions_by_duplicate_arguments(const completion_t &a, } static bool compare_completions_by_tilde(const completion_t &a, const completion_t &b) { - return (a.completion.empty() < b.completion.empty()) || (a.completion.back() == L'~') < (b.completion.back() == L'~'); + return (a.completion.empty() < b.completion.empty()) || + (a.completion.back() == L'~') < (b.completion.back() == L'~'); } /// Unique the list of completions, without perturbing their order. static void unique_completions_retaining_order(std::vector *comps) { @@ -286,7 +287,8 @@ void completions_sort_and_prioritize(std::vector *comps, stable_sort(comps->begin(), comps->end(), compare_completions_by_match_type); // Lastly, if this is for an autosuggestion, prefer to avoid completions that duplicate - // arguments, and penalize files that end in tilde - they're frequently autosave files from e.g. emacs. + // arguments, and penalize files that end in tilde - they're frequently autosave files from e.g. + // emacs. if (flags & completion_request_t::autosuggestion) { stable_sort(comps->begin(), comps->end(), compare_completions_by_duplicate_arguments); stable_sort(comps->begin(), comps->end(), compare_completions_by_tilde); diff --git a/src/exec.cpp b/src/exec.cpp index eb2f163ed..a9dbc1d43 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -715,8 +715,8 @@ static bool exec_external_command(parser_t &parser, const std::shared_ptr // A 0 pid means we failed to posix_spawn. Since we have no pid, we'll never get // told when it's exited, so we have to mark the process as failed. - FLOGF(exec_fork, L"Fork #%d, pid %d: spawn external command '%s' from '%ls'", g_fork_count, pid, - actual_cmd, file ? file : L""); + FLOGF(exec_fork, L"Fork #%d, pid %d: spawn external command '%s' from '%ls'", g_fork_count, + pid, actual_cmd, file ? file : L""); if (pid == 0) { job_mark_process_as_failed(j, p); return false; diff --git a/src/expand.cpp b/src/expand.cpp index d6c55c1b0..a9d155260 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -124,7 +124,9 @@ static void append_cmdsub_error(parse_error_list_t *errors, size_t source_start, /// Test if the specified string does not contain character which can not be used inside a quoted /// string. -static bool is_quotable(const wcstring &str) { return str.find_first_of(L"\n\t\r\b\x1B") == wcstring::npos; } +static bool is_quotable(const wcstring &str) { + return str.find_first_of(L"\n\t\r\b\x1B") == wcstring::npos; +} wcstring expand_escape_variable(const env_var_t &var) { wcstring buff; diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index ef2fc6168..4d78166fc 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -236,8 +236,7 @@ void prettifier_t::prettify_node(const parse_node_tree_t &tree, node_offset_t no if (last_was_semicolon) { // We keep the semicolon for `; and` and `; or`, // others we turn into newlines. - if (node.keyword != parse_keyword_and - && node.keyword != parse_keyword_or) { + if (node.keyword != parse_keyword_and && node.keyword != parse_keyword_or) { append_newline(); } else { output.push_back(L';'); @@ -621,12 +620,12 @@ int main(int argc, char *argv[]) { argv += optind; wcstring src; - for (int i = 0; i < argc || (argc == 0 && i == 0) ; i++) { + for (int i = 0; i < argc || (argc == 0 && i == 0); i++) { if (argc == 0 && i == 0) { if (output_type == output_type_file) { - std::fwprintf(stderr, - _(L"Expected file path to read/write for -w:\n\n $ %ls -w foo.fish\n"), - program_name); + std::fwprintf( + stderr, _(L"Expected file path to read/write for -w:\n\n $ %ls -w foo.fish\n"), + program_name); exit(1); } src = read_file(stdin); @@ -637,7 +636,8 @@ int main(int argc, char *argv[]) { fclose(fh); output_location = argv[i]; } else { - std::fwprintf(stderr, _(L"Opening \"%s\" failed: %s\n"), *argv, std::strerror(errno)); + std::fwprintf(stderr, _(L"Opening \"%s\" failed: %s\n"), *argv, + std::strerror(errno)); exit(1); } } @@ -659,34 +659,34 @@ int main(int argc, char *argv[]) { std::string colored_output; switch (output_type) { - case output_type_plain_text: { - colored_output = no_colorize(output_wtext); - break; - } - case output_type_file: { - FILE *fh = fopen(output_location, "w"); - if (fh) { - std::fputws(output_wtext.c_str(), fh); - fclose(fh); - } else { - std::fwprintf(stderr, _(L"Opening \"%s\" failed: %s\n"), output_location, - std::strerror(errno)); - exit(1); + case output_type_plain_text: { + colored_output = no_colorize(output_wtext); + break; + } + case output_type_file: { + FILE *fh = fopen(output_location, "w"); + if (fh) { + std::fputws(output_wtext.c_str(), fh); + fclose(fh); + } else { + std::fwprintf(stderr, _(L"Opening \"%s\" failed: %s\n"), output_location, + std::strerror(errno)); + exit(1); + } + break; + } + case output_type_ansi: { + colored_output = ansi_colorize(output_wtext, colors); + break; + } + case output_type_html: { + colored_output = html_colorize(output_wtext, colors); + break; + } + case output_type_pygments_csv: { + DIE("pygments_csv should have been handled above"); + break; } - break; - } - case output_type_ansi: { - colored_output = ansi_colorize(output_wtext, colors); - break; - } - case output_type_html: { - colored_output = html_colorize(output_wtext, colors); - break; - } - case output_type_pygments_csv: { - DIE("pygments_csv should have been handled above"); - break; - } } std::fputws(str2wcstring(colored_output).c_str(), stdout); diff --git a/src/screen.cpp b/src/screen.cpp index cda851cad..180e2f228 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -467,8 +467,8 @@ static void s_move(screen_t *s, int new_x, int new_y) { str = cursor_up; } else if (y_steps > 0) { str = cursor_down; - if ((shell_modes.c_oflag & ONLCR) != 0 - && std::strcmp(str, "\n") == 0) { // See GitHub issue #4505. + if ((shell_modes.c_oflag & ONLCR) != 0 && + std::strcmp(str, "\n") == 0) { // See GitHub issue #4505. // Most consoles use a simple newline as the cursor down escape. // If ONLCR is enabled (which it normally is) this will of course // also move the cursor to the beginning of the line. @@ -558,7 +558,8 @@ static size_t line_shared_prefix(const line_t &a, const line_t &b) { if (ac != bc || a.color_at(idx) != b.color_at(idx)) { if (idx > 0) { const line_t *c = nullptr; - // Possible combining mark, go back until we hit _two_ printable characters or idx of 0. + // Possible combining mark, go back until we hit _two_ printable characters or idx + // of 0. if (fish_wcwidth(a.char_at(idx)) < 1) { c = &a; } else if (fish_wcwidth(b.char_at(idx)) < 1) { @@ -566,7 +567,9 @@ static size_t line_shared_prefix(const line_t &a, const line_t &b) { } if (c) { - while (idx > 1 && (fish_wcwidth(c->char_at(idx - 1)) < 1 || fish_wcwidth(c->char_at(idx)) < 1)) idx--; + while (idx > 1 && (fish_wcwidth(c->char_at(idx - 1)) < 1 || + fish_wcwidth(c->char_at(idx)) < 1)) + idx--; if (idx == 1 && fish_wcwidth(c->char_at(idx)) < 1) idx = 0; } } @@ -1036,7 +1039,8 @@ void s_write(screen_t *s, const wcstring &left_prompt, const wcstring &right_pro cursor_arr = s->desired.cursor; } s_desired_append_char(s, effective_commandline.at(i), colors[i], indent[i], - first_line_prompt_space, fish_wcwidth_min_0(effective_commandline.at(i))); + first_line_prompt_space, + fish_wcwidth_min_0(effective_commandline.at(i))); } // Cursor may have been at the end too. diff --git a/src/wutil.cpp b/src/wutil.cpp index f5e245239..df8a1e447 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -28,7 +28,7 @@ #include "common.h" #include "fallback.h" // IWYU pragma: keep #include "flog.h" -#include "wutil.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep typedef std::string cstring;