mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
Improve coding style
This commit is contained in:
@@ -21250,9 +21250,8 @@ void ex_oldfiles(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
|
||||
/* reset v:option_new, v:option_old and v:option_type */
|
||||
void
|
||||
reset_v_option_vars(void)
|
||||
// reset v:option_new, v:option_old and v:option_type
|
||||
void reset_v_option_vars(void)
|
||||
{
|
||||
set_vim_var_string(VV_OPTION_NEW, NULL, -1);
|
||||
set_vim_var_string(VV_OPTION_OLD, NULL, -1);
|
||||
|
@@ -1511,7 +1511,7 @@ do_set (
|
||||
} 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 *oldval = NULL; // previous value if *varp
|
||||
char_u *newval;
|
||||
char_u *origval = NULL;
|
||||
char_u *saved_origval = NULL;
|
||||
@@ -1781,10 +1781,11 @@ do_set (
|
||||
/* Set the new value. */
|
||||
*(char_u **)(varp) = newval;
|
||||
|
||||
if (!starting && origval != NULL)
|
||||
/* origval may be freed by
|
||||
* did_set_string_option(), make a copy. */
|
||||
if (!starting && origval != NULL) {
|
||||
// origval may be freed by
|
||||
// did_set_string_option(), make a copy.
|
||||
saved_origval = vim_strsave(origval);
|
||||
}
|
||||
|
||||
/* Handle side effects, and set the global value for
|
||||
* ":set" on local options. */
|
||||
@@ -1798,14 +1799,14 @@ do_set (
|
||||
char_u buf_type[7];
|
||||
|
||||
sprintf((char *)buf_type, "%s",
|
||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||
set_vim_var_string(VV_OPTION_NEW,
|
||||
*(char_u **)varp, -1);
|
||||
*(char_u **)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);
|
||||
(char_u *)options[opt_idx].fullname,
|
||||
NULL, FALSE, NULL);
|
||||
reset_v_option_vars();
|
||||
xfree(saved_origval);
|
||||
}
|
||||
@@ -2373,22 +2374,25 @@ set_string_option (
|
||||
oldval = *varp;
|
||||
*varp = s;
|
||||
|
||||
if (!starting)
|
||||
saved_oldval = vim_strsave(oldval);
|
||||
if (!starting) {
|
||||
saved_oldval = vim_strsave(oldval);
|
||||
}
|
||||
|
||||
if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
|
||||
opt_flags)) == NULL)
|
||||
did_set_option(opt_idx, opt_flags, TRUE);
|
||||
|
||||
/* call autocommand after handling side effects */
|
||||
// call autocommand after handling side effects
|
||||
if (saved_oldval != NULL) {
|
||||
char_u buf_type[7];
|
||||
sprintf((char *)buf_type, "%s",
|
||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||
(opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||
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_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();
|
||||
xfree(saved_oldval);
|
||||
}
|
||||
@@ -3861,19 +3865,22 @@ set_bool_option (
|
||||
* 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;
|
||||
|
||||
if (!starting) {
|
||||
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_new, 2, "%d", value ? TRUE: FALSE);
|
||||
vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
|
||||
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_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_OLD, buf_old, -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();
|
||||
}
|
||||
|
||||
@@ -4252,11 +4259,14 @@ set_num_option (
|
||||
char_u buf_old[11], buf_new[11], buf_type[7];
|
||||
vim_snprintf((char *)buf_old, 10, "%ld", old_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_OLD, buf_old, -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user