Patch 9.0.1374

3 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 3, 2023, 7:26:51 AM3/3/23
to vim...@googlegroups.com

Patch 9.0.1374
Problem: Function for setting options not used consistently.
Solution: Use a function for 'encoding' and terminal options. (Yegappan
Lakshmanan, closes #12099)
Files: src/optiondefs.h, src/optionstr.c, src/proto/optionstr.pro,
src/screen.c, src/structs.h


*** ../vim-9.0.1373/src/optiondefs.h 2023-03-02 14:46:43.885086003 +0000
--- src/optiondefs.h 2023-03-03 12:16:17.441979930 +0000
***************
*** 862,868 ****
{(char_u *)TRUE, (char_u *)0L}
SCTX_INIT},
{"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
! (char_u *)&p_enc, PV_NONE, NULL,
{(char_u *)ENC_DFLT, (char_u *)0L}
SCTX_INIT},
{"endoffile", "eof", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
--- 862,868 ----
{(char_u *)TRUE, (char_u *)0L}
SCTX_INIT},
{"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
! (char_u *)&p_enc, PV_NONE, did_set_encoding,
{(char_u *)ENC_DFLT, (char_u *)0L}
SCTX_INIT},
{"endoffile", "eof", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
***************
*** 914,920 ****
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
|P_NO_MKRC,
! (char_u *)&p_fenc, PV_FENC, NULL,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
--- 914,920 ----
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
|P_NO_MKRC,
! (char_u *)&p_fenc, PV_FENC, did_set_encoding,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
***************
*** 1606,1612 ****
#endif
SCTX_INIT},
{"makeencoding","menc", P_STRING|P_VI_DEF,
! (char_u *)&p_menc, PV_MENC, NULL,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
--- 1606,1612 ----
#endif
SCTX_INIT},
{"makeencoding","menc", P_STRING|P_VI_DEF,
! (char_u *)&p_menc, PV_MENC, did_set_encoding,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
***************
*** 2516,2522 ****
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
! (char_u *)&p_tenc, PV_NONE, NULL,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
--- 2516,2522 ----
#endif
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
! (char_u *)&p_tenc, PV_NONE, did_set_encoding,
{(char_u *)"", (char_u *)0L}
SCTX_INIT},
{"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
***************
*** 2901,2907 ****
// terminal output codes
#define p_term(sss, vvv) \
{sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
! (char_u *)&vvv, PV_NONE, NULL, \
{(char_u *)"", (char_u *)0L} SCTX_INIT},

p_term("t_AB", T_CAB)
--- 2901,2907 ----
// terminal output codes
#define p_term(sss, vvv) \
{sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
! (char_u *)&vvv, PV_NONE, did_set_term_option, \
{(char_u *)"", (char_u *)0L} SCTX_INIT},

p_term("t_AB", T_CAB)
*** ../vim-9.0.1373/src/optionstr.c 2023-03-02 14:46:43.889086014 +0000
--- src/optionstr.c 2023-03-03 12:22:43.538249339 +0000
***************
*** 683,693 ****
* 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);

--- 683,693 ----
* An option which is a list of flags is set. Valid values are in 'flags'.
*/
static char *
! did_set_option_listflag(char_u *val, char_u *flags, char *errbuf)
{
char_u *s;

! for (s = val; *s; ++s)
if (vim_strchr(flags, *s) == NULL)
return illegal_char(errbuf, *s);

***************
*** 946,962 ****
char *
did_set_chars_option(optset_T *args)
{
char *errmsg = NULL;

! if ( args->os_varp == p_lcs // global 'listchars'
! || args->os_varp == p_fcs) // global 'fillchars'
! errmsg = did_set_global_listfillchars(args->os_varp,
! args->os_varp == p_lcs,
! args->os_flags);
! else if (args->os_varp == curwin->w_p_lcs) // local 'listchars'
! errmsg = set_listchars_option(curwin, args->os_varp, TRUE);
! else if (args->os_varp == curwin->w_p_fcs) // local 'fillchars'
! errmsg = set_fillchars_option(curwin, args->os_varp, TRUE);

return errmsg;
}
--- 946,962 ----
char *
did_set_chars_option(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char *errmsg = NULL;

! if ( varp == &p_lcs // global 'listchars'
! || varp == &p_fcs) // global 'fillchars'
! errmsg = did_set_global_listfillchars(*varp, varp == &p_lcs,
! args->os_flags);
! else if (varp == &curwin->w_p_lcs) // local 'listchars'
! errmsg = set_listchars_option(curwin, *varp, TRUE);
! else if (varp == &curwin->w_p_fcs) // local 'fillchars'
! errmsg = set_fillchars_option(curwin, *varp, TRUE);

return errmsg;
}
***************
*** 990,999 ****
char *
did_set_comments(optset_T *args)
{
char_u *s;
char *errmsg = NULL;

! for (s = args->os_varp; *s; )
{
while (*s && *s != ':')
{
--- 990,1000 ----
char *
did_set_comments(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *s;
char *errmsg = NULL;

! for (s = *varp; *s; )
{
while (*s && *s != ':')
{
***************
*** 1030,1036 ****
char *
did_set_commentstring(optset_T *args)
{
! if (*args->os_varp != NUL && strstr((char *)args->os_varp, "%s") == NULL)
return e_commentstring_must_be_empty_or_contain_str;

return NULL;
--- 1031,1039 ----
char *
did_set_commentstring(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
return e_commentstring_must_be_empty_or_contain_str;

return NULL;
***************
*** 1043,1052 ****
char *
did_set_complete(optset_T *args)
{
char_u *s;

// check if it is a valid value for 'complete' -- Acevedo
! for (s = args->os_varp; *s;)
{
while (*s == ',' || *s == ' ')
s++;
--- 1046,1056 ----
char *
did_set_complete(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *s;

// check if it is a valid value for 'complete' -- Acevedo
! for (s = *varp; *s;)
{
while (*s == ',' || *s == ' ')
s++;
***************
*** 1132,1139 ****
char *
did_set_concealcursor(optset_T *args)
{
! return did_set_option_listflag(args->os_varp, (char_u *)COCU_ALL,
! args->os_errbuf);
}
#endif

--- 1136,1144 ----
char *
did_set_concealcursor(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! return did_set_option_listflag(*varp, (char_u *)COCU_ALL, args->os_errbuf);
}
#endif

***************
*** 1143,1150 ****
char *
did_set_cpoptions(optset_T *args)
{
! return did_set_option_listflag(args->os_varp, (char_u *)CPO_ALL,
! args->os_errbuf);
}

#if defined(FEAT_CRYPT) || defined(PROTO)
--- 1148,1156 ----
char *
did_set_cpoptions(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! return did_set_option_listflag(*varp, (char_u *)CPO_ALL, args->os_errbuf);
}

#if defined(FEAT_CRYPT) || defined(PROTO)
***************
*** 1268,1275 ****
char *
did_set_cursorlineopt(optset_T *args)
{
! if (*args->os_varp == NUL
! || fill_culopt_flags(args->os_varp, curwin) != OK)
return e_invalid_argument;

return NULL;
--- 1274,1282 ----
char *
did_set_cursorlineopt(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK)
return e_invalid_argument;

return NULL;
***************
*** 1325,1339 ****
* One of the 'encoding', 'fileencoding', 'termencoding' or 'makeencoding'
* options is changed.
*/
! static char *
! did_set_encoding(char_u **varp, char_u **gvarp, int opt_flags)
{
char *errmsg = NULL;
char_u *p;

if (gvarp == &p_fenc)
{
! if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
errmsg = e_cannot_make_changes_modifiable_is_off;
else if (vim_strchr(*varp, ',') != NULL)
// No comma allowed in 'fileencoding'; catches confusing it
--- 1332,1352 ----
* One of the 'encoding', 'fileencoding', 'termencoding' or 'makeencoding'
* options is changed.
*/
! char *
! did_set_encoding(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
+ char_u **gvarp;
char *errmsg = NULL;
char_u *p;

+ // Get the global option to compare with, otherwise we would have to check
+ // two values for all local options.
+ gvarp = (char_u **)get_option_varp_scope(args->os_idx, OPT_GLOBAL);
+
if (gvarp == &p_fenc)
{
! if (!curbuf->b_p_ma && args->os_flags != OPT_GLOBAL)
errmsg = e_cannot_make_changes_modifiable_is_off;
else if (vim_strchr(*varp, ',') != NULL)
// No comma allowed in 'fileencoding'; catches confusing it
***************
*** 1425,1433 ****
char *
did_set_fileformat(optset_T *args)
{
if (!curbuf->b_p_ma && !(args->os_flags & OPT_GLOBAL))
return e_cannot_make_changes_modifiable_is_off;
! else if (check_opt_strings(args->os_varp, p_ff_values, FALSE) != OK)
return e_invalid_argument;

// may also change 'textmode'
--- 1438,1448 ----
char *
did_set_fileformat(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
+
if (!curbuf->b_p_ma && !(args->os_flags & OPT_GLOBAL))
return e_cannot_make_changes_modifiable_is_off;
! else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
return e_invalid_argument;

// may also change 'textmode'
***************
*** 1470,1480 ****
char *
did_set_filetype_or_syntax(optset_T *args)
{
! if (!valid_filetype(args->os_varp))
return e_invalid_argument;

! args->os_value_changed =
! STRCMP(args->os_oldval.string, args->os_varp) != 0;

// Since we check the value, there is no need to set P_INSECURE,
// even when the value comes from a modeline.
--- 1485,1496 ----
char *
did_set_filetype_or_syntax(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (!valid_filetype(*varp))
return e_invalid_argument;

! args->os_value_changed = STRCMP(args->os_oldval.string, *varp) != 0;

// Since we check the value, there is no need to set P_INSECURE,
// even when the value comes from a modeline.
***************
*** 1526,1537 ****
char *
did_set_foldmarker(optset_T *args)
{
char_u *p;

! p = vim_strchr(args->os_varp, ',');
if (p == NULL)
return e_comma_required;
! else if (p == args->os_varp || p[1] == NUL)
return e_invalid_argument;
else if (foldmethodIsMarker(curwin))
foldUpdateAll(curwin);
--- 1542,1554 ----
char *
did_set_foldmarker(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *p;

! p = vim_strchr(*varp, ',');
if (p == NULL)
return e_comma_required;
! else if (p == *varp || p[1] == NUL)
return e_invalid_argument;
else if (foldmethodIsMarker(curwin))
foldUpdateAll(curwin);
***************
*** 1545,1551 ****
char *
did_set_foldmethod(optset_T *args)
{
! if (check_opt_strings(args->os_varp, p_fdm_values, FALSE) != OK
|| *curwin->w_p_fdm == NUL)
return e_invalid_argument;

--- 1562,1570 ----
char *
did_set_foldmethod(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
|| *curwin->w_p_fdm == NUL)
return e_invalid_argument;

***************
*** 1571,1578 ****
char *
did_set_formatoptions(optset_T *args)
{
! return did_set_option_listflag(args->os_varp, (char_u *)FO_ALL,
! args->os_errbuf);
}

#if defined(CURSOR_SHAPE) || defined(PROTO)
--- 1590,1598 ----
char *
did_set_formatoptions(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! return did_set_option_listflag(*varp, (char_u *)FO_ALL, args->os_errbuf);
}

#if defined(CURSOR_SHAPE) || defined(PROTO)
***************
*** 1683,1692 ****
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;

--- 1703,1712 ----
char *
did_set_guioptions(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char *errmsg;

! errmsg = did_set_option_listflag(*varp, (char_u *)GO_ALL, args->os_errbuf);
if (errmsg != NULL)
return errmsg;

***************
*** 1765,1773 ****
parse_titleiconstring(optset_T *args UNUSED, int flagval UNUSED)
{
#ifdef FEAT_STL_OPT
// NULL => statusline syntax
! if (vim_strchr(args->os_varp, '%')
! && check_stl_option(args->os_varp) == NULL)
stl_syntax |= flagval;
else
stl_syntax &= ~flagval;
--- 1785,1794 ----
parse_titleiconstring(optset_T *args UNUSED, int flagval UNUSED)
{
#ifdef FEAT_STL_OPT
+ char_u **varp = (char_u **)args->os_varp;
+
// NULL => statusline syntax
! if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
stl_syntax |= flagval;
else
stl_syntax &= ~flagval;
***************
*** 1831,1839 ****
char *
did_set_keymap(optset_T *args)
{
char *errmsg = NULL;

! if (!valid_filetype(args->os_varp))
errmsg = e_invalid_argument;
else
{
--- 1852,1861 ----
char *
did_set_keymap(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char *errmsg = NULL;

! if (!valid_filetype(*varp))
errmsg = e_invalid_argument;
else
{
***************
*** 1914,1922 ****
char *
did_set_lispoptions(optset_T *args)
{
! if (*args->os_varp != NUL
! && STRCMP(args->os_varp, "expr:0") != 0
! && STRCMP(args->os_varp, "expr:1") != 0)
return e_invalid_argument;

return NULL;
--- 1936,1946 ----
char *
did_set_lispoptions(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (**varp != NUL
! && STRCMP(*varp, "expr:0") != 0
! && STRCMP(*varp, "expr:1") != 0)
return e_invalid_argument;

return NULL;
***************
*** 1928,1938 ****
char *
did_set_matchpairs(optset_T *args)
{
char_u *p;

if (has_mbyte)
{
! for (p = args->os_varp; *p != NUL; ++p)
{
int x2 = -1;
int x3 = -1;
--- 1952,1963 ----
char *
did_set_matchpairs(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *p;

if (has_mbyte)
{
! for (p = *varp; *p != NUL; ++p)
{
int x2 = -1;
int x3 = -1;
***************
*** 1954,1960 ****
else
{
// Check for "x:y,x:y"
! for (p = args->os_varp; *p != NUL; p += 4)
{
if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
return e_invalid_argument;
--- 1979,1985 ----
else
{
// Check for "x:y,x:y"
! for (p = *varp; *p != NUL; p += 4)
{
if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
return e_invalid_argument;
***************
*** 1986,1992 ****
char *
did_set_mouse(optset_T *args)
{
! return did_set_option_listflag(args->os_varp, (char_u *)MOUSE_ALL,
args->os_errbuf);
}

--- 2011,2019 ----
char *
did_set_mouse(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! return did_set_option_listflag(*varp, (char_u *)MOUSE_ALL,
args->os_errbuf);
}

***************
*** 2027,2070 ****
char *
did_set_nrformats(optset_T *args)
{
! return did_set_opt_strings(args->os_varp, p_nf_values, TRUE);
! }

! #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',
--- 2054,2065 ----
char *
did_set_nrformats(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;

! return did_set_opt_strings(*varp, p_nf_values, TRUE);
}

+ #if defined(FEAT_EVAL) || defined(PROTO)
/*
* One of the '*expr' options is changed: 'balloonexpr', 'diffexpr',
* 'foldexpr', 'foldtext', 'formatexpr', 'includeexpr', 'indentexpr',
***************
*** 2074,2086 ****
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(args->os_varp);
if (name != NULL)
{
! free_string_option(args->os_varp);
! args->os_varp = name;
}

return NULL;
--- 2069,2083 ----
char *
did_set_optexpr(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
+
// If the option value starts with <SID> or s:, then replace that with
// the script identifier.
! char_u *name = get_scriptlocal_funcname(*varp);
if (name != NULL)
{
! free_string_option(*varp);
! *varp = name;
}

return NULL;
***************
*** 2164,2176 ****
static char *
parse_statustabline_rulerformat(optset_T *args, int rulerformat)
{
char_u *s;
char *errmsg = NULL;
int wid;

if (rulerformat) // reset ru_wid first
ru_wid = 0;
! s = args->os_varp;
if (rulerformat && *s == '%')
{
// set ru_wid if 'ruf' starts with "%99("
--- 2161,2174 ----
static char *
parse_statustabline_rulerformat(optset_T *args, int rulerformat)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *s;
char *errmsg = NULL;
int wid;

if (rulerformat) // reset ru_wid first
ru_wid = 0;
! s = *varp;
if (rulerformat && *s == '%')
{
// set ru_wid if 'ruf' starts with "%99("
***************
*** 2213,2220 ****
char *
did_set_rightleftcmd(optset_T *args)
{
// Currently only "search" is a supported value.
! if (*args->os_varp != NUL && STRCMP(args->os_varp, "search") != 0)
return e_invalid_argument;

return NULL;
--- 2211,2220 ----
char *
did_set_rightleftcmd(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
+
// Currently only "search" is a supported value.
! if (**varp != NUL && STRCMP(*varp, "search") != 0)
return e_invalid_argument;

return NULL;
***************
*** 2290,2297 ****
char *
did_set_shortmess(optset_T *args)
{
! return did_set_option_listflag(args->os_varp, (char_u *)SHM_ALL,
! args->os_errbuf);
}

#if defined(FEAT_LINEBREAK) || defined(PROTO)
--- 2290,2298 ----
char *
did_set_shortmess(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! return did_set_option_listflag(*varp, (char_u *)SHM_ALL, args->os_errbuf);
}

#if defined(FEAT_LINEBREAK) || defined(PROTO)
***************
*** 2301,2309 ****
char *
did_set_showbreak(optset_T *args)
{
char_u *s;

! for (s = args->os_varp; *s; )
{
if (ptr2cells(s) != 1)
return e_showbreak_contains_unprintable_or_wide_character;
--- 2302,2311 ----
char *
did_set_showbreak(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *s;

! for (s = *varp; *s; )
{
if (ptr2cells(s) != 1)
return e_showbreak_contains_unprintable_or_wide_character;
***************
*** 2330,2336 ****
char *
did_set_signcolumn(optset_T *args)
{
! if (check_opt_strings(args->os_varp, p_scl_values, FALSE) != OK)
return e_invalid_argument;
// When changing the 'signcolumn' to or from 'number', recompute the
// width of the number column if 'number' or 'relativenumber' is set.
--- 2332,2340 ----
char *
did_set_signcolumn(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
return e_invalid_argument;
// When changing the 'signcolumn' to or from 'number', recompute the
// width of the number column if 'number' or 'relativenumber' is set.
***************
*** 2360,2366 ****
char *
did_set_spellfile(optset_T *args)
{
! if (!valid_spellfile(args->os_varp))
return e_invalid_argument;

// If there is a window for this buffer in which 'spell' is set load the
--- 2364,2372 ----
char *
did_set_spellfile(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (!valid_spellfile(*varp))
return e_invalid_argument;

// If there is a window for this buffer in which 'spell' is set load the
***************
*** 2374,2380 ****
char *
did_set_spelllang(optset_T *args)
{
! if (!valid_spelllang(args->os_varp))
return e_invalid_argument;

// If there is a window for this buffer in which 'spell' is set load the
--- 2380,2388 ----
char *
did_set_spelllang(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (!valid_spelllang(*varp))
return e_invalid_argument;

// If there is a window for this buffer in which 'spell' is set load the
***************
*** 2388,2394 ****
char *
did_set_spelloptions(optset_T *args)
{
! if (*args->os_varp != NUL && STRCMP("camel", args->os_varp) != 0)
return e_invalid_argument;

return NULL;
--- 2396,2404 ----
char *
did_set_spelloptions(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! if (**varp != NUL && STRCMP("camel", *varp) != 0)
return e_invalid_argument;

return NULL;
***************
*** 2522,2530 ****
/*
* Some terminal option (t_xxx) is changed
*/
! static void
! did_set_term_option(char_u **varp, int *did_swaptcap UNUSED)
{
// ":set t_Co=0" and ":set t_Co=1" do ":set t_Co="
if (varp == &T_CCO)
{
--- 2532,2545 ----
/*
* Some terminal option (t_xxx) is changed
*/
! char *
! did_set_term_option(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
+
+ if (!full_screen)
+ return NULL;
+
// ":set t_Co=0" and ":set t_Co=1" do ":set t_Co="
if (varp == &T_CCO)
{
***************
*** 2545,2551 ****
if (is_term_win32())
{
swap_tcap();
! *did_swaptcap = TRUE;
}
#endif
// We now have a different color setup, initialize it again.
--- 2560,2566 ----
if (is_term_win32())
{
swap_tcap();
! args->os_did_swaptcap = TRUE;
}
#endif
// We now have a different color setup, initialize it again.
***************
*** 2578,2583 ****
--- 2593,2600 ----
else
out_str(T_BE);
}
+
+ return NULL;
}

#if defined(FEAT_TERMINAL) || defined(PROTO)
***************
*** 2705,2713 ****
char *
did_set_varsofttabstop(optset_T *args)
{
char_u *cp;

! if (!(args->os_varp[0]) || (args->os_varp[0] == '0' && !(args->os_varp[1])))
{
if (curbuf->b_p_vsts_array)
{
--- 2722,2731 ----
char *
did_set_varsofttabstop(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *cp;

! if (!((*varp)[0]) || ((*varp)[0] == '0' && !((*varp)[1])))
{
if (curbuf->b_p_vsts_array)
{
***************
*** 2717,2733 ****
}
else
{
! for (cp = args->os_varp; *cp; ++cp)
{
if (vim_isdigit(*cp))
continue;
! if (*cp == ',' && cp > args->os_varp && *(cp-1) != ',')
continue;
return e_invalid_argument;
}

int *oldarray = curbuf->b_p_vsts_array;
! if (tabstop_set(args->os_varp, &(curbuf->b_p_vsts_array)) == OK)
{
if (oldarray)
vim_free(oldarray);
--- 2735,2751 ----
}
else
{
! for (cp = *varp; *cp; ++cp)
{
if (vim_isdigit(*cp))
continue;
! if (*cp == ',' && cp > *varp && *(cp-1) != ',')
continue;
return e_invalid_argument;
}

int *oldarray = curbuf->b_p_vsts_array;
! if (tabstop_set(*varp, &(curbuf->b_p_vsts_array)) == OK)
{
if (oldarray)
vim_free(oldarray);
***************
*** 2745,2753 ****
char *
did_set_vartabstop(optset_T *args)
{
char_u *cp;

! if (!(args->os_varp[0]) || (args->os_varp[0] == '0' && !(args->os_varp[1])))
{
if (curbuf->b_p_vts_array)
{
--- 2763,2772 ----
char *
did_set_vartabstop(optset_T *args)
{
+ char_u **varp = (char_u **)args->os_varp;
char_u *cp;

! if (!((*varp)[0]) || ((*varp)[0] == '0' && !((*varp)[1])))
{
if (curbuf->b_p_vts_array)
{
***************
*** 2757,2774 ****
}
else
{
! for (cp = args->os_varp; *cp; ++cp)
{
if (vim_isdigit(*cp))
continue;
! if (*cp == ',' && cp > args->os_varp && *(cp-1) != ',')
continue;
return e_invalid_argument;
}

int *oldarray = curbuf->b_p_vts_array;

! if (tabstop_set(args->os_varp, &(curbuf->b_p_vts_array)) == OK)
{
vim_free(oldarray);
# ifdef FEAT_FOLDING
--- 2776,2793 ----
}
else
{
! for (cp = *varp; *cp; ++cp)
{
if (vim_isdigit(*cp))
continue;
! if (*cp == ',' && cp > *varp && *(cp-1) != ',')
continue;
return e_invalid_argument;
}

int *oldarray = curbuf->b_p_vts_array;

! if (tabstop_set(*varp, &(curbuf->b_p_vts_array)) == OK)
{
vim_free(oldarray);
# ifdef FEAT_FOLDING
***************
*** 2918,2925 ****
char *
did_set_whichwrap(optset_T *args)
{
! return did_set_option_listflag(args->os_varp, (char_u *)WW_ALL,
! args->os_errbuf);
}

/*
--- 2937,2945 ----
char *
did_set_whichwrap(optset_T *args)
{
! char_u **varp = (char_u **)args->os_varp;
!
! return did_set_option_listflag(*varp, (char_u *)WW_ALL, args->os_errbuf);
}

/*
***************
*** 3078,3093 ****
{
char *errmsg = NULL;
int restore_chartab = FALSE;
- char_u **gvarp;
long_u free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
int value_changed = FALSE;
int did_swaptcap = FALSE;
opt_did_set_cb_T did_set_cb = get_option_did_set_cb(opt_idx);

- // Get the global option to compare with, otherwise we would have to check
- // two values for all local options.
- gvarp = (char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
-
// Disallow changing some options from secure mode
if ((secure
#ifdef HAVE_SANDBOX
--- 3098,3110 ----
{
char *errmsg = NULL;
int restore_chartab = FALSE;
long_u free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
int value_changed = FALSE;
+ #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
int did_swaptcap = FALSE;
+ #endif
opt_did_set_cb_T did_set_cb = get_option_did_set_cb(opt_idx);

// Disallow changing some options from secure mode
if ((secure
#ifdef HAVE_SANDBOX
***************
*** 3102,3125 ****
{
optset_T args;

! args.os_varp = *varp;
args.os_flags = opt_flags;
args.os_oldval.string = oldval;
args.os_newval.string = value;
- args.os_value_checked = FALSE;
- args.os_value_changed = FALSE;
- args.os_restore_chartab = FALSE;
args.os_errbuf = errbuf;
// Invoke the option specific callback function to validate and apply
// the new option value.
errmsg = did_set_cb(&args);

- #ifdef FEAT_EVAL
- // The '*expr' option (e.g. diffexpr, foldexpr, etc.), callback
- // functions may modify '*varp'.
- if (errmsg == NULL && is_expr_option(varp, gvarp))
- *varp = args.os_varp;
- #endif
// The 'filetype' and 'syntax' option callback functions may change
// the os_value_changed field.
value_changed = args.os_value_changed;
--- 3119,3135 ----
{
optset_T args;

! CLEAR_FIELD(args);
! args.os_varp = (char_u *)varp;
! args.os_idx = opt_idx;
args.os_flags = opt_flags;
args.os_oldval.string = oldval;
args.os_newval.string = value;
args.os_errbuf = errbuf;
// Invoke the option specific callback function to validate and apply
// the new option value.
errmsg = did_set_cb(&args);

// The 'filetype' and 'syntax' option callback functions may change
// the os_value_changed field.
value_changed = args.os_value_changed;
***************
*** 3129,3145 ****
// The 'isident', 'iskeyword', 'isprint' and 'isfname' options may
// change the character table. On failure, this needs to be restored.
restore_chartab = args.os_restore_chartab;
}
else if (varp == &T_NAME) // 'term'
errmsg = did_set_term(&opt_idx, &free_oldval);
- else if ( varp == &p_enc // 'encoding'
- || gvarp == &p_fenc // 'fileencoding'
- || varp == &p_tenc // 'termencoding'
- || gvarp == &p_menc) // 'makeencoding'
- errmsg = did_set_encoding(varp, gvarp, opt_flags);
- // terminal options
- else if (istermoption_idx(opt_idx) && full_screen)
- did_set_term_option(varp, &did_swaptcap);

// If an error is detected, restore the previous value.
if (errmsg != NULL)
--- 3139,3151 ----
// The 'isident', 'iskeyword', 'isprint' and 'isfname' options may
// change the character table. On failure, this needs to be restored.
restore_chartab = args.os_restore_chartab;
+ #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
+ // The 't_xxx' terminal options may swap the termcap entries.
+ did_swaptcap = args.os_did_swaptcap;
+ #endif
}
else if (varp == &T_NAME) // 'term'
errmsg = did_set_term(&opt_idx, &free_oldval);

// If an error is detected, restore the previous value.
if (errmsg != NULL)
*** ../vim-9.0.1373/src/proto/optionstr.pro 2023-03-02 14:46:43.889086014 +0000
--- src/proto/optionstr.pro 2023-03-03 12:16:17.445979936 +0000
***************
*** 39,44 ****
--- 39,45 ----
char *did_set_diffopt(optset_T *args);
char *did_set_display(optset_T *args);
char *did_set_eadirection(optset_T *args);
+ char *did_set_encoding(optset_T *args);
char *did_set_eventignore(optset_T *args);
char *did_set_fileformat(optset_T *args);
char *did_set_fileformats(optset_T *args);
***************
*** 99,104 ****
--- 100,106 ----
char *did_set_switchbuf(optset_T *args);
char *did_set_tabline(optset_T *args);
char *did_set_tagcase(optset_T *args);
+ char *did_set_term_option(optset_T *args);
char *did_set_termwinkey(optset_T *args);
char *did_set_termwinsize(optset_T *args);
char *did_set_termwintype(optset_T *args);
*** ../vim-9.0.1373/src/screen.c 2023-03-02 14:46:43.889086014 +0000
--- src/screen.c 2023-03-03 12:16:17.445979936 +0000
***************
*** 4655,4668 ****

/*
* Handle setting 'listchars' or 'fillchars'.
! * "val" points to either the global or the window-local value.
* "opt_lcs" is TRUE for "listchars" and FALSE for "fillchars".
* When "apply" is FALSE do not store the flags, only check for errors.
* Assume monocell characters.
* Returns error message, NULL if it's OK.
*/
static char *
! set_chars_option(win_T *wp, char_u *val, int opt_lcs, int apply)
{
int round, i, len, len2, entries;
char_u *p, *s;
--- 4655,4668 ----

/*
* Handle setting 'listchars' or 'fillchars'.
! * "value" points to either the global or the window-local value.
* "opt_lcs" is TRUE for "listchars" and FALSE for "fillchars".
* When "apply" is FALSE do not store the flags, only check for errors.
* Assume monocell characters.
* Returns error message, NULL if it's OK.
*/
static char *
! set_chars_option(win_T *wp, char_u *value, int opt_lcs, int apply)
{
int round, i, len, len2, entries;
char_u *p, *s;
***************
*** 4672,4678 ****
int multispace_len = 0; // Length of lcs-multispace string
int lead_multispace_len = 0; // Length of lcs-leadmultispace string
int is_listchars = opt_lcs;
- char_u *value = val;

struct charstab
{
--- 4672,4677 ----
*** ../vim-9.0.1373/src/structs.h 2023-02-27 12:47:44.107282452 +0000
--- src/structs.h 2023-03-03 12:21:16.926301855 +0000
***************
*** 4797,4804 ****
*/
typedef struct
{
int os_flags;
- char_u *os_varp; // pointer to the option variable

// old value of the option (can be a string, number or a boolean)
union
--- 4797,4807 ----
*/
typedef struct
{
+ // Pointer to the option variable. The variable can be a long (numeric
+ // option), an int (boolean option) or a char pointer (string option).
+ char_u *os_varp;
+ int os_idx;
int os_flags;

// old value of the option (can be a string, number or a boolean)
union
***************
*** 4831,4836 ****
--- 4834,4844 ----
// option and need to be restored because of a failure.
int os_restore_chartab;

+ #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
+ // Used by the 't_xxx' terminal options on MS-Windows.
+ int os_did_swaptcap;
+ #endif
+
// 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).
*** ../vim-9.0.1373/src/version.c 2023-03-02 18:49:05.989526230 +0000
--- src/version.c 2023-03-03 12:18:49.514144713 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1374,
/**/

--
hundred-and-one symptoms of being an internet addict:
217. Your sex life has drastically improved...so what if it's only cyber-sex!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages