aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index d52b9ebf7a..3d596f81cc 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1989,7 +1989,7 @@ void set_init_1(void)
char_u *save_enc;
/* Try setting 'encoding' and check if the value is valid.
- * If not, go back to the default "latin1". */
+ * If not, go back to the default "utf-8". */
save_enc = p_enc;
p_enc = p;
if (STRCMP(p_enc, "gb18030") == 0) {
@@ -2029,8 +2029,13 @@ void set_init_1(void)
} else {
free(p_enc);
+ // mb_init() failed; fallback to utf8 and try again.
p_enc = save_enc;
+ mb_init();
}
+ } else {
+ // enc_locale() failed; initialize the default (utf8).
+ mb_init();
}
/* Set the default for 'helplang'. */
@@ -2525,13 +2530,11 @@ do_set (
goto skip;
}
-#ifdef HAVE_SANDBOX
/* Disallow changing some options in the sandbox */
if (sandbox != 0 && (flags & P_SECURE)) {
errmsg = (char_u *)_(e_sandbox);
goto skip;
}
-#endif
if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) {
arg += len;
@@ -3066,9 +3069,7 @@ did_set_option (
* flag. */
uint32_t *p = insecure_flag(opt_idx, opt_flags);
if (secure
-#ifdef HAVE_SANDBOX
|| sandbox != 0
-#endif
|| (opt_flags & OPT_MODELINE))
*p = *p | P_INSECURE;
else if (new_value)
@@ -3577,11 +3578,8 @@ did_set_string_option (
gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
/* Disallow changing some options from secure mode */
- if ((secure
-#ifdef HAVE_SANDBOX
- || sandbox != 0
-#endif
- ) && (options[opt_idx].flags & P_SECURE)) {
+ 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
@@ -4697,12 +4695,10 @@ set_bool_option (
int old_value = *(int *)varp;
/* Disallow changing some options from secure mode */
- if ((secure
-#ifdef HAVE_SANDBOX
- || sandbox != 0
-#endif
- ) && (options[opt_idx].flags & P_SECURE))
+ if ((secure || sandbox != 0)
+ && (options[opt_idx].flags & P_SECURE)) {
return e_secure;
+ }
*(int *)varp = value; /* set the new value */
/* Remember where the option was set. */
@@ -5064,12 +5060,10 @@ set_num_option (
long *pp = (long *)varp;
/* Disallow changing some options from secure mode. */
- if ((secure
-#ifdef HAVE_SANDBOX
- || sandbox != 0
-#endif
- ) && (options[opt_idx].flags & P_SECURE))
+ if ((secure || sandbox != 0)
+ && (options[opt_idx].flags & P_SECURE)) {
return e_secure;
+ }
*pp = value;
/* Remember where the option was set. */
@@ -5755,13 +5749,11 @@ set_option_value (
EMSG2(_("E355: Unknown option: %s"), name);
else {
uint32_t flags = options[opt_idx].flags;
-#ifdef HAVE_SANDBOX
- /* Disallow changing some options in the sandbox */
+ // Disallow changing some options in the sandbox
if (sandbox > 0 && (flags & P_SECURE)) {
EMSG(_(e_sandbox));
return NULL;
}
-#endif
if (flags & P_STRING)
return set_string_option(opt_idx, string, opt_flags);
else {