diff --git a/src/builtin_status.cpp b/src/builtin_status.cpp index 1aecc9621..f2f2ed17b 100644 --- a/src/builtin_status.cpp +++ b/src/builtin_status.cpp @@ -138,7 +138,7 @@ static bool set_status_cmd(wchar_t *const cmd, status_cmd_opts_t &opts, status_c /// Print the features and their values. static void print_features(io_streams_t &streams) { for (const auto &md : features_t::metadata) { - int set = fish_features().test(md.flag); + int set = feature_test(md.flag); streams.out.append_format(L"%ls\t%s\t%ls\t%ls\n", md.name, set ? "on" : "off", md.groups, md.description); } @@ -339,7 +339,7 @@ int builtin_status(parser_t &parser, io_streams_t &streams, wchar_t **argv) { if (!metadata) { retval = TEST_FEATURE_NOT_RECOGNIZED; } else { - retval = fish_features().test(metadata->flag) ? TEST_FEATURE_ON : TEST_FEATURE_OFF; + retval = feature_test(metadata->flag) ? TEST_FEATURE_ON : TEST_FEATURE_OFF; } break; } diff --git a/src/common.cpp b/src/common.cpp index 83f2fae04..6462ee811 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -932,8 +932,8 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring const bool escape_all = static_cast(flags & ESCAPE_ALL); const bool no_quoted = static_cast(flags & ESCAPE_NO_QUOTED); const bool no_tilde = static_cast(flags & ESCAPE_NO_TILDE); - const bool no_caret = fish_features().test(features_t::stderr_nocaret); - const bool no_qmark = fish_features().test(features_t::qmark_noglob); + const bool no_caret = feature_test(features_t::stderr_nocaret); + const bool no_qmark = feature_test(features_t::qmark_noglob); int need_escape = 0; int need_complex_escape = 0; @@ -1361,7 +1361,7 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in break; } case L'?': { - if (unescape_special && !fish_features().test(features_t::qmark_noglob)) { + if (unescape_special && !feature_test(features_t::qmark_noglob)) { to_append_or_none = ANY_CHAR; } break; diff --git a/src/future_feature_flags.h b/src/future_feature_flags.h index 2f9aec788..7ccc7f570 100644 --- a/src/future_feature_flags.h +++ b/src/future_feature_flags.h @@ -68,6 +68,9 @@ public: /// Return the global set of features for fish. This is const to prevent accidental mutation. const features_t &fish_features(); +/// Perform a feature test on the global set of features. +inline bool feature_test(features_t::flag_t f) { return fish_features().test(f); } + /// Return the global set of features for fish, but mutable. In general fish features should be set /// at startup only. features_t &mutable_fish_features(); diff --git a/src/highlight.cpp b/src/highlight.cpp index 782725b1f..5bf286422 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -550,7 +550,7 @@ static void color_argument_internal(const wcstring &buffstr, break; } case L'?': { - if (!fish_features().test(features_t::qmark_noglob)) { + if (!feature_test(features_t::qmark_noglob)) { colors[in_pos] = highlight_spec_operator; } break; diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 4fb9e79d8..eb60f25e5 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -419,7 +419,7 @@ void parse_util_token_extent(const wchar_t *buff, size_t cursor_pos, const wchar wcstring parse_util_unescape_wildcards(const wcstring &str) { wcstring result; result.reserve(str.size()); - bool unesc_qmark = !fish_features().test(features_t::qmark_noglob); + bool unesc_qmark = !feature_test(features_t::qmark_noglob); const wchar_t *const cs = str.c_str(); for (size_t i = 0; cs[i] != L'\0'; i++) { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 1bbc784f0..7f1f86a20 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -36,7 +36,7 @@ const wchar_t *tokenizer_error::Message() const { } // Whether carets redirect stderr. -static bool caret_redirs() { return !fish_features().test(features_t::stderr_nocaret); } +static bool caret_redirs() { return !feature_test(features_t::stderr_nocaret); } /// Return an error token and mark that we no longer have a next token. tok_t tokenizer_t::call_error(tokenizer_error *error_type, const wchar_t *token_start, diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 05f551f1a..e12307495 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -62,7 +62,7 @@ static size_t wildcard_find(const wchar_t *wc) { /// Implementation of wildcard_has. Needs to take the length to handle embedded nulls (issue #1631). static bool wildcard_has_impl(const wchar_t *str, size_t len, bool internal) { assert(str != NULL); - bool qmark_is_wild = !fish_features().test(features_t::qmark_noglob); + bool qmark_is_wild = !feature_test(features_t::qmark_noglob); const wchar_t *end = str + len; if (internal) { for (; str < end; str++) {