Improve coding style

This commit is contained in:
watiko
2015-11-28 18:19:40 +09:00
parent d9c0293824
commit cf673f60c6
2 changed files with 32 additions and 23 deletions

View File

@@ -21250,9 +21250,8 @@ void ex_oldfiles(exarg_T *eap)
} }
} }
/* reset v:option_new, v:option_old and v:option_type */ // reset v:option_new, v:option_old and v:option_type
void void reset_v_option_vars(void)
reset_v_option_vars(void)
{ {
set_vim_var_string(VV_OPTION_NEW, NULL, -1); set_vim_var_string(VV_OPTION_NEW, NULL, -1);
set_vim_var_string(VV_OPTION_OLD, NULL, -1); set_vim_var_string(VV_OPTION_OLD, NULL, -1);

View File

@@ -1511,7 +1511,7 @@ do_set (
} else if (opt_idx >= 0) { /* string */ } else if (opt_idx >= 0) { /* string */
char_u *save_arg = NULL; char_u *save_arg = NULL;
char_u *s = NULL; char_u *s = NULL;
char_u *oldval = NULL; /* previous value if *varp */ char_u *oldval = NULL; // previous value if *varp
char_u *newval; char_u *newval;
char_u *origval = NULL; char_u *origval = NULL;
char_u *saved_origval = NULL; char_u *saved_origval = NULL;
@@ -1781,10 +1781,11 @@ do_set (
/* Set the new value. */ /* Set the new value. */
*(char_u **)(varp) = newval; *(char_u **)(varp) = newval;
if (!starting && origval != NULL) if (!starting && origval != NULL) {
/* origval may be freed by // origval may be freed by
* did_set_string_option(), make a copy. */ // did_set_string_option(), make a copy.
saved_origval = vim_strsave(origval); saved_origval = vim_strsave(origval);
}
/* Handle side effects, and set the global value for /* Handle side effects, and set the global value for
* ":set" on local options. */ * ":set" on local options. */
@@ -2373,14 +2374,15 @@ set_string_option (
oldval = *varp; oldval = *varp;
*varp = s; *varp = s;
if (!starting) if (!starting) {
saved_oldval = vim_strsave(oldval); saved_oldval = vim_strsave(oldval);
}
if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
opt_flags)) == NULL) opt_flags)) == NULL)
did_set_option(opt_idx, opt_flags, TRUE); did_set_option(opt_idx, opt_flags, TRUE);
/* call autocommand after handling side effects */ // call autocommand after handling side effects
if (saved_oldval != NULL) { if (saved_oldval != NULL) {
char_u buf_type[7]; char_u buf_type[7];
sprintf((char *)buf_type, "%s", sprintf((char *)buf_type, "%s",
@@ -2388,7 +2390,9 @@ set_string_option (
set_vim_var_string(VV_OPTION_NEW, *varp, -1); set_vim_var_string(VV_OPTION_NEW, *varp, -1);
set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1); set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL); apply_autocmds(EVENT_OPTIONSET,
(char_u *)options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars(); reset_v_option_vars();
xfree(saved_oldval); xfree(saved_oldval);
} }
@@ -3861,19 +3865,22 @@ set_bool_option (
* End of handling side effects for bool options. * End of handling side effects for bool options.
*/ */
/* after handling side effects, call autocommand */ // after handling side effects, call autocommand
options[opt_idx].flags |= P_WAS_SET; options[opt_idx].flags |= P_WAS_SET;
if (!starting) { if (!starting) {
char_u buf_old[2], buf_new[2], buf_type[7]; char_u buf_old[2], buf_new[2], buf_type[7];
vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); vim_snprintf((char *)buf_old, 2, "%d", old_value ? true: false);
vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); vim_snprintf((char *)buf_new, 2, "%d", value ? true: false);
vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); vim_snprintf((char *)buf_type, 7, "%s",
(opt_flags & OPT_LOCAL) ? "local" : "global");
set_vim_var_string(VV_OPTION_NEW, buf_new, -1); set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
set_vim_var_string(VV_OPTION_OLD, buf_old, -1); set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL); apply_autocmds(EVENT_OPTIONSET,
(char_u *) options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars(); reset_v_option_vars();
} }
@@ -4252,11 +4259,14 @@ set_num_option (
char_u buf_old[11], buf_new[11], buf_type[7]; char_u buf_old[11], buf_new[11], buf_type[7];
vim_snprintf((char *)buf_old, 10, "%ld", old_value); vim_snprintf((char *)buf_old, 10, "%ld", old_value);
vim_snprintf((char *)buf_new, 10, "%ld", value); vim_snprintf((char *)buf_new, 10, "%ld", value);
vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); vim_snprintf((char *)buf_type, 7, "%s",
(opt_flags & OPT_LOCAL) ? "local" : "global");
set_vim_var_string(VV_OPTION_NEW, buf_new, -1); set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
set_vim_var_string(VV_OPTION_OLD, buf_old, -1); set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL); apply_autocmds(EVENT_OPTIONSET,
(char_u *) options[opt_idx].fullname,
NULL, false, NULL);
reset_v_option_vars(); reset_v_option_vars();
} }