From af22bf350177ee5ed7f2c53eceaee3f9cc1258c6 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Fri, 16 Jun 2017 21:00:24 -0700 Subject: [PATCH] style cleanups (make style-all) --- share/functions/__fish_print_hostnames.fish | 3 +- src/builtin_bind.cpp | 4 +- src/builtin_block.cpp | 2 +- src/builtin_fg.cpp | 2 +- src/builtin_function.cpp | 27 +++++---- src/builtin_status.cpp | 3 +- src/builtin_string.cpp | 63 ++++++++++----------- src/wgetopt.h | 1 - 8 files changed, 51 insertions(+), 54 deletions(-) diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index dcf6ffd49..dfd0c5f1e 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -74,7 +74,8 @@ function __fish_print_hostnames -d "Print a list of known hostnames" end end - if test -n "$new_paths"; + if test -n "$new_paths" + _recursive $new_paths end end diff --git a/src/builtin_bind.cpp b/src/builtin_bind.cpp index 8153400de..2ff8a7d2f 100644 --- a/src/builtin_bind.cpp +++ b/src/builtin_bind.cpp @@ -241,8 +241,8 @@ static bool builtin_bind_insert(bind_cmd_opts_t &opts, int optind, int argc, wch return true; } } else { - if (builtin_bind_add(argv[optind], argv + (optind + 1), argc - (optind + 1), - opts.bind_mode, opts.sets_bind_mode, opts.use_terminfo, streams)) { + if (builtin_bind_add(argv[optind], argv + (optind + 1), argc - (optind + 1), opts.bind_mode, + opts.sets_bind_mode, opts.use_terminfo, streams)) { return true; } } diff --git a/src/builtin_block.cpp b/src/builtin_block.cpp index bc2bdff4e..28e2b93fe 100644 --- a/src/builtin_block.cpp +++ b/src/builtin_block.cpp @@ -114,7 +114,7 @@ int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } case UNSET: { while (block != NULL && block->type() != FUNCTION_CALL && - block->type() != FUNCTION_CALL_NO_SHADOW) { + block->type() != FUNCTION_CALL_NO_SHADOW) { // Set it in function scope block = parser.block_at_index(++block_idx); } diff --git a/src/builtin_fg.cpp b/src/builtin_fg.cpp index b4b32e4d7..4fb05c846 100644 --- a/src/builtin_fg.cpp +++ b/src/builtin_fg.cpp @@ -15,7 +15,7 @@ #include "proc.h" #include "reader.h" #include "tokenizer.h" -#include "wutil.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep /// Builtin for putting a job in the foreground. int builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv) { diff --git a/src/builtin_function.cpp b/src/builtin_function.cpp index 58aa73665..37539fdd4 100644 --- a/src/builtin_function.cpp +++ b/src/builtin_function.cpp @@ -37,19 +37,18 @@ struct function_cmd_opts_t { // This command is atypical in using the "+" (REQUIRE_ORDER) option for flag parsing. // This is needed due to the semantics of the -a/--argument-names flag. static const wchar_t *short_options = L"+:a:d:e:hj:p:s:v:w:SV:"; -static const struct woption long_options[] = { - {L"description", required_argument, NULL, 'd'}, - {L"on-signal", required_argument, NULL, 's'}, - {L"on-job-exit", required_argument, NULL, 'j'}, - {L"on-process-exit", required_argument, NULL, 'p'}, - {L"on-variable", required_argument, NULL, 'v'}, - {L"on-event", required_argument, NULL, 'e'}, - {L"wraps", required_argument, NULL, 'w'}, - {L"help", no_argument, NULL, 'h'}, - {L"argument-names", required_argument, NULL, 'a'}, - {L"no-scope-shadowing", no_argument, NULL, 'S'}, - {L"inherit-variable", required_argument, NULL, 'V'}, - {NULL, 0, NULL, 0}}; +static const struct woption long_options[] = {{L"description", required_argument, NULL, 'd'}, + {L"on-signal", required_argument, NULL, 's'}, + {L"on-job-exit", required_argument, NULL, 'j'}, + {L"on-process-exit", required_argument, NULL, 'p'}, + {L"on-variable", required_argument, NULL, 'v'}, + {L"on-event", required_argument, NULL, 'e'}, + {L"wraps", required_argument, NULL, 'w'}, + {L"help", no_argument, NULL, 'h'}, + {L"argument-names", required_argument, NULL, 'a'}, + {L"no-scope-shadowing", no_argument, NULL, 'S'}, + {L"inherit-variable", required_argument, NULL, 'V'}, + {NULL, 0, NULL, 0}}; static int parse_cmd_opts(function_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method) int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams, @@ -250,7 +249,7 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis function_data_t d; d.name = function_name; if (!opts.description.empty()) d.description = opts.description; - //d.description = opts.description; + // d.description = opts.description; d.events.swap(opts.events); d.shadow_scope = opts.shadow_scope; d.named_arguments.swap(opts.named_arguments); diff --git a/src/builtin_status.cpp b/src/builtin_status.cpp index 9ef251e4b..ece5bbb3d 100644 --- a/src/builtin_status.cpp +++ b/src/builtin_status.cpp @@ -127,8 +127,7 @@ static int parse_cmd_opts(status_cmd_opts_t &opts, int *optind, //!OCLINT(high break; } case 2: { - if (!set_status_cmd(cmd, opts, STATUS_IS_INTERACTIVE_JOB_CTRL, - streams)) { + if (!set_status_cmd(cmd, opts, STATUS_IS_INTERACTIVE_JOB_CTRL, streams)) { return STATUS_CMD_ERROR; } break; diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index b525ee8e8..9ba7c75ad 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -355,8 +355,7 @@ static std::map flag_to_function = { {'N', handle_flag_N}, {'a', handle_flag_a}, {'c', handle_flag_c}, {'e', handle_flag_e}, {'f', handle_flag_f}, {'i', handle_flag_i}, {'l', handle_flag_l}, {'m', handle_flag_m}, {'n', handle_flag_n}, {'q', handle_flag_q}, {'r', handle_flag_r}, {'s', handle_flag_s}, - {'v', handle_flag_v} -}; + {'v', handle_flag_v}}; /// Parse the arguments for flags recognized by a specific string subcommand. static int parse_opts(options_t *opts, int *optind, int n_req_args, int argc, wchar_t **argv, @@ -514,38 +513,38 @@ class wildcard_matcher_t : public string_matcher_t { if (wcpattern.front() != ANY_STRING) wcpattern.insert(0, 1, ANY_STRING); if (wcpattern.back() != ANY_STRING) wcpattern.push_back(ANY_STRING); } + } + + virtual ~wildcard_matcher_t() {} + + bool report_matches(const wchar_t *arg) { + // Note: --all is a no-op for glob matching since the pattern is always matched + // against the entire argument. + bool match; + + if (opts.ignore_case) { + wcstring s = arg; + for (size_t i = 0; i < s.length(); i++) { + s[i] = towlower(s[i]); } - - virtual ~wildcard_matcher_t() {} - - bool report_matches(const wchar_t *arg) { - // Note: --all is a no-op for glob matching since the pattern is always matched - // against the entire argument. - bool match; - - if (opts.ignore_case) { - wcstring s = arg; - for (size_t i = 0; i < s.length(); i++) { - s[i] = towlower(s[i]); - } - match = wildcard_match(s, wcpattern, false); - } else { - match = wildcard_match(arg, wcpattern, false); - } - if (match ^ opts.invert_match) { - total_matched++; - - if (!opts.quiet) { - if (opts.index) { - streams.out.append_format(L"1 %lu\n", wcslen(arg)); - } else { - streams.out.append(arg); - streams.out.append(L'\n'); - } - } - } - return true; + match = wildcard_match(s, wcpattern, false); + } else { + match = wildcard_match(arg, wcpattern, false); } + if (match ^ opts.invert_match) { + total_matched++; + + if (!opts.quiet) { + if (opts.index) { + streams.out.append_format(L"1 %lu\n", wcslen(arg)); + } else { + streams.out.append(arg); + streams.out.append(L'\n'); + } + } + } + return true; + } }; static wcstring pcre2_strerror(int err_code) { diff --git a/src/wgetopt.h b/src/wgetopt.h index 137ec2526..cf82cb6b8 100644 --- a/src/wgetopt.h +++ b/src/wgetopt.h @@ -133,7 +133,6 @@ class wgetopter_t { #endif }; - /// Describe the long-named options requested by the application. The LONG_OPTIONS argument to /// getopt_long or getopt_long_only is a vector of `struct option' terminated by an element /// containing a name which is zero.