Mark short_options as const everywhere

These were needlessly mutable file-scoped variables.
This commit is contained in:
ridiculousfish
2018-09-28 23:45:56 -04:00
parent f465760d1f
commit d7b2576fb5
22 changed files with 22 additions and 22 deletions

View File

@@ -102,7 +102,7 @@ void builtin_wperror(const wchar_t *s, io_streams_t &streams) {
}
}
static const wchar_t *short_options = L"+:h";
static const wchar_t *const short_options = L"+:h";
static const struct woption long_options[] = {{L"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};

View File

@@ -274,7 +274,7 @@ void builtin_bind_t::list_modes(io_streams_t &streams) {
int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams) {
wchar_t *cmd = argv[0];
static const wchar_t *short_options = L":aehkKfM:Lm:s";
static const wchar_t *const short_options = L":aehkKfM:Lm:s";
static const struct woption long_options[] = {{L"all", no_argument, NULL, 'a'},
{L"erase", no_argument, NULL, 'e'},
{L"function-names", no_argument, NULL, 'f'},

View File

@@ -23,7 +23,7 @@ struct block_cmd_opts_t {
static int parse_cmd_opts(block_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams) {
wchar_t *cmd = argv[0];
static const wchar_t *short_options = L":eghl";
static const wchar_t *const short_options = L":eghl";
static const struct woption long_options[] = {{L"erase", no_argument, NULL, 'e'},
{L"local", no_argument, NULL, 'l'},
{L"global", no_argument, NULL, 'g'},

View File

@@ -18,7 +18,7 @@ struct builtin_cmd_opts_t {
bool print_help = false;
bool list_names = false;
};
static const wchar_t *short_options = L":hn";
static const wchar_t *const short_options = L":hn";
static const struct woption long_options[] = {
{L"help", no_argument, NULL, 'h'}, {L"names", no_argument, NULL, 'n'}, {NULL, 0, NULL, 0}};

View File

@@ -20,7 +20,7 @@ struct command_cmd_opts_t {
bool quiet = false;
bool all_paths = false;
};
static const wchar_t *short_options = L":ahqsv";
static const wchar_t *const short_options = L":ahqsv";
static const struct woption long_options[] = {{L"help", no_argument, NULL, 'h'},
{L"all", no_argument, NULL, 'a'},
{L"quiet", no_argument, NULL, 'q'},

View File

@@ -206,7 +206,7 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv)
return STATUS_CMD_ERROR;
}
static const wchar_t *short_options = L":abijpctwforhI:CLSsP";
static const wchar_t *const short_options = L":abijpctwforhI:CLSsP";
static const struct woption long_options[] = {{L"append", no_argument, NULL, 'a'},
{L"insert", no_argument, NULL, 'i'},
{L"replace", no_argument, NULL, 'r'},

View File

@@ -130,7 +130,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
wcstring_list_t wrap_targets;
bool preserve_order = false;
static const wchar_t *short_options = L":a:c:p:s:l:o:d:frxeuAn:C::w:hk";
static const wchar_t *const short_options = L":a:c:p:s:l:o:d:frxeuAn:C::w:hk";
static const struct woption long_options[] = {{L"exclusive", no_argument, NULL, 'x'},
{L"no-files", no_argument, NULL, 'f'},
{L"require-parameter", no_argument, NULL, 'r'},

View File

@@ -16,7 +16,7 @@ struct contains_cmd_opts_t {
bool print_help = false;
bool print_index = false;
};
static const wchar_t *short_options = L"+:hi";
static const wchar_t *const short_options = L"+:hi";
static const struct woption long_options[] = {
{L"help", no_argument, NULL, 'h'}, {L"index", no_argument, NULL, 'i'}, {NULL, 0, NULL, 0}};

View File

@@ -17,7 +17,7 @@ struct echo_cmd_opts_t {
bool print_spaces = true;
bool interpret_special_chars = false;
};
static const wchar_t *short_options = L"+:Eens";
static const wchar_t *const short_options = L"+:Eens";
static const struct woption *long_options = NULL;
static int parse_cmd_opts(echo_cmd_opts_t &opts, int *optind, int argc, wchar_t **argv,

View File

@@ -17,7 +17,7 @@
struct exit_cmd_opts_t {
bool print_help = false;
};
static const wchar_t *short_options = L":h";
static const wchar_t *const short_options = L":h";
static const struct woption long_options[] = {{L"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};

View File

@@ -37,7 +37,7 @@ 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 wchar_t *const 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'},

View File

@@ -39,7 +39,7 @@ struct functions_cmd_opts_t {
wchar_t *handlers_type = NULL;
wchar_t *description = NULL;
};
static const wchar_t *short_options = L":HDacd:ehnqv";
static const wchar_t *const short_options = L":HDacd:ehnqv";
static const struct woption long_options[] = {
{L"erase", no_argument, NULL, 'e'}, {L"description", required_argument, NULL, 'd'},
{L"names", no_argument, NULL, 'n'}, {L"all", no_argument, NULL, 'a'},

View File

@@ -42,7 +42,7 @@ struct history_cmd_opts_t {
/// the non-flag subcommand form. While many of these flags are deprecated they must be
/// supported at least until fish 3.0 and possibly longer to avoid breaking everyones
/// config.fish and other scripts.
static const wchar_t *short_options = L":CRcehmn:pt::z";
static const wchar_t *const short_options = L":CRcehmn:pt::z";
static const struct woption long_options[] = {{L"prefix", no_argument, NULL, 'p'},
{L"contains", no_argument, NULL, 'c'},
{L"help", no_argument, NULL, 'h'},

View File

@@ -119,7 +119,7 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
int mode = JOBS_DEFAULT;
int print_last = 0;
static const wchar_t *short_options = L":cghlpq";
static const wchar_t *const short_options = L":cghlpq";
static const struct woption long_options[] = {
{L"command", no_argument, NULL, 'c'},
{L"group", no_argument, NULL, 'g'},

View File

@@ -34,7 +34,7 @@ struct math_cmd_opts_t {
// This command is atypical in using the "+" (REQUIRE_ORDER) option for flag parsing.
// This is needed because of the minus, `-`, operator in math expressions.
static const wchar_t *short_options = L"+:hs:";
static const wchar_t *const short_options = L"+:hs:";
static const struct woption long_options[] = {{L"scale", required_argument, NULL, 's'},
{L"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};

View File

@@ -54,7 +54,7 @@ struct read_cmd_opts_t {
bool one_line = false;
};
static const wchar_t *short_options = L":Aac:d:ghiLlm:n:p:suxzP:UR:LB";
static const wchar_t *const short_options = L":Aac:d:ghiLlm:n:p:suxzP:UR:LB";
static const struct woption long_options[] = {
{L"array", no_argument, NULL, 'a'},
{L"all-lines", no_argument, NULL, 'A'},

View File

@@ -17,7 +17,7 @@
struct return_cmd_opts_t {
bool print_help = false;
};
static const wchar_t *short_options = L":h";
static const wchar_t *const short_options = L":h";
static const struct woption long_options[] = {{L"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};

View File

@@ -48,7 +48,7 @@ struct set_cmd_opts_t {
// Variables used for parsing the argument list. This command is atypical in using the "+"
// (REQUIRE_ORDER) option for flag parsing. This is not typical of most fish commands. It means
// we stop scanning for flags when the first non-flag argument is seen.
static const wchar_t *short_options = L"+:LSUaeghlnpqux";
static const wchar_t *const short_options = L"+:LSUaeghlnpqux";
static const struct woption long_options[] = {
{L"export", no_argument, NULL, 'x'}, {L"global", no_argument, NULL, 'g'},
{L"local", no_argument, NULL, 'l'}, {L"erase", no_argument, NULL, 'e'},

View File

@@ -49,7 +49,7 @@ static int set_color_builtin_outputter(char c) {
return 0;
}
static const wchar_t *short_options = L":b:hvoidrcu";
static const wchar_t *const short_options = L":b:hvoidrcu";
static const struct woption long_options[] = {{L"background", required_argument, NULL, 'b'},
{L"help", no_argument, NULL, 'h'},
{L"bold", no_argument, NULL, 'o'},

View File

@@ -98,7 +98,7 @@ struct status_cmd_opts_t {
/// the non-flag subcommand form. While these flags are deprecated they must be supported at
/// least until fish 3.0 and possibly longer to avoid breaking everyones config.fish and other
/// scripts.
static const wchar_t *short_options = L":L:cbilfnhj:t";
static const wchar_t *const short_options = L":L:cbilfnhj:t";
static const struct woption long_options[] = {{L"help", no_argument, NULL, 'h'},
{L"is-command-substitution", no_argument, NULL, 'c'},
{L"is-block", no_argument, NULL, 'b'},

View File

@@ -157,7 +157,7 @@ int builtin_ulimit(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
bool soft = false;
int what = RLIMIT_FSIZE;
static const wchar_t *short_options = L":HSacdflmnstuvh";
static const wchar_t *const short_options = L":HSacdflmnstuvh";
static const struct woption long_options[] = {
{L"all", no_argument, NULL, 'a'},
{L"hard", no_argument, NULL, 'H'},

View File

@@ -185,7 +185,7 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
int argc = builtin_count_args(argv);
bool any_flag = false; // flag for -n option
static const wchar_t *short_options = L":n";
static const wchar_t *const short_options = L":n";
static const struct woption long_options[] = {{L"any", no_argument, NULL, 'n'},
{NULL, 0, NULL, 0}};