summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-02-25 11:59:33 +0000
committerBram Moolenaar <Bram@vim.org>2023-02-25 11:59:33 +0000
commit6d611de58c8e324491415da8e79c6bd3faa3e848 (patch)
treedf9157b48308e8685ae667ceaa24dca27deec72b /src
parenta63fd8232895bbf6751087d90fd15c8ea45f1cf0 (diff)
downloadvim-git-6d611de58c8e324491415da8e79c6bd3faa3e848.tar.gz
patch 9.0.1353: too many "else if" statements to handle option valuesv9.0.1353
Problem: Too many "else if" statements to handle option values. Solution: Add more functions to handle option value changes. (Yegappan Lakshmanan, closes #12058)
Diffstat (limited to 'src')
-rw-r--r--src/option.c2
-rw-r--r--src/option.h3
-rw-r--r--src/optiondefs.h41
-rw-r--r--src/optionstr.c264
-rw-r--r--src/proto/optionstr.pro12
-rw-r--r--src/structs.h5
-rw-r--r--src/testdir/gen_opt_test.vim1
-rw-r--r--src/version.c2
8 files changed, 215 insertions, 115 deletions
diff --git a/src/option.c b/src/option.c
index d93d3859f..3fa3b1c14 100644
--- a/src/option.c
+++ b/src/option.c
@@ -3898,6 +3898,7 @@ set_bool_option(
args.os_oldval.boolean = old_value;
args.os_newval.boolean = value;
args.os_doskip = FALSE;
+ args.os_errbuf = NULL;
errmsg = options[opt_idx].opt_did_set_cb(&args);
if (args.os_doskip)
return errmsg;
@@ -4669,6 +4670,7 @@ set_num_option(
args.os_flags = opt_flags;
args.os_oldval.number = old_value;
args.os_newval.number = value;
+ args.os_errbuf = NULL;
errmsg = options[opt_idx].opt_did_set_cb(&args);
}
diff --git a/src/option.h b/src/option.h
index 9cc540a24..487d87c31 100644
--- a/src/option.h
+++ b/src/option.h
@@ -299,7 +299,8 @@ typedef enum {
#define GO_FOOTER 'F' // add footer
#define GO_VERTICAL 'v' // arrange dialog buttons vertically
#define GO_KEEPWINSIZE 'k' // keep GUI window size
-#define GO_ALL "!aAbcdefFghilmMprtTvk" // all possible flags for 'go'
+// all possible flags for 'go'
+#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk"
// flags for 'comments' option
#define COM_NEST 'n' // comments strings nest
diff --git a/src/optiondefs.h b/src/optiondefs.h
index 6ae07fd65..ecaaf4529 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -468,7 +468,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
- (char_u *)&p_bexpr, PV_BEXPR, NULL,
+ (char_u *)&p_bexpr, PV_BEXPR, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -559,7 +559,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
#if defined(FEAT_EVAL)
- (char_u *)&p_ccv, PV_NONE, NULL,
+ (char_u *)&p_ccv, PV_NONE, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -616,7 +616,7 @@ static struct vimoption options[] =
{(char_u *)80L, (char_u *)0L} SCTX_INIT},
{"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
|P_NODUP|P_CURSWANT,
- (char_u *)&p_com, PV_COM, NULL,
+ (char_u *)&p_com, PV_COM, did_set_comments,
{(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
(char_u *)0L}
SCTX_INIT},
@@ -635,12 +635,12 @@ static struct vimoption options[] =
(char_u *)&p_cp, PV_NONE, did_set_compatible,
{(char_u *)TRUE, (char_u *)FALSE} SCTX_INIT},
{"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
- (char_u *)&p_cpt, PV_CPT, NULL,
+ (char_u *)&p_cpt, PV_CPT, did_set_complete,
{(char_u *)".,w,b,u,t,i", (char_u *)0L}
SCTX_INIT},
{"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
#ifdef FEAT_CONCEAL
- (char_u *)VAR_WIN, PV_COCU, NULL,
+ (char_u *)VAR_WIN, PV_COCU, did_set_concealcursor,
{(char_u *)"", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -700,7 +700,7 @@ static struct vimoption options[] =
(char_u *)&p_ci, PV_CI, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
- (char_u *)&p_cpo, PV_NONE, NULL,
+ (char_u *)&p_cpo, PV_NONE, did_set_cpoptions,
{(char_u *)CPO_VI, (char_u *)CPO_VIM}
SCTX_INIT},
{"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
@@ -818,7 +818,7 @@ static struct vimoption options[] =
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
- (char_u *)&p_dex, PV_NONE, NULL,
+ (char_u *)&p_dex, PV_NONE, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -986,7 +986,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN|P_MLE,
#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
- (char_u *)VAR_WIN, PV_FDE, NULL,
+ (char_u *)VAR_WIN, PV_FDE, did_set_foldexpr,
{(char_u *)"0", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -1069,7 +1069,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN|P_MLE,
#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
- (char_u *)VAR_WIN, PV_FDT, NULL,
+ (char_u *)VAR_WIN, PV_FDT, did_set_optexpr,
{(char_u *)"foldtext()", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -1078,7 +1078,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
#ifdef FEAT_EVAL
- (char_u *)&p_fex, PV_FEX, NULL,
+ (char_u *)&p_fex, PV_FEX, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -1086,7 +1086,7 @@ static struct vimoption options[] =
#endif
SCTX_INIT},
{"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
- (char_u *)&p_fo, PV_FO, NULL,
+ (char_u *)&p_fo, PV_FO, did_set_formatoptions,
{(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
SCTX_INIT},
{"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
@@ -1144,7 +1144,8 @@ static struct vimoption options[] =
SCTX_INIT},
{"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
#ifdef CURSOR_SHAPE
- (char_u *)&p_guicursor, PV_NONE, NULL,
+ (char_u *)&p_guicursor, PV_NONE,
+ did_set_guicursor,
{
# ifdef FEAT_GUI
(char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
@@ -1375,7 +1376,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF|P_MLE,
#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
- (char_u *)&p_inex, PV_INEX, NULL,
+ (char_u *)&p_inex, PV_INEX, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -1387,7 +1388,7 @@ static struct vimoption options[] =
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM|P_MLE,
#if defined(FEAT_EVAL)
- (char_u *)&p_inde, PV_INDE, NULL,
+ (char_u *)&p_inde, PV_INDE, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -1689,7 +1690,7 @@ static struct vimoption options[] =
(char_u *)&p_more, PV_NONE, NULL,
{(char_u *)FALSE, (char_u *)TRUE} SCTX_INIT},
{"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
- (char_u *)&p_mouse, PV_NONE, NULL,
+ (char_u *)&p_mouse, PV_NONE, did_set_mouse,
{
#if defined(MSWIN)
(char_u *)"a",
@@ -1834,7 +1835,7 @@ static struct vimoption options[] =
{(char_u *)"", (char_u *)0L} SCTX_INIT},
{"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
- (char_u *)&p_pex, PV_NONE, NULL,
+ (char_u *)&p_pex, PV_NONE, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -1910,7 +1911,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
#ifdef FEAT_POSTSCRIPT
- (char_u *)&p_pexpr, PV_NONE, NULL,
+ (char_u *)&p_pexpr, PV_NONE, did_set_optexpr,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL,
@@ -2259,7 +2260,7 @@ static struct vimoption options[] =
did_set_shiftwidth_tabstop,
{(char_u *)8L, (char_u *)0L} SCTX_INIT},
{"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
- (char_u *)&p_shm, PV_NONE, NULL,
+ (char_u *)&p_shm, PV_NONE, did_set_shortmess,
{(char_u *)"S", (char_u *)"filnxtToOS"}
SCTX_INIT},
{"shortname", "sn", P_BOOL|P_VI_DEF,
@@ -2742,7 +2743,7 @@ static struct vimoption options[] =
SCTX_INIT},
{"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
#ifdef FEAT_VIMINFO
- (char_u *)&p_viminfo, PV_NONE, NULL,
+ (char_u *)&p_viminfo, PV_NONE, did_set_viminfo,
#if defined(MSWIN)
{(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
#elif defined(AMIGA)
@@ -2790,7 +2791,7 @@ static struct vimoption options[] =
(char_u *)&p_wiv, PV_NONE, did_set_weirdinvert,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
- (char_u *)&p_ww, PV_NONE, NULL,
+ (char_u *)&p_ww, PV_NONE, did_set_whichwrap,
{(char_u *)"", (char_u *)"b,s"} SCTX_INIT},
{"wildchar", "wc", P_NUM|P_VIM,
(char_u *)&p_wc, PV_NONE, NULL,
diff --git a/src/optionstr.c b/src/optionstr.c
index f6a02b2a4..4671e835f 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -790,7 +790,7 @@ did_set_helpfile(optset_T *args UNUSED)
return NULL;
}
-#ifdef FEAT_SYN_HL
+#if defined(FEAT_SYN_HL) || defined(PROTO)
/*
* The 'colorcolumn' option is changed.
*/
@@ -1458,20 +1458,20 @@ did_set_matchpairs(optset_T *args)
/*
* The 'comments' option is changed.
*/
- static char *
-did_set_comments(char_u **varp, char *errbuf)
+ char *
+did_set_comments(optset_T *args)
{
char_u *s;
char *errmsg = NULL;
- for (s = *varp; *s; )
+ for (s = args->os_varp; *s; )
{
while (*s && *s != ':')
{
if (vim_strchr((char_u *)COM_ALL, *s) == NULL
&& !VIM_ISDIGIT(*s) && *s != '-')
{
- errmsg = illegal_char(errbuf, *s);
+ errmsg = illegal_char(args->os_errbuf, *s);
break;
}
++s;
@@ -1547,12 +1547,12 @@ did_set_verbosefile(optset_T *args UNUSED)
return NULL;
}
-#ifdef FEAT_VIMINFO
+#if defined(FEAT_VIMINFO) || defined(PROTO)
/*
* The 'viminfo' option is changed.
*/
- static char *
-did_set_viminfo(char *errbuf)
+ char *
+did_set_viminfo(optset_T *args)
{
char_u *s;
char *errmsg = NULL;
@@ -1562,7 +1562,7 @@ did_set_viminfo(char *errbuf)
// Check it's a valid character
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
{
- errmsg = illegal_char(errbuf, *s);
+ errmsg = illegal_char(args->os_errbuf, *s);
break;
}
if (*s == 'n') // name is always last one
@@ -1587,12 +1587,12 @@ did_set_viminfo(char *errbuf)
if (!VIM_ISDIGIT(*(s - 1)))
{
- if (errbuf != NULL)
+ if (args->os_errbuf != NULL)
{
- sprintf(errbuf,
+ sprintf(args->os_errbuf,
_(e_missing_number_after_angle_str_angle),
transchar_byte(*(s - 1)));
- errmsg = errbuf;
+ errmsg = args->os_errbuf;
}
else
errmsg = "";
@@ -1603,7 +1603,7 @@ did_set_viminfo(char *errbuf)
++s;
else if (*s)
{
- if (errbuf != NULL)
+ if (args->os_errbuf != NULL)
errmsg = e_missing_comma;
else
errmsg = "";
@@ -1698,6 +1698,17 @@ did_set_showbreak(optset_T *args)
}
#endif
+#if defined(CURSOR_SHAPE) || defined(PROTO)
+/*
+ * The 'guicursor' option is changed.
+ */
+ char *
+did_set_guicursor(optset_T *args UNUSED)
+{
+ return parse_shape_opt(SHAPE_CURSOR);
+}
+#endif
+
#if defined(FEAT_GUI) || defined(PROTO)
/*
* The 'guifont' option is changed.
@@ -1849,13 +1860,35 @@ did_set_iconstring(optset_T *args)
return did_set_titleiconstring(args, flagval);
}
-#ifdef FEAT_GUI
+/*
+ * An option which is a list of flags is set. Valid values are in 'flags'.
+ */
+ static char *
+did_set_option_listflag(char_u *varp, char_u *flags, char *errbuf)
+{
+ char_u *s;
+
+ for (s = varp; *s; ++s)
+ if (vim_strchr(flags, *s) == NULL)
+ return illegal_char(errbuf, *s);
+
+ return NULL;
+}
+
+#if defined(FEAT_GUI) || defined(PROTO)
/*
* The 'guioptions' option is changed.
*/
char *
did_set_guioptions(optset_T *args)
{
+ char *errmsg;
+
+ errmsg = did_set_option_listflag(args->os_varp, (char_u *)GO_ALL,
+ args->os_errbuf);
+ if (errmsg != NULL)
+ return errmsg;
+
gui_init_which_components(args->os_oldval.string);
return NULL;
}
@@ -2095,7 +2128,7 @@ did_set_buftype(optset_T *args UNUSED)
return NULL;
}
-#ifdef FEAT_STL_OPT
+#if defined(FEAT_STL_OPT) || defined(PROTO)
/*
* The 'statusline' or the 'tabline' or the 'rulerformat' option is changed.
* "rulerformat" is TRUE if the 'rulerformat' option is changed.
@@ -2162,20 +2195,20 @@ did_set_rulerformat(optset_T *args)
/*
* The 'complete' option is changed.
*/
- static char *
-did_set_complete(char_u **varp, char *errbuf)
+ char *
+did_set_complete(optset_T *args)
{
char_u *s;
// check if it is a valid value for 'complete' -- Acevedo
- for (s = *varp; *s;)
+ for (s = args->os_varp; *s;)
{
while (*s == ',' || *s == ' ')
s++;
if (!*s)
break;
if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
- return illegal_char(errbuf, *s);
+ return illegal_char(args->os_errbuf, *s);
if (*++s != NUL && *s != ',' && *s != ' ')
{
if (s[-1] == 'k' || s[-1] == 's')
@@ -2190,11 +2223,11 @@ did_set_complete(char_u **varp, char *errbuf)
}
else
{
- if (errbuf != NULL)
+ if (args->os_errbuf != NULL)
{
- sprintf((char *)errbuf,
+ sprintf((char *)args->os_errbuf,
_(e_illegal_character_after_chr), *--s);
- return errbuf;
+ return args->os_errbuf;
}
return "";
}
@@ -2744,45 +2777,137 @@ did_set_completepopup(optset_T *args UNUSED)
# endif
#endif
-#ifdef FEAT_EVAL
+#if defined(FEAT_EVAL) || defined(PROTO)
+/*
+ * Returns TRUE if the option pointed by "varp" or "gvarp" is one of the
+ * '*expr' options: 'balloonexpr', 'diffexpr', 'foldexpr', 'foldtext',
+ * 'formatexpr', 'includeexpr', 'indentexpr', 'patchexpr', 'printexpr' or
+ * 'charconvert'.
+ */
+ static int
+is_expr_option(char_u **varp, char_u **gvarp)
+{
+ return (
+# ifdef FEAT_BEVAL
+ varp == &p_bexpr || // 'balloonexpr'
+# endif
+# ifdef FEAT_DIFF
+ varp == &p_dex || // 'diffexpr'
+# endif
+# ifdef FEAT_FOLDING
+ gvarp == &curwin->w_allbuf_opt.wo_fde || // 'foldexpr'
+ gvarp == &curwin->w_allbuf_opt.wo_fdt || // 'foldtext'
+# endif
+ gvarp == &p_fex || // 'formatexpr'
+# ifdef FEAT_FIND_ID
+ gvarp == &p_inex || // 'includeexpr'
+# endif
+ gvarp == &p_inde || // 'indentexpr'
+# ifdef FEAT_DIFF
+ varp == &p_pex || // 'patchexpr'
+# endif
+# ifdef FEAT_POSTSCRIPT
+ varp == &p_pexpr || // 'printexpr'
+# endif
+ varp == &p_ccv); // 'charconvert'
+}
+
/*
* One of the '*expr' options is changed: 'balloonexpr', 'diffexpr',
* 'foldexpr', 'foldtext', 'formatexpr', 'includeexpr', 'indentexpr',
* 'patchexpr', 'printexpr' and 'charconvert'.
*
*/
- static void
-did_set_optexpr(char_u **varp)
+ char *
+did_set_optexpr(optset_T *args)
{
// If the option value starts with <SID> or s:, then replace that with
// the script identifier.
- char_u *name = get_scriptlocal_funcname(*varp);
+ char_u *name = get_scriptlocal_funcname(args->os_varp);
if (name != NULL)
{
- free_string_option(*varp);
- *varp = name;
+ free_string_option(args->os_varp);
+ args->os_varp = name;
}
-# ifdef FEAT_FOLDING
- if (varp == &curwin->w_p_fde && foldmethodIsExpr(curwin))
+ return NULL;
+}
+
+# if defined(FEAT_FOLDING) || defined(PROTO)
+/*
+ * The 'foldexpr' option is changed.
+ */
+ char *
+did_set_foldexpr(optset_T *args)
+{
+ (void)did_set_optexpr(args);
+ if (foldmethodIsExpr(curwin))
foldUpdateAll(curwin);
+ return NULL;
+}
# endif
+#endif
+
+#if defined(FEAT_CONCEAL) || defined(PROTO)
+/*
+ * The 'concealcursor' option is changed.
+ */
+ char *
+did_set_concealcursor(optset_T *args)
+{
+ return did_set_option_listflag(args->os_varp, (char_u *)COCU_ALL,
+ args->os_errbuf);
}
#endif
/*
- * An option which is a list of flags is set. Valid values are in 'flags'.
+ * The 'cpoptions' option is changed.
*/
- static char *
-did_set_option_listflag(char_u **varp, char_u *flags, char *errbuf)
+ char *
+did_set_cpoptions(optset_T *args)
{
- char_u *s;
+ return did_set_option_listflag(args->os_varp, (char_u *)CPO_ALL,
+ args->os_errbuf);
+}
- for (s = *varp; *s; ++s)
- if (vim_strchr(flags, *s) == NULL)
- return illegal_char(errbuf, *s);
+/*
+ * The 'formatoptions' option is changed.
+ */
+ char *
+did_set_formatoptions(optset_T *args)
+{
+ return did_set_option_listflag(args->os_varp, (char_u *)FO_ALL,
+ args->os_errbuf);
+}
- return NULL;
+/*
+ * The 'mouse' option is changed.
+ */
+ char *
+did_set_mouse(optset_T *args)
+{
+ return did_set_option_listflag(args->os_varp, (char_u *)MOUSE_ALL,
+ args->os_errbuf);
+}
+
+/*
+ * The 'shortmess' option is changed.
+ */
+ char *
+did_set_shortmess(optset_T *args)
+{
+ return did_set_option_listflag(args->os_varp, (char_u *)SHM_ALL,
+ args->os_errbuf);
+}
+
+/*
+ * The 'whichwrap' option is changed.
+ */
+ char *
+did_set_whichwrap(optset_T *args)
+{
+ return did_set_option_listflag(args->os_varp, (char_u *)WW_ALL,
+ args->os_errbuf);
}
#ifdef FEAT_SYN_HL
@@ -2912,7 +3037,14 @@ did_set_string_option(
args.os_flags = opt_flags;
args.os_oldval.string = oldval;
args.os_newval.string = value;
+ args.os_errbuf = errbuf;
errmsg = did_set_cb(&args);
+#ifdef FEAT_EVAL
+ // When processing the '*expr' options (e.g. diffexpr, foldexpr, etc.),
+ // the did_set_cb() function may modify '*varp'.
+ if (errmsg == NULL && is_expr_option(varp, gvarp))
+ *varp = args.os_varp;
+#endif
}
else if (varp == &T_NAME) // 'term'
errmsg = did_set_term(&opt_idx, &free_oldval);
@@ -2930,8 +3062,6 @@ did_set_string_option(
else if (varp == &curbuf->b_p_keymap) // 'keymap'
errmsg = did_set_keymap(varp, opt_flags, value_checked);
#endif
- else if (gvarp == &p_com) // 'comments'
- errmsg = did_set_comments(varp, errbuf);
else if ( varp == &p_lcs // global 'listchars'
|| varp == &p_fcs) // global 'fillchars'
errmsg = did_set_global_listfillchars(varp, opt_flags);
@@ -2939,19 +3069,9 @@ did_set_string_option(
errmsg = set_chars_option(curwin, varp, TRUE);
else if (varp == &curwin->w_p_fcs) // local 'fillchars'
errmsg = set_chars_option(curwin, varp, TRUE);
-#ifdef FEAT_VIMINFO
- else if (varp == &p_viminfo) // 'viminfo'
- errmsg = did_set_viminfo(errbuf);
-#endif // FEAT_VIMINFO
// terminal options
else if (istermoption_idx(opt_idx) && full_screen)
did_set_term_option(varp, &did_swaptcap);
-#ifdef CURSOR_SHAPE
- else if (varp == &p_guicursor) // 'guicursor'
- errmsg = parse_shape_opt(SHAPE_CURSOR);
-#endif
- else if (gvarp == &p_cpt) // 'complete'
- errmsg = did_set_complete(varp, errbuf);
else if (gvarp == &p_ft) // 'filetype'
errmsg = did_set_filetype_or_syntax(varp, oldval, value_checked,
&value_changed);
@@ -2960,50 +3080,6 @@ did_set_string_option(
errmsg = did_set_filetype_or_syntax(varp, oldval, value_checked,
&value_changed);
#endif
-#ifdef FEAT_EVAL
- else if (
-# ifdef FEAT_BEVAL
- varp == &p_bexpr || // 'balloonexpr'
-# endif
-# ifdef FEAT_DIFF
- varp == &p_dex || // 'diffexpr'
-# endif
-# ifdef FEAT_FOLDING
- gvarp == &curwin->w_allbuf_opt.wo_fde || // 'foldexpr'
- gvarp == &curwin->w_allbuf_opt.wo_fdt || // 'foldtext'
-# endif
- gvarp == &p_fex || // 'formatexpr'
-# ifdef FEAT_FIND_ID
- gvarp == &p_inex || // 'includeexpr'
-# endif
- gvarp == &p_inde || // 'indentexpr'
-# ifdef FEAT_DIFF
- varp == &p_pex || // 'patchexpr'
-# endif
-# ifdef FEAT_POSTSCRIPT
- varp == &p_pexpr || // 'printexpr'
-# endif
- varp == &p_ccv) // 'charconvert'
- did_set_optexpr(varp);
-#endif
- else if (varp == &p_ww) // 'whichwrap'
- errmsg = did_set_option_listflag(varp, (char_u *)WW_ALL, errbuf);
- else if (varp == &p_shm) // 'shortmess'
- errmsg = did_set_option_listflag(varp, (char_u *)SHM_ALL, errbuf);
- else if (varp == &(p_cpo)) // 'cpoptions'
- errmsg = did_set_option_listflag(varp, (char_u *)CPO_ALL, errbuf);
- else if (varp == &(curbuf->b_p_fo)) // 'formatoptions'
- errmsg = did_set_option_listflag(varp, (char_u *)FO_ALL, errbuf);
-#ifdef FEAT_CONCEAL
- else if (varp == &curwin->w_p_cocu) // 'concealcursor'
- errmsg = did_set_option_listflag(varp, (char_u *)COCU_ALL, errbuf);
-#endif
- else if (varp == &p_mouse) // 'mouse'
- errmsg = did_set_option_listflag(varp, (char_u *)MOUSE_ALL, errbuf);
-#if defined(FEAT_GUI)
- else if (varp == &p_go) // 'guioptions'
- errmsg = did_set_option_listflag(varp, (char_u *)GO_ALL, errbuf);
-#endif
// If an error is detected, restore the previous value.
if (errmsg != NULL)
diff --git a/src/proto/optionstr.pro b/src/proto/optionstr.pro
index 650fc067e..594632e15 100644
--- a/src/proto/optionstr.pro
+++ b/src/proto/optionstr.pro
@@ -41,8 +41,11 @@ char *did_set_fileformats(optset_T *args);
char *did_set_cryptkey(optset_T *args);
char *did_set_cryptmethod(optset_T *args);
char *did_set_matchpairs(optset_T *args);
+char *did_set_comments(optset_T *args);
char *did_set_verbosefile(optset_T *args);
+char *did_set_viminfo(optset_T *args);
char *did_set_showbreak(optset_T *args);
+char *did_set_guicursor(optset_T *args);
char *did_set_guifont(optset_T *args);
char *did_set_guifontset(optset_T *args);
char *did_set_guifontwide(optset_T *args);
@@ -71,6 +74,7 @@ char *did_set_buftype(optset_T *args);
char *did_set_statusline(optset_T *args);
char *did_set_tabline(optset_T *args);
char *did_set_rulerformat(optset_T *args);
+char *did_set_complete(optset_T *args);
char *did_set_completeopt(optset_T *args);
char *did_set_completeslash(optset_T *args);
char *did_set_signcolumn(optset_T *args);
@@ -99,6 +103,14 @@ char *did_set_varsofttabstop(optset_T *args);
char *did_set_vartabstop(optset_T *args);
char *did_set_previewpopup(optset_T *args);
char *did_set_completepopup(optset_T *args);
+char *did_set_optexpr(optset_T *args);
+char *did_set_foldexpr(optset_T *args);
+char *did_set_concealcursor(optset_T *args);
+char *did_set_cpoptions(optset_T *args);
+char *did_set_formatoptions(optset_T *args);
+char *did_set_mouse(optset_T *args);
+char *did_set_shortmess(optset_T *args);
+char *did_set_whichwrap(optset_T *args);
char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, char_u *value, char *errbuf, int opt_flags, int *value_checked);
int check_ff_value(char_u *p);
void save_clear_shm_value(void);
diff --git a/src/structs.h b/src/structs.h
index 655293942..d33ddb254 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4819,4 +4819,9 @@ typedef struct
// When set by the called function: Stop processing the option further.
// Currently only used for boolean options.
int os_doskip;
+
+ // If the value specified for an option is not valid and the error message
+ // is parameterized, then the "os_errbuf" buffer is used to store the error
+ // message (when it is not NULL).
+ char *os_errbuf;
} optset_T;
diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim
index a18aa66df..6124bb2d2 100644
--- a/src/testdir/gen_opt_test.vim
+++ b/src/testdir/gen_opt_test.vim
@@ -104,6 +104,7 @@ let test_values = {
\ 'guifont': [['', fontname], []],
\ 'guifontwide': [['', fontname], []],
\ 'guifontset': [['', fontname], []],
+ \ 'guioptions': [['', 'a'], ['Q']],
\ 'helplang': [['', 'de', 'de,it'], ['xxx']],
\ 'highlight': [['', 'e:Error'], ['xxx']],
\ 'imactivatekey': [['', 'S-space'], ['xxx']],
diff --git a/src/version.c b/src/version.c
index 9b539356d..c3631e6cc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1353,
+/**/
1352,
/**/
1351,