mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: pass window to was_set_insecurely
working on get_foldtext and wanted to get rid of the curwin backup/restore. Turns out it's not possible else f_foldtext is run on the same window. Kept the cleanup anyway.
This commit is contained in:
parent
7dfeadb0fc
commit
4f1fc0f6d5
@ -3198,7 +3198,7 @@ void maketitle(void)
|
|||||||
int use_sandbox = false;
|
int use_sandbox = false;
|
||||||
int save_called_emsg = called_emsg;
|
int save_called_emsg = called_emsg;
|
||||||
|
|
||||||
use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
|
use_sandbox = was_set_insecurely(curwin, (char_u *)"titlestring", 0);
|
||||||
called_emsg = false;
|
called_emsg = false;
|
||||||
build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
|
build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
|
||||||
p_titlestring, use_sandbox,
|
p_titlestring, use_sandbox,
|
||||||
@ -3309,7 +3309,7 @@ void maketitle(void)
|
|||||||
int use_sandbox = false;
|
int use_sandbox = false;
|
||||||
int save_called_emsg = called_emsg;
|
int save_called_emsg = called_emsg;
|
||||||
|
|
||||||
use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
|
use_sandbox = was_set_insecurely(curwin, (char_u *)"iconstring", 0);
|
||||||
called_emsg = false;
|
called_emsg = false;
|
||||||
build_stl_str_hl(curwin, icon_str, sizeof(buf),
|
build_stl_str_hl(curwin, icon_str, sizeof(buf),
|
||||||
p_iconstring, use_sandbox,
|
p_iconstring, use_sandbox,
|
||||||
|
@ -1178,8 +1178,7 @@ int eval_foldexpr(char_u *arg, int *cp)
|
|||||||
{
|
{
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
varnumber_T retval;
|
varnumber_T retval;
|
||||||
int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
|
int use_sandbox = was_set_insecurely(curwin, (char_u *)"foldexpr", OPT_LOCAL);
|
||||||
OPT_LOCAL);
|
|
||||||
|
|
||||||
++emsg_off;
|
++emsg_off;
|
||||||
if (use_sandbox)
|
if (use_sandbox)
|
||||||
|
@ -1835,10 +1835,11 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
|
|||||||
curwin = wp;
|
curwin = wp;
|
||||||
curbuf = wp->w_buffer;
|
curbuf = wp->w_buffer;
|
||||||
|
|
||||||
++emsg_silent; /* handle exceptions, but don't display errors */
|
emsg_silent++; // handle exceptions, but don't display errors
|
||||||
text = eval_to_string_safe(wp->w_p_fdt, NULL,
|
text = eval_to_string_safe(
|
||||||
was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
|
wp->w_p_fdt, NULL,
|
||||||
--emsg_silent;
|
was_set_insecurely(wp, (char_u *)"foldtext", OPT_LOCAL));
|
||||||
|
emsg_silent--;
|
||||||
|
|
||||||
if (text == NULL || did_emsg)
|
if (text == NULL || did_emsg)
|
||||||
got_fdt_error = TRUE;
|
got_fdt_error = TRUE;
|
||||||
|
@ -546,7 +546,7 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum,
|
|||||||
curwin->w_botline = lnum + 63;
|
curwin->w_botline = lnum + 63;
|
||||||
printer_page_num = pagenum;
|
printer_page_num = pagenum;
|
||||||
|
|
||||||
use_sandbox = was_set_insecurely((char_u *)"printheader", 0);
|
use_sandbox = was_set_insecurely(curwin, (char_u *)"printheader", 0);
|
||||||
build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE,
|
build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE,
|
||||||
p_header, use_sandbox,
|
p_header, use_sandbox,
|
||||||
' ', width, NULL, NULL);
|
' ', width, NULL, NULL);
|
||||||
|
@ -453,7 +453,8 @@ int get_expr_indent(void)
|
|||||||
colnr_T save_curswant;
|
colnr_T save_curswant;
|
||||||
int save_set_curswant;
|
int save_set_curswant;
|
||||||
int save_State;
|
int save_State;
|
||||||
int use_sandbox = was_set_insecurely((char_u *)"indentexpr", OPT_LOCAL);
|
int use_sandbox = was_set_insecurely(
|
||||||
|
curwin, (char_u *)"indentexpr", OPT_LOCAL);
|
||||||
|
|
||||||
// Save and restore cursor position and curswant, in case it was changed
|
// Save and restore cursor position and curswant, in case it was changed
|
||||||
// * via :normal commands.
|
// * via :normal commands.
|
||||||
|
@ -4117,8 +4117,8 @@ fex_format(
|
|||||||
int c /* character to be inserted */
|
int c /* character to be inserted */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int use_sandbox = was_set_insecurely((char_u *)"formatexpr",
|
int use_sandbox = was_set_insecurely(
|
||||||
OPT_LOCAL);
|
curwin, (char_u *)"formatexpr", OPT_LOCAL);
|
||||||
int r;
|
int r;
|
||||||
char_u *fex;
|
char_u *fex;
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ set_option_default(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The default value is not insecure.
|
// The default value is not insecure.
|
||||||
uint32_t *flagsp = insecure_flag(opt_idx, opt_flags);
|
uint32_t *flagsp = insecure_flag(curwin, opt_idx, opt_flags);
|
||||||
*flagsp = *flagsp & ~P_INSECURE;
|
*flagsp = *flagsp & ~P_INSECURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1880,7 +1880,7 @@ int do_set(
|
|||||||
saved_newval = (newval != NULL) ? xstrdup((char *)newval) : 0;
|
saved_newval = (newval != NULL) ? xstrdup((char *)newval) : 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
uint32_t *p = insecure_flag(opt_idx, opt_flags);
|
uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags);
|
||||||
const int secure_saved = secure;
|
const int secure_saved = secure;
|
||||||
|
|
||||||
// When an option is set in the sandbox, from a
|
// When an option is set in the sandbox, from a
|
||||||
@ -2007,7 +2007,7 @@ static void did_set_option(
|
|||||||
/* When an option is set in the sandbox, from a modeline or in secure mode
|
/* When an option is set in the sandbox, from a modeline or in secure mode
|
||||||
* set the P_INSECURE flag. Otherwise, if a new value is stored reset the
|
* set the P_INSECURE flag. Otherwise, if a new value is stored reset the
|
||||||
* flag. */
|
* flag. */
|
||||||
uint32_t *p = insecure_flag(opt_idx, opt_flags);
|
uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags);
|
||||||
if (!value_checked && (secure
|
if (!value_checked && (secure
|
||||||
|| sandbox != 0
|
|| sandbox != 0
|
||||||
|| (opt_flags & OPT_MODELINE))) {
|
|| (opt_flags & OPT_MODELINE))) {
|
||||||
@ -2346,12 +2346,12 @@ static void check_string_option(char_u **pp)
|
|||||||
/// Return true when option "opt" was set from a modeline or in secure mode.
|
/// Return true when option "opt" was set from a modeline or in secure mode.
|
||||||
/// Return false when it wasn't.
|
/// Return false when it wasn't.
|
||||||
/// Return -1 for an unknown option.
|
/// Return -1 for an unknown option.
|
||||||
int was_set_insecurely(char_u *opt, int opt_flags)
|
int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags)
|
||||||
{
|
{
|
||||||
int idx = findoption((const char *)opt);
|
int idx = findoption((const char *)opt);
|
||||||
|
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
uint32_t *flagp = insecure_flag(idx, opt_flags);
|
uint32_t *flagp = insecure_flag(wp, idx, opt_flags);
|
||||||
return (*flagp & P_INSECURE) != 0;
|
return (*flagp & P_INSECURE) != 0;
|
||||||
}
|
}
|
||||||
internal_error("was_set_insecurely()");
|
internal_error("was_set_insecurely()");
|
||||||
@ -2360,16 +2360,16 @@ int was_set_insecurely(char_u *opt, int opt_flags)
|
|||||||
|
|
||||||
/// Get a pointer to the flags used for the P_INSECURE flag of option
|
/// Get a pointer to the flags used for the P_INSECURE flag of option
|
||||||
/// "opt_idx". For some local options a local flags field is used.
|
/// "opt_idx". For some local options a local flags field is used.
|
||||||
static uint32_t *insecure_flag(int opt_idx, int opt_flags)
|
static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags)
|
||||||
{
|
{
|
||||||
if (opt_flags & OPT_LOCAL)
|
if (opt_flags & OPT_LOCAL)
|
||||||
switch ((int)options[opt_idx].indir) {
|
switch ((int)options[opt_idx].indir) {
|
||||||
case PV_STL: return &curwin->w_p_stl_flags;
|
case PV_STL: return &wp->w_p_stl_flags;
|
||||||
case PV_FDE: return &curwin->w_p_fde_flags;
|
case PV_FDE: return &wp->w_p_fde_flags;
|
||||||
case PV_FDT: return &curwin->w_p_fdt_flags;
|
case PV_FDT: return &wp->w_p_fdt_flags;
|
||||||
case PV_INDE: return &curbuf->b_p_inde_flags;
|
case PV_INDE: return &wp->w_buffer->b_p_inde_flags;
|
||||||
case PV_FEX: return &curbuf->b_p_fex_flags;
|
case PV_FEX: return &wp->w_buffer->b_p_fex_flags;
|
||||||
case PV_INEX: return &curbuf->b_p_inex_flags;
|
case PV_INEX: return &wp->w_buffer->b_p_inex_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing special, return global flags field.
|
// Nothing special, return global flags field.
|
||||||
|
@ -1612,8 +1612,8 @@ static char *eval_includeexpr(const char *const ptr, const size_t len)
|
|||||||
{
|
{
|
||||||
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
|
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
|
||||||
char *res = (char *)eval_to_string_safe(
|
char *res = (char *)eval_to_string_safe(
|
||||||
curbuf->b_p_inex, NULL, was_set_insecurely((char_u *)"includeexpr",
|
curbuf->b_p_inex, NULL,
|
||||||
OPT_LOCAL));
|
was_set_insecurely(curwin, (char_u *)"includeexpr", OPT_LOCAL));
|
||||||
set_vim_var_string(VV_FNAME, NULL, 0);
|
set_vim_var_string(VV_FNAME, NULL, 0);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -5205,7 +5205,7 @@ win_redr_custom (
|
|||||||
fillchar = ' ';
|
fillchar = ' ';
|
||||||
attr = HL_ATTR(HLF_TPF);
|
attr = HL_ATTR(HLF_TPF);
|
||||||
maxwidth = Columns;
|
maxwidth = Columns;
|
||||||
use_sandbox = was_set_insecurely((char_u *)"tabline", 0);
|
use_sandbox = was_set_insecurely(wp, (char_u *)"tabline", 0);
|
||||||
} else {
|
} else {
|
||||||
row = W_ENDROW(wp);
|
row = W_ENDROW(wp);
|
||||||
fillchar = fillchar_status(&attr, wp);
|
fillchar = fillchar_status(&attr, wp);
|
||||||
@ -5236,14 +5236,14 @@ win_redr_custom (
|
|||||||
attr = HL_ATTR(HLF_MSG);
|
attr = HL_ATTR(HLF_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0);
|
use_sandbox = was_set_insecurely(wp, (char_u *)"rulerformat", 0);
|
||||||
} else {
|
} else {
|
||||||
if (*wp->w_p_stl != NUL)
|
if (*wp->w_p_stl != NUL)
|
||||||
stl = wp->w_p_stl;
|
stl = wp->w_p_stl;
|
||||||
else
|
else
|
||||||
stl = p_stl;
|
stl = p_stl;
|
||||||
use_sandbox = was_set_insecurely((char_u *)"statusline",
|
use_sandbox = was_set_insecurely(
|
||||||
*wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
|
wp, (char_u *)"statusline", *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
col += wp->w_wincol;
|
col += wp->w_wincol;
|
||||||
|
Loading…
Reference in New Issue
Block a user