diff options
| -rw-r--r-- | src/nvim/ex_cmds.c | 31 | ||||
| -rw-r--r-- | src/nvim/option.c | 6 | 
2 files changed, 18 insertions, 19 deletions
| diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d679a3c8f8..00d4513051 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -718,7 +718,7 @@ void ex_retab(exarg_T *eap)    char_u      *ptr;    char_u      *new_line = (char_u *)1;  // init to non-NULL    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    int save_list; @@ -729,17 +729,18 @@ void ex_retab(exarg_T *eap)    curwin->w_p_list = 0;             /* don't want list mode here */    new_ts_str = eap->arg; -  if (!tabstop_set(eap->arg, &new_ts)) { +  if (!tabstop_set(eap->arg, &new_vts_array)) {      return;    }    while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') {      (eap->arg)++;    } -  // This ensures that either new_ts and new_ts_str are freshly allocated, -  // or new_ts points to an existing array and new_ts_str is null. -  if (new_ts == 0) { -    new_ts = curbuf->b_p_vts_array; +  // This ensures that either new_vts_array and new_ts_str are freshly +  // allocated, or new_vts_array points to an existing array and new_ts_str +  // is null. +  if (new_vts_array == NULL) { +    new_vts_array = curbuf->b_p_vts_array;      new_ts_str = NULL;    } else {      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;              tabstop_fromto(start_vcol, vcol, -                           tabstop_count(new_ts) ? 0 : curbuf->b_p_ts, -                           new_ts, -                           &t, &s); +                           curbuf->b_p_ts, new_vts_array, &t, &s);              num_tabs = t;              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    // either the value of 'tabstop' or the value of 'vartabstop'.    if (tabstop_count(curbuf->b_p_vts_array) == 0 -      && tabstop_count(new_ts) == 1 -      && curbuf->b_p_ts == tabstop_first(new_ts)) { +      && tabstop_count(new_vts_array) == 1 +      && curbuf->b_p_ts == tabstop_first(new_vts_array)) {      // not changed    } 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    } else {      redraw_curbuf_later(NOT_VALID); @@ -851,17 +850,17 @@ void ex_retab(exarg_T *eap)      // than one tabstop then update 'vartabstop'.      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,                                 OPT_FREE | OPT_LOCAL, 0);        xfree(new_ts_str); -      curbuf->b_p_vts_array = new_ts; +      curbuf->b_p_vts_array = new_vts_array;        xfree(old_vts_ary);      } else {        // 'vartabstop' wasn't in use and a single value was given to        // retab then update 'tabstop'. -      curbuf->b_p_ts = tabstop_first(new_ts); -      xfree(new_ts); +      curbuf->b_p_ts = tabstop_first(new_vts_array); +      xfree(new_vts_array);      }    }    coladvance(curwin->w_curswant); diff --git a/src/nvim/option.c b/src/nvim/option.c index ad4d12ff7b..fc3771f42b 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -7168,7 +7168,7 @@ int tabstop_at(colnr_T col, long ts, long *vts)    int t;    int tab_size = 0; -  if (vts == 0 || vts[0] == 0) { +  if (vts == NULL || vts[0] == 0) {      return (int)ts;    } @@ -7195,7 +7195,7 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts)    int t;    int excess; -  if (vts == 0 || vts[0] == 0) { +  if (vts == NULL || vts[0] == 0) {      return (col / (int)ts) * (int)ts;    } @@ -7226,7 +7226,7 @@ void tabstop_fromto(colnr_T start_col,    int tabcount;    int t; -  if (vts == 0 || vts[0] == 0) { +  if (vts == NULL || vts[0] == 0) {      int tabs = 0;      int initspc = (int)ts - (start_col % (int)ts);      if (spaces >= initspc) { | 
