Skip to content

Commit f678273

Browse files
zeertzjqbrammool
authored andcommitted
patch 9.0.0096: flag "new_value_alloced" is always true
Problem: Flag "new_value_alloced" is always true. Solution: Remove "new_value_alloced". (closes #10792)
1 parent 122dea7 commit f678273

4 files changed

Lines changed: 14 additions & 35 deletions

File tree

src/option.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,8 +1716,6 @@ do_set(
17161716
#endif
17171717
unsigned newlen;
17181718
int comma;
1719-
int new_value_alloced; // new string option
1720-
// was allocated
17211719

17221720
// When using ":set opt=val" for a global option
17231721
// with a local value the local value will be
@@ -1785,13 +1783,11 @@ do_set(
17851783
s = newval;
17861784
newval = vim_strsave(s);
17871785
}
1788-
new_value_alloced = TRUE;
17891786
}
17901787
else if (nextchar == '<') // set to global val
17911788
{
17921789
newval = vim_strsave(*(char_u **)get_varp_scope(
17931790
&(options[opt_idx]), OPT_GLOBAL));
1794-
new_value_alloced = TRUE;
17951791
}
17961792
else
17971793
{
@@ -2060,7 +2056,6 @@ do_set(
20602056

20612057
if (save_arg != NULL) // number for 'whichwrap'
20622058
arg = save_arg;
2063-
new_value_alloced = TRUE;
20642059
}
20652060

20662061
/*
@@ -2109,8 +2104,7 @@ do_set(
21092104
// 'syntax' or 'filetype' autocommands may be
21102105
// triggered that can cause havoc.
21112106
errmsg = did_set_string_option(
2112-
opt_idx, (char_u **)varp,
2113-
new_value_alloced, oldval, errbuf,
2107+
opt_idx, (char_u **)varp, oldval, errbuf,
21142108
opt_flags, &value_checked);
21152109

21162110
secure = secure_saved;

src/optionstr.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ set_string_option(
537537
saved_newval = vim_strsave(s);
538538
}
539539
#endif
540-
if ((errmsg = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
540+
if ((errmsg = did_set_string_option(opt_idx, varp, oldval, NULL,
541541
opt_flags, &value_checked)) == NULL)
542542
did_set_option(opt_idx, opt_flags, TRUE, value_checked);
543543

@@ -639,13 +639,13 @@ check_stl_option(char_u *s)
639639

640640
/*
641641
* Handle string options that need some action to perform when changed.
642+
* The new value must be allocated.
642643
* Returns NULL for success, or an unstranslated error message for an error.
643644
*/
644645
char *
645646
did_set_string_option(
646647
int opt_idx, // index in options[] table
647648
char_u **varp, // pointer to the option variable
648-
int new_value_alloced, // new value was allocated
649649
char_u *oldval, // previous value of the option
650650
char *errbuf, // buffer for errors, or NULL
651651
int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
@@ -1188,10 +1188,8 @@ did_set_string_option(
11881188
// When setting the global value to empty, make it "zip".
11891189
if (*p_cm == NUL)
11901190
{
1191-
if (new_value_alloced)
1192-
free_string_option(p_cm);
1191+
free_string_option(p_cm);
11931192
p_cm = vim_strsave((char_u *)"zip");
1194-
new_value_alloced = TRUE;
11951193
}
11961194
// When using ":set cm=name" the local value is going to be empty.
11971195
// Do that here, otherwise the crypt functions will still use the
@@ -1441,8 +1439,7 @@ did_set_string_option(
14411439
t_colors = colors;
14421440
if (t_colors <= 1)
14431441
{
1444-
if (new_value_alloced)
1445-
vim_free(T_CCO);
1442+
vim_free(T_CCO);
14461443
T_CCO = empty_option;
14471444
}
14481445
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
@@ -1511,12 +1508,8 @@ did_set_string_option(
15111508
if (STRCMP(p, "*") == 0)
15121509
{
15131510
p = gui_mch_font_dialog(oldval);
1514-
1515-
if (new_value_alloced)
1516-
free_string_option(p_guifont);
1517-
1511+
free_string_option(p_guifont);
15181512
p_guifont = (p != NULL) ? p : vim_strsave(oldval);
1519-
new_value_alloced = TRUE;
15201513
}
15211514
# endif
15221515
if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
@@ -1526,10 +1519,8 @@ did_set_string_option(
15261519
{
15271520
// Dialog was cancelled: Keep the old value without giving
15281521
// an error message.
1529-
if (new_value_alloced)
1530-
free_string_option(p_guifont);
1522+
free_string_option(p_guifont);
15311523
p_guifont = vim_strsave(oldval);
1532-
new_value_alloced = TRUE;
15331524
}
15341525
else
15351526
# endif
@@ -1950,10 +1941,8 @@ did_set_string_option(
19501941
REPTERM_FROM_PART | REPTERM_DO_LT, NULL);
19511942
if (p != NULL)
19521943
{
1953-
if (new_value_alloced)
1954-
free_string_option(p_pt);
1944+
free_string_option(p_pt);
19551945
p_pt = p;
1956-
new_value_alloced = TRUE;
19571946
}
19581947
}
19591948
}
@@ -2369,10 +2358,8 @@ did_set_string_option(
23692358
name = get_scriptlocal_funcname(*p_opt);
23702359
if (name != NULL)
23712360
{
2372-
if (new_value_alloced)
2373-
free_string_option(*p_opt);
2361+
free_string_option(*p_opt);
23742362
*p_opt = name;
2375-
new_value_alloced = TRUE;
23762363
}
23772364
}
23782365

@@ -2486,8 +2473,7 @@ did_set_string_option(
24862473
// If error detected, restore the previous value.
24872474
if (errmsg != NULL)
24882475
{
2489-
if (new_value_alloced)
2490-
free_string_option(*varp);
2476+
free_string_option(*varp);
24912477
*varp = oldval;
24922478
// When resetting some values, need to act on it.
24932479
if (did_chartab)
@@ -2506,10 +2492,7 @@ did_set_string_option(
25062492
// our fingers (esp. init_highlight()).
25072493
if (free_oldval)
25082494
free_string_option(oldval);
2509-
if (new_value_alloced)
2510-
set_option_flag(opt_idx, P_ALLOCED);
2511-
else
2512-
clear_option_flag(opt_idx, P_ALLOCED);
2495+
set_option_flag(opt_idx, P_ALLOCED);
25132496

25142497
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
25152498
&& is_global_local_option(opt_idx))

src/proto/optionstr.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ void set_string_option_direct(char_u *name, int opt_idx, char_u *val, int opt_fl
99
void set_string_option_direct_in_win(win_T *wp, char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid);
1010
void set_string_option_direct_in_buf(buf_T *buf, char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid);
1111
char *set_string_option(int opt_idx, char_u *value, int opt_flags);
12-
char *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char *errbuf, int opt_flags, int *value_checked);
12+
char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, char *errbuf, int opt_flags, int *value_checked);
1313
int check_ff_value(char_u *p);
1414
/* vim: set ft=c : */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
96,
738740
/**/
739741
95,
740742
/**/

0 commit comments

Comments
 (0)