mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
style cleanups
This commit is contained in:
parent
f0469d829a
commit
84cf391faa
7 changed files with 41 additions and 51 deletions
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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"); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1271,7 +1271,8 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_c
|
|||
|
||||
if (!done) {
|
||||
parse_node_tree_t tree;
|
||||
parse_tree_from_string(cmd, parse_flag_continue_after_error |
|
||||
parse_tree_from_string(cmd,
|
||||
parse_flag_continue_after_error |
|
||||
parse_flag_accept_incomplete_tokens |
|
||||
parse_flag_include_comments,
|
||||
&tree, NULL);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue