vim-patch:8.1.0114: confusing variable name

Problem:    Confusing variable name.
Solution:   Rename new_ts to new_vts_array.  Change zero to NULL.
0119a59ffd
This commit is contained in:
VVKot
2021-02-13 19:51:49 +00:00
parent 6752ac4968
commit 3e55811acf
2 changed files with 18 additions and 19 deletions

View File

@@ -718,7 +718,7 @@ void ex_retab(exarg_T *eap)
char_u *ptr; char_u *ptr;
char_u *new_line = (char_u *)1; // init to non-NULL char_u *new_line = (char_u *)1; // init to non-NULL
int did_undo; // called u_save for current line int did_undo; // called u_save for current line
long *new_ts = 0; long *new_vts_array = NULL;
char_u *new_ts_str; // string value of tab argument char_u *new_ts_str; // string value of tab argument
int save_list; int save_list;
@@ -729,17 +729,18 @@ void ex_retab(exarg_T *eap)
curwin->w_p_list = 0; /* don't want list mode here */ curwin->w_p_list = 0; /* don't want list mode here */
new_ts_str = eap->arg; new_ts_str = eap->arg;
if (!tabstop_set(eap->arg, &new_ts)) { if (!tabstop_set(eap->arg, &new_vts_array)) {
return; return;
} }
while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') { while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') {
(eap->arg)++; (eap->arg)++;
} }
// This ensures that either new_ts and new_ts_str are freshly allocated, // This ensures that either new_vts_array and new_ts_str are freshly
// or new_ts points to an existing array and new_ts_str is null. // allocated, or new_vts_array points to an existing array and new_ts_str
if (new_ts == 0) { // is null.
new_ts = curbuf->b_p_vts_array; if (new_vts_array == NULL) {
new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL; new_ts_str = NULL;
} else { } else {
new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str); new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
@@ -771,9 +772,7 @@ void ex_retab(exarg_T *eap)
int t, s; int t, s;
tabstop_fromto(start_vcol, vcol, tabstop_fromto(start_vcol, vcol,
tabstop_count(new_ts) ? 0 : curbuf->b_p_ts, curbuf->b_p_ts, new_vts_array, &t, &s);
new_ts,
&t, &s);
num_tabs = t; num_tabs = t;
num_spaces = s; num_spaces = s;
} }
@@ -831,11 +830,11 @@ void ex_retab(exarg_T *eap)
// If a single value was given then it can be considered equal to // If a single value was given then it can be considered equal to
// either the value of 'tabstop' or the value of 'vartabstop'. // either the value of 'tabstop' or the value of 'vartabstop'.
if (tabstop_count(curbuf->b_p_vts_array) == 0 if (tabstop_count(curbuf->b_p_vts_array) == 0
&& tabstop_count(new_ts) == 1 && tabstop_count(new_vts_array) == 1
&& curbuf->b_p_ts == tabstop_first(new_ts)) { && curbuf->b_p_ts == tabstop_first(new_vts_array)) {
// not changed // not changed
} else if (tabstop_count(curbuf->b_p_vts_array) > 0 } else if (tabstop_count(curbuf->b_p_vts_array) > 0
&& tabstop_eq(curbuf->b_p_vts_array, new_ts)) { && tabstop_eq(curbuf->b_p_vts_array, new_vts_array)) {
// not changed // not changed
} else { } else {
redraw_curbuf_later(NOT_VALID); redraw_curbuf_later(NOT_VALID);
@@ -851,17 +850,17 @@ void ex_retab(exarg_T *eap)
// than one tabstop then update 'vartabstop'. // than one tabstop then update 'vartabstop'.
long *old_vts_ary = curbuf->b_p_vts_array; long *old_vts_ary = curbuf->b_p_vts_array;
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_ts) > 1) { if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) {
set_string_option_direct("vts", -1, new_ts_str, set_string_option_direct("vts", -1, new_ts_str,
OPT_FREE | OPT_LOCAL, 0); OPT_FREE | OPT_LOCAL, 0);
xfree(new_ts_str); xfree(new_ts_str);
curbuf->b_p_vts_array = new_ts; curbuf->b_p_vts_array = new_vts_array;
xfree(old_vts_ary); xfree(old_vts_ary);
} else { } else {
// 'vartabstop' wasn't in use and a single value was given to // 'vartabstop' wasn't in use and a single value was given to
// retab then update 'tabstop'. // retab then update 'tabstop'.
curbuf->b_p_ts = tabstop_first(new_ts); curbuf->b_p_ts = tabstop_first(new_vts_array);
xfree(new_ts); xfree(new_vts_array);
} }
} }
coladvance(curwin->w_curswant); coladvance(curwin->w_curswant);

View File

@@ -7168,7 +7168,7 @@ int tabstop_at(colnr_T col, long ts, long *vts)
int t; int t;
int tab_size = 0; int tab_size = 0;
if (vts == 0 || vts[0] == 0) { if (vts == NULL || vts[0] == 0) {
return (int)ts; return (int)ts;
} }
@@ -7195,7 +7195,7 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts)
int t; int t;
int excess; int excess;
if (vts == 0 || vts[0] == 0) { if (vts == NULL || vts[0] == 0) {
return (col / (int)ts) * (int)ts; return (col / (int)ts) * (int)ts;
} }
@@ -7226,7 +7226,7 @@ void tabstop_fromto(colnr_T start_col,
int tabcount; int tabcount;
int t; int t;
if (vts == 0 || vts[0] == 0) { if (vts == NULL || vts[0] == 0) {
int tabs = 0; int tabs = 0;
int initspc = (int)ts - (start_col % (int)ts); int initspc = (int)ts - (start_col % (int)ts);
if (spaces >= initspc) { if (spaces >= initspc) {