From 1406d63b857a3c97728f399192692f6e58cf1591 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 26 Mar 2020 20:45:40 +0100 Subject: [PATCH] Restyle I kinda hate how fussy clang-format is. It reflows text constantly (line limit), forces things onto one line *except* when they're too long, and wants to turn this: ```c++ return true;; ``` into this: ```c++ return true; ; ``` instead of, you know, eliminating the second semicolon? Anyway, it is what it is and we use it, I'll just look into getting some more slack. --- share/tools/create_manpage_completions.py | 4 +-- .../tools/web_config/sample_prompts/nim.fish | 3 ++- src/builtin_test.cpp | 3 ++- src/common.cpp | 12 ++++----- src/common.h | 6 ++--- src/fish_indent.cpp | 25 ++++++++++--------- src/fish_test_helper.cpp | 2 +- src/flog.h | 3 ++- src/highlight.cpp | 2 +- src/path.cpp | 6 +++-- src/postfork.cpp | 17 +++++++------ 11 files changed, 45 insertions(+), 38 deletions(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index 05874b67b..23cef2a95 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -997,9 +997,7 @@ def get_paths_from_man_locations(): def usage(script_name): print( "Usage: {0} [-v, --verbose] [-s, --stdout] [-d, --directory] [-p, --progress]" - " [-c, --cleanup-in] [-z] files...".format( - script_name - ) + " [-c, --cleanup-in] [-z] files...".format(script_name) ) print( """Command options are: diff --git a/share/tools/web_config/sample_prompts/nim.fish b/share/tools/web_config/sample_prompts/nim.fish index 09af8361f..1f41995e0 100644 --- a/share/tools/web_config/sample_prompts/nim.fish +++ b/share/tools/web_config/sample_prompts/nim.fish @@ -77,7 +77,8 @@ function fish_prompt # Vi-mode # The default mode prompt would be prefixed, which ruins our alignment. - function fish_mode_prompt; end + function fish_mode_prompt + end if test "$fish_key_bindings" = fish_vi_key_bindings or test "$fish_key_bindings" = fish_hybrid_key_bindings set -l mode diff --git a/src/builtin_test.cpp b/src/builtin_test.cpp index 3058a5998..c2007f0dd 100644 --- a/src/builtin_test.cpp +++ b/src/builtin_test.cpp @@ -670,7 +670,8 @@ static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t // Break the floating point value into base and delta. Ensure that base is <= the floating // point value. // - // Note that a non-finite number like infinity or NaN doesn't work for us, so we checked above. + // Note that a non-finite number like infinity or NaN doesn't work for us, so we checked + // above. double intpart = std::floor(floating); double delta = floating - intpart; *number = number_t{static_cast(intpart), delta}; diff --git a/src/common.cpp b/src/common.cpp index a666a3083..0f33f7364 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1453,16 +1453,16 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in switch (c) { case L'\\': { if (!ignore_backslashes) { - // Backslashes (escapes) are complicated and may result in errors, or appending - // INTERNAL_SEPARATORs, so we have to handle them specially. - auto escape_chars = read_unquoted_escape(input + input_position, &result, - allow_incomplete, unescape_special); + // Backslashes (escapes) are complicated and may result in errors, or + // appending INTERNAL_SEPARATORs, so we have to handle them specially. + auto escape_chars = read_unquoted_escape( + input + input_position, &result, allow_incomplete, unescape_special); if (!escape_chars) { // A none() return indicates an error. errored = true; } else { - // Skip over the characters we read, minus one because the outer loop will - // increment it. + // Skip over the characters we read, minus one because the outer loop + // will increment it. assert(*escape_chars > 0); input_position += *escape_chars - 1; } diff --git a/src/common.h b/src/common.h index 310d27b29..33c71d675 100644 --- a/src/common.h +++ b/src/common.h @@ -119,9 +119,9 @@ enum escape_string_style_t { // Flags for unescape_string functions. enum { - UNESCAPE_DEFAULT = 0, // default behavior - UNESCAPE_SPECIAL = 1 << 0, // escape special fish syntax characters like the semicolon - UNESCAPE_INCOMPLETE = 1 << 1, // allow incomplete escape sequences + UNESCAPE_DEFAULT = 0, // default behavior + UNESCAPE_SPECIAL = 1 << 0, // escape special fish syntax characters like the semicolon + UNESCAPE_INCOMPLETE = 1 << 1, // allow incomplete escape sequences UNESCAPE_NO_BACKSLASHES = 1 << 2, // don't handle backslash escapes }; typedef unsigned int unescape_flags_t; diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index b292ab595..52c21b3fc 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -207,20 +207,19 @@ void prettifier_t::prettify_node(const parse_node_tree_t &tree, node_offset_t no if (dump_parse_tree) dump_node(node_indent, node, source); // Prepend any escaped newline, but only for certain cases. - // We allow it to split arguments (including at the end - this is like trailing commas in lists, makes for better diffs), - // to separate pipelines (but it has to be *before* the pipe, so the pipe symbol is the first thing on the new line after the indent) - // and to separate &&/|| job lists (`and` and `or` are handled separately below, as they *allow* semicolons) + // We allow it to split arguments (including at the end - this is like trailing commas in + // lists, makes for better diffs), to separate pipelines (but it has to be *before* the + // pipe, so the pipe symbol is the first thing on the new line after the indent) and to + // separate &&/|| job lists (`and` and `or` are handled separately below, as they *allow* + // semicolons) // TODO: Handle // foo | \ // bar - // so it just removes the escape - pipes don't need it. This was changed in some fish version, figure out which it was and if - // it is worth supporting. - if (prev_node_type == symbol_arguments_or_redirections_list - || prev_node_type == symbol_argument_list - || node_type == parse_token_type_andand - || node_type == parse_token_type_pipe - || node_type == parse_token_type_end - ) { + // so it just removes the escape - pipes don't need it. This was changed in some fish + // version, figure out which it was and if it is worth supporting. + if (prev_node_type == symbol_arguments_or_redirections_list || + prev_node_type == symbol_argument_list || node_type == parse_token_type_andand || + node_type == parse_token_type_pipe || node_type == parse_token_type_end) { maybe_prepend_escaped_newline(node); } @@ -282,7 +281,9 @@ void prettifier_t::prettify_node(const parse_node_tree_t &tree, node_offset_t no // This can be extended to other characters, but giving the precise list is tough, // can change over time (see "^", "%" and "?", in some cases "{}") and it just makes // people feel more at ease. - auto goodchars = [](wchar_t ch) { return fish_iswalnum(ch) || ch == L'_' || ch == L'-' || ch == L'/'; }; + auto goodchars = [](wchar_t ch) { + return fish_iswalnum(ch) || ch == L'_' || ch == L'-' || ch == L'/'; + }; if (std::find_if_not(unescaped.begin(), unescaped.end(), goodchars) == unescaped.end() && !unescaped.empty()) { diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index efddb7038..bb56debfa 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -9,7 +9,7 @@ #include #include #include -#include // for std::begin/end +#include // for std::begin/end static void become_foreground_then_print_stderr() { if (tcsetpgrp(STDOUT_FILENO, getpgrp()) < 0) { diff --git a/src/flog.h b/src/flog.h index 9e9c763f6..7512ea307 100644 --- a/src/flog.h +++ b/src/flog.h @@ -52,7 +52,8 @@ class category_list_t { category_t debug{L"debug", L"Debugging aid (on by default)", true}; category_t warning{L"warning", L"Warnings (on by default)", true}; - category_t warning_path{L"warning-path", L"Warnings about unusable paths for config/history (on by default)", true}; + category_t warning_path{ + L"warning-path", L"Warnings about unusable paths for config/history (on by default)", true}; category_t config{L"config", L"Finding and reading configuration"}; diff --git a/src/highlight.cpp b/src/highlight.cpp index fffc200a4..f94898077 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -273,7 +273,7 @@ bool is_potential_path(const wcstring &potential_path_fragment, const wcstring_l const wcstring filename_fragment = wbasename(abs_path); if (dir_name == L"/" && filename_fragment == L"/") { // cd ///.... No autosuggestion. - return true;; + return true; } else if ((dir = wopendir(dir_name))) { cleanup_t cleanup_dir([&] { closedir(dir); }); diff --git a/src/path.cpp b/src/path.cpp index 2a4b3a1ec..570d06a44 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -273,14 +273,16 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring & FLOG(error, custom_error_msg.c_str()); if (path.empty()) { FLOGF(warning_path, _(L"Unable to locate the %ls directory."), which_dir.c_str()); - FLOGF(warning_path, _(L"Please set the %ls or HOME environment variable before starting fish."), + FLOGF(warning_path, + _(L"Please set the %ls or HOME environment variable before starting fish."), xdg_var.c_str()); } else { const wchar_t *env_var = using_xdg ? xdg_var.c_str() : L"HOME"; FLOGF(warning_path, _(L"Unable to locate %ls directory derived from $%ls: '%ls'."), which_dir.c_str(), env_var, path.c_str()); FLOGF(warning_path, _(L"The error was '%s'."), std::strerror(saved_errno)); - FLOGF(warning_path, _(L"Please set $%ls to a directory where you have write access."), env_var); + FLOGF(warning_path, _(L"Please set $%ls to a directory where you have write access."), + env_var); } ignore_result(write(STDERR_FILENO, "\n", 1)); } diff --git a/src/postfork.cpp b/src/postfork.cpp index 85182f63a..459b9349b 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -323,15 +323,18 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const * if (arg_max > 0) { if (sz >= static_cast(arg_max)) { format_size_safe(sz2, static_cast(arg_max)); - debug_safe(0, - "The total size of the argument and environment lists %s exceeds the " - "operating system limit of %s.", - sz1, sz2); + debug_safe( + 0, + "The total size of the argument and environment lists %s exceeds the " + "operating system limit of %s.", + sz1, sz2); } else { - // MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's defined in binfmt.h, but - // we don't want to include that just to be able to print the real limit. + // MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's + // defined in binfmt.h, but we don't want to include that just to be able to + // print the real limit. debug_safe(0, - "One of your arguments exceeds the operating system's argument length limit."); + "One of your arguments exceeds the operating system's argument " + "length limit."); } } else { debug_safe(0,