From 2e440763976e3cd68ea6098fc8ca1b5335b4c35b Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 7 Apr 2021 22:41:25 +0800 Subject: [PATCH] feature flags: add the notion of a default value for each flag --- src/future_feature_flags.cpp | 13 +++++++++---- src/future_feature_flags.h | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/future_feature_flags.cpp b/src/future_feature_flags.cpp index 54673d3b1..fff9cac6e 100644 --- a/src/future_feature_flags.cpp +++ b/src/future_feature_flags.cpp @@ -6,15 +6,20 @@ #include "wcstringutil.h" -features_t::features_t() = default; +features_t::features_t() { + for (const metadata_t &md : metadata) { + this->set(md.flag, md.default_value); + } +} /// The set of features applying to this instance. features_t features_t::global_features; const features_t::metadata_t features_t::metadata[features_t::flag_count] = { - {stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr"}, - {qmark_noglob, L"qmark-noglob", L"3.0", L"? no longer globs"}, - {string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s"}, + {stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr", false}, + {qmark_noglob, L"qmark-noglob", L"3.0", L"? no longer globs", false}, + {string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s", + false}, }; const struct features_t::metadata_t *features_t::metadata_for(const wchar_t *name) { diff --git a/src/future_feature_flags.h b/src/future_feature_flags.h index e31b306e7..0ed5d5d95 100644 --- a/src/future_feature_flags.h +++ b/src/future_feature_flags.h @@ -57,6 +57,9 @@ class features_t { /// User-presentable description of the feature flag. const wchar_t *description; + + /// Default flag value. + const bool default_value; }; /// The metadata, indexed by flag.