summaryrefslogtreecommitdiff
path: root/src/option_manager.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-03-25 16:35:33 +1100
committerMaxime Coste <mawww@kakoune.org>2018-03-25 16:35:33 +1100
commit435b5b7ff97c7e52d50c002c9480af7066ead2ad (patch)
tree0e5e9bbf0443e8078a56fde1b9cd620309f048f7 /src/option_manager.hh
parent2d85e945167bb47fac5389172f190536352df8f1 (diff)
Unify code that validates identifiers in Kakoune
Session/Client/User modes names are now requiered to be "identifiers" they must be in [a-zA-Z0-9_-]. Option names are the same except they do not allow '-' as they need to be made available through the env vars and '-' is not supported there. Fixes #1946
Diffstat (limited to 'src/option_manager.hh')
-rw-r--r--src/option_manager.hh8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/option_manager.hh b/src/option_manager.hh
index 674cf6da..84c1be98 100644
--- a/src/option_manager.hh
+++ b/src/option_manager.hh
@@ -214,13 +214,11 @@ public:
const T& value,
OptionFlags flags = OptionFlags::None)
{
- auto is_not_identifier = [](char c) {
- return (c < 'a' or c > 'z') and
- (c < 'A' or c > 'Z') and
- (c < '0' or c > '9') and c != '_';
+ auto is_option_identifier = [](char c) {
+ return is_basic_alpha(c) or is_basic_digit(c) or c == '_';
};
- if (contains_that(name, is_not_identifier))
+ if (not all_of(name, is_option_identifier))
throw runtime_error{format("name '{}' contains char out of [a-zA-Z0-9_]", name)};
auto& opts = m_global_manager.m_options;