mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(optionstr.c): break up did_set_string_option 1
This commit is contained in:
@@ -640,6 +640,34 @@ char *check_stl_option(char *s)
|
|||||||
|
|
||||||
static int shada_idx = -1;
|
static int shada_idx = -1;
|
||||||
|
|
||||||
|
static void did_set_backupcopy(buf_T *buf, char *oldval, int opt_flags, char **errmsg)
|
||||||
|
{
|
||||||
|
char *bkc = p_bkc;
|
||||||
|
unsigned int *flags = &bkc_flags;
|
||||||
|
|
||||||
|
if (opt_flags & OPT_LOCAL) {
|
||||||
|
bkc = buf->b_p_bkc;
|
||||||
|
flags = &buf->b_bkc_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((opt_flags & OPT_LOCAL) && *bkc == NUL) {
|
||||||
|
// make the local value empty: use the global value
|
||||||
|
*flags = 0;
|
||||||
|
} else {
|
||||||
|
if (opt_strings_flags(bkc, p_bkc_values, flags, true) != OK) {
|
||||||
|
*errmsg = e_invarg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((*flags & BKC_AUTO) != 0)
|
||||||
|
+ ((*flags & BKC_YES) != 0)
|
||||||
|
+ ((*flags & BKC_NO) != 0) != 1) {
|
||||||
|
// Must have exactly one of "auto", "yes" and "no".
|
||||||
|
(void)opt_strings_flags(oldval, p_bkc_values, flags, true);
|
||||||
|
*errmsg = e_invarg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Handle string options that need some action to perform when changed.
|
/// Handle string options that need some action to perform when changed.
|
||||||
/// The new value must be allocated.
|
/// The new value must be allocated.
|
||||||
///
|
///
|
||||||
@@ -678,30 +706,7 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
|
|||||||
// are often illegal in a file name. Be more permissive if "secure" is off.
|
// are often illegal in a file name. Be more permissive if "secure" is off.
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
} else if (gvarp == &p_bkc) { // 'backupcopy'
|
} else if (gvarp == &p_bkc) { // 'backupcopy'
|
||||||
char *bkc = p_bkc;
|
did_set_backupcopy(curbuf, oldval, opt_flags, &errmsg);
|
||||||
unsigned int *flags = &bkc_flags;
|
|
||||||
|
|
||||||
if (opt_flags & OPT_LOCAL) {
|
|
||||||
bkc = curbuf->b_p_bkc;
|
|
||||||
flags = &curbuf->b_bkc_flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((opt_flags & OPT_LOCAL) && *bkc == NUL) {
|
|
||||||
// make the local value empty: use the global value
|
|
||||||
*flags = 0;
|
|
||||||
} else {
|
|
||||||
if (opt_strings_flags(bkc, p_bkc_values, flags, true) != OK) {
|
|
||||||
errmsg = e_invarg;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((*flags & BKC_AUTO) != 0)
|
|
||||||
+ ((*flags & BKC_YES) != 0)
|
|
||||||
+ ((*flags & BKC_NO) != 0) != 1) {
|
|
||||||
// Must have exactly one of "auto", "yes" and "no".
|
|
||||||
(void)opt_strings_flags(oldval, p_bkc_values, flags, true);
|
|
||||||
errmsg = e_invarg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (varp == &p_bex || varp == &p_pm) { // 'backupext' and 'patchmode'
|
} else if (varp == &p_bex || varp == &p_pm) { // 'backupext' and 'patchmode'
|
||||||
if (strcmp(*p_bex == '.' ? p_bex + 1 : p_bex,
|
if (strcmp(*p_bex == '.' ? p_bex + 1 : p_bex,
|
||||||
*p_pm == '.' ? p_pm + 1 : p_pm) == 0) {
|
*p_pm == '.' ? p_pm + 1 : p_pm) == 0) {
|
||||||
|
Reference in New Issue
Block a user