From 1127d7d68f39e4ad70e01777cf48523bbe0eae05 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 30 May 2022 16:14:32 -0700 Subject: [PATCH] clang-format C++ files No functional change (hopefully!) --- src/autoload.cpp | 4 +--- src/common.cpp | 3 +-- src/fish_tests.cpp | 2 +- src/future_feature_flags.cpp | 4 +++- src/highlight.h | 5 +++-- src/history.h | 2 +- src/io.cpp | 6 ++++-- src/io.h | 3 ++- src/parse_execution.cpp | 3 ++- src/parser_keywords.cpp | 4 ++-- src/postfork.cpp | 33 +++++++++++++++++++-------------- src/timer.cpp | 20 ++++++++++---------- src/wutil.cpp | 19 ++++++++++++------- 13 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/autoload.cpp b/src/autoload.cpp index d096f5331..b3f1ed5ad 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -211,8 +211,6 @@ void autoload_t::perform_autoload(const wcstring &path, parser_t &parser) { wcstring script_source = L"source " + escape_string(path, ESCAPE_ALL); auto prev_statuses = parser.get_last_statuses(); - const cleanup_t put_back([&] { - parser.set_last_statuses(prev_statuses); - }); + const cleanup_t put_back([&] { parser.set_last_statuses(prev_statuses); }); parser.eval(script_source, io_chain_t{}); } diff --git a/src/common.cpp b/src/common.cpp index c80451eef..0c746e6e3 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -991,8 +991,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring case L'"': case L'%': case L'~': { - bool char_is_normal = (c == L'~' && no_tilde) || - (c == L'?' && no_qmark); + bool char_is_normal = (c == L'~' && no_tilde) || (c == L'?' && no_qmark); if (!char_is_normal) { need_escape = true; if (escape_all) out += L'\\'; diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 9c803c970..2f5e31604 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -3750,7 +3750,7 @@ static void test_autosuggest_suggest_special() { parser_t::principal_parser().vars().remove(L"HOME", ENV_LOCAL | ENV_EXPORT); popd(); -#endif //ndef SANITIZE_ADDRESS +#endif // ndef SANITIZE_ADDRESS } static void perform_one_autosuggestion_should_ignore_test(const wcstring &command, long line) { diff --git a/src/future_feature_flags.cpp b/src/future_feature_flags.cpp index 395a1738b..e30065f0b 100644 --- a/src/future_feature_flags.cpp +++ b/src/future_feature_flags.cpp @@ -16,7 +16,9 @@ features_t::features_t() { features_t features_t::global_features; const features_t::metadata_t features_t::metadata[features_t::flag_count] = { - {stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr (historical, can no longer be changed)", true, true /* read-only */}, + {stderr_nocaret, L"stderr-nocaret", L"3.0", + L"^ no longer redirects stderr (historical, can no longer be changed)", true, + true /* read-only */}, {qmark_noglob, L"qmark-noglob", L"3.0", L"? no longer globs", false, false}, {string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s", true, false}, diff --git a/src/highlight.h b/src/highlight.h index b08902d45..1f302f9dd 100644 --- a/src/highlight.h +++ b/src/highlight.h @@ -76,8 +76,9 @@ namespace std { template <> struct hash { std::size_t operator()(const highlight_spec_t &v) const { - const size_t vals[4] = {static_cast(v.foreground), static_cast(v.background), - v.valid_path, v.force_underline}; + const size_t vals[4] = {static_cast(v.foreground), + static_cast(v.background), v.valid_path, + v.force_underline}; return (vals[0] << 0) + (vals[1] << 6) + (vals[2] << 12) + (vals[3] << 18); } }; diff --git a/src/history.h b/src/history.h index 5073bce1b..5521769df 100644 --- a/src/history.h +++ b/src/history.h @@ -247,7 +247,7 @@ class history_search_t { /// The (possibly lowercased) search term. wcstring canon_term_; - /// Our search type. + /// Our search type. enum history_search_type_t search_type_ { history_search_type_t::contains }; /// Our flags. diff --git a/src/io.cpp b/src/io.cpp index c2a1de33f..cf603ac9a 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -251,9 +251,11 @@ bool io_chain_t::append_from_specs(const redirection_spec_list_t &specs, const w auto next = wdirname(dname); if (!wstat(next, &buf)) { if (!S_ISDIR(buf.st_mode)) { - FLOGF(warning, _(L"Path '%ls' is not a directory"), next.c_str()); + FLOGF(warning, _(L"Path '%ls' is not a directory"), + next.c_str()); } else { - FLOGF(warning, _(L"Path '%ls' does not exist"), dname.c_str()); + FLOGF(warning, _(L"Path '%ls' does not exist"), + dname.c_str()); } break; } diff --git a/src/io.h b/src/io.h index 9ed9e9ba6..e362b880f 100644 --- a/src/io.h +++ b/src/io.h @@ -371,7 +371,8 @@ class output_stream_t : noncopyable_t, nonmovable_t { bool want_newline = true); /// The following are all convenience overrides. - void append_with_separation(const wcstring &s, separation_type_t type, bool want_newline = true) { + void append_with_separation(const wcstring &s, separation_type_t type, + bool want_newline = true) { append_with_separation(s.data(), s.size(), type, want_newline); } diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 5fff7f486..353ede543 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -891,7 +891,8 @@ end_execution_reason_t parse_execution_context_t::populate_plain_process( function_exists(L"cd", *parser) ? process_type_t::function : process_type_t::builtin; } else { // Not implicit cd. - const globspec_t glob_behavior = (cmd == L"set" || cmd == L"count" || cmd == L"path") ? nullglob : failglob; + const globspec_t glob_behavior = + (cmd == L"set" || cmd == L"count" || cmd == L"path") ? nullglob : failglob; // Form the list of arguments. The command is the first argument, followed by any arguments // from expanding the command, followed by the argument nodes themselves. E.g. if the // command is '$gco foo' and $gco is git checkout. diff --git a/src/parser_keywords.cpp b/src/parser_keywords.cpp index 810fa6b5f..e3253d2de 100644 --- a/src/parser_keywords.cpp +++ b/src/parser_keywords.cpp @@ -23,8 +23,8 @@ static const string_set_t block_keywords = {L"for", L"while", L"if", L"function", L"switch", L"begin"}; static const wcstring reserved_keywords[] = { - L"end", L"case", L"else", L"return", L"continue", L"break", L"argparse", - L"read", L"string", L"set", L"status", L"test", L"[", L"_", L"eval"}; + L"end", L"case", L"else", L"return", L"continue", L"break", L"argparse", L"read", + L"string", L"set", L"status", L"test", L"[", L"_", L"eval"}; // The lists above are purposely implemented separately from the logic below, so that future // maintainers may assume the contents of the list based off their names, and not off what the diff --git a/src/postfork.cpp b/src/postfork.cpp index 84f2e101e..8b1784997 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -392,30 +392,34 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const * if (sz >= static_cast(arg_max)) { char sz2[128]; format_size_safe(sz2, static_cast(arg_max)); - FLOGF_SAFE(exec, - "Failed to execute process '%s': the total size of the argument list and " - "exported variables (%s) exceeds the OS limit of %s.", - actual_cmd, sz1, sz2); + FLOGF_SAFE( + exec, + "Failed to execute process '%s': the total size of the argument list and " + "exported variables (%s) exceeds the OS limit of %s.", + actual_cmd, sz1, sz2); } else { // MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's // defined in binfmts.h, but we don't want to include that just to be able to // print the real limit. FLOGF_SAFE(exec, - "Failed to execute process '%s': An argument or exported variable exceeds the OS " - "argument length limit.", actual_cmd); + "Failed to execute process '%s': An argument or exported variable " + "exceeds the OS " + "argument length limit.", + actual_cmd); } if (szenv >= static_cast(arg_max) / 2) { FLOGF_SAFE(exec, - "Hint: Your exported variables take up over half the limit. Try erasing or unexporting variables." - ); + "Hint: Your exported variables take up over half the limit. Try " + "erasing or unexporting variables."); } } else { - FLOGF_SAFE(exec, - "Failed to execute process '%s': the total size of the argument list and " - "exported variables (%s) exceeds the " - "operating system limit.", - actual_cmd, sz1); + FLOGF_SAFE( + exec, + "Failed to execute process '%s': the total size of the argument list and " + "exported variables (%s) exceeds the " + "operating system limit.", + actual_cmd, sz1); } break; } @@ -471,7 +475,8 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const * } } else if (access(actual_cmd, X_OK) == 0) { FLOGF_SAFE(exec, - "Failed to execute process '%s': The file exists and is executable. Check the interpreter or linker?", + "Failed to execute process '%s': The file exists and is executable. " + "Check the interpreter or linker?", actual_cmd); } else { FLOGF_SAFE(exec, diff --git a/src/timer.cpp b/src/timer.cpp index 3906afc52..c424b759a 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -163,14 +163,14 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s wcstring output; if (!verbose) { - append_format(output, L"\n_______________________________" - L"\nExecuted in %6.2F %s" - L"\n usr time %6.2F %s" - L"\n sys time %6.2F %s" - L"\n", - wall_time, unit_name(wall_unit), - usr_time, unit_name(cpu_unit), - sys_time, unit_name(cpu_unit)); + append_format(output, + L"\n_______________________________" + L"\nExecuted in %6.2F %s" + L"\n usr time %6.2F %s" + L"\n sys time %6.2F %s" + L"\n", + wall_time, unit_name(wall_unit), usr_time, unit_name(cpu_unit), sys_time, + unit_name(cpu_unit)); } else { auto fish_unit = get_unit(std::max(fish_sys_micros, fish_usr_micros)); auto child_unit = get_unit(std::max(child_sys_micros, child_usr_micros)); @@ -179,8 +179,8 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s double child_usr_time = convert(child_usr_micros, child_unit); double child_sys_time = convert(child_sys_micros, child_unit); - int column2_unit_len = std::max(strlen(unit_short_name(wall_unit)), - strlen(unit_short_name(cpu_unit))); + int column2_unit_len = + std::max(strlen(unit_short_name(wall_unit)), strlen(unit_short_name(cpu_unit))); append_format(output, L"\n________________________________________________________" L"\nExecuted in %6.2F %-*s %-*s %s" diff --git a/src/wutil.cpp b/src/wutil.cpp index e3791b6b2..21ec26d6f 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -728,7 +728,7 @@ double fish_wcstod(const wcstring &str, wchar_t **endptr) { /// are not consumed. double fish_wcstod_underscores(const wchar_t *str, wchar_t **endptr) { const wchar_t *orig = str; - while (iswspace(*str)) str++; // Skip leading whitespace. + while (iswspace(*str)) str++; // Skip leading whitespace. size_t leading_whitespace = size_t(str - orig); auto is_sign = [](wchar_t c) { return c == L'+' || c == L'-'; }; auto is_inf_or_nan_char = [](wchar_t c) { @@ -757,8 +757,11 @@ double fish_wcstod_underscores(const wchar_t *str, wchar_t **endptr) { // literals using 0o, etc., we could just use iswalnum, instead of iswxdigit and P/p/X/x checks. while (iswxdigit(*str) || *str == L'P' || *str == L'p' || *str == L'X' || *str == L'x' || is_sign(*str) || *str == L'.' || *str == L'_') { - if (*str == L'_') underscores.push_back(pruned.length()); - else pruned.push_back(*str); + if (*str == L'_') { + underscores.push_back(pruned.length()); + } else { + pruned.push_back(*str); + } str++; } const wchar_t *pruned_begin = pruned.c_str(); @@ -768,11 +771,13 @@ double fish_wcstod_underscores(const wchar_t *str, wchar_t **endptr) { if (endptr) *endptr = (wchar_t *)orig; return result; } - auto consumed_underscores_end = std::upper_bound(underscores.begin(), underscores.end(), - size_t(pruned_end - pruned_begin)); + auto consumed_underscores_end = + std::upper_bound(underscores.begin(), underscores.end(), size_t(pruned_end - pruned_begin)); size_t num_underscores_consumed = std::distance(underscores.begin(), consumed_underscores_end); - if (endptr) *endptr = (wchar_t *)(orig + leading_whitespace + (pruned_end - pruned_begin) - + num_underscores_consumed); + if (endptr) { + *endptr = (wchar_t *)(orig + leading_whitespace + (pruned_end - pruned_begin) + + num_underscores_consumed); + } return result; }