Mercurial > vim
diff src/option.c @ 4513:cadb57fbb781 v7.3.1004
updated for version 7.3.1004
Problem: No error when option could not be set.
Solution: Report an error. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 21 May 2013 22:38:18 +0200 |
parents | ccecb03e5e8b |
children | 3f2319a953b3 |
line wrap: on
line diff
--- a/src/option.c +++ b/src/option.c @@ -3018,7 +3018,7 @@ static long_u *insecure_flag __ARGS((int # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) #endif static void set_string_option_global __ARGS((int opt_idx, char_u **varp)); -static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags)); +static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags)); static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags)); static char_u *set_chars_option __ARGS((char_u **varp)); #ifdef FEAT_SYN_HL @@ -5600,8 +5600,10 @@ set_string_option_global(opt_idx, varp) /* * Set a string option to a new value, and handle the effects. - */ - static void + * + * Returns NULL on success or error message on error. + */ + static char_u * set_string_option(opt_idx, value, opt_flags) int opt_idx; char_u *value; @@ -5610,9 +5612,10 @@ set_string_option(opt_idx, value, opt_fl char_u *s; char_u **varp; char_u *oldval; + char_u *r = NULL; if (options[opt_idx].var == NULL) /* don't set hidden option */ - return; + return NULL; s = vim_strsave(value); if (s != NULL) @@ -5624,10 +5627,11 @@ set_string_option(opt_idx, value, opt_fl : opt_flags); oldval = *varp; *varp = s; - if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, - opt_flags) == NULL) + if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, + opt_flags)) == NULL) did_set_option(opt_idx, opt_flags, TRUE); } + return r; } /* @@ -8969,8 +8973,10 @@ get_option_value_strict(name, numval, st /* * Set the value of option "name". * Use "string" for string options, use "number" for other options. - */ - void + * + * Returns NULL on success or error message on error. + */ + char_u * set_option_value(name, number, string, opt_flags) char_u *name; long number; @@ -8992,11 +8998,11 @@ set_option_value(name, number, string, o if (sandbox > 0 && (flags & P_SECURE)) { EMSG(_(e_sandbox)); - return; + return NULL; } #endif if (flags & P_STRING) - set_string_option(opt_idx, string, opt_flags); + return set_string_option(opt_idx, string, opt_flags); else { varp = get_varp_scope(&(options[opt_idx]), opt_flags); @@ -9017,19 +9023,20 @@ set_option_value(name, number, string, o * num option using a string. */ EMSG3(_("E521: Number required: &%s = '%s'"), name, string); - return; /* do nothing as we hit an error */ + return NULL; /* do nothing as we hit an error */ } } if (flags & P_NUM) - (void)set_num_option(opt_idx, varp, number, + return set_num_option(opt_idx, varp, number, NULL, 0, opt_flags); else - (void)set_bool_option(opt_idx, varp, (int)number, + return set_bool_option(opt_idx, varp, (int)number, opt_flags); } } } + return NULL; } /*