diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index f19706a2d..c4f4a9868 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -991,7 +991,8 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha case 'n': { long lcount = fish_wcstol(w.woptarg); if (lcount < 0 || errno == ERANGE) { - string_error(streams, _(L"%ls: Invalid count value '%ls'\n"), argv[0], w.woptarg); + string_error(streams, _(L"%ls: Invalid count value '%ls'\n"), argv[0], + w.woptarg); return BUILTIN_STRING_ERROR; } else if (errno) { string_error(streams, BUILTIN_ERR_NOT_NUMBER, argv[0], w.woptarg); @@ -1022,11 +1023,11 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha } case ':': { string_error(streams, STRING_ERR_MISSING, argv[0]); - return BUILTIN_STRING_ERROR; + return BUILTIN_STRING_ERROR; } case '?': { string_unknown_option(parser, streams, argv[0], argv[w.woptind - 1]); - return BUILTIN_STRING_ERROR; + return BUILTIN_STRING_ERROR; } default: { DIE("unexpected opt"); @@ -1039,7 +1040,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha if (string_args_from_stdin(streams) && argc > i) { string_error(streams, BUILTIN_ERR_TOO_MANY_ARGUMENTS, argv[0]); - return BUILTIN_STRING_ERROR; + return BUILTIN_STRING_ERROR; } const wchar_t *to_repeat; @@ -1048,7 +1049,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha if ((to_repeat = string_get_arg(&i, argv, &storage, streams)) != NULL && *to_repeat) { const wcstring word(to_repeat); - const bool rep_until = (0 < max && word.length()*count > max) || !count; + const bool rep_until = (0 < max && word.length() * count > max) || !count; const wcstring repeated = rep_until ? wcsrepeat_until(word, max) : wcsrepeat(word, count); is_empty = repeated.empty(); @@ -1266,11 +1267,11 @@ static const struct string_subcommand { wchar_t **argv); //!OCLINT(unused param) } -string_subcommands[] = { - {L"escape", &string_escape}, {L"join", &string_join}, {L"length", &string_length}, - {L"match", &string_match}, {L"replace", &string_replace}, {L"split", &string_split}, - {L"sub", &string_sub}, {L"trim", &string_trim}, {L"repeat", &string_repeat}, - {0, 0}}; +string_subcommands[] = {{L"escape", &string_escape}, {L"join", &string_join}, + {L"length", &string_length}, {L"match", &string_match}, + {L"replace", &string_replace}, {L"split", &string_split}, + {L"sub", &string_sub}, {L"trim", &string_trim}, + {L"repeat", &string_repeat}, {0, 0}}; /// The string builtin, for manipulating strings. int builtin_string(parser_t &parser, io_streams_t &streams, wchar_t **argv) { diff --git a/src/color.cpp b/src/color.cpp index 3f6ebac2a..cca3153c4 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -153,28 +153,17 @@ struct named_color_t { }; static const named_color_t named_colors[] = { - {L"black", 0, {0x00, 0x00, 0x00}, false}, - {L"red", 1, {0x80, 0x00, 0x00}, false}, - {L"green", 2, {0x00, 0x80, 0x00}, false}, - {L"brown", 3, {0x72, 0x50, 0x00}, true}, - {L"yellow", 3, {0x80, 0x80, 0x00}, false}, - {L"blue", 4, {0x00, 0x00, 0x80}, false}, - {L"magenta", 5, {0x80, 0x00, 0x80}, false}, - {L"purple", 5, {0x80, 0x00, 0x80}, true}, - {L"cyan", 6, {0x00, 0x80, 0x80}, false}, - {L"white", 7, {0xC0, 0xC0, 0xC0}, false}, - {L"grey", 7, {0xE5, 0xE5, 0xE5}, true}, - {L"brblack", 8, {0x80, 0x80, 0x80}, false}, - {L"brgrey", 8, {0x55, 0x55, 0x55}, true}, - {L"brred", 9, {0xFF, 0x00, 0x00}, false}, - {L"brgreen", 10, {0x00, 0xFF, 0x00}, false}, - {L"brbrown", 11, {0xFF, 0xFF, 0x00}, true}, - {L"bryellow", 11, {0xFF, 0xFF, 0x00}, false}, - {L"brblue", 12, {0x00, 0x00, 0xFF}, false}, - {L"brmagenta", 13, {0xFF, 0x00, 0xFF}, false}, - {L"brpurple", 13, {0xFF, 0x00, 0xFF}, true}, - {L"brcyan", 14, {0x00, 0xFF, 0xFF}, false}, - {L"brwhite", 15, {0xFF, 0xFF, 0xFF}, false}, + {L"black", 0, {0x00, 0x00, 0x00}, false}, {L"red", 1, {0x80, 0x00, 0x00}, false}, + {L"green", 2, {0x00, 0x80, 0x00}, false}, {L"brown", 3, {0x72, 0x50, 0x00}, true}, + {L"yellow", 3, {0x80, 0x80, 0x00}, false}, {L"blue", 4, {0x00, 0x00, 0x80}, false}, + {L"magenta", 5, {0x80, 0x00, 0x80}, false}, {L"purple", 5, {0x80, 0x00, 0x80}, true}, + {L"cyan", 6, {0x00, 0x80, 0x80}, false}, {L"white", 7, {0xC0, 0xC0, 0xC0}, false}, + {L"grey", 7, {0xE5, 0xE5, 0xE5}, true}, {L"brblack", 8, {0x80, 0x80, 0x80}, false}, + {L"brgrey", 8, {0x55, 0x55, 0x55}, true}, {L"brred", 9, {0xFF, 0x00, 0x00}, false}, + {L"brgreen", 10, {0x00, 0xFF, 0x00}, false}, {L"brbrown", 11, {0xFF, 0xFF, 0x00}, true}, + {L"bryellow", 11, {0xFF, 0xFF, 0x00}, false}, {L"brblue", 12, {0x00, 0x00, 0xFF}, false}, + {L"brmagenta", 13, {0xFF, 0x00, 0xFF}, false}, {L"brpurple", 13, {0xFF, 0x00, 0xFF}, true}, + {L"brcyan", 14, {0x00, 0xFF, 0xFF}, false}, {L"brwhite", 15, {0xFF, 0xFF, 0xFF}, false}, }; wcstring_list_t rgb_color_t::named_color_names(void) { @@ -340,8 +329,6 @@ wcstring rgb_color_t::description() const { case type_normal: { return L"normal"; } - default: { - DIE("unknown color type"); - } + default: { DIE("unknown color type"); } } } diff --git a/src/common.cpp b/src/common.cpp index d73a2473f..e141d970f 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -852,7 +852,7 @@ static void escape_string_internal(const wchar_t *orig_in, size_t in_len, wcstri case L'\\': case L'\'': { need_escape = need_complex_escape = 1; - //WTF if (escape_all) out += L'\\'; + // WTF if (escape_all) out += L'\\'; out += L'\\'; out += *in; break; diff --git a/src/complete.cpp b/src/complete.cpp index 2e609bac9..25dae2747 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -1271,9 +1271,10 @@ void complete(const wcstring &cmd_with_subcmds, std::vector *out_c if (!done) { parse_node_tree_t tree; - parse_tree_from_string(cmd, parse_flag_continue_after_error | - parse_flag_accept_incomplete_tokens | - parse_flag_include_comments, + parse_tree_from_string(cmd, + parse_flag_continue_after_error | + parse_flag_accept_incomplete_tokens | + parse_flag_include_comments, &tree, NULL); // Find the plain statement to operate on. The cursor may be past it (#1261), so backtrack diff --git a/src/fallback.cpp b/src/fallback.cpp index b73807875..d81d4ba3d 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -191,7 +191,7 @@ int wcsncasecmp(const wchar_t *a, const wchar_t *b, size_t n) { #endif #endif -#endif // __APPLE__ +#endif // __APPLE__ #ifndef HAVE_WCSNDUP wchar_t *wcsndup(const wchar_t *in, size_t c) { diff --git a/src/fallback.h b/src/fallback.h index 1814b5e22..4d26760b2 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -96,24 +96,24 @@ wchar_t *wcsndup(const wchar_t *in, size_t c); using std::wcsdup; #else wchar_t *wcsdup(const wchar_t *in); -#endif // HAVE_STD__WCSDUP -#endif // HAVE_WCSDUP +#endif // HAVE_STD__WCSDUP +#endif // HAVE_WCSDUP #ifndef HAVE_WCSCASECMP #ifdef HAVE_STD__WCSCASECMP using std::wcscasecmp; #else int wcscasecmp(const wchar_t *a, const wchar_t *b); -#endif // HAVE_STD__WCSCASECMP -#endif // HAVE_WCSCASECMP +#endif // HAVE_STD__WCSCASECMP +#endif // HAVE_WCSCASECMP #ifndef HAVE_WCSNCASECMP #ifdef HAVE_STD__WCSNCASECMP using std::wcsncasecmp; #else int wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n); -#endif // HAVE_STD__WCSNCASECMP -#endif // HAVE_WCSNCASECMP +#endif // HAVE_STD__WCSNCASECMP +#endif // HAVE_WCSNCASECMP #ifndef HAVE_DIRFD #ifndef __XOPEN_OR_POSIX diff --git a/src/highlight.cpp b/src/highlight.cpp index 70003facd..37de974ae 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -842,9 +842,9 @@ void highlighter_t::color_redirection(const parse_node_t &redirection_node) { this->parse_tree.type_for_redirection(redirection_node, this->buff, NULL, &target); // We may get a TOK_NONE redirection type, e.g. if the redirection is invalid. - this->color_node(*redirection_primitive, redirect_type == TOK_NONE - ? highlight_spec_error - : highlight_spec_redirection); + this->color_node( + *redirection_primitive, + redirect_type == TOK_NONE ? highlight_spec_error : highlight_spec_redirection); // Check if the argument contains a command substitution. If so, highlight it as a param // even though it's a command redirection, and don't try to do any other validation. @@ -941,8 +941,9 @@ void highlighter_t::color_redirection(const parse_node_t &redirection_node) { } if (redirection_target != NULL) { - this->color_node(*redirection_target, target_is_valid ? highlight_spec_redirection - : highlight_spec_error); + this->color_node( + *redirection_target, + target_is_valid ? highlight_spec_redirection : highlight_spec_error); } } }