diff options
author | Famiu Haque <famiuhaque@proton.me> | 2023-10-12 20:09:52 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@proton.me> | 2023-10-17 00:08:47 +0600 |
commit | ca77089e2dae8d68209f26756774c73ad7ca018e (patch) | |
tree | b5674419aa8269b103aead17770db0a9a0343465 /src/nvim/optionstr.c | |
parent | 36e4901cbdb1c2b4b1d88cf9a7da157bf725fae4 (diff) | |
download | rneovim-ca77089e2dae8d68209f26756774c73ad7ca018e.tar.gz rneovim-ca77089e2dae8d68209f26756774c73ad7ca018e.tar.bz2 rneovim-ca77089e2dae8d68209f26756774c73ad7ca018e.zip |
refactor(options): deduplicate `do_set_option_string`
Reduce code duplication between `do_set_option_string` and `set_string_option` by making the former call the latter within itself.
Diffstat (limited to 'src/nvim/optionstr.c')
-rw-r--r-- | src/nvim/optionstr.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 4aa51db3f1..fba1615dee 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -442,7 +442,8 @@ void set_string_option_direct_in_buf(buf_T *buf, const char *name, int opt_idx, /// /// @return NULL on success, an untranslated error message on error. const char *set_string_option(const int opt_idx, void *varp, const char *value, const int opt_flags, - bool *value_checked, char *const errbuf, const size_t errbuflen) + const bool new_value, bool *value_checked, char *const errbuf, + const size_t errbuflen) FUNC_ATTR_WARN_UNUSED_RESULT { vimoption_T *opt = get_option(opt_idx); @@ -492,13 +493,12 @@ const char *set_string_option(const int opt_idx, void *varp, const char *value, char *const saved_newval = xstrdup(*(char **)varp); const int secure_saved = secure; + const uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags); - // When an option is set in the sandbox, from a modeline or in secure - // mode, then deal with side effects in secure mode. Also when the - // value was set with the P_INSECURE flag and is not completely - // replaced. - if ((opt_flags & OPT_MODELINE) - || sandbox != 0) { + // When an option is set in the sandbox, from a modeline or in secure mode, then deal with side + // effects in secure mode. Also when the value was set with the P_INSECURE flag and is not + // completely replaced. + if ((opt_flags & OPT_MODELINE) || sandbox != 0 || (!new_value && (*p & P_INSECURE))) { secure = 1; } |