From 119545190c1ec35e1c7b482f593b98d0fc485b6f Mon Sep 17 00:00:00 2001 From: watiko Date: Fri, 27 Nov 2015 23:56:52 +0900 Subject: vim-patch:7.4.786 Problem: It is not possible for a plugin to adjust to a changed setting. Solution: Add the OptionSet autocommand event. (Christian Brabandt) https://github.com/vim/vim/commit/537443018d41918639695a442c91b34ccec69fc3 --- src/nvim/option.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 8b4aab88a3..20f005eba9 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1511,9 +1511,10 @@ do_set ( } else if (opt_idx >= 0) { /* string */ char_u *save_arg = NULL; char_u *s = NULL; - char_u *oldval; /* previous value if *varp */ + char_u *oldval = NULL; /* previous value if *varp */ char_u *newval; - char_u *origval; + char_u *origval = NULL; + char_u *saved_origval = NULL; unsigned newlen; int comma; int bs; @@ -1780,6 +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. */ + saved_origval = vim_strsave(origval); + /* Handle side effects, and set the global value for * ":set" on local options. */ errmsg = did_set_string_option(opt_idx, (char_u **)varp, @@ -1788,6 +1794,20 @@ do_set ( /* If error detected, print the error message. */ if (errmsg != NULL) goto skip; + if (saved_origval != NULL) { + char_u buf_type[7]; + + sprintf((char *)buf_type, "%s", + (opt_flags & OPT_LOCAL) ? "local" : "global"); + set_vim_var_string(VV_OPTION_NEW, newval, -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) @@ -2337,6 +2357,7 @@ set_string_option ( char_u *s; char_u **varp; char_u *oldval; + char_u *saved_oldval = NULL; char_u *r = NULL; if (options[opt_idx].var == NULL) /* don't set hidden option */ @@ -2350,10 +2371,27 @@ set_string_option ( : opt_flags); oldval = *varp; *varp = s; + + 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 */ + if (saved_oldval != NULL) { + char_u buf_type[7]; + sprintf((char *)buf_type, "%s", + (opt_flags & OPT_LOCAL) ? "local" : "global"); + set_vim_var_string(VV_OPTION_NEW, s, -1); + set_vim_var_string(VV_OPTION_OLD, 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; } @@ -3822,8 +3860,22 @@ set_bool_option ( * End of handling side effects for bool options. */ + /* 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]; + snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); + snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); + sprintf((char *)buf_type, "%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); + reset_v_option_vars(); + } + comp_col(); /* in case 'ruler' or 'showcmd' changed */ if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) @@ -4195,6 +4247,18 @@ set_num_option ( options[opt_idx].flags |= P_WAS_SET; + if (!starting && errmsg == NULL) { + char_u buf_old[11], buf_new[11], buf_type[7]; + snprintf((char *)buf_old, 10, "%ld", old_value); + snprintf((char *)buf_new, 10, "%ld", value); + 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); + reset_v_option_vars(); + } + comp_col(); /* in case 'columns' or 'ls' changed */ if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) -- cgit From 789041c2829d8abb96a0f5f7a844632052a1a448 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 28 Nov 2015 01:24:01 +0900 Subject: vim-patch:7.4.787 Problem: snprintf() isn't available everywhere. Solution: Use vim_snprintf(). (Ken Takata) https://github.com/vim/vim/commit/fb9bc4829a1442fc8e93f078c9f923c9d382dbd2 --- src/nvim/option.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 20f005eba9..87b213818c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3866,9 +3866,9 @@ set_bool_option ( if (!starting) { char_u buf_old[2], buf_new[2], buf_type[7]; - snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); - snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); - sprintf((char *)buf_type, "%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); @@ -4249,9 +4249,9 @@ set_num_option ( if (!starting && errmsg == NULL) { char_u buf_old[11], buf_new[11], buf_type[7]; - snprintf((char *)buf_old, 10, "%ld", old_value); - snprintf((char *)buf_new, 10, "%ld", value); - snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); + 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"); 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); -- cgit From 09f6066bb48150566ba7f1f44ae4148deb0e02c0 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 28 Nov 2015 01:31:00 +0900 Subject: vim-patch:7.4.789 Problem: Using freed memory and crash. (Dominique Pellej) Solution: Correct use of pointers. (Hirohito Higashi) https://github.com/vim/vim/commit/9cac424d05c0e79cd621f1b9f2f01a9f459fcbe6 --- src/nvim/option.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 87b213818c..84b953e592 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1799,7 +1799,8 @@ do_set ( sprintf((char *)buf_type, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); - set_vim_var_string(VV_OPTION_NEW, newval, -1); + set_vim_var_string(VV_OPTION_NEW, + *(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, @@ -2384,8 +2385,8 @@ set_string_option ( char_u buf_type[7]; sprintf((char *)buf_type, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); - set_vim_var_string(VV_OPTION_NEW, s, -1); - set_vim_var_string(VV_OPTION_OLD, oldval, -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_TYPE, buf_type, -1); apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL); reset_v_option_vars(); -- cgit From cf673f60c64e82528207e636b7a04e7ed3610f77 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 28 Nov 2015 18:19:40 +0900 Subject: Improve coding style --- src/nvim/option.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 84b953e592..a3da057374 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -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(); } -- cgit From 972b43459b22d5500cbb8f0004f45d8bdfacecf8 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 28 Nov 2015 19:48:17 +0900 Subject: Improve coding style --- src/nvim/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index a3da057374..6ec0d4a095 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1806,7 +1806,7 @@ do_set ( set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, - NULL, FALSE, NULL); + NULL, false, NULL); reset_v_option_vars(); xfree(saved_origval); } -- cgit From 597547e7977c6c9404ec4d730bfc02584c9f1564 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 28 Nov 2015 20:14:49 +0900 Subject: Use vim_snprintf instead of sprintf --- src/nvim/option.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 6ec0d4a095..3e74d4d23c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1798,8 +1798,8 @@ do_set ( if (saved_origval != NULL) { char_u buf_type[7]; - sprintf((char *)buf_type, "%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, *(char_u **)varp, -1); set_vim_var_string(VV_OPTION_OLD, saved_origval, -1); @@ -2385,8 +2385,8 @@ set_string_option ( // 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"); + vim_snprintf((char *)buf_type, 7, "%s", + (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); -- cgit From 3a60f927b818bd870d184407859fb85c140a3aa0 Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 1 Dec 2015 23:35:37 +0900 Subject: Improve coding style --- src/nvim/option.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 3e74d4d23c..878bc33c6d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1796,9 +1796,8 @@ do_set ( if (errmsg != NULL) goto skip; if (saved_origval != NULL) { - char_u buf_type[7]; - - vim_snprintf((char *)buf_type, 7, "%s", + 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_u **)varp, -1); @@ -2384,8 +2383,8 @@ set_string_option ( // call autocommand after handling side effects if (saved_oldval != NULL) { - char_u buf_type[7]; - vim_snprintf((char *)buf_type, 7, "%s", + 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, *varp, -1); set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1); @@ -3870,10 +3869,14 @@ set_bool_option ( 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", + char buf_old[2]; + char buf_new[2]; + char buf_type[7]; + vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%d", + old_value ? true: false); + vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%d", + value ? true: false); + vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%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); @@ -4256,10 +4259,12 @@ set_num_option ( options[opt_idx].flags |= P_WAS_SET; if (!starting && errmsg == NULL) { - 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", + char buf_old[NUMBUFLEN]; + char buf_new[NUMBUFLEN]; + char buf_type[7]; + vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%ld", old_value); + vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%ld", value); + vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%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); -- cgit From 8c684b2fdb58487a40968a2fee996bb70e911d56 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 12 Dec 2015 04:17:39 +0900 Subject: Revert char to char_u --- src/nvim/option.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 878bc33c6d..1db8831941 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1796,8 +1796,8 @@ do_set ( if (errmsg != NULL) goto skip; if (saved_origval != NULL) { - char buf_type[7]; - vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", + char_u buf_type[7]; + vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); set_vim_var_string(VV_OPTION_NEW, *(char_u **)varp, -1); @@ -2383,8 +2383,8 @@ set_string_option ( // call autocommand after handling side effects if (saved_oldval != NULL) { - char buf_type[7]; - vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", + char_u buf_type[7]; + vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s", (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); @@ -3869,14 +3869,14 @@ set_bool_option ( options[opt_idx].flags |= P_WAS_SET; if (!starting) { - char buf_old[2]; - char buf_new[2]; - char buf_type[7]; - vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%d", + char_u buf_old[2]; + char_u buf_new[2]; + char_u buf_type[7]; + vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%d", old_value ? true: false); - vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%d", + vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%d", value ? true: false); - vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", + vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%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); @@ -4259,12 +4259,12 @@ set_num_option ( options[opt_idx].flags |= P_WAS_SET; if (!starting && errmsg == NULL) { - char buf_old[NUMBUFLEN]; - char buf_new[NUMBUFLEN]; - char buf_type[7]; - vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%ld", old_value); - vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%ld", value); - vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", + char_u buf_old[NUMBUFLEN]; + char_u buf_new[NUMBUFLEN]; + char_u buf_type[7]; + vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%ld", old_value); + vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%ld", value); + vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%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); -- cgit From 74341ca5cacfcd254aee49fa2ed130ed7ffb5071 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 12 Dec 2015 05:28:27 +0900 Subject: Fix the memory leaking --- src/nvim/option.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index 1db8831941..ff140bd221 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1792,9 +1792,12 @@ do_set ( 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) + // If error detected, print the error message. + if (errmsg != NULL) { + xfree(saved_origval); goto skip; + } + if (saved_origval != NULL) { char_u buf_type[7]; vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s", -- cgit From 1b56425662068a40cf3a19cd47ac79d7511840b5 Mon Sep 17 00:00:00 2001 From: watiko Date: Sat, 12 Dec 2015 05:58:21 +0900 Subject: Make clint status valid --- src/nvim/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/option.c') diff --git a/src/nvim/option.c b/src/nvim/option.c index ff140bd221..60c415f297 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2380,7 +2380,7 @@ set_string_option ( 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, (int)true, oldval, NULL, opt_flags)) == NULL) did_set_option(opt_idx, opt_flags, TRUE); -- cgit