project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void ExpandOldSetting(int *num_file, char_u ***file)
{
char_u *var = NULL;
*num_file = 0;
*file = (char_u **)xmalloc(sizeof(char_u *));
/*
* For a terminal key code expand_option_idx is < 0.
*/
if (expand_option_idx < 0) {
expand_option_idx = findoption(expand_option_name);
}
if (expand_option_idx >= 0) {
/* put string of option value in NameBuff */
option_value2string(&options[expand_option_idx], expand_option_flags);
var = NameBuff;
} else if (var == NULL)
var = (char_u *)"";
/* A backslash is required before some characters. This is the reverse of
* what happens in do_set(). */
char_u *buf = vim_strsave_escaped(var, escape_chars);
#ifdef BACKSLASH_IN_FILENAME
/* For MS-Windows et al. we don't double backslashes at the start and
* before a file name character. */
for (var = buf; *var != NUL; mb_ptr_adv(var))
if (var[0] == '\\' && var[1] == '\\'
&& expand_option_idx >= 0
&& (options[expand_option_idx].flags & P_EXPAND)
&& vim_isfilec(var[2])
&& (var[2] != '\\' || (var == buf && var[4] != '\\')))
STRMOVE(var, var + 1);
#endif
*file[0] = buf;
*num_file = 1;
}
|
CWE-20
| null | 517,227 |
54231981100265666562576480783444007272
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void set_runtimepath_default(void)
{
size_t rtp_size = 0;
char *const data_home = stdpaths_get_xdg_var(kXDGDataHome);
char *const config_home = stdpaths_get_xdg_var(kXDGConfigHome);
char *const vimruntime = vim_getenv("VIMRUNTIME");
char *const data_dirs = stdpaths_get_xdg_var(kXDGDataDirs);
char *const config_dirs = stdpaths_get_xdg_var(kXDGConfigDirs);
#define SITE_SIZE (sizeof("site") - 1)
#define AFTER_SIZE (sizeof("after") - 1)
size_t data_len = 0;
size_t config_len = 0;
size_t vimruntime_len = 0;
if (data_home != NULL) {
data_len = strlen(data_home);
if (data_len != 0) {
rtp_size += ((data_len + memcnt(data_home, ',', data_len)
+ NVIM_SIZE + 1 + SITE_SIZE + 1
+ !after_pathsep(data_home, data_home + data_len)) * 2
+ AFTER_SIZE + 1);
}
}
if (config_home != NULL) {
config_len = strlen(config_home);
if (config_len != 0) {
rtp_size += ((config_len + memcnt(config_home, ',', config_len)
+ NVIM_SIZE + 1
+ !after_pathsep(config_home, config_home + config_len)) * 2
+ AFTER_SIZE + 1);
}
}
if (vimruntime != NULL) {
vimruntime_len = strlen(vimruntime);
if (vimruntime_len != 0) {
rtp_size += vimruntime_len + memcnt(vimruntime, ',', vimruntime_len) + 1;
}
}
rtp_size += compute_double_colon_len(data_dirs, NVIM_SIZE + 1 + SITE_SIZE + 1,
AFTER_SIZE + 1);
rtp_size += compute_double_colon_len(config_dirs, NVIM_SIZE + 1,
AFTER_SIZE + 1);
if (rtp_size == 0) {
return;
}
char *const rtp = xmalloc(rtp_size);
char *rtp_cur = rtp;
rtp_cur = add_dir(rtp_cur, config_home, config_len, true, NULL, 0, NULL, 0);
rtp_cur = add_colon_dirs(rtp_cur, config_dirs, NULL, 0, NULL, 0, true);
rtp_cur = add_dir(rtp_cur, data_home, data_len, true, "site", SITE_SIZE,
NULL, 0);
rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE, NULL, 0,
true);
rtp_cur = add_dir(rtp_cur, vimruntime, vimruntime_len, false, NULL, 0,
NULL, 0);
rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE,
"after", AFTER_SIZE, false);
rtp_cur = add_dir(rtp_cur, data_home, data_len, true, "site", SITE_SIZE,
"after", AFTER_SIZE);
rtp_cur = add_colon_dirs(rtp_cur, config_dirs, "after", AFTER_SIZE, NULL, 0,
false);
rtp_cur = add_dir(rtp_cur, config_home, config_len, true,
"after", AFTER_SIZE, NULL, 0);
// Strip trailing comma.
rtp_cur[-1] = NUL;
assert((size_t) (rtp_cur - rtp) == rtp_size);
#undef SITE_SIZE
#undef AFTER_SIZE
set_string_default("runtimepath", rtp, true);
// Make a copy of 'rtp' for 'packpath'
set_string_default("packpath", rtp, false);
xfree(data_dirs);
xfree(config_dirs);
xfree(data_home);
xfree(config_home);
xfree(vimruntime);
}
|
CWE-20
| null | 517,228 |
196489995093127188031812408023892875738
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
set_string_option_direct (
char_u *name,
int opt_idx,
char_u *val,
int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
int set_sid
)
{
char_u *s;
char_u **varp;
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
int idx = opt_idx;
if (idx == -1) { /* use name */
idx = findoption(name);
if (idx < 0) { /* not found (should not happen) */
EMSG2(_(e_intern2), "set_string_option_direct()");
EMSG2(_("For option %s"), name);
return;
}
}
if (options[idx].var == NULL) /* can't set hidden option */
return;
assert((void *) options[idx].var != (void *) &p_shada);
s = vim_strsave(val);
{
varp = (char_u **)get_varp_scope(&(options[idx]),
both ? OPT_LOCAL : opt_flags);
if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
free_string_option(*varp);
*varp = s;
/* For buffer/window local option may also set the global value. */
if (both)
set_string_option_global(idx, varp);
options[idx].flags |= P_ALLOCED;
/* When setting both values of a global option with a local value,
* make the local value empty, so that the global value is used. */
if (((int)options[idx].indir & PV_BOTH) && both) {
free_string_option(*varp);
*varp = empty_option;
}
if (set_sid != SID_NONE)
set_option_scriptID_idx(idx, opt_flags,
set_sid == 0 ? current_SID : set_sid);
}
}
|
CWE-20
| null | 517,229 |
60299335470755298378264826204312344804
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int check_opt_strings(
char_u *val,
char **values,
int list /* when TRUE: accept a list of values */
)
{
return opt_strings_flags(val, values, NULL, list);
}
|
CWE-20
| null | 517,230 |
172813824871384399236592072919457845220
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int csh_like_shell(void)
{
return strstr((char *)path_tail(p_sh), "csh") != NULL;
}
|
CWE-20
| null | 517,231 |
292483883239164452885062515756550255918
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void win_copy_options(win_T *wp_from, win_T *wp_to)
{
copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
/* Is this right? */
wp_to->w_farsi = wp_from->w_farsi;
briopt_check(wp_to);
}
|
CWE-20
| null | 517,232 |
297951787905848613442976894114593118305
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static uint32_t *insecure_flag(int opt_idx, int opt_flags)
{
if (opt_flags & OPT_LOCAL)
switch ((int)options[opt_idx].indir) {
case PV_STL: return &curwin->w_p_stl_flags;
case PV_FDE: return &curwin->w_p_fde_flags;
case PV_FDT: return &curwin->w_p_fdt_flags;
case PV_INDE: return &curbuf->b_p_inde_flags;
case PV_FEX: return &curbuf->b_p_fex_flags;
case PV_INEX: return &curbuf->b_p_inex_flags;
}
/* Nothing special, return global flags field. */
return &options[opt_idx].flags;
}
|
CWE-20
| null | 517,233 |
192908477413302243440379224777794715971
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void set_string_default(const char *name, char *val, bool allocated)
FUNC_ATTR_NONNULL_ALL
{
int opt_idx = findoption((char_u *)name);
if (opt_idx >= 0) {
if (options[opt_idx].flags & P_DEF_ALLOCED) {
xfree(options[opt_idx].def_val[VI_DEFAULT]);
}
options[opt_idx].def_val[VI_DEFAULT] = (char_u *) (
allocated
? (char_u *) val
: (char_u *) xstrdup(val));
options[opt_idx].flags |= P_DEF_ALLOCED;
}
}
|
CWE-20
| null | 517,234 |
35635084377421158772849536795409740006
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
set_options_default (
int opt_flags /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
)
{
for (int i = 0; options[i].fullname; i++) {
if (!(options[i].flags & P_NODEFAULT)) {
set_option_default(i, opt_flags, p_cp);
}
}
/* The 'scroll' option must be computed for all windows. */
FOR_ALL_TAB_WINDOWS(tp, wp) {
win_comp_scroll(wp);
}
parse_cino(curbuf);
}
|
CWE-20
| null | 517,235 |
129561574704614971103303987577358400744
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void check_win_options(win_T *win)
{
check_winopt(&win->w_onebuf_opt);
check_winopt(&win->w_allbuf_opt);
}
|
CWE-20
| null | 517,236 |
170079552058473412851892586401792597468
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
char_u *check_stl_option(char_u *s)
{
int itemcnt = 0;
int groupdepth = 0;
static char_u errbuf[80];
while (*s && itemcnt < STL_MAX_ITEM) {
/* Check for valid keys after % sequences */
while (*s && *s != '%')
s++;
if (!*s)
break;
s++;
if (*s != '%' && *s != ')') {
itemcnt++;
}
if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_SEPARATE) {
s++;
continue;
}
if (*s == ')') {
s++;
if (--groupdepth < 0)
break;
continue;
}
if (*s == '-')
s++;
while (ascii_isdigit(*s))
s++;
if (*s == STL_USER_HL)
continue;
if (*s == '.') {
s++;
while (*s && ascii_isdigit(*s))
s++;
}
if (*s == '(') {
groupdepth++;
continue;
}
if (vim_strchr(STL_ALL, *s) == NULL) {
return illegal_char(errbuf, *s);
}
if (*s == '{') {
s++;
while (*s != '}' && *s)
s++;
if (*s != '}')
return (char_u *)N_("E540: Unclosed expression sequence");
}
}
if (itemcnt >= STL_MAX_ITEM)
return (char_u *)N_("E541: too many items");
if (groupdepth != 0)
return (char_u *)N_("E542: unbalanced groups");
return NULL;
}
|
CWE-20
| null | 517,237 |
58969669573690447980102846167040702327
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *did_set_spell_option(bool is_spellfile)
{
char_u *errmsg = NULL;
if (is_spellfile) {
int l = (int)STRLEN(curwin->w_s->b_p_spf);
if (l > 0
&& (l < 4 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0)) {
errmsg = e_invarg;
}
}
if (errmsg == NULL) {
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_buffer == curbuf && wp->w_p_spell) {
errmsg = did_set_spelllang(wp);
break;
}
}
}
return errmsg;
}
|
CWE-20
| null | 517,238 |
267968269182293397849824918841636941107
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static bool briopt_check(win_T *wp)
{
int bri_shift = 0;
int bri_min = 20;
bool bri_sbr = false;
char_u *p = wp->w_p_briopt;
while (*p != NUL)
{
if (STRNCMP(p, "shift:", 6) == 0
&& ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6])))
{
p += 6;
bri_shift = getdigits_int(&p);
}
else if (STRNCMP(p, "min:", 4) == 0 && ascii_isdigit(p[4]))
{
p += 4;
bri_min = getdigits_int(&p);
}
else if (STRNCMP(p, "sbr", 3) == 0)
{
p += 3;
bri_sbr = true;
}
if (*p != ',' && *p != NUL)
return false;
if (*p == ',')
++p;
}
wp->w_p_brishift = bri_shift;
wp->w_p_brimin = bri_min;
wp->w_p_brisbr = bri_sbr;
return true;
}
|
CWE-20
| null | 517,239 |
178550773797275290951288115626983083604
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void redraw_titles(void) {
need_maketitle = TRUE;
redraw_tabline = TRUE;
}
|
CWE-20
| null | 517,240 |
10708727272030624977665242029784702602
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
did_set_title (
int icon /* Did set icon instead of title */
)
{
if (starting != NO_SCREEN) {
maketitle();
if (icon) {
if (!p_icon) {
ui_set_icon(NULL);
}
} else {
if (!p_title) {
ui_set_title(NULL);
}
}
}
}
|
CWE-20
| null | 517,241 |
315589280590335408325128580052803752354
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int findoption(char_u *arg)
{
return findoption_len(arg, STRLEN(arg));
}
|
CWE-20
| null | 517,242 |
19091442448865295483448331846576535217
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int int_cmp(const void *a, const void *b)
{
return *(const int *)a - *(const int *)b;
}
|
CWE-20
| null | 517,243 |
237076312469859399516711131919806542762
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
showoptions (
int all,
int opt_flags /* OPT_LOCAL and/or OPT_GLOBAL */
)
{
vimoption_T *p;
int col;
char_u *varp;
int item_count;
int run;
int row, rows;
int cols;
int i;
int len;
#define INC 20
#define GAP 3
vimoption_T **items = xmalloc(sizeof(vimoption_T *) * PARAM_COUNT);
/* Highlight title */
if (all == 2)
MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
else if (opt_flags & OPT_GLOBAL)
MSG_PUTS_TITLE(_("\n--- Global option values ---"));
else if (opt_flags & OPT_LOCAL)
MSG_PUTS_TITLE(_("\n--- Local option values ---"));
else
MSG_PUTS_TITLE(_("\n--- Options ---"));
/*
* do the loop two times:
* 1. display the short items
* 2. display the long items (only strings and numbers)
*/
for (run = 1; run <= 2 && !got_int; ++run) {
/*
* collect the items in items[]
*/
item_count = 0;
for (p = &options[0]; p->fullname != NULL; p++) {
varp = NULL;
if (opt_flags != 0) {
if (p->indir != PV_NONE)
varp = get_varp_scope(p, opt_flags);
} else
varp = get_varp(p);
if (varp != NULL
&& (all == 1 || (all == 0 && !optval_default(p, varp)))) {
if (p->flags & P_BOOL)
len = 1; /* a toggle option fits always */
else {
option_value2string(p, opt_flags);
len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
}
if ((len <= INC - GAP && run == 1)
|| (len > INC - GAP && run == 2)) {
items[item_count++] = p;
}
}
}
/*
* display the items
*/
if (run == 1) {
assert(Columns <= LONG_MAX - GAP
&& Columns + GAP >= LONG_MIN + 3
&& (Columns + GAP - 3) / INC >= INT_MIN
&& (Columns + GAP - 3) / INC <= INT_MAX);
cols = (int)((Columns + GAP - 3) / INC);
if (cols == 0)
cols = 1;
rows = (item_count + cols - 1) / cols;
} else /* run == 2 */
rows = item_count;
for (row = 0; row < rows && !got_int; ++row) {
msg_putchar('\n'); /* go to next line */
if (got_int) /* 'q' typed in more */
break;
col = 0;
for (i = row; i < item_count; i += rows) {
msg_col = col; /* make columns */
showoneopt(items[i], opt_flags);
col += INC;
}
ui_flush();
os_breakcheck();
}
}
xfree(items);
}
|
CWE-20
| null | 517,244 |
184507883369540398200080275353924661421
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void didset_options2(void)
{
// Initialize the highlight_attr[] table.
(void)highlight_changed();
// Parse default for 'clipboard'.
(void)opt_strings_flags(p_cb, p_cb_values, &cb_flags, true);
// Parse default for 'fillchars'.
(void)set_chars_option(&p_fcs);
// Parse default for 'listchars'.
(void)set_chars_option(&p_lcs);
// Parse default for 'wildmode'.
check_opt_wim();
}
|
CWE-20
| null | 517,245 |
122409434509988367903917097003497022321
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void check_winopt(winopt_T *wop)
{
check_string_option(&wop->wo_fdi);
check_string_option(&wop->wo_fdm);
check_string_option(&wop->wo_fdm_save);
check_string_option(&wop->wo_fde);
check_string_option(&wop->wo_fdt);
check_string_option(&wop->wo_fmr);
check_string_option(&wop->wo_rlc);
check_string_option(&wop->wo_stl);
check_string_option(&wop->wo_cc);
check_string_option(&wop->wo_cocu);
check_string_option(&wop->wo_briopt);
}
|
CWE-20
| null | 517,246 |
141892925656240709656797834731272197280
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static bool valid_filetype(char_u *val)
{
for (char_u *s = val; *s != NUL; s++) {
if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL) {
return false;
}
}
return true;
}
|
CWE-20
| null | 517,247 |
36061582430801801975568831804661704915
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
set_options_bin (
int oldval,
int newval,
int opt_flags /* OPT_LOCAL and/or OPT_GLOBAL */
)
{
/*
* The option values that are changed when 'bin' changes are
* copied when 'bin is set and restored when 'bin' is reset.
*/
if (newval) {
if (!oldval) { /* switched on */
if (!(opt_flags & OPT_GLOBAL)) {
curbuf->b_p_tw_nobin = curbuf->b_p_tw;
curbuf->b_p_wm_nobin = curbuf->b_p_wm;
curbuf->b_p_ml_nobin = curbuf->b_p_ml;
curbuf->b_p_et_nobin = curbuf->b_p_et;
}
if (!(opt_flags & OPT_LOCAL)) {
p_tw_nobin = p_tw;
p_wm_nobin = p_wm;
p_ml_nobin = p_ml;
p_et_nobin = p_et;
}
}
if (!(opt_flags & OPT_GLOBAL)) {
curbuf->b_p_tw = 0; /* no automatic line wrap */
curbuf->b_p_wm = 0; /* no automatic line wrap */
curbuf->b_p_ml = 0; /* no modelines */
curbuf->b_p_et = 0; /* no expandtab */
}
if (!(opt_flags & OPT_LOCAL)) {
p_tw = 0;
p_wm = 0;
p_ml = FALSE;
p_et = FALSE;
p_bin = TRUE; /* needed when called for the "-b" argument */
}
} else if (oldval) { /* switched off */
if (!(opt_flags & OPT_GLOBAL)) {
curbuf->b_p_tw = curbuf->b_p_tw_nobin;
curbuf->b_p_wm = curbuf->b_p_wm_nobin;
curbuf->b_p_ml = curbuf->b_p_ml_nobin;
curbuf->b_p_et = curbuf->b_p_et_nobin;
}
if (!(opt_flags & OPT_LOCAL)) {
p_tw = p_tw_nobin;
p_wm = p_wm_nobin;
p_ml = p_ml_nobin;
p_et = p_et_nobin;
}
}
}
|
CWE-20
| null | 517,248 |
79718058950400671553578880857634841787
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
showoneopt (
vimoption_T *p,
int opt_flags /* OPT_LOCAL or OPT_GLOBAL */
)
{
char_u *varp;
int save_silent = silent_mode;
silent_mode = FALSE;
info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
varp = get_varp_scope(p, opt_flags);
// for 'modified' we also need to check if 'ff' or 'fenc' changed.
if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
? !curbufIsChanged() : !*(int *)varp)) {
MSG_PUTS("no");
} else if ((p->flags & P_BOOL) && *(int *)varp < 0) {
MSG_PUTS("--");
} else {
MSG_PUTS(" ");
}
MSG_PUTS(p->fullname);
if (!(p->flags & P_BOOL)) {
msg_putchar('=');
/* put value string in NameBuff */
option_value2string(p, opt_flags);
msg_outtrans(NameBuff);
}
silent_mode = save_silent;
info_message = FALSE;
}
|
CWE-20
| null | 517,249 |
88370836170209031393780280263118309520
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_fileformat(int eol_style, int opt_flags)
{
char *p = NULL;
switch (eol_style) {
case EOL_UNIX:
p = FF_UNIX;
break;
case EOL_MAC:
p = FF_MAC;
break;
case EOL_DOS:
p = FF_DOS;
break;
}
// p is NULL if "eol_style" is EOL_UNKNOWN.
if (p != NULL) {
set_string_option_direct((char_u *)"ff",
-1,
(char_u *)p,
OPT_FREE | opt_flags,
0);
}
// This may cause the buffer to become (un)modified.
check_status(curbuf);
redraw_tabline = true;
need_maketitle = true; // Set window title later.
}
|
CWE-20
| null | 517,250 |
106791039266873296384382399415933353898
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void vimrc_found(char_u *fname, char_u *envname)
{
char_u *p;
if (fname != NULL) {
p = (char_u *)vim_getenv((char *)envname);
if (p == NULL) {
/* Set $MYVIMRC to the first vimrc file found. */
p = (char_u *)FullName_save((char *)fname, FALSE);
if (p != NULL) {
vim_setenv((char *)envname, (char *)p);
xfree(p);
}
} else {
xfree(p);
}
}
}
|
CWE-20
| null | 517,251 |
220446917936849942330432906474399665226
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen,
char *sep_chars)
{
size_t len = 0;
char_u *p = *option;
// skip '.' at start of option part, for 'suffixes'
if (*p == '.') {
buf[len++] = *p++;
}
while (*p != NUL && vim_strchr((char_u *)sep_chars, *p) == NULL) {
// Skip backslash before a separator character and space.
if (p[0] == '\\' && vim_strchr((char_u *)sep_chars, p[1]) != NULL) {
p++;
}
if (len < maxlen - 1) {
buf[len++] = *p;
}
p++;
}
buf[len] = NUL;
if (*p != NUL && *p != ',') { // skip non-standard separator
p++;
}
p = skip_to_option_part(p); // p points to next file name
*option = p;
return len;
}
|
CWE-20
| null | 517,252 |
249979933505976530297358029308997790939
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_iminsert_global(void)
{
p_iminsert = curbuf->b_p_iminsert;
}
|
CWE-20
| null | 517,253 |
19396316560739587956846737337938192709
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *illegal_char(char_u *errbuf, int c)
{
if (errbuf == NULL)
return (char_u *)"";
sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
(char *)transchar(c));
return errbuf;
}
|
CWE-20
| null | 517,254 |
74303755566180042216221599513178715220
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
set_context_in_set_cmd (
expand_T *xp,
char_u *arg,
int opt_flags /* OPT_GLOBAL and/or OPT_LOCAL */
)
{
char_u nextchar;
uint32_t flags = 0; /* init for GCC */
int opt_idx = 0; /* init for GCC */
char_u *p;
char_u *s;
int is_term_option = FALSE;
int key;
expand_option_flags = opt_flags;
xp->xp_context = EXPAND_SETTINGS;
if (*arg == NUL) {
xp->xp_pattern = arg;
return;
}
p = arg + STRLEN(arg) - 1;
if (*p == ' ' && *(p - 1) != '\\') {
xp->xp_pattern = p + 1;
return;
}
while (p > arg) {
s = p;
/* count number of backslashes before ' ' or ',' */
if (*p == ' ' || *p == ',') {
while (s > arg && *(s - 1) == '\\')
--s;
}
/* break at a space with an even number of backslashes */
if (*p == ' ' && ((p - s) & 1) == 0) {
++p;
break;
}
--p;
}
if (STRNCMP(p, "no", 2) == 0) {
xp->xp_context = EXPAND_BOOL_SETTINGS;
p += 2;
}
if (STRNCMP(p, "inv", 3) == 0) {
xp->xp_context = EXPAND_BOOL_SETTINGS;
p += 3;
}
xp->xp_pattern = arg = p;
if (*arg == '<') {
while (*p != '>')
if (*p++ == NUL) /* expand terminal option name */
return;
key = get_special_key_code(arg + 1);
if (key == 0) { /* unknown name */
xp->xp_context = EXPAND_NOTHING;
return;
}
nextchar = *++p;
is_term_option = TRUE;
expand_option_name[2] = (char_u)KEY2TERMCAP0(key);
expand_option_name[3] = KEY2TERMCAP1(key);
} else {
if (p[0] == 't' && p[1] == '_') {
p += 2;
if (*p != NUL)
++p;
if (*p == NUL)
return; /* expand option name */
nextchar = *++p;
is_term_option = TRUE;
expand_option_name[2] = p[-2];
expand_option_name[3] = p[-1];
} else {
/* Allow * wildcard */
while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
p++;
if (*p == NUL)
return;
nextchar = *p;
*p = NUL;
opt_idx = findoption(arg);
*p = nextchar;
if (opt_idx == -1 || options[opt_idx].var == NULL) {
xp->xp_context = EXPAND_NOTHING;
return;
}
flags = options[opt_idx].flags;
if (flags & P_BOOL) {
xp->xp_context = EXPAND_NOTHING;
return;
}
}
}
/* handle "-=" and "+=" */
if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') {
++p;
nextchar = '=';
}
if ((nextchar != '=' && nextchar != ':')
|| xp->xp_context == EXPAND_BOOL_SETTINGS) {
xp->xp_context = EXPAND_UNSUCCESSFUL;
return;
}
if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) {
xp->xp_context = EXPAND_OLD_SETTING;
if (is_term_option)
expand_option_idx = -1;
else
expand_option_idx = opt_idx;
xp->xp_pattern = p + 1;
return;
}
xp->xp_context = EXPAND_NOTHING;
if (is_term_option || (flags & P_NUM))
return;
xp->xp_pattern = p + 1;
if (flags & P_EXPAND) {
p = options[opt_idx].var;
if (p == (char_u *)&p_bdir
|| p == (char_u *)&p_dir
|| p == (char_u *)&p_path
|| p == (char_u *)&p_pp
|| p == (char_u *)&p_rtp
|| p == (char_u *)&p_cdpath
|| p == (char_u *)&p_vdir
) {
xp->xp_context = EXPAND_DIRECTORIES;
if (p == (char_u *)&p_path
|| p == (char_u *)&p_cdpath
)
xp->xp_backslash = XP_BS_THREE;
else
xp->xp_backslash = XP_BS_ONE;
} else {
xp->xp_context = EXPAND_FILES;
/* for 'tags' need three backslashes for a space */
if (p == (char_u *)&p_tags)
xp->xp_backslash = XP_BS_THREE;
else
xp->xp_backslash = XP_BS_ONE;
}
}
/* For an option that is a list of file names, find the start of the
* last file name. */
for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) {
/* count number of backslashes before ' ' or ',' */
if (*p == ' ' || *p == ',') {
s = p;
while (s > xp->xp_pattern && *(s - 1) == '\\')
--s;
if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
|| (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) {
xp->xp_pattern = p + 1;
break;
}
}
/* for 'spellsuggest' start at "file:" */
if (options[opt_idx].var == (char_u *)&p_sps
&& STRNCMP(p, "file:", 5) == 0) {
xp->xp_pattern = p + 5;
break;
}
}
return;
}
|
CWE-20
| null | 517,255 |
328717378839518742424388318310874783803
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int default_fileformat(void)
{
switch (*p_ffs) {
case 'm': return EOL_MAC;
case 'd': return EOL_DOS;
}
return EOL_UNIX;
}
|
CWE-20
| null | 517,256 |
75488802328040953787472210029574030522
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *set_chars_option(char_u **varp)
{
int round, i, len, entries;
char_u *p, *s;
int c1, c2 = 0;
struct charstab {
int *cp;
char *name;
};
static struct charstab filltab[] =
{
{&fill_stl, "stl"},
{&fill_stlnc, "stlnc"},
{&fill_vert, "vert"},
{&fill_fold, "fold"},
{&fill_diff, "diff"},
};
static struct charstab lcstab[] =
{
{&lcs_eol, "eol"},
{&lcs_ext, "extends"},
{&lcs_nbsp, "nbsp"},
{&lcs_prec, "precedes"},
{&lcs_space, "space"},
{&lcs_tab2, "tab"},
{&lcs_trail, "trail"},
{&lcs_conceal, "conceal"},
};
struct charstab *tab;
if (varp == &p_lcs) {
tab = lcstab;
entries = ARRAY_SIZE(lcstab);
} else {
tab = filltab;
entries = ARRAY_SIZE(filltab);
}
/* first round: check for valid value, second round: assign values */
for (round = 0; round <= 1; ++round) {
if (round > 0) {
/* After checking that the value is valid: set defaults: space for
* 'fillchars', NUL for 'listchars' */
for (i = 0; i < entries; ++i)
if (tab[i].cp != NULL)
*(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
if (varp == &p_lcs)
lcs_tab1 = NUL;
else
fill_diff = '-';
}
p = *varp;
while (*p) {
for (i = 0; i < entries; ++i) {
len = (int)STRLEN(tab[i].name);
if (STRNCMP(p, tab[i].name, len) == 0
&& p[len] == ':'
&& p[len + 1] != NUL) {
s = p + len + 1;
c1 = mb_ptr2char_adv(&s);
if (mb_char2cells(c1) > 1)
continue;
if (tab[i].cp == &lcs_tab2) {
if (*s == NUL)
continue;
c2 = mb_ptr2char_adv(&s);
if (mb_char2cells(c2) > 1)
continue;
}
if (*s == ',' || *s == NUL) {
if (round) {
if (tab[i].cp == &lcs_tab2) {
lcs_tab1 = c1;
lcs_tab2 = c2;
} else if (tab[i].cp != NULL)
*(tab[i].cp) = c1;
}
p = s;
break;
}
}
}
if (i == entries)
return e_invarg;
if (*p == ',')
++p;
}
}
return NULL; /* no error */
}
|
CWE-20
| null | 517,257 |
98396272104359800008558581486411365718
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void free_string_option(char_u *p)
{
if (p != empty_option)
xfree(p);
}
|
CWE-20
| null | 517,258 |
203722839415627930884613401609715483556
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int get_option_value_strict(char *name,
int64_t *numval,
char **stringval,
int opt_type,
void *from)
{
if (get_tty_option(name, stringval)) {
return SOPT_STRING | SOPT_GLOBAL;
}
char_u *varp = NULL;
vimoption_T *p;
int rv = 0;
int opt_idx = findoption((uint8_t *)name);
if (opt_idx < 0) {
return 0;
}
p = &(options[opt_idx]);
// Hidden option
if (p->var == NULL) {
return 0;
}
if (p->flags & P_BOOL) {
rv |= SOPT_BOOL;
} else if (p->flags & P_NUM) {
rv |= SOPT_NUM;
} else if (p->flags & P_STRING) {
rv |= SOPT_STRING;
}
if (p->indir == PV_NONE) {
if (opt_type == SREQ_GLOBAL)
rv |= SOPT_GLOBAL;
else
return 0; // Did not request global-only option
} else {
if (p->indir & PV_BOTH) {
rv |= SOPT_GLOBAL;
} else if (opt_type == SREQ_GLOBAL) {
return 0; // Requested global option
}
if (p->indir & PV_WIN) {
if (opt_type == SREQ_BUF) {
return 0; // Did not request window-local option
} else {
rv |= SOPT_WIN;
}
} else if (p->indir & PV_BUF) {
if (opt_type == SREQ_WIN) {
return 0; // Did not request buffer-local option
} else {
rv |= SOPT_BUF;
}
}
}
if (stringval == NULL) {
return rv;
}
if (opt_type == SREQ_GLOBAL) {
varp = p->var;
} else {
if (opt_type == SREQ_BUF) {
// Special case: 'modified' is b_changed, but we also want to
// consider it set when 'ff' or 'fenc' changed.
if (p->indir == PV_MOD) {
*numval = bufIsChanged((buf_T *) from);
varp = NULL;
} else {
aco_save_T aco;
aucmd_prepbuf(&aco, (buf_T *) from);
varp = get_varp(p);
aucmd_restbuf(&aco);
}
} else if (opt_type == SREQ_WIN) {
win_T *save_curwin;
save_curwin = curwin;
curwin = (win_T *) from;
curbuf = curwin->w_buffer;
varp = get_varp(p);
curwin = save_curwin;
curbuf = curwin->w_buffer;
}
if (varp == p->var) {
return (rv | SOPT_UNSET);
}
}
if (varp != NULL) {
if (p->flags & P_STRING) {
*stringval = xstrdup(*(char **)(varp));
} else if (p->flags & P_NUM) {
*numval = *(long *) varp;
} else {
*numval = *(int *)varp;
}
}
return rv;
}
|
CWE-20
| null | 517,259 |
240966407123311829262367769146202576024
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_imsearch_global(void)
{
p_imsearch = curbuf->b_p_imsearch;
}
|
CWE-20
| null | 517,260 |
109571102215235838064362015211639810618
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void check_redraw(uint32_t flags)
{
/* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
bool doclear = (flags & P_RCLR) == P_RCLR;
bool all = ((flags & P_RALL) == P_RALL || doclear);
if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
status_redraw_all();
if ((flags & P_RBUF) || (flags & P_RWIN) || all)
changed_window_setting();
if (flags & P_RBUF)
redraw_curbuf_later(NOT_VALID);
if (doclear)
redraw_all_later(CLEAR);
else if (all)
redraw_all_later(NOT_VALID);
}
|
CWE-20
| null | 517,261 |
98033848264974659202300729809659944790
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void langmap_set_entry(int from, int to)
{
langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
unsigned int a = 0;
assert(langmap_mapga.ga_len >= 0);
unsigned int b = (unsigned int)langmap_mapga.ga_len;
/* Do a binary search for an existing entry. */
while (a != b) {
unsigned int i = (a + b) / 2;
int d = entries[i].from - from;
if (d == 0) {
entries[i].to = to;
return;
}
if (d < 0)
a = i + 1;
else
b = i;
}
ga_grow(&langmap_mapga, 1);
/* insert new entry at position "a" */
entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
memmove(entries + 1, entries,
((unsigned int)langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
++langmap_mapga.ga_len;
entries[0].from = from;
entries[0].to = to;
}
|
CWE-20
| null | 517,262 |
271393339703219494443664273404830924288
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *compile_cap_prog(synblock_T *synblock)
{
regprog_T *rp = synblock->b_cap_prog;
char_u *re;
if (*synblock->b_p_spc == NUL)
synblock->b_cap_prog = NULL;
else {
/* Prepend a ^ so that we only match at one column */
re = concat_str((char_u *)"^", synblock->b_p_spc);
synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
xfree(re);
if (synblock->b_cap_prog == NULL) {
synblock->b_cap_prog = rp; /* restore the previous program */
return e_invarg;
}
}
vim_regfree(rp);
return NULL;
}
|
CWE-20
| null | 517,263 |
259069955454803494238690149413636423534
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *option_expand(int opt_idx, char_u *val)
{
/* if option doesn't need expansion nothing to do */
if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
return NULL;
if (val == NULL) {
val = *(char_u **)options[opt_idx].var;
}
// If val is longer than MAXPATHL no meaningful expansion can be done,
// expand_env() would truncate the string.
if (val == NULL || STRLEN(val) > MAXPATHL) {
return NULL;
}
/*
* Expanding this with NameBuff, expand_env() must not be passed IObuff.
* Escape spaces when expanding 'tags', they are used to separate file
* names.
* For 'spellsuggest' expand after "file:".
*/
expand_env_esc(val, NameBuff, MAXPATHL,
(char_u **)options[opt_idx].var == &p_tags, FALSE,
(char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
NULL);
if (STRCMP(NameBuff, val) == 0) /* they are the same */
return NULL;
return NameBuff;
}
|
CWE-20
| null | 517,264 |
324306925047380170957149623407780341941
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int makeset(FILE *fd, int opt_flags, int local_only)
{
vimoption_T *p;
char_u *varp; /* currently used value */
char_u *varp_fresh; /* local value */
char_u *varp_local = NULL; /* fresh value */
char *cmd;
int round;
int pri;
/*
* Some options are never written:
* - Options that don't have a default (terminal name, columns, lines).
* - Terminal options.
* - Hidden options.
*
* Do the loop over "options[]" twice: once for options with the
* P_PRI_MKRC flag and once without.
*/
for (pri = 1; pri >= 0; --pri) {
for (p = &options[0]; p->fullname; p++)
if (!(p->flags & P_NO_MKRC)
&& ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) {
/* skip global option when only doing locals */
if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
continue;
/* Do not store options like 'bufhidden' and 'syntax' in a vimrc
* file, they are always buffer-specific. */
if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
continue;
varp = get_varp_scope(p, opt_flags);
/* Hidden options are never written. */
if (!varp)
continue;
/* Global values are only written when not at the default value. */
if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
continue;
round = 2;
if (p->indir != PV_NONE) {
if (p->var == VAR_WIN) {
/* skip window-local option when only doing globals */
if (!(opt_flags & OPT_LOCAL))
continue;
/* When fresh value of window-local option is not at the
* default, need to write it too. */
if (!(opt_flags & OPT_GLOBAL) && !local_only) {
varp_fresh = get_varp_scope(p, OPT_GLOBAL);
if (!optval_default(p, varp_fresh)) {
round = 1;
varp_local = varp;
varp = varp_fresh;
}
}
}
}
/* Round 1: fresh value for window-local options.
* Round 2: other values */
for (; round <= 2; varp = varp_local, ++round) {
if (round == 1 || (opt_flags & OPT_GLOBAL))
cmd = "set";
else
cmd = "setlocal";
if (p->flags & P_BOOL) {
if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
return FAIL;
} else if (p->flags & P_NUM) {
if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
return FAIL;
} else { /* P_STRING */
int do_endif = FALSE;
// Don't set 'syntax' and 'filetype' again if the value is
// already right, avoids reloading the syntax file.
if (p->indir == PV_SYN || p->indir == PV_FT) {
if (fprintf(fd, "if &%s != '%s'", p->fullname,
*(char_u **)(varp)) < 0
|| put_eol(fd) < 0) {
return FAIL;
}
do_endif = true;
}
if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
(p->flags & P_EXPAND) != 0) == FAIL)
return FAIL;
if (do_endif) {
if (put_line(fd, "endif") == FAIL)
return FAIL;
}
}
}
}
}
return OK;
}
|
CWE-20
| null | 517,265 |
220130341379159154772814728023544055625
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int was_set_insecurely(char_u *opt, int opt_flags)
{
int idx = findoption(opt);
if (idx >= 0) {
uint32_t *flagp = insecure_flag(idx, opt_flags);
return (*flagp & P_INSECURE) != 0;
}
EMSG2(_(e_intern2), "was_set_insecurely()");
return -1;
}
|
CWE-20
| null | 517,266 |
71866289950173681827218627754437152487
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_title_defaults(void)
{
int idx1;
/*
* If GUI is (going to be) used, we can always set the window title and
* icon name. Saves a bit of time, because the X11 display server does
* not need to be contacted.
*/
idx1 = findoption((char_u *)"title");
if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) {
options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)0;
p_title = 0;
}
idx1 = findoption((char_u *)"icon");
if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) {
options[idx1].def_val[VI_DEFAULT] = (char_u *)(intptr_t)0;
p_icon = 0;
}
}
|
CWE-20
| null | 517,267 |
101532123638976444709778352371844773455
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int get_sw_value(buf_T *buf)
{
long result = buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
assert(result >= 0 && result <= INT_MAX);
return (int)result;
}
|
CWE-20
| null | 517,268 |
200828774504016427695024517888020743711
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int get_fileformat(buf_T *buf)
{
int c = *buf->b_p_ff;
if (buf->b_p_bin || c == 'u') {
return EOL_UNIX;
}
if (c == 'm') {
return EOL_MAC;
}
return EOL_DOS;
}
|
CWE-20
| null | 517,269 |
231703658587025207775699714037589924461
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void paste_option_changed(void)
{
static int old_p_paste = FALSE;
static int save_sm = 0;
static int save_sta = 0;
static int save_ru = 0;
static int save_ri = 0;
static int save_hkmap = 0;
if (p_paste) {
/*
* Paste switched from off to on.
* Save the current values, so they can be restored later.
*/
if (!old_p_paste) {
/* save options for each buffer */
FOR_ALL_BUFFERS(buf) {
buf->b_p_tw_nopaste = buf->b_p_tw;
buf->b_p_wm_nopaste = buf->b_p_wm;
buf->b_p_sts_nopaste = buf->b_p_sts;
buf->b_p_ai_nopaste = buf->b_p_ai;
buf->b_p_et_nopaste = buf->b_p_et;
}
// save global options
save_sm = p_sm;
save_sta = p_sta;
save_ru = p_ru;
save_ri = p_ri;
save_hkmap = p_hkmap;
// save global values for local buffer options
p_ai_nopaste = p_ai;
p_et_nopaste = p_et;
p_sts_nopaste = p_sts;
p_tw_nopaste = p_tw;
p_wm_nopaste = p_wm;
}
// Always set the option values, also when 'paste' is set when it is
// already on.
// set options for each buffer
FOR_ALL_BUFFERS(buf) {
buf->b_p_tw = 0; // textwidth is 0
buf->b_p_wm = 0; // wrapmargin is 0
buf->b_p_sts = 0; // softtabstop is 0
buf->b_p_ai = 0; // no auto-indent
buf->b_p_et = 0; // no expandtab
}
// set global options
p_sm = 0; // no showmatch
p_sta = 0; // no smarttab
if (p_ru) {
status_redraw_all(); // redraw to remove the ruler
}
p_ru = 0; // no ruler
p_ri = 0; // no reverse insert
p_hkmap = 0; // no Hebrew keyboard
// set global values for local buffer options
p_tw = 0;
p_wm = 0;
p_sts = 0;
p_ai = 0;
}
/*
* Paste switched from on to off: Restore saved values.
*/
else if (old_p_paste) {
/* restore options for each buffer */
FOR_ALL_BUFFERS(buf) {
buf->b_p_tw = buf->b_p_tw_nopaste;
buf->b_p_wm = buf->b_p_wm_nopaste;
buf->b_p_sts = buf->b_p_sts_nopaste;
buf->b_p_ai = buf->b_p_ai_nopaste;
buf->b_p_et = buf->b_p_et_nopaste;
}
/* restore global options */
p_sm = save_sm;
p_sta = save_sta;
if (p_ru != save_ru) {
status_redraw_all(); // redraw to draw the ruler
}
p_ru = save_ru;
p_ri = save_ri;
p_hkmap = save_hkmap;
// set global values for local buffer options
p_ai = p_ai_nopaste;
p_et = p_et_nopaste;
p_sts = p_sts_nopaste;
p_tw = p_tw_nopaste;
p_wm = p_wm_nopaste;
}
old_p_paste = p_paste;
}
|
CWE-20
| null | 517,270 |
118868170600699995696686827916462740314
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int get_fileformat_force(buf_T *buf, exarg_T *eap)
{
int c;
if (eap != NULL && eap->force_ff != 0) {
c = eap->cmd[eap->force_ff];
} else {
if ((eap != NULL && eap->force_bin != 0)
? (eap->force_bin == FORCE_BIN) : buf->b_p_bin) {
return EOL_UNIX;
}
c = *buf->b_p_ff;
}
if (c == 'u') {
return EOL_UNIX;
}
if (c == 'm') {
return EOL_MAC;
}
return EOL_DOS;
}
|
CWE-20
| null | 517,271 |
191983219894251180044442219155525735798
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
do_set (
char_u *arg, /* option string (may be written to!) */
int opt_flags
)
{
int opt_idx;
char_u *errmsg;
char_u errbuf[80];
char_u *startarg;
int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
char_u nextchar; /* next non-white char after option name */
int afterchar; /* character just after option name */
int len;
int i;
long value;
int key;
uint32_t flags; /* flags for current option */
char_u *varp = NULL; /* pointer to variable for current option */
int did_show = FALSE; /* already showed one value */
int adding; /* "opt+=arg" */
int prepending; /* "opt^=arg" */
int removing; /* "opt-=arg" */
int cp_val = 0;
if (*arg == NUL) {
showoptions(0, opt_flags);
did_show = TRUE;
goto theend;
}
while (*arg != NUL) { /* loop to process all options */
errmsg = NULL;
startarg = arg; /* remember for error message */
if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
&& !(opt_flags & OPT_MODELINE)) {
/*
* ":set all" show all options.
* ":set all&" set all options to their default value.
*/
arg += 3;
if (*arg == '&') {
arg++;
// Only for :set command set global value of local options.
set_options_default(OPT_FREE | opt_flags);
didset_options();
didset_options2();
redraw_all_later(CLEAR);
} else {
showoptions(1, opt_flags);
did_show = TRUE;
}
} else if (STRNCMP(arg, "termcap",
7) == 0 && !(opt_flags & OPT_MODELINE)) {
did_show = TRUE;
arg += 7;
} else {
prefix = 1;
if (STRNCMP(arg, "no", 2) == 0) {
prefix = 0;
arg += 2;
} else if (STRNCMP(arg, "inv", 3) == 0) {
prefix = 2;
arg += 3;
}
/* find end of name */
key = 0;
if (*arg == '<') {
opt_idx = -1;
/* look out for <t_>;> */
if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
len = 5;
else {
len = 1;
while (arg[len] != NUL && arg[len] != '>')
++len;
}
if (arg[len] != '>') {
errmsg = e_invarg;
goto skip;
}
if (arg[1] == 't' && arg[2] == '_') { // could be term code
opt_idx = findoption_len(arg + 1, (size_t) (len - 1));
}
len++;
if (opt_idx == -1) {
key = find_key_option(arg + 1);
}
} else {
len = 0;
// The two characters after "t_" may not be alphanumeric.
if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) {
len = 4;
} else {
while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') {
len++;
}
}
opt_idx = findoption_len(arg, (size_t) len);
if (opt_idx == -1) {
key = find_key_option(arg);
}
}
/* remember character after option name */
afterchar = arg[len];
/* skip white space, allow ":set ai ?" */
while (ascii_iswhite(arg[len]))
++len;
adding = FALSE;
prepending = FALSE;
removing = FALSE;
if (arg[len] != NUL && arg[len + 1] == '=') {
if (arg[len] == '+') {
adding = TRUE; /* "+=" */
++len;
} else if (arg[len] == '^') {
prepending = TRUE; /* "^=" */
++len;
} else if (arg[len] == '-') {
removing = TRUE; /* "-=" */
++len;
}
}
nextchar = arg[len];
if (opt_idx == -1 && key == 0) { /* found a mismatch: skip */
errmsg = (char_u *)N_("E518: Unknown option");
goto skip;
}
if (opt_idx >= 0) {
if (options[opt_idx].var == NULL) { /* hidden option: skip */
/* Only give an error message when requesting the value of
* a hidden option, ignore setting it. */
if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
&& (!(options[opt_idx].flags & P_BOOL)
|| nextchar == '?'))
errmsg = (char_u *)_(e_unsupportedoption);
goto skip;
}
flags = options[opt_idx].flags;
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
} else {
flags = P_STRING;
}
/* Skip all options that are not window-local (used when showing
* an already loaded buffer in a window). */
if ((opt_flags & OPT_WINONLY)
&& (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
goto skip;
/* Skip all options that are window-local (used for :vimgrep). */
if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
&& options[opt_idx].var == VAR_WIN)
goto skip;
/* Disallow changing some options from modelines. */
if (opt_flags & OPT_MODELINE) {
if (flags & (P_SECURE | P_NO_ML)) {
errmsg = (char_u *)_("E520: Not allowed in a modeline");
goto skip;
}
/* In diff mode some options are overruled. This avoids that
* 'foldmethod' becomes "marker" instead of "diff" and that
* "wrap" gets set. */
if (curwin->w_p_diff
&& opt_idx >= 0 /* shut up coverity warning */
&& (options[opt_idx].indir == PV_FDM
|| options[opt_idx].indir == PV_WRAP))
goto skip;
}
/* Disallow changing some options in the sandbox */
if (sandbox != 0 && (flags & P_SECURE)) {
errmsg = (char_u *)_(e_sandbox);
goto skip;
}
if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) {
arg += len;
cp_val = p_cp;
if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') {
if (arg[3] == 'm') { /* "opt&vim": set to Vim default */
cp_val = FALSE;
arg += 3;
} else { /* "opt&vi": set to Vi default */
cp_val = TRUE;
arg += 2;
}
}
if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
&& arg[1] != NUL && !ascii_iswhite(arg[1])) {
errmsg = e_trailing;
goto skip;
}
}
/*
* allow '=' and ':' as MSDOS command.com allows only one
* '=' character per "set" command line. grrr. (jw)
*/
if (nextchar == '?'
|| (prefix == 1
&& vim_strchr((char_u *)"=:&<", nextchar) == NULL
&& !(flags & P_BOOL))) {
/*
* print value
*/
if (did_show)
msg_putchar('\n'); /* cursor below last one */
else {
gotocmdline(TRUE); /* cursor at status line */
did_show = TRUE; /* remember that we did a line */
}
if (opt_idx >= 0) {
showoneopt(&options[opt_idx], opt_flags);
if (p_verbose > 0) {
/* Mention where the option was last set. */
if (varp == options[opt_idx].var)
last_set_msg(options[opt_idx].scriptID);
else if ((int)options[opt_idx].indir & PV_WIN)
last_set_msg(curwin->w_p_scriptID[
(int)options[opt_idx].indir & PV_MASK]);
else if ((int)options[opt_idx].indir & PV_BUF)
last_set_msg(curbuf->b_p_scriptID[
(int)options[opt_idx].indir & PV_MASK]);
}
} else {
errmsg = (char_u *)N_("E846: Key code not set");
goto skip;
}
if (nextchar != '?'
&& nextchar != NUL && !ascii_iswhite(afterchar))
errmsg = e_trailing;
} else {
if (flags & P_BOOL) { /* boolean */
if (nextchar == '=' || nextchar == ':') {
errmsg = e_invarg;
goto skip;
}
/*
* ":set opt!": invert
* ":set opt&": reset to default value
* ":set opt<": reset to global value
*/
if (nextchar == '!')
value = *(int *)(varp) ^ 1;
else if (nextchar == '&')
value = (int)(intptr_t)options[opt_idx].def_val[
((flags & P_VI_DEF) || cp_val)
? VI_DEFAULT : VIM_DEFAULT];
else if (nextchar == '<') {
/* For 'autoread' -1 means to use global value. */
if ((int *)varp == &curbuf->b_p_ar
&& opt_flags == OPT_LOCAL)
value = -1;
else
value = *(int *)get_varp_scope(&(options[opt_idx]),
OPT_GLOBAL);
} else {
/*
* ":set invopt": invert
* ":set opt" or ":set noopt": set or reset
*/
if (nextchar != NUL && !ascii_iswhite(afterchar)) {
errmsg = e_trailing;
goto skip;
}
if (prefix == 2) /* inv */
value = *(int *)(varp) ^ 1;
else
value = prefix;
}
errmsg = set_bool_option(opt_idx, varp, (int)value,
opt_flags);
} else { /* numeric or string */
if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
|| prefix != 1) {
errmsg = e_invarg;
goto skip;
}
if (flags & P_NUM) { /* numeric */
/*
* Different ways to set a number option:
* & set to default value
* < set to global value
* <xx> accept special key codes for 'wildchar'
* c accept any non-digit for 'wildchar'
* [-]0-9 set number
* other error
*/
++arg;
if (nextchar == '&')
value = (long)options[opt_idx].def_val[
((flags & P_VI_DEF) || cp_val)
? VI_DEFAULT : VIM_DEFAULT];
else if (nextchar == '<') {
/* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
* use the global value. */
if ((long *)varp == &curbuf->b_p_ul
&& opt_flags == OPT_LOCAL)
value = NO_LOCAL_UNDOLEVEL;
else
value = *(long *)get_varp_scope(
&(options[opt_idx]), OPT_GLOBAL);
} else if (((long *)varp == &p_wc
|| (long *)varp == &p_wcm)
&& (*arg == '<'
|| *arg == '^'
|| ((!arg[1] || ascii_iswhite(arg[1]))
&& !ascii_isdigit(*arg)))) {
value = string_to_key(arg);
if (value == 0 && (long *)varp != &p_wcm) {
errmsg = e_invarg;
goto skip;
}
} else if (*arg == '-' || ascii_isdigit(*arg)) {
// Allow negative (for 'undolevels'), octal and
// hex numbers.
vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0);
if (arg[i] != NUL && !ascii_iswhite(arg[i])) {
errmsg = e_invarg;
goto skip;
}
} else {
errmsg = (char_u *)N_("E521: Number required after =");
goto skip;
}
if (adding)
value = *(long *)varp + value;
if (prepending)
value = *(long *)varp * value;
if (removing)
value = *(long *)varp - value;
errmsg = set_num_option(opt_idx, varp, value,
errbuf, sizeof(errbuf), opt_flags);
} else if (opt_idx >= 0) { /* string */
char_u *save_arg = NULL;
char_u *s = NULL;
char_u *oldval = NULL; // previous value if *varp
char_u *newval;
char_u *origval = NULL;
char *saved_origval = NULL;
unsigned newlen;
int comma;
int bs;
int new_value_alloced; /* new string option
was allocated */
/* When using ":set opt=val" for a global option
* with a local value the local value will be
* reset, use the global value here. */
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& ((int)options[opt_idx].indir & PV_BOTH))
varp = options[opt_idx].var;
/* The old value is kept until we are sure that the
* new value is valid. */
oldval = *(char_u **)varp;
if (nextchar == '&') { /* set to default val */
newval = options[opt_idx].def_val[
((flags & P_VI_DEF) || cp_val)
? VI_DEFAULT : VIM_DEFAULT];
/* expand environment variables and ~ (since the
* default value was already expanded, only
* required when an environment variable was set
* later */
new_value_alloced = true;
if (newval == NULL) {
newval = empty_option;
} else if (!(options[opt_idx].flags | P_NO_DEF_EXP)) {
s = option_expand(opt_idx, newval);
if (s == NULL) {
s = newval;
}
newval = vim_strsave(s);
} else {
newval = (char_u *)xstrdup((char *)newval);
}
} else if (nextchar == '<') { // set to global val
newval = vim_strsave(*(char_u **)get_varp_scope(
&(options[opt_idx]), OPT_GLOBAL));
new_value_alloced = TRUE;
} else {
++arg; /* jump to after the '=' or ':' */
/*
* Set 'keywordprg' to ":help" if an empty
* value was passed to :set by the user.
* Misuse errbuf[] for the resulting string.
*/
if (varp == (char_u *)&p_kp
&& (*arg == NUL || *arg == ' ')) {
STRCPY(errbuf, ":help");
save_arg = arg;
arg = errbuf;
}
/*
* Convert 'backspace' number to string, for
* adding, prepending and removing string.
*/
else if (varp == (char_u *)&p_bs
&& ascii_isdigit(**(char_u **)varp)) {
i = getdigits_int((char_u **)varp);
switch (i) {
case 0:
*(char_u **)varp = empty_option;
break;
case 1:
*(char_u **)varp = vim_strsave(
(char_u *)"indent,eol");
break;
case 2:
*(char_u **)varp = vim_strsave(
(char_u *)"indent,eol,start");
break;
}
xfree(oldval);
oldval = *(char_u **)varp;
}
/*
* Convert 'whichwrap' number to string, for
* backwards compatibility with Vim 3.0.
* Misuse errbuf[] for the resulting string.
*/
else if (varp == (char_u *)&p_ww
&& ascii_isdigit(*arg)) {
*errbuf = NUL;
i = getdigits_int(&arg);
if (i & 1)
STRCAT(errbuf, "b,");
if (i & 2)
STRCAT(errbuf, "s,");
if (i & 4)
STRCAT(errbuf, "h,l,");
if (i & 8)
STRCAT(errbuf, "<,>,");
if (i & 16)
STRCAT(errbuf, "[,],");
if (*errbuf != NUL) /* remove trailing , */
errbuf[STRLEN(errbuf) - 1] = NUL;
save_arg = arg;
arg = errbuf;
}
/*
* Remove '>' before 'dir' and 'bdir', for
* backwards compatibility with version 3.0
*/
else if ( *arg == '>'
&& (varp == (char_u *)&p_dir
|| varp == (char_u *)&p_bdir)) {
++arg;
}
/* When setting the local value of a global
* option, the old value may be the global value. */
if (((int)options[opt_idx].indir & PV_BOTH)
&& (opt_flags & OPT_LOCAL))
origval = *(char_u **)get_varp(
&options[opt_idx]);
else
origval = oldval;
/*
* Copy the new string into allocated memory.
* Can't use set_string_option_direct(), because
* we need to remove the backslashes.
*/
/* get a bit too much */
newlen = (unsigned)STRLEN(arg) + 1;
if (adding || prepending || removing)
newlen += (unsigned)STRLEN(origval) + 1;
newval = xmalloc(newlen);
s = newval;
/*
* Copy the string, skip over escaped chars.
* For WIN32 backslashes before normal
* file name characters are not removed, and keep
* backslash at start, for "\\machine\path", but
* do remove it for "\\\\machine\\path".
* The reverse is found in ExpandOldSetting().
*/
while (*arg && !ascii_iswhite(*arg)) {
if (*arg == '\\' && arg[1] != NUL
#ifdef BACKSLASH_IN_FILENAME
&& !((flags & P_EXPAND)
&& vim_isfilec(arg[1])
&& (arg[1] != '\\'
|| (s == newval
&& arg[2] != '\\')))
#endif
)
++arg; /* remove backslash */
if (has_mbyte
&& (i = (*mb_ptr2len)(arg)) > 1) {
/* copy multibyte char */
memmove(s, arg, (size_t)i);
arg += i;
s += i;
} else
*s++ = *arg++;
}
*s = NUL;
/*
* Expand environment variables and ~.
* Don't do it when adding without inserting a
* comma.
*/
if (!(adding || prepending || removing)
|| (flags & P_COMMA)) {
s = option_expand(opt_idx, newval);
if (s != NULL) {
xfree(newval);
newlen = (unsigned)STRLEN(s) + 1;
if (adding || prepending || removing)
newlen += (unsigned)STRLEN(origval) + 1;
newval = xmalloc(newlen);
STRCPY(newval, s);
}
}
/* locate newval[] in origval[] when removing it
* and when adding to avoid duplicates */
i = 0; /* init for GCC */
if (removing || (flags & P_NODUP)) {
i = (int)STRLEN(newval);
bs = 0;
for (s = origval; *s; ++s) {
if ((!(flags & P_COMMA)
|| s == origval
|| (s[-1] == ',' && !(bs & 1)))
&& STRNCMP(s, newval, i) == 0
&& (!(flags & P_COMMA)
|| s[i] == ','
|| s[i] == NUL)) {
break;
}
// Count backslashes. Only a comma with an even number of
// backslashes or a single backslash preceded by a comma
// before it is recognized as a separator
if ((s > origval + 1 && s[-1] == '\\' && s[-2] != ',')
|| (s == origval + 1 && s[-1] == '\\')) {
bs++;
} else {
bs = 0;
}
}
// do not add if already there
if ((adding || prepending) && *s) {
prepending = FALSE;
adding = FALSE;
STRCPY(newval, origval);
}
}
/* concatenate the two strings; add a ',' if
* needed */
if (adding || prepending) {
comma = ((flags & P_COMMA) && *origval != NUL
&& *newval != NUL);
if (adding) {
i = (int)STRLEN(origval);
// Strip a trailing comma, would get 2.
if (comma && i > 1
&& (flags & P_ONECOMMA) == P_ONECOMMA
&& origval[i - 1] == ','
&& origval[i - 2] != '\\') {
i--;
}
memmove(newval + i + comma, newval,
STRLEN(newval) + 1);
memmove(newval, origval, (size_t)i);
} else {
i = (int)STRLEN(newval);
STRMOVE(newval + i + comma, origval);
}
if (comma)
newval[i] = ',';
}
/* Remove newval[] from origval[]. (Note: "i" has
* been set above and is used here). */
if (removing) {
STRCPY(newval, origval);
if (*s) {
/* may need to remove a comma */
if (flags & P_COMMA) {
if (s == origval) {
/* include comma after string */
if (s[i] == ',')
++i;
} else {
/* include comma before string */
--s;
++i;
}
}
STRMOVE(newval + (s - origval), s + i);
}
}
if (flags & P_FLAGLIST) {
// Remove flags that appear twice.
for (s = newval; *s; s++) {
// if options have P_FLAGLIST and P_ONECOMMA such as
// 'whichwrap'
if (flags & P_ONECOMMA) {
if (*s != ',' && *(s + 1) == ','
&& vim_strchr(s + 2, *s) != NULL) {
// Remove the duplicated value and the next comma.
STRMOVE(s, s + 2);
s -= 2;
}
} else {
if ((!(flags & P_COMMA) || *s != ',')
&& vim_strchr(s + 1, *s) != NULL) {
STRMOVE(s, s + 1);
s--;
}
}
}
}
if (save_arg != NULL) /* number for 'whichwrap' */
arg = save_arg;
new_value_alloced = TRUE;
}
/* Set the new value. */
*(char_u **)(varp) = newval;
if (!starting && origval != NULL) {
// origval may be freed by
// did_set_string_option(), make a copy.
saved_origval = xstrdup((char *) origval);
}
/* Handle side effects, and set the global value for
* ":set" on local options. */
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
new_value_alloced, oldval, errbuf, opt_flags);
// If error detected, print the error message.
if (errmsg != NULL) {
xfree(saved_origval);
goto skip;
}
if (saved_origval != NULL) {
char buf_type[7];
vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s",
(opt_flags & OPT_LOCAL) ? "local" : "global");
set_vim_var_string(VV_OPTION_NEW, *(char **) varp, -1);
set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET,
(char_u *)options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars();
xfree(saved_origval);
}
} else {
// key code option(FIXME(tarruda): Show a warning or something
// similar)
}
}
if (opt_idx >= 0)
did_set_option(opt_idx, opt_flags,
!prepending && !adding && !removing);
}
skip:
/*
* Advance to next argument.
* - skip until a blank found, taking care of backslashes
* - skip blanks
* - skip one "=val" argument (for hidden options ":set gfn =xx")
*/
for (i = 0; i < 2; ++i) {
while (*arg != NUL && !ascii_iswhite(*arg))
if (*arg++ == '\\' && *arg != NUL)
++arg;
arg = skipwhite(arg);
if (*arg != '=')
break;
}
}
if (errmsg != NULL) {
STRLCPY(IObuff, _(errmsg), IOSIZE);
i = (int)STRLEN(IObuff) + 2;
if (i + (arg - startarg) < IOSIZE) {
/* append the argument with the error */
STRCAT(IObuff, ": ");
assert(arg >= startarg);
memmove(IObuff + i, startarg, (size_t)(arg - startarg));
IObuff[i + (arg - startarg)] = NUL;
}
/* make sure all characters are printable */
trans_characters(IObuff, IOSIZE);
++no_wait_return; /* wait_return done later */
emsg(IObuff); /* show error highlighted */
--no_wait_return;
return FAIL;
}
arg = skipwhite(arg);
}
theend:
if (silent_mode && did_show) {
/* After displaying option values in silent mode. */
silent_mode = FALSE;
info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
msg_putchar('\n');
ui_flush();
silent_mode = TRUE;
info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
}
return OK;
}
|
CWE-20
| null | 517,272 |
54133472034274375580117903387592418458
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
char_u *find_shada_parameter(int type)
{
char_u *p;
for (p = p_shada; *p; ++p) {
if (*p == type)
return p + 1;
if (*p == 'n') /* 'n' is always the last one */
break;
p = vim_strchr(p, ','); /* skip until next ',' */
if (p == NULL) /* hit the end without finding parameter */
break;
}
return NULL;
}
|
CWE-20
| null | 517,273 |
67368210357977800138647624607719600560
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void check_string_option(char_u **pp)
{
if (*pp == NULL)
*pp = empty_option;
}
|
CWE-20
| null | 517,274 |
282410885797320138407531488330914182911
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
set_option_value (
char_u *name,
long number,
char_u *string,
int opt_flags /* OPT_LOCAL or 0 (both) */
)
{
if (set_tty_option((char *)name, (char *)string)) {
return NULL;
}
int opt_idx;
char_u *varp;
opt_idx = findoption(name);
if (opt_idx < 0)
EMSG2(_("E355: Unknown option: %s"), name);
else {
uint32_t flags = options[opt_idx].flags;
// Disallow changing some options in the sandbox
if (sandbox > 0 && (flags & P_SECURE)) {
EMSG(_(e_sandbox));
return NULL;
}
if (flags & P_STRING) {
const char *s = (const char *)string;
if (s == NULL) {
s = "";
}
return (char_u *)set_string_option(opt_idx, s, opt_flags);
} else {
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
if (varp != NULL) { /* hidden option is not changed */
if (number == 0 && string != NULL) {
int idx;
// Either we are given a string or we are setting option
// to zero.
for (idx = 0; string[idx] == '0'; idx++) {}
if (string[idx] != NUL || idx == 0) {
// There's another character after zeros or the string
// is empty. In both cases, we are trying to set a
// num option using a string.
EMSG3(_("E521: Number required: &%s = '%s'"),
name, string);
return NULL; // do nothing as we hit an error
}
}
if (flags & P_NUM)
return set_num_option(opt_idx, varp, number,
NULL, 0, opt_flags);
else
return set_bool_option(opt_idx, varp, (int)number,
opt_flags);
}
}
}
return NULL;
}
|
CWE-20
| null | 517,275 |
227968565758737655958232629522789855202
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *get_varp_scope(vimoption_T *p, int opt_flags)
{
if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) {
if (p->var == VAR_WIN)
return (char_u *)GLOBAL_WO(get_varp(p));
return p->var;
}
if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) {
switch ((int)p->indir) {
case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
case PV_GP: return (char_u *)&(curbuf->b_p_gp);
case PV_MP: return (char_u *)&(curbuf->b_p_mp);
case PV_EP: return (char_u *)&(curbuf->b_p_ep);
case PV_KP: return (char_u *)&(curbuf->b_p_kp);
case PV_PATH: return (char_u *)&(curbuf->b_p_path);
case PV_AR: return (char_u *)&(curbuf->b_p_ar);
case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
case PV_TC: return (char_u *)&(curbuf->b_p_tc);
case PV_DEF: return (char_u *)&(curbuf->b_p_def);
case PV_INC: return (char_u *)&(curbuf->b_p_inc);
case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
case PV_STL: return (char_u *)&(curwin->w_p_stl);
case PV_UL: return (char_u *)&(curbuf->b_p_ul);
case PV_LW: return (char_u *)&(curbuf->b_p_lw);
case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
}
return NULL; /* "cannot happen" */
}
return get_varp(p);
}
|
CWE-20
| null | 517,276 |
264056809512401033442204659068691014938
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void check_options(void)
{
int opt_idx;
for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
check_string_option((char_u **)get_varp(&(options[opt_idx])));
}
|
CWE-20
| null | 517,277 |
159304936993307078548345145982474232585
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int find_key_option(const char_u *arg)
{
return find_key_option_len(arg, STRLEN(arg));
}
|
CWE-20
| null | 517,278 |
74523344971745633206057510352221289418
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int optval_default(vimoption_T *p, char_u *varp)
{
int dvi;
if (varp == NULL)
return TRUE; /* hidden option is always at default */
dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
if (p->flags & P_NUM)
return *(long *)varp == (long)p->def_val[dvi];
if (p->flags & P_BOOL)
return *(int *)varp == (int)(intptr_t)p->def_val[dvi];
/* P_STRING */
return STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0;
}
|
CWE-20
| null | 517,279 |
113043119173785608278283892990281498312
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
bool file_ff_differs(buf_T *buf, bool ignore_empty)
{
/* In a buffer that was never loaded the options are not valid. */
if (buf->b_flags & BF_NEVERLOADED)
return FALSE;
if (ignore_empty
&& (buf->b_flags & BF_NEW)
&& buf->b_ml.ml_line_count == 1
&& *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
return FALSE;
if (buf->b_start_ffc != *buf->b_p_ff)
return true;
if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
return true;
if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
return TRUE;
if (buf->b_start_fenc == NULL)
return *buf->b_p_fenc != NUL;
return STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0;
}
|
CWE-20
| null | 517,280 |
113879708467252953942464729567485368822
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int option_was_set(char_u *name)
{
int idx;
idx = findoption(name);
if (idx < 0) /* unknown option */
return FALSE;
if (options[idx].flags & P_WAS_SET)
return TRUE;
return FALSE;
}
|
CWE-20
| null | 517,281 |
186606420967715561206576979028323011757
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_number_default(char *name, long val)
{
int opt_idx;
opt_idx = findoption((char_u *)name);
if (opt_idx >= 0)
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)val;
}
|
CWE-20
| null | 517,282 |
92670474876520856352599871581624485660
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int put_setbool(FILE *fd, char *cmd, char *name, int value)
{
if (value < 0) /* global/local option using global value */
return OK;
if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
|| put_eol(fd) < 0)
return FAIL;
return OK;
}
|
CWE-20
| null | 517,283 |
153432949441897104136127308223340538071
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void free_all_options(void)
{
int i;
for (i = 0; options[i].fullname; i++) {
if (options[i].indir == PV_NONE) {
/* global option: free value and default value. */
if (options[i].flags & P_ALLOCED && options[i].var != NULL)
free_string_option(*(char_u **)options[i].var);
if (options[i].flags & P_DEF_ALLOCED)
free_string_option(options[i].def_val[VI_DEFAULT]);
} else if (options[i].var != VAR_WIN
&& (options[i].flags & P_STRING))
/* buffer-local option: free global value */
free_string_option(*(char_u **)options[i].var);
}
}
|
CWE-20
| null | 517,284 |
28818071455727018282878789401755154810
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep)
{
long wc;
if (fprintf(fd, "%s %s=", cmd, name) < 0)
return FAIL;
if (wc_use_keyname((char_u *)valuep, &wc)) {
/* print 'wildchar' and 'wildcharm' as a key name */
if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
return FAIL;
} else if (fprintf(fd, "%" PRId64, (int64_t)*valuep) < 0)
return FAIL;
if (put_eol(fd) < 0)
return FAIL;
return OK;
}
|
CWE-20
| null | 517,285 |
11912708857783809850478990607183079093
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
did_set_string_option (
int opt_idx, /* index in options[] table */
char_u **varp, /* pointer to the option variable */
int new_value_alloced, /* new value was allocated */
char_u *oldval, /* previous value of the option */
char_u *errbuf, /* buffer for errors, or NULL */
int opt_flags /* OPT_LOCAL and/or OPT_GLOBAL */
)
{
char_u *errmsg = NULL;
char_u *s, *p;
int did_chartab = FALSE;
char_u **gvarp;
bool free_oldval = (options[opt_idx].flags & P_ALLOCED);
/* Get the global option to compare with, otherwise we would have to check
* two values for all local options. */
gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
/* Disallow changing some options from secure mode */
if ((secure || sandbox != 0)
&& (options[opt_idx].flags & P_SECURE)) {
errmsg = e_secure;
}
/* Check for a "normal" file name in some options. Disallow a path
* separator (slash and/or backslash), wildcards and characters that are
* often illegal in a file name. */
else if ((options[opt_idx].flags & P_NFNAME)
&& vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) {
errmsg = e_invarg;
}
/* 'backupcopy' */
else if (gvarp == &p_bkc) {
char_u *bkc = p_bkc;
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;
}
}
}
/* 'backupext' and 'patchmode' */
else if (varp == &p_bex || varp == &p_pm) {
if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
*p_pm == '.' ? p_pm + 1 : p_pm) == 0)
errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
}
/* 'breakindentopt' */
else if (varp == &curwin->w_p_briopt) {
if (briopt_check(curwin) == FAIL)
errmsg = e_invarg;
} else if (varp == &p_isi
|| varp == &(curbuf->b_p_isk)
|| varp == &p_isp
|| varp == &p_isf) {
// 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
// If the new option is invalid, use old value. 'lisp' option: refill
// g_chartab[] for '-' char
if (init_chartab() == FAIL) {
did_chartab = TRUE; /* need to restore it below */
errmsg = e_invarg; /* error in value */
}
}
/* 'helpfile' */
else if (varp == &p_hf) {
/* May compute new values for $VIM and $VIMRUNTIME */
if (didset_vim) {
vim_setenv("VIM", "");
didset_vim = FALSE;
}
if (didset_vimruntime) {
vim_setenv("VIMRUNTIME", "");
didset_vimruntime = FALSE;
}
}
/* 'colorcolumn' */
else if (varp == &curwin->w_p_cc)
errmsg = check_colorcolumn(curwin);
/* 'helplang' */
else if (varp == &p_hlg) {
/* Check for "", "ab", "ab,cd", etc. */
for (s = p_hlg; *s != NUL; s += 3) {
if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) {
errmsg = e_invarg;
break;
}
if (s[2] == NUL)
break;
}
}
/* 'highlight' */
else if (varp == &p_hl) {
if (highlight_changed() == FAIL)
errmsg = e_invarg; /* invalid flags */
}
/* 'nrformats' */
else if (gvarp == &p_nf) {
if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
errmsg = e_invarg;
} else if (varp == &p_ssop) { // 'sessionoptions'
if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true) != OK)
errmsg = e_invarg;
if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) {
/* Don't allow both "sesdir" and "curdir". */
(void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true);
errmsg = e_invarg;
}
} else if (varp == &p_vop) { // 'viewoptions'
if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, true) != OK)
errmsg = e_invarg;
}
/* 'scrollopt' */
else if (varp == &p_sbo) {
if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
errmsg = e_invarg;
} else if (varp == &p_ambw || (int *)varp == &p_emoji) {
// 'ambiwidth'
if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) {
errmsg = e_invarg;
} else if (set_chars_option(&p_lcs) != NULL) {
errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
} else if (set_chars_option(&p_fcs) != NULL) {
errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
}
}
/* 'background' */
else if (varp == &p_bg) {
if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) {
int dark = (*p_bg == 'd');
init_highlight(FALSE, FALSE);
if (dark != (*p_bg == 'd')
&& get_var_value((char_u *)"g:colors_name") != NULL) {
/* The color scheme must have set 'background' back to another
* value, that's not what we want here. Disable the color
* scheme and set the colors again. */
do_unlet((char_u *)"g:colors_name", TRUE);
free_string_option(p_bg);
p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
check_string_option(&p_bg);
init_highlight(FALSE, FALSE);
}
} else
errmsg = e_invarg;
}
/* 'wildmode' */
else if (varp == &p_wim) {
if (check_opt_wim() == FAIL)
errmsg = e_invarg;
}
/* 'wildoptions' */
else if (varp == &p_wop) {
if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
errmsg = e_invarg;
}
/* 'winaltkeys' */
else if (varp == &p_wak) {
if (*p_wak == NUL
|| check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
errmsg = e_invarg;
}
/* 'eventignore' */
else if (varp == &p_ei) {
if (check_ei() == FAIL)
errmsg = e_invarg;
/* 'encoding' and 'fileencoding' */
} else if (varp == &p_enc || gvarp == &p_fenc) {
if (gvarp == &p_fenc) {
if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) {
errmsg = e_modifiable;
} else if (vim_strchr(*varp, ',') != NULL) {
// No comma allowed in 'fileencoding'; catches confusing it
// with 'fileencodings'.
errmsg = e_invarg;
} else {
// May show a "+" in the title now.
redraw_titles();
// Add 'fileencoding' to the swap file.
ml_setflags(curbuf);
}
}
if (errmsg == NULL) {
/* canonize the value, so that STRCMP() can be used on it */
p = enc_canonize(*varp);
xfree(*varp);
*varp = p;
if (varp == &p_enc) {
// only encoding=utf-8 allowed
if (STRCMP(p_enc, "utf-8") != 0) {
errmsg = e_invarg;
}
}
}
} else if (varp == &p_penc) {
/* Canonize printencoding if VIM standard one */
p = enc_canonize(p_penc);
xfree(p_penc);
p_penc = p;
} else if (varp == &curbuf->b_p_keymap) {
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
} else {
// load or unload key mapping tables
errmsg = keymap_init();
}
if (errmsg == NULL) {
if (*curbuf->b_p_keymap != NUL) {
/* Installed a new keymap, switch on using it. */
curbuf->b_p_iminsert = B_IMODE_LMAP;
if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
curbuf->b_p_imsearch = B_IMODE_LMAP;
} else {
/* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
curbuf->b_p_iminsert = B_IMODE_NONE;
if (curbuf->b_p_imsearch == B_IMODE_LMAP)
curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
}
if ((opt_flags & OPT_LOCAL) == 0) {
set_iminsert_global();
set_imsearch_global();
}
status_redraw_curbuf();
}
}
/* 'fileformat' */
else if (gvarp == &p_ff) {
if (!MODIFIABLE(curbuf) && !(opt_flags & OPT_GLOBAL))
errmsg = e_modifiable;
else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
errmsg = e_invarg;
else {
redraw_titles();
/* update flag in swap file */
ml_setflags(curbuf);
/* Redraw needed when switching to/from "mac": a CR in the text
* will be displayed differently. */
if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
redraw_curbuf_later(NOT_VALID);
}
}
/* 'fileformats' */
else if (varp == &p_ffs) {
if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) {
errmsg = e_invarg;
}
}
/* 'matchpairs' */
else if (gvarp == &p_mps) {
if (has_mbyte) {
for (p = *varp; *p != NUL; ++p) {
int x2 = -1;
int x3 = -1;
if (*p != NUL)
p += mb_ptr2len(p);
if (*p != NUL)
x2 = *p++;
if (*p != NUL) {
x3 = mb_ptr2char(p);
p += mb_ptr2len(p);
}
if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) {
errmsg = e_invarg;
break;
}
if (*p == NUL)
break;
}
} 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] != ',')) {
errmsg = e_invarg;
break;
}
if (p[3] == NUL)
break;
}
}
}
/* 'comments' */
else if (gvarp == &p_com) {
for (s = *varp; *s; ) {
while (*s && *s != ':') {
if (vim_strchr((char_u *)COM_ALL, *s) == NULL
&& !ascii_isdigit(*s) && *s != '-') {
errmsg = illegal_char(errbuf, *s);
break;
}
++s;
}
if (*s++ == NUL)
errmsg = (char_u *)N_("E524: Missing colon");
else if (*s == ',' || *s == NUL)
errmsg = (char_u *)N_("E525: Zero length string");
if (errmsg != NULL)
break;
while (*s && *s != ',') {
if (*s == '\\' && s[1] != NUL)
++s;
++s;
}
s = skip_to_option_part(s);
}
}
/* 'listchars' */
else if (varp == &p_lcs) {
errmsg = set_chars_option(varp);
}
/* 'fillchars' */
else if (varp == &p_fcs) {
errmsg = set_chars_option(varp);
}
/* 'cedit' */
else if (varp == &p_cedit) {
errmsg = check_cedit();
}
/* 'verbosefile' */
else if (varp == &p_vfile) {
verbose_stop();
if (*p_vfile != NUL && verbose_open() == FAIL)
errmsg = e_invarg;
/* 'shada' */
} else if (varp == &p_shada) {
// TODO(ZyX-I): Remove this code in the future, alongside with &viminfo
// option.
opt_idx = ((options[opt_idx].fullname[0] == 'v')
? (shada_idx == -1
? ((shada_idx = findoption((char_u *) "shada")))
: shada_idx)
: opt_idx);
for (s = p_shada; *s; ) {
/* Check it's a valid character */
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
break;
}
if (*s == 'n') { /* name is always last one */
break;
} else if (*s == 'r') { /* skip until next ',' */
while (*++s && *s != ',')
;
} else if (*s == '%') {
/* optional number */
while (ascii_isdigit(*++s))
;
} else if (*s == '!' || *s == 'h' || *s == 'c')
++s; /* no extra chars */
else { /* must have a number */
while (ascii_isdigit(*++s))
;
if (!ascii_isdigit(*(s - 1))) {
if (errbuf != NULL) {
sprintf((char *)errbuf,
_("E526: Missing number after <%s>"),
transchar_byte(*(s - 1)));
errmsg = errbuf;
} else
errmsg = (char_u *)"";
break;
}
}
if (*s == ',')
++s;
else if (*s) {
if (errbuf != NULL)
errmsg = (char_u *)N_("E527: Missing comma");
else
errmsg = (char_u *)"";
break;
}
}
if (*p_shada && errmsg == NULL && get_shada_parameter('\'') < 0)
errmsg = (char_u *)N_("E528: Must specify a ' value");
}
/* 'showbreak' */
else if (varp == &p_sbr) {
for (s = p_sbr; *s; ) {
if (ptr2cells(s) != 1)
errmsg = (char_u *)N_("E595: contains unprintable or wide character");
mb_ptr_adv(s);
}
}
/* 'guicursor' */
else if (varp == &p_guicursor)
errmsg = parse_shape_opt(SHAPE_CURSOR);
else if (varp == &p_popt)
errmsg = parse_printoptions();
else if (varp == &p_pmfn)
errmsg = parse_printmbfont();
/* 'langmap' */
else if (varp == &p_langmap)
langmap_set();
/* 'breakat' */
else if (varp == &p_breakat)
fill_breakat_flags();
/* 'titlestring' and 'iconstring' */
else if (varp == &p_titlestring || varp == &p_iconstring) {
int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
/* NULL => statusline syntax */
if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
stl_syntax |= flagval;
else
stl_syntax &= ~flagval;
did_set_title(varp == &p_iconstring);
}
/* 'selection' */
else if (varp == &p_sel) {
if (*p_sel == NUL
|| check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
errmsg = e_invarg;
}
/* 'selectmode' */
else if (varp == &p_slm) {
if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
errmsg = e_invarg;
}
/* 'keymodel' */
else if (varp == &p_km) {
if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
errmsg = e_invarg;
else {
km_stopsel = (vim_strchr(p_km, 'o') != NULL);
km_startsel = (vim_strchr(p_km, 'a') != NULL);
}
}
/* 'mousemodel' */
else if (varp == &p_mousem) {
if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
errmsg = e_invarg;
} else if (varp == &p_swb) { // 'switchbuf'
if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, true) != OK)
errmsg = e_invarg;
}
/* 'debug' */
else if (varp == &p_debug) {
if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
errmsg = e_invarg;
} else if (varp == &p_dy) { // 'display'
if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK)
errmsg = e_invarg;
else
(void)init_chartab();
}
/* 'eadirection' */
else if (varp == &p_ead) {
if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
errmsg = e_invarg;
} else if (varp == &p_cb) { // 'clipboard'
if (opt_strings_flags(p_cb, p_cb_values, &cb_flags, true) != OK) {
errmsg = e_invarg;
}
} else if (varp == &(curwin->w_s->b_p_spl) // 'spell'
|| varp == &(curwin->w_s->b_p_spf)) {
// When 'spelllang' or 'spellfile' is set and there is a window for this
// buffer in which 'spell' is set load the wordlists.
errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
}
/* When 'spellcapcheck' is set compile the regexp program. */
else if (varp == &(curwin->w_s->b_p_spc)) {
errmsg = compile_cap_prog(curwin->w_s);
}
/* 'spellsuggest' */
else if (varp == &p_sps) {
if (spell_check_sps() != OK)
errmsg = e_invarg;
}
/* 'mkspellmem' */
else if (varp == &p_msm) {
if (spell_check_msm() != OK)
errmsg = e_invarg;
}
/* When 'bufhidden' is set, check for valid value. */
else if (gvarp == &p_bh) {
if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
errmsg = e_invarg;
}
/* When 'buftype' is set, check for valid value. */
else if (gvarp == &p_bt) {
if ((curbuf->terminal && curbuf->b_p_bt[0] != 't')
|| (!curbuf->terminal && curbuf->b_p_bt[0] == 't')
|| check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) {
errmsg = e_invarg;
} else {
if (curwin->w_status_height) {
curwin->w_redr_status = TRUE;
redraw_later(VALID);
}
curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
redraw_titles();
}
}
/* 'statusline' or 'rulerformat' */
else if (gvarp == &p_stl || varp == &p_ruf) {
int wid;
if (varp == &p_ruf) /* reset ru_wid first */
ru_wid = 0;
s = *varp;
if (varp == &p_ruf && *s == '%') {
/* set ru_wid if 'ruf' starts with "%99(" */
if (*++s == '-') /* ignore a '-' */
s++;
wid = getdigits_int(&s);
if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
ru_wid = wid;
else
errmsg = check_stl_option(p_ruf);
}
/* check 'statusline' only if it doesn't start with "%!" */
else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
errmsg = check_stl_option(s);
if (varp == &p_ruf && errmsg == NULL)
comp_col();
}
/* check if it is a valid value for 'complete' -- Acevedo */
else if (gvarp == &p_cpt) {
for (s = *varp; *s; ) {
while (*s == ',' || *s == ' ')
s++;
if (!*s)
break;
if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
break;
}
if (*++s != NUL && *s != ',' && *s != ' ') {
if (s[-1] == 'k' || s[-1] == 's') {
/* skip optional filename after 'k' and 's' */
while (*s && *s != ',' && *s != ' ') {
if (*s == '\\')
++s;
++s;
}
} else {
if (errbuf != NULL) {
sprintf((char *)errbuf,
_("E535: Illegal character after <%c>"),
*--s);
errmsg = errbuf;
} else
errmsg = (char_u *)"";
break;
}
}
}
}
/* 'completeopt' */
else if (varp == &p_cot) {
if (check_opt_strings(p_cot, p_cot_values, true) != OK) {
errmsg = e_invarg;
} else {
completeopt_was_set();
}
}
/* 'pastetoggle': translate key codes like in a mapping */
else if (varp == &p_pt) {
if (*p_pt) {
(void)replace_termcodes(p_pt, STRLEN(p_pt), &p, true, true, false,
CPO_TO_CPO_FLAGS);
if (p != NULL) {
if (new_value_alloced)
free_string_option(p_pt);
p_pt = p;
new_value_alloced = TRUE;
}
}
}
/* 'backspace' */
else if (varp == &p_bs) {
if (ascii_isdigit(*p_bs)) {
if (*p_bs >'2' || p_bs[1] != NUL)
errmsg = e_invarg;
} else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
errmsg = e_invarg;
} else if (varp == &p_bo) {
if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, true) != OK) {
errmsg = e_invarg;
}
} else if (gvarp == &p_tc) { // 'tagcase'
unsigned int *flags;
if (opt_flags & OPT_LOCAL) {
p = curbuf->b_p_tc;
flags = &curbuf->b_tc_flags;
} else {
p = p_tc;
flags = &tc_flags;
}
if ((opt_flags & OPT_LOCAL) && *p == NUL) {
// make the local value empty: use the global value
*flags = 0;
} else if (*p == NUL
|| opt_strings_flags(p, p_tc_values, flags, false) != OK) {
errmsg = e_invarg;
}
} else if (varp == &p_cmp) { // 'casemap'
if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, true) != OK)
errmsg = e_invarg;
}
/* 'diffopt' */
else if (varp == &p_dip) {
if (diffopt_changed() == FAIL)
errmsg = e_invarg;
}
/* 'foldmethod' */
else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) {
if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
|| *curwin->w_p_fdm == NUL)
errmsg = e_invarg;
else {
foldUpdateAll(curwin);
if (foldmethodIsDiff(curwin))
newFoldLevel();
}
}
/* 'foldexpr' */
else if (varp == &curwin->w_p_fde) {
if (foldmethodIsExpr(curwin))
foldUpdateAll(curwin);
}
/* 'foldmarker' */
else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) {
p = vim_strchr(*varp, ',');
if (p == NULL)
errmsg = (char_u *)N_("E536: comma required");
else if (p == *varp || p[1] == NUL)
errmsg = e_invarg;
else if (foldmethodIsMarker(curwin))
foldUpdateAll(curwin);
}
/* 'commentstring' */
else if (gvarp == &p_cms) {
if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
errmsg = (char_u *)N_(
"E537: 'commentstring' must be empty or contain %s");
} else if (varp == &p_fdo) { // 'foldopen'
if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, true) != OK)
errmsg = e_invarg;
}
/* 'foldclose' */
else if (varp == &p_fcl) {
if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
errmsg = e_invarg;
}
/* 'foldignore' */
else if (gvarp == &curwin->w_allbuf_opt.wo_fdi) {
if (foldmethodIsIndent(curwin))
foldUpdateAll(curwin);
} else if (varp == &p_ve) { // 'virtualedit'
if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, true) != OK)
errmsg = e_invarg;
else if (STRCMP(p_ve, oldval) != 0) {
/* Recompute cursor position in case the new 've' setting
* changes something. */
validate_virtcol();
coladvance(curwin->w_virtcol);
}
} else if (varp == &p_csqf) {
if (p_csqf != NULL) {
p = p_csqf;
while (*p != NUL) {
if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
|| p[1] == NUL
|| vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
|| (p[2] != NUL && p[2] != ',')) {
errmsg = e_invarg;
break;
} else if (p[2] == NUL)
break;
else
p += 3;
}
}
}
/* 'cinoptions' */
else if (gvarp == &p_cino) {
/* TODO: recognize errors */
parse_cino(curbuf);
// inccommand
} else if (varp == &p_icm) {
if (check_opt_strings(p_icm, p_icm_values, false) != OK) {
errmsg = e_invarg;
}
} else if (gvarp == &p_ft) {
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
}
} else if (gvarp == &p_syn) {
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
}
} else {
// Options that are a list of flags.
p = NULL;
if (varp == &p_ww)
p = (char_u *)WW_ALL;
if (varp == &p_shm)
p = (char_u *)SHM_ALL;
else if (varp == &(p_cpo))
p = (char_u *)CPO_VI;
else if (varp == &(curbuf->b_p_fo))
p = (char_u *)FO_ALL;
else if (varp == &curwin->w_p_cocu)
p = (char_u *)COCU_ALL;
else if (varp == &p_mouse) {
p = (char_u *)MOUSE_ALL;
}
if (p != NULL) {
for (s = *varp; *s; ++s)
if (vim_strchr(p, *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
break;
}
}
}
/*
* If error detected, restore the previous value.
*/
if (errmsg != NULL) {
if (new_value_alloced)
free_string_option(*varp);
*varp = oldval;
/*
* When resetting some values, need to act on it.
*/
if (did_chartab)
(void)init_chartab();
if (varp == &p_hl)
(void)highlight_changed();
} else {
/* Remember where the option was set. */
set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
/*
* Free string options that are in allocated memory.
* Use "free_oldval", because recursiveness may change the flags under
* our fingers (esp. init_highlight()).
*/
if (free_oldval)
free_string_option(oldval);
if (new_value_alloced)
options[opt_idx].flags |= P_ALLOCED;
else
options[opt_idx].flags &= ~P_ALLOCED;
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& ((int)options[opt_idx].indir & PV_BOTH)) {
/* global option with local value set to use global value; free
* the local value and make it empty */
p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
free_string_option(*(char_u **)p);
*(char_u **)p = empty_option;
}
/* May set global value for local option. */
else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
set_string_option_global(opt_idx, varp);
/*
* Trigger the autocommand only after setting the flags.
*/
/* When 'syntax' is set, load the syntax of that name */
if (varp == &(curbuf->b_p_syn)) {
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
curbuf->b_fname, TRUE, curbuf);
} else if (varp == &(curbuf->b_p_ft)) {
/* 'filetype' is set, trigger the FileType autocommand */
did_filetype = TRUE;
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
curbuf->b_fname, TRUE, curbuf);
}
if (varp == &(curwin->w_s->b_p_spl)) {
char_u fname[200];
char_u *q = curwin->w_s->b_p_spl;
/* Skip the first name if it is "cjk". */
if (STRNCMP(q, "cjk,", 4) == 0)
q += 4;
/*
* Source the spell/LANG.vim in 'runtimepath'.
* They could set 'spellcapcheck' depending on the language.
* Use the first name in 'spelllang' up to '_region' or
* '.encoding'.
*/
for (p = q; *p != NUL; ++p)
if (vim_strchr((char_u *)"_.,", *p) != NULL)
break;
vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim",
(int)(p - q), q);
source_runtime(fname, DIP_ALL);
}
}
if (varp == &p_mouse) {
if (*p_mouse == NUL) {
ui_mouse_off();
} else {
setmouse(); // in case 'mouse' changed
}
}
if (curwin->w_curswant != MAXCOL
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
curwin->w_set_curswant = TRUE;
check_redraw(options[opt_idx].flags);
return errmsg;
}
|
CWE-20
| null | 517,286 |
40220503311682989092971097258466584865
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void copy_winopt(winopt_T *from, winopt_T *to)
{
to->wo_arab = from->wo_arab;
to->wo_list = from->wo_list;
to->wo_nu = from->wo_nu;
to->wo_rnu = from->wo_rnu;
to->wo_nuw = from->wo_nuw;
to->wo_rl = from->wo_rl;
to->wo_rlc = vim_strsave(from->wo_rlc);
to->wo_stl = vim_strsave(from->wo_stl);
to->wo_wrap = from->wo_wrap;
to->wo_wrap_save = from->wo_wrap_save;
to->wo_lbr = from->wo_lbr;
to->wo_bri = from->wo_bri;
to->wo_briopt = vim_strsave(from->wo_briopt);
to->wo_scb = from->wo_scb;
to->wo_scb_save = from->wo_scb_save;
to->wo_crb = from->wo_crb;
to->wo_crb_save = from->wo_crb_save;
to->wo_spell = from->wo_spell;
to->wo_cuc = from->wo_cuc;
to->wo_cul = from->wo_cul;
to->wo_cc = vim_strsave(from->wo_cc);
to->wo_diff = from->wo_diff;
to->wo_diff_saved = from->wo_diff_saved;
to->wo_cocu = vim_strsave(from->wo_cocu);
to->wo_cole = from->wo_cole;
to->wo_fdc = from->wo_fdc;
to->wo_fdc_save = from->wo_fdc_save;
to->wo_fen = from->wo_fen;
to->wo_fen_save = from->wo_fen_save;
to->wo_fdi = vim_strsave(from->wo_fdi);
to->wo_fml = from->wo_fml;
to->wo_fdl = from->wo_fdl;
to->wo_fdl_save = from->wo_fdl_save;
to->wo_fdm = vim_strsave(from->wo_fdm);
to->wo_fdm_save = from->wo_diff_saved
? vim_strsave(from->wo_fdm_save) : empty_option;
to->wo_fdn = from->wo_fdn;
to->wo_fde = vim_strsave(from->wo_fde);
to->wo_fdt = vim_strsave(from->wo_fdt);
to->wo_fmr = vim_strsave(from->wo_fmr);
check_winopt(to); /* don't want NULL pointers */
}
|
CWE-20
| null | 517,287 |
306242405227786598704412328811921685162
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
unsigned int get_bkc_value(buf_T *buf)
{
return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
}
|
CWE-20
| null | 517,288 |
94488928368567140598357359873921455879
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
char_u *get_equalprg(void)
{
if (*curbuf->b_p_ep == NUL)
return p_ep;
return curbuf->b_p_ep;
}
|
CWE-20
| null | 517,289 |
157533811274165170232591238647186901333
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void fill_breakat_flags(void)
{
char_u *p;
int i;
for (i = 0; i < 256; i++)
breakat_flags[i] = FALSE;
if (p_breakat != NULL)
for (p = p_breakat; *p; p++)
breakat_flags[*p] = TRUE;
}
|
CWE-20
| null | 517,290 |
239255577317143717395149845647019979950
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void reset_modifiable(void)
{
int opt_idx;
curbuf->b_p_ma = FALSE;
p_ma = FALSE;
opt_idx = findoption((char_u *)"ma");
if (opt_idx >= 0)
options[opt_idx].def_val[VI_DEFAULT] = FALSE;
}
|
CWE-20
| null | 517,291 |
99127318761844143985035341022970260139
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int get_shada_parameter(int type)
{
char_u *p;
p = find_shada_parameter(type);
if (p != NULL && ascii_isdigit(*p))
return atoi((char *)p);
return -1;
}
|
CWE-20
| null | 517,292 |
326023930146618964777103967213310535697
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int string_to_key(char_u *arg)
{
if (*arg == '<')
return find_key_option(arg + 1);
if (*arg == '^')
return Ctrl_chr(arg[1]);
return *arg;
}
|
CWE-20
| null | 517,293 |
34186647970462511476893805591344104471
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static char_u *check_cedit(void)
{
int n;
if (*p_cedit == NUL)
cedit_key = -1;
else {
n = string_to_key(p_cedit);
if (vim_isprintc(n))
return e_invarg;
cedit_key = n;
}
return NULL;
}
|
CWE-20
| null | 517,294 |
162675437946278263031794367236001463815
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static void langmap_init(void)
{
for (int i = 0; i < 256; i++)
langmap_mapchar[i] = (char_u)i; /* we init with a one-to-one map */
ga_init(&langmap_mapga, sizeof(langmap_entry_T), 8);
}
|
CWE-20
| null | 517,295 |
260230616450527140824600961030803558471
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int find_key_option_len(const char_u *arg, size_t len)
{
int key;
int modifiers;
// Don't use get_special_key_code() for t_xx, we don't want it to call
// add_termcap_entry().
if (len >= 4 && arg[0] == 't' && arg[1] == '_') {
key = TERMCAP2KEY(arg[2], arg[3]);
} else {
arg--; // put arg at the '<'
modifiers = 0;
key = find_special_key(&arg, len + 1, &modifiers, true, true);
if (modifiers) { // can't handle modifiers here
key = 0;
}
}
return key;
}
|
CWE-20
| null | 517,296 |
307642817301905758490376569513065264988
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
{
if (val == NULL || *val == NUL) {
return dest;
}
const void *iter = NULL;
do {
size_t dir_len;
const char *dir;
iter = (forward ? vim_colon_env_iter : vim_colon_env_iter_rev)(
val, iter, &dir, &dir_len);
if (dir != NULL && dir_len > 0) {
dest = strcpy_comma_escaped(dest, dir, dir_len);
if (!after_pathsep(dest - 1, dest)) {
*dest++ = PATHSEP;
}
memmove(dest, "nvim", NVIM_SIZE);
dest += NVIM_SIZE;
if (suf1 != NULL) {
*dest++ = PATHSEP;
memmove(dest, suf1, len1);
dest += len1;
if (suf2 != NULL) {
*dest++ = PATHSEP;
memmove(dest, suf2, len2);
dest += len2;
}
}
*dest++ = ',';
}
} while (iter != NULL);
return dest;
}
|
CWE-20
| null | 517,297 |
155447581089138634451419800938467028562
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_helplang_default(const char *lang)
{
int idx;
if (lang == NULL || STRLEN(lang) < 2) /* safety check */
return;
idx = findoption((char_u *)"hlg");
if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) {
if (options[idx].flags & P_ALLOCED)
free_string_option(p_hlg);
p_hlg = (char_u *)xstrdup(lang);
/* zh_CN becomes "cn", zh_TW becomes "tw". */
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) {
p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]);
p_hlg[1] = (char_u)TOLOWER_ASC(p_hlg[4]);
}
p_hlg[2] = NUL;
options[idx].flags |= P_ALLOCED;
}
}
|
CWE-20
| null | 517,298 |
141600854039449186879983866226106770586
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void unset_global_local_option(char *name, void *from)
{
vimoption_T *p;
buf_T *buf = (buf_T *)from;
int opt_idx = findoption((uint8_t *)name);
if (opt_idx < 0) {
EMSG2(_("E355: Unknown option: %s"), name);
return;
}
p = &(options[opt_idx]);
switch ((int)p->indir)
{
// global option with local value: use local value if it's been set
case PV_EP:
clear_string_option(&buf->b_p_ep);
break;
case PV_KP:
clear_string_option(&buf->b_p_kp);
break;
case PV_PATH:
clear_string_option(&buf->b_p_path);
break;
case PV_AR:
buf->b_p_ar = -1;
break;
case PV_BKC:
clear_string_option(&buf->b_p_bkc);
buf->b_bkc_flags = 0;
break;
case PV_TAGS:
clear_string_option(&buf->b_p_tags);
break;
case PV_TC:
clear_string_option(&buf->b_p_tc);
buf->b_tc_flags = 0;
break;
case PV_DEF:
clear_string_option(&buf->b_p_def);
break;
case PV_INC:
clear_string_option(&buf->b_p_inc);
break;
case PV_DICT:
clear_string_option(&buf->b_p_dict);
break;
case PV_TSR:
clear_string_option(&buf->b_p_tsr);
break;
case PV_EFM:
clear_string_option(&buf->b_p_efm);
break;
case PV_GP:
clear_string_option(&buf->b_p_gp);
break;
case PV_MP:
clear_string_option(&buf->b_p_mp);
break;
case PV_STL:
clear_string_option(&((win_T *)from)->w_p_stl);
break;
case PV_UL:
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
break;
case PV_LW:
clear_string_option(&buf->b_p_lw);
break;
}
}
|
CWE-20
| null | 517,299 |
122290451372585411775054389741342641895
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
char_u *skip_to_option_part(char_u *p)
{
if (*p == ',') {
p++;
}
while (*p == ' ') {
p++;
}
return p;
}
|
CWE-20
| null | 517,300 |
111420945872364082656346585950814128539
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
if (val == NULL || *val == NUL) {
return 0;
}
|
CWE-20
| null | 517,301 |
50486748247041059325013879712528814085
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
char_u *check_colorcolumn(win_T *wp)
{
char_u *s;
int col;
unsigned int count = 0;
int color_cols[256];
int j = 0;
if (wp->w_buffer == NULL)
return NULL; /* buffer was closed */
for (s = wp->w_p_cc; *s != NUL && count < 255; ) {
if (*s == '-' || *s == '+') {
/* -N and +N: add to 'textwidth' */
col = (*s == '-') ? -1 : 1;
++s;
if (!ascii_isdigit(*s))
return e_invarg;
col = col * getdigits_int(&s);
if (wp->w_buffer->b_p_tw == 0)
goto skip; /* 'textwidth' not set, skip this item */
assert((col >= 0
&& wp->w_buffer->b_p_tw <= INT_MAX - col
&& wp->w_buffer->b_p_tw + col >= INT_MIN)
|| (col < 0
&& wp->w_buffer->b_p_tw >= INT_MIN - col
&& wp->w_buffer->b_p_tw + col <= INT_MAX));
col += (int)wp->w_buffer->b_p_tw;
if (col < 0)
goto skip;
} else if (ascii_isdigit(*s))
col = getdigits_int(&s);
else
return e_invarg;
color_cols[count++] = col - 1; /* 1-based to 0-based */
skip:
if (*s == NUL)
break;
if (*s != ',')
return e_invarg;
if (*++s == NUL)
return e_invarg; /* illegal trailing comma as in "set cc=80," */
}
xfree(wp->w_p_cc_cols);
if (count == 0)
wp->w_p_cc_cols = NULL;
else {
wp->w_p_cc_cols = xmalloc(sizeof(int) * (count + 1));
/* sort the columns for faster usage on screen redraw inside
* win_line() */
qsort(color_cols, count, sizeof(int), int_cmp);
for (unsigned int i = 0; i < count; ++i)
/* skip duplicates */
if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
wp->w_p_cc_cols[j++] = color_cols[i];
wp->w_p_cc_cols[j] = -1; /* end marker */
}
return NULL; /* no error */
}
|
CWE-20
| null | 517,302 |
135074137159898719037846446202594813789
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int opt_strings_flags(
char_u *val, /* new value */
char **values, /* array of valid string values */
unsigned *flagp,
bool list /* when TRUE: accept a list of values */
)
{
unsigned int new_flags = 0;
while (*val) {
for (unsigned int i = 0;; ++i) {
if (values[i] == NULL) /* val not found in values[] */
return FAIL;
size_t len = STRLEN(values[i]);
if (STRNCMP(values[i], val, len) == 0
&& ((list && val[len] == ',') || val[len] == NUL)) {
val += len + (val[len] == ',');
assert(i < sizeof(1U) * 8);
new_flags |= (1U << i);
break; /* check next item in val list */
}
}
}
if (flagp != NULL)
*flagp = new_flags;
return OK;
}
|
CWE-20
| null | 517,303 |
186028255225726315442261199059946916514
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
bool can_bs(int what)
{
switch (*p_bs) {
case '2': return TRUE;
case '1': return what != BS_START;
case '0': return FALSE;
}
return vim_strchr(p_bs, what) != NULL;
}
|
CWE-20
| null | 517,304 |
284501939181966987158122214931147994067
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
get_option_value (
char_u *name,
long *numval,
char_u **stringval, /* NULL when only checking existence */
int opt_flags
)
{
if (get_tty_option((char *)name, (char **)stringval)) {
return 0;
}
int opt_idx;
char_u *varp;
opt_idx = findoption(name);
if (opt_idx < 0) /* unknown option */
return -3;
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
if (options[opt_idx].flags & P_STRING) {
if (varp == NULL) /* hidden option */
return -2;
if (stringval != NULL) {
*stringval = vim_strsave(*(char_u **)(varp));
}
return 0;
}
if (varp == NULL) /* hidden option */
return -1;
if (options[opt_idx].flags & P_NUM)
*numval = *(long *)varp;
else {
/* Special case: 'modified' is b_changed, but we also want to consider
* it set when 'ff' or 'fenc' changed. */
if ((int *)varp == &curbuf->b_changed) {
*numval = curbufIsChanged();
} else {
*numval = *(int *)varp;
}
}
return 1;
}
|
CWE-20
| null | 517,305 |
98614209536222095218526185395447559649
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_WARN_UNUSED_RESULT
{
if (options[opt_idx].var == NULL) { // don't set hidden option
return NULL;
}
char *const s = xstrdup(value);
char **const varp = (char **)get_varp_scope(
&(options[opt_idx]),
((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
? (((int)options[opt_idx].indir & PV_BOTH)
? OPT_GLOBAL : OPT_LOCAL)
: opt_flags));
char *const oldval = *varp;
*varp = s;
char *const saved_oldval = (starting ? NULL : xstrdup(oldval));
char *const r = (char *)did_set_string_option(
opt_idx, (char_u **)varp, (int)true, (char_u *)oldval, NULL, opt_flags);
if (r == NULL) {
did_set_option(opt_idx, opt_flags, true);
}
// call autocommand after handling side effects
if (saved_oldval != NULL) {
char buf_type[7];
vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s",
(opt_flags & OPT_LOCAL) ? "local" : "global");
set_vim_var_string(VV_OPTION_NEW, (char *)(*varp), -1);
set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET,
(char_u *)options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars();
xfree(saved_oldval);
}
return r;
}
|
CWE-20
| null | 517,306 |
253372994468131554749193362127792487509
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int findoption_len(const char_u *const arg, const size_t len)
{
char *s, *p;
static int quick_tab[27] = { 0, 0 }; // quick access table
int is_term_opt;
/*
* For first call: Initialize the quick-access table.
* It contains the index for the first option that starts with a certain
* letter. There are 26 letters, plus the first "t_" option.
*/
if (quick_tab[1] == 0) {
p = options[0].fullname;
for (short int i = 1; (s = options[i].fullname) != NULL; i++) {
if (s[0] != p[0]) {
if (s[0] == 't' && s[1] == '_')
quick_tab[26] = i;
else
quick_tab[CharOrdLow(s[0])] = i;
}
p = s;
}
}
/*
* Check for name starting with an illegal character.
*/
if (len == 0 || arg[0] < 'a' || arg[0] > 'z') {
return -1;
}
int opt_idx;
is_term_opt = (len > 2 && arg[0] == 't' && arg[1] == '_');
if (is_term_opt) {
opt_idx = quick_tab[26];
} else {
opt_idx = quick_tab[CharOrdLow(arg[0])];
}
// Match full name
for (; (s = options[opt_idx].fullname) != NULL; opt_idx++) {
if (STRNCMP(arg, s, len) == 0 && s[len] == NUL) {
break;
}
}
if (s == NULL && !is_term_opt) {
opt_idx = quick_tab[CharOrdLow(arg[0])];
// Match short name
for (; options[opt_idx].fullname != NULL; opt_idx++) {
s = options[opt_idx].shortname;
if (s != NULL && STRNCMP(arg, s, len) == 0 && s[len] == NUL) {
break;
}
s = NULL;
}
}
if (s == NULL)
opt_idx = -1;
return opt_idx;
}
|
CWE-20
| null | 517,307 |
325897530923523976580371983037725805655
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
set_string_option_global (
int opt_idx, /* option index */
char_u **varp /* pointer to option variable */
)
{
char_u **p, *s;
/* the global value is always allocated */
if (options[opt_idx].var == VAR_WIN)
p = (char_u **)GLOBAL_WO(varp);
else
p = (char_u **)options[opt_idx].var;
if (options[opt_idx].indir != PV_NONE && p != varp) {
s = vim_strsave(*varp);
free_string_option(*p);
*p = s;
}
}
|
CWE-20
| null | 517,308 |
250656159236901469180068760706287363932
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
int get_sts_value(void)
{
long result = curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
assert(result >= 0 && result <= INT_MAX);
return (int)result;
}
|
CWE-20
| null | 517,309 |
176315444747834341745629510695925834059
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
void set_init_3(void)
{
// Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
// This is done after other initializations, where 'shell' might have been
// set, but only if they have not been set before.
int idx_srr;
int do_srr;
int idx_sp;
int do_sp;
idx_srr = findoption((char_u *)"srr");
if (idx_srr < 0)
do_srr = FALSE;
else
do_srr = !(options[idx_srr].flags & P_WAS_SET);
idx_sp = findoption((char_u *)"sp");
if (idx_sp < 0)
do_sp = FALSE;
else
do_sp = !(options[idx_sp].flags & P_WAS_SET);
size_t len = 0;
char_u *p = (char_u *)invocation_path_tail(p_sh, &len);
p = vim_strnsave(p, len);
{
/*
* Default for p_sp is "| tee", for p_srr is ">".
* For known shells it is changed here to include stderr.
*/
if ( fnamecmp(p, "csh") == 0
|| fnamecmp(p, "tcsh") == 0
) {
if (do_sp) {
p_sp = (char_u *)"|& tee";
options[idx_sp].def_val[VI_DEFAULT] = p_sp;
}
if (do_srr) {
p_srr = (char_u *)">&";
options[idx_srr].def_val[VI_DEFAULT] = p_srr;
}
} else if ( fnamecmp(p, "sh") == 0
|| fnamecmp(p, "ksh") == 0
|| fnamecmp(p, "mksh") == 0
|| fnamecmp(p, "pdksh") == 0
|| fnamecmp(p, "zsh") == 0
|| fnamecmp(p, "zsh-beta") == 0
|| fnamecmp(p, "bash") == 0
|| fnamecmp(p, "fish") == 0
) {
if (do_sp) {
p_sp = (char_u *)"2>&1| tee";
options[idx_sp].def_val[VI_DEFAULT] = p_sp;
}
if (do_srr) {
p_srr = (char_u *)">%s 2>&1";
options[idx_srr].def_val[VI_DEFAULT] = p_srr;
}
}
xfree(p);
}
if (bufempty()) {
int idx_ffs = findoption((char_u *)"ffs");
// Apply the first entry of 'fileformats' to the initial buffer.
if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) {
set_fileformat(default_fileformat(), OPT_LOCAL);
}
}
set_title_defaults();
}
|
CWE-20
| null | 517,310 |
4413132518242969069029655968294340484
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand)
{
char_u *s;
char_u *buf;
if (fprintf(fd, "%s %s=", cmd, name) < 0)
return FAIL;
if (*valuep != NULL) {
/* Output 'pastetoggle' as key names. For other
* options some characters have to be escaped with
* CTRL-V or backslash */
if (valuep == &p_pt) {
s = *valuep;
while (*s != NUL)
if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
return FAIL;
} else if (expand) {
buf = xmalloc(MAXPATHL);
home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
if (put_escstr(fd, buf, 2) == FAIL) {
xfree(buf);
return FAIL;
}
xfree(buf);
} else if (put_escstr(fd, *valuep, 2) == FAIL)
return FAIL;
}
if (put_eol(fd) < 0)
return FAIL;
return OK;
}
|
CWE-20
| null | 517,311 |
316435236916511867091635371460545408745
| null | null |
other
|
neovim
|
4fad66fbe637818b6b3d6bc5d21923ba72795040
| 0 |
static int wc_use_keyname(char_u *varp, long *wcp)
{
if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) {
*wcp = *(long *)varp;
if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
return TRUE;
}
return FALSE;
}
|
CWE-20
| null | 517,312 |
15686662932639488469029012724699216361
| null | null |
other
|
monit
|
f12d0cdb42d4e74dffe1525d4062c815c48ac57a
| 0 |
static char *is_str_defined(char *s) {
return((s && *s) ? s : "(not defined)");
}
|
CWE-125
| null | 517,460 |
45291388481540933630944411297586610412
| null | null |
other
|
monit
|
f12d0cdb42d4e74dffe1525d4062c815c48ac57a
| 0 |
static void printevents(unsigned int events) {
if (events == Event_Null) {
printf("No events");
} else if (events == Event_All) {
printf("All events");
} else {
if (IS_EVENT_SET(events, Event_Action))
printf("Action ");
if (IS_EVENT_SET(events, Event_ByteIn))
printf("ByteIn ");
if (IS_EVENT_SET(events, Event_ByteOut))
printf("ByteOut ");
if (IS_EVENT_SET(events, Event_Checksum))
printf("Checksum ");
if (IS_EVENT_SET(events, Event_Connection))
printf("Connection ");
if (IS_EVENT_SET(events, Event_Content))
printf("Content ");
if (IS_EVENT_SET(events, Event_Data))
printf("Data ");
if (IS_EVENT_SET(events, Event_Exec))
printf("Exec ");
if (IS_EVENT_SET(events, Event_Exist))
printf("Exist ");
if (IS_EVENT_SET(events, Event_FsFlag))
printf("Fsflags ");
if (IS_EVENT_SET(events, Event_Gid))
printf("Gid ");
if (IS_EVENT_SET(events, Event_Icmp))
printf("Icmp ");
if (IS_EVENT_SET(events, Event_Instance))
printf("Instance ");
if (IS_EVENT_SET(events, Event_Invalid))
printf("Invalid ");
if (IS_EVENT_SET(events, Event_Link))
printf("Link ");
if (IS_EVENT_SET(events, Event_NonExist))
printf("Nonexist ");
if (IS_EVENT_SET(events, Event_PacketIn))
printf("PacketIn ");
if (IS_EVENT_SET(events, Event_PacketOut))
printf("PacketOut ");
if (IS_EVENT_SET(events, Event_Permission))
printf("Permission ");
if (IS_EVENT_SET(events, Event_Pid))
printf("PID ");
if (IS_EVENT_SET(events, Event_PPid))
printf("PPID ");
if (IS_EVENT_SET(events, Event_Resource))
printf("Resource ");
if (IS_EVENT_SET(events, Event_Saturation))
printf("Saturation ");
if (IS_EVENT_SET(events, Event_Size))
printf("Size ");
if (IS_EVENT_SET(events, Event_Speed))
printf("Speed ");
if (IS_EVENT_SET(events, Event_Status))
printf("Status ");
if (IS_EVENT_SET(events, Event_Timeout))
printf("Timeout ");
if (IS_EVENT_SET(events, Event_Timestamp))
printf("Timestamp ");
if (IS_EVENT_SET(events, Event_Uid))
printf("Uid ");
if (IS_EVENT_SET(events, Event_Uptime))
printf("Uptime ");
}
printf("\n");
}
|
CWE-125
| null | 517,461 |
298056203837357212052055919374493830636
| null | null |
other
|
monit
|
f12d0cdb42d4e74dffe1525d4062c815c48ac57a
| 0 |
static char _x2c(char *hex) {
register char digit;
digit = ((hex[0] >= 'A') ? ((hex[0] & 0xdf) - 'A')+10 : (hex[0] - '0'));
digit *= 16;
digit += (hex[1] >= 'A' ? ((hex[1] & 0xdf) - 'A')+10 : (hex[1] - '0'));
return(digit);
}
|
CWE-125
| null | 517,462 |
138535708238441135113329058361494594059
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
ParseNodePtr Parser::CreateParamPatternNode(ParseNodePtr pnode1)
{
ParseNodePtr paramPatternNode = CreateNode(knopParamPattern, pnode1->ichMin, pnode1->ichLim);
paramPatternNode->sxParamPattern.pnode1 = pnode1;
paramPatternNode->sxParamPattern.pnodeNext = nullptr;
paramPatternNode->sxParamPattern.location = Js::Constants::NoRegister;
return paramPatternNode;
}
|
CWE-119
| null | 517,463 |
225630007716367296647862079416335293554
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
OpCode GetNop() const
{
AnalysisAssert(isDeferred || pnodeStmt != nullptr);
return isDeferred ? op : pnodeStmt->nop;
}
|
CWE-119
| null | 517,464 |
245664380751697014093799118160172458409
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
~AutoParsingSuperRestrictionStateRestorer()
{
AssertMsg(this->m_parser != nullptr, "This just should not happen");
this->m_parser->m_parsingSuperRestrictionState = m_originalParsingSuperRestrictionState;
}
|
CWE-119
| null | 517,465 |
247038118466503270814279383489237874074
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
ParseNodePtr Parser::ParseDestructuredArrayLiteral(tokens declarationType, bool isDecl, bool topLevel)
{
Assert(m_token.tk == tkLBrack);
charcount_t ichMin = m_pscan->IchMinTok();
m_pscan->Scan();
ParseNodePtr pnodeDestructArr = nullptr;
ParseNodePtr pnodeList = nullptr;
ParseNodePtr *lastNodeRef = nullptr;
uint count = 0;
bool hasMissingValues = false;
bool seenRest = false;
if (m_token.tk != tkRBrack)
{
while (true)
{
ParseNodePtr pnodeElem = ParseDestructuredVarDecl<buildAST>(declarationType, isDecl, &seenRest, topLevel);
if (buildAST)
{
if (pnodeElem == nullptr && buildAST)
{
pnodeElem = CreateNodeWithScanner<knopEmpty>();
hasMissingValues = true;
}
AddToNodeListEscapedUse(&pnodeList, &lastNodeRef, pnodeElem);
}
count++;
if (m_token.tk == tkRBrack)
{
break;
}
if (m_token.tk != tkComma)
{
Error(ERRDestructNoOper);
}
if (seenRest) // Rest must be in the last position.
{
Error(ERRDestructRestLast);
}
m_pscan->Scan();
// break if we have the trailing comma as well, eg. [a,]
if (m_token.tk == tkRBrack)
{
break;
}
}
}
if (buildAST)
{
pnodeDestructArr = CreateNodeWithScanner<knopArrayPattern>();
pnodeDestructArr->sxArrLit.pnode1 = pnodeList;
pnodeDestructArr->sxArrLit.arrayOfTaggedInts = false;
pnodeDestructArr->sxArrLit.arrayOfInts = false;
pnodeDestructArr->sxArrLit.arrayOfNumbers = false;
pnodeDestructArr->sxArrLit.hasMissingValues = hasMissingValues;
pnodeDestructArr->sxArrLit.count = count;
pnodeDestructArr->sxArrLit.spreadCount = seenRest ? 1 : 0;
pnodeDestructArr->ichMin = ichMin;
pnodeDestructArr->ichLim = m_pscan->IchLimTok();
if (pnodeDestructArr->sxArrLit.pnode1)
{
this->CheckArguments(pnodeDestructArr->sxArrLit.pnode1);
}
}
return pnodeDestructArr;
}
|
CWE-119
| null | 517,466 |
261011706115430737556882489940271029459
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
ParseNodePtr Parser::CreateTempNode(ParseNode* initExpr)
{
ParseNodePtr pnode = CreateNode(knopTemp, (charcount_t)0);
pnode->sxVar.pnodeInit =initExpr;
pnode->sxVar.pnodeNext = nullptr;
return pnode;
}
|
CWE-119
| null | 517,467 |
68554758967641883227246978796040420619
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
LPCOLESTR Parser::AppendNameHints(LPCOLESTR left, LPCOLESTR right, uint32 *pNameLength, uint32 *pShortNameOffset, bool ignoreAddDotWithSpace, bool wrapInBrackets)
{
uint32 leftLen = (left == nullptr) ? 0 : (uint32) wcslen(left);
uint32 rightLen = (right == nullptr) ? 0 : (uint32) wcslen(right);
if (pShortNameOffset != nullptr)
{
*pShortNameOffset = 0;
}
Assert(rightLen <= ULONG_MAX && leftLen <= ULONG_MAX); // name hints should not exceed ULONG_MAX characters
if (leftLen == 0 && !wrapInBrackets)
{
*pNameLength = right ? rightLen : 0;
return right;
}
if (rightLen == 0 && !wrapInBrackets)
{
*pNameLength = leftLen;
return left;
}
return AppendNameHints(left, leftLen, right, rightLen, pNameLength, pShortNameOffset, ignoreAddDotWithSpace, wrapInBrackets);
}
|
CWE-119
| null | 517,468 |
146238286897340201197183767229751594479
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
void Parser::TrackAssignment(ParseNodePtr pnodeT, IdentToken* pToken)
{
if (buildAST)
{
Assert(pnodeT != nullptr);
if (pnodeT->nop == knopName)
{
PidRefStack *ref = pnodeT->sxPid.pid->GetTopRef();
Assert(ref);
ref->isAsg = true;
}
}
else
{
Assert(pToken != nullptr);
if (pToken->tk == tkID)
{
PidRefStack *ref = pToken->pid->GetTopRef();
Assert(ref);
ref->isAsg = true;
}
}
}
|
CWE-119
| null | 517,469 |
157640755010637157983562353327079691445
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
inline bool Parser::IsNaNOrInfinityLiteral(LPCOLESTR str)
{
// Note: wcscmp crashes when one of the parameters is NULL.
return str &&
(wcscmp(_u("NaN"), str) == 0 ||
wcscmp(_u("Infinity"), str) == 0 ||
(CheckForNegativeInfinity && wcscmp(_u("-Infinity"), str) == 0));
}
|
CWE-119
| null | 517,470 |
305437978791579272918645795839453249873
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
IdentPtrList* Parser::EnsureRequestedModulesList()
{
if (m_currentNodeProg->sxModule.requestedModules == nullptr)
{
m_currentNodeProg->sxModule.requestedModules = Anew(&m_nodeAllocator, IdentPtrList, &m_nodeAllocator);
}
return m_currentNodeProg->sxModule.requestedModules;
}
|
CWE-119
| null | 517,471 |
316799453167396906386515760939383024303
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
Parser::CreateCallNode(OpCode nop, ParseNodePtr pnode1, ParseNodePtr pnode2,charcount_t ichMin,charcount_t ichLim)
{
Assert(!this->m_deferringAST);
DebugOnly(VerifyNodeSize(nop, kcbPnCall));
ParseNodePtr pnode = (ParseNodePtr)m_nodeAllocator.Alloc(kcbPnCall);
Assert(m_pCurrentAstSize != nullptr);
*m_pCurrentAstSize += kcbPnCall;
InitNode(nop, pnode);
pnode->sxCall.pnodeTarget = pnode1;
pnode->sxCall.pnodeArgs = pnode2;
pnode->sxCall.argCount = 0;
pnode->sxCall.spreadArgCount = 0;
pnode->sxCall.callOfConstants = false;
pnode->sxCall.isApplyCall = false;
pnode->sxCall.isEvalCall = false;
pnode->ichMin = ichMin;
pnode->ichLim = ichLim;
return pnode;
}
|
CWE-119
| null | 517,472 |
314830900732106569214974774930096403110
| null | null |
other
|
ChakraCore
|
402f3d967c0a905ec5b9ca9c240783d3f2c15724
| 0 |
void Parser::CheckStrictFormalParameters()
{
if (m_token.tk == tkID)
{
// single parameter arrow function case
IdentPtr pid = m_token.GetIdentifier(m_phtbl);
CheckStrictModeEvalArgumentsUsage(pid);
return;
}
Assert(m_token.tk == tkLParen);
m_pscan->ScanForcingPid();
if (m_token.tk != tkRParen)
{
SList<IdentPtr> formals(&m_nodeAllocator);
for (;;)
{
if (m_token.tk != tkID)
{
IdentifierExpectedError(m_token);
}
IdentPtr pid = m_token.GetIdentifier(m_phtbl);
CheckStrictModeEvalArgumentsUsage(pid);
if (formals.Has(pid))
{
Error(ERRES5ArgSame, m_pscan->IchMinTok(), m_pscan->IchLimTok());
}
else
{
formals.Prepend(pid);
}
m_pscan->Scan();
if (m_token.tk == tkAsg && m_scriptContext->GetConfig()->IsES6DefaultArgsEnabled())
{
m_pscan->Scan();
// We can avoid building the AST since we are just checking the default expression.
ParseNodePtr pnodeInit = ParseExpr<false>(koplCma);
Assert(pnodeInit == nullptr);
}
if (m_token.tk != tkComma)
{
break;
}
m_pscan->ScanForcingPid();
if (m_token.tk == tkRParen && m_scriptContext->GetConfig()->IsES7TrailingCommaEnabled())
{
break;
}
}
}
Assert(m_token.tk == tkRParen);
}
|
CWE-119
| null | 517,473 |
206158671604056240074032666534150018294
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.