diff options
Diffstat (limited to 'src')
57 files changed, 535 insertions, 335 deletions
| diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index f84e25cdfb..8327f3c836 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1758,7 +1758,7 @@ buflist_findpat (          FOR_ALL_BUFFERS(buf) {            if (buf->b_p_bl == find_listed                && (!diffmode || diff_mode_buf(buf)) -              && buflist_match(prog, buf) != NULL) { +              && buflist_match(prog, buf, false) != NULL) {              if (curtab_only) {                /* Ignore the match if the buffer is not open in                 * the current tab. */ @@ -1852,7 +1852,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)        FOR_ALL_BUFFERS(buf) {          if (!buf->b_p_bl)               /* skip unlisted buffers */            continue; -        p = buflist_match(prog, buf); +        p = buflist_match(prog, buf, p_wic);          if (p != NULL) {            if (round == 1)              ++count; @@ -1885,26 +1885,27 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)  #ifdef HAVE_BUFLIST_MATCH -/* - * Check for a match on the file name for buffer "buf" with regprog "prog". - */ -static char_u *buflist_match(regprog_T *prog, buf_T *buf) +/// Check for a match on the file name for buffer "buf" with regprog "prog". +/// +/// @param ignore_case When TRUE, ignore case. Use 'fic' otherwise. +static char_u *buflist_match(regprog_T *prog, buf_T *buf, bool ignore_case)  {    char_u      *match;    /* First try the short file name, then the long file name. */ -  match = fname_match(prog, buf->b_sfname); -  if (match == NULL) -    match = fname_match(prog, buf->b_ffname); +  match = fname_match(prog, buf->b_sfname, ignore_case); +  if (match == NULL) { +    match = fname_match(prog, buf->b_ffname, ignore_case); +  }    return match;  } -/* - * Try matching the regexp in "prog" with file name "name". - * Return "name" when there is a match, NULL when not. - */ -static char_u *fname_match(regprog_T *prog, char_u *name) +/// Try matching the regexp in "prog" with file name "name". +/// +/// @param ignore_case When TRUE, ignore case. Use 'fileignorecase' otherwise. +/// @return "name" when there is a match, NULL when not. +static char_u *fname_match(regprog_T *prog, char_u *name, bool ignore_case)  {    char_u      *match = NULL;    char_u      *p; @@ -1912,7 +1913,8 @@ static char_u *fname_match(regprog_T *prog, char_u *name)    if (name != NULL) {      regmatch.regprog = prog; -    regmatch.rm_ic = p_fic;     /* ignore case when 'fileignorecase' is set */ +    // Ignore case when 'fileignorecase' or the argument is set. +    regmatch.rm_ic = p_fic || ignore_case;      if (vim_regexec(®match, name, (colnr_T)0))        match = name;      else { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 71cb83e566..d058e6ccae 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6652,7 +6652,7 @@ char_u *get_function_name(expand_T *xp, int idx)      if (name != NULL)        return name;    } -  if (++intidx < (int)(sizeof(functions) / sizeof(struct fst))) { +  if (++intidx < (int)ARRAY_SIZE(functions)) {      STRCPY(IObuff, functions[intidx].f_name);      STRCAT(IObuff, "(");      if (functions[intidx].f_max_argc == 0) @@ -6695,7 +6695,7 @@ find_internal_func (  )  {    int first = 0; -  int last = (int)(sizeof(functions) / sizeof(struct fst)) - 1; +  int last = (int)ARRAY_SIZE(functions) - 1;    /*     * Find the function name in the table. Binary search. @@ -9603,7 +9603,8 @@ static void f_getregtype(typval_T *argvars, typval_T *rettv)   */  static void f_gettabvar(typval_T *argvars, typval_T *rettv)  { -  tabpage_T   *tp; +  win_T *oldcurwin; +  tabpage_T *tp, *oldtabpage;    dictitem_T  *v;    char_u      *varname;    int done = FALSE; @@ -9614,16 +9615,25 @@ static void f_gettabvar(typval_T *argvars, typval_T *rettv)    varname = get_tv_string_chk(&argvars[1]);    tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL));    if (tp != NULL && varname != NULL) { +    /* Set tp to be our tabpage, temporarily.  Also set the window to the +     * first window in the tabpage, otherwise the window is not valid. */ +    switch_win(&oldcurwin, &oldtabpage, tp->tp_firstwin, tp, TRUE); +      /* look up the variable */ -    v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 0, varname, FALSE); +    /* Let gettabvar({nr}, "") return the "t:" dictionary. */ +    v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't', varname, FALSE);      if (v != NULL) {        copy_tv(&v->di_tv, rettv);        done = TRUE;      } + +    /* restore previous notion of curwin */ +    restore_win(oldcurwin, oldtabpage, TRUE);    } -  if (!done && argvars[2].v_type != VAR_UNKNOWN) +  if (!done && argvars[2].v_type != VAR_UNKNOWN) {      copy_tv(&argvars[2], rettv); +  }  }  /* diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 049934d680..a8d2f5589e 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1294,14 +1294,6 @@ do_shell (      }      starttermcap();             /* start termcap if not done by wait_return() */ - -    /* -     * In an Amiga window redrawing is caused by asking the window size. -     * If we got an interrupt this will not work. The chance that the -     * window size is wrong is very small, but we need to redraw the -     * screen.  Don't do this if ':' hit in wait_return().	THIS IS UGLY -     * but it saves an extra redraw. -     */    }    /* display any error messages now */ @@ -4954,7 +4946,7 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la     * Recognize a few exceptions to the rule.	Some strings that contain '*'     * with "star".  Otherwise '*' is recognized as a wildcard.     */ -  for (i = (int)(sizeof(mtable) / sizeof(char *)); --i >= 0; ) +  for (i = (int)ARRAY_SIZE(mtable); --i >= 0; )      if (STRCMP(arg, mtable[i]) == 0) {        STRCPY(d, rtable[i]);        break; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index fa78047a46..072972d24e 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3291,3 +3291,79 @@ static void script_host_do_range(char *name, exarg_T *eap)    (void)eval_call_provider(name, "do_range", args);  } +/* + * ":drop" + * Opens the first argument in a window.  When there are two or more arguments + * the argument list is redefined. + */ +void ex_drop(exarg_T   *eap) +{ +    int                split = FALSE; +    buf_T      *buf; + +    /* +     * Check if the first argument is already being edited in a window.  If +     * so, jump to that window. +     * We would actually need to check all arguments, but that's complicated +     * and mostly only one file is dropped. +     * This also ignores wildcards, since it is very unlikely the user is +     * editing a file name with a wildcard character. +     */ +    do_arglist(eap->arg, AL_SET, 0); + +    /* +     * Expanding wildcards may result in an empty argument list.  E.g. when +     * editing "foo.pyc" and ".pyc" is in 'wildignore'.  Assume that we +     * already did an error message for this. +     */ +    if (ARGCOUNT == 0) +       return; + +    if (cmdmod.tab) +    { +       /* ":tab drop file ...": open a tab for each argument that isn't +        * edited in a window yet.  It's like ":tab all" but without closing +        * windows or tabs. */ +       ex_all(eap); +    } +    else +    { +       /* ":drop file ...": Edit the first argument.  Jump to an existing +        * window if possible, edit in current window if the current buffer +        * can be abandoned, otherwise open a new window. */ +       buf = buflist_findnr(ARGLIST[0].ae_fnum); + +       FOR_ALL_TAB_WINDOWS(tp, wp) +       { +           if (wp->w_buffer == buf) +           { +               goto_tabpage_win(tp, wp); +               curwin->w_arg_idx = 0; +               return; +           } +       } + +       /* +        * Check whether the current buffer is changed. If so, we will need +        * to split the current window or data could be lost. +        * Skip the check if the 'hidden' option is set, as in this case the +        * buffer won't be lost. +        */ +       if (!P_HID(curbuf)) +       { +           ++emsg_off; +           split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD); +           --emsg_off; +       } + +       /* Fake a ":sfirst" or ":first" command edit the first argument. */ +       if (split) +       { +           eap->cmdidx = CMD_sfirst; +           eap->cmd[0] = 's'; +       } +       else +           eap->cmdidx = CMD_first; +       ex_rewind(eap); +    } +} diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 56c8206d2a..f25af3f587 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -135,7 +135,6 @@ struct dbg_stuff {  #endif  # define HAVE_EX_SCRIPT_NI -# define ex_drop                ex_ni  # define ex_gui                 ex_nogui  # define ex_tearoff             ex_ni  # define ex_popup               ex_ni @@ -2281,7 +2280,7 @@ int modifier_len(char_u *cmd)    if (VIM_ISDIGIT(*cmd))      p = skipwhite(skipdigits(cmd)); -  for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) { +  for (i = 0; i < (int)ARRAY_SIZE(cmdmods); ++i) {      for (j = 0; p[j] != NUL; ++j)        if (p[j] != cmdmods[i].name[j])          break; @@ -2306,7 +2305,7 @@ int cmd_exists(char_u *name)    char_u      *p;    /* Check command modifiers. */ -  for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) { +  for (i = 0; i < (int)ARRAY_SIZE(cmdmods); ++i) {      for (j = 0; name[j] != NUL; ++j)        if (name[j] != cmdmods[i].name[j])          break; @@ -4974,7 +4973,7 @@ char_u *get_user_cmd_flags(expand_T *xp, int idx)    {"bang", "bar", "buffer", "complete", "count",     "nargs", "range", "register"}; -  if (idx >= (int)(sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0]))) +  if (idx >= (int)ARRAY_SIZE(user_cmd_flags))      return NULL;    return (char_u *)user_cmd_flags[idx];  } @@ -4986,7 +4985,7 @@ char_u *get_user_cmd_nargs(expand_T *xp, int idx)  {    static char *user_cmd_nargs[] = {"0", "1", "*", "?", "+"}; -  if (idx >= (int)(sizeof(user_cmd_nargs) / sizeof(user_cmd_nargs[0]))) +  if (idx >= (int)ARRAY_SIZE(user_cmd_nargs))      return NULL;    return (char_u *)user_cmd_nargs[idx];  } @@ -5142,8 +5141,7 @@ static void ex_quit(exarg_T *eap)   */  static void ex_cquit(exarg_T *eap)  { -  getout(1);    /* this does not always pass on the exit code to the Manx -                   compiler. why? */ +  getout(1);  }  /* @@ -7482,7 +7480,7 @@ int find_cmdline_var(const char_u *src, int *usedlen) FUNC_ATTR_NONNULL_ALL  # define SPEC_AMATCH 9    }; -  for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) { +  for (i = 0; i < (int)ARRAY_SIZE(spec_str); ++i) {      len = (int)STRLEN(spec_str[i]);      if (STRNCMP(src, spec_str[i], len) == 0) {        *usedlen = len; @@ -8543,7 +8541,9 @@ static void ex_loadview(exarg_T *eap)    fname = get_view_file(*eap->arg);    if (fname != NULL) { -    do_source(fname, FALSE, DOSO_NONE); +    if (do_source(fname, FALSE, DOSO_NONE) == FAIL) { +      EMSG2(_(e_notopen), fname); +    }      free(fname);    }  } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index aed0484356..a19cb36d12 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3715,7 +3715,7 @@ ExpandFromContext (       * right function to do the expansion.       */      ret = FAIL; -    for (i = 0; i < (int)(sizeof(tab) / sizeof(struct expgen)); ++i) +    for (i = 0; i < (int)ARRAY_SIZE(tab); ++i)        if (xp->xp_context == tab[i].context) {          if (tab[i].ic) {            regmatch.rm_ic = TRUE; @@ -4155,7 +4155,7 @@ static char_u *get_history_arg(expand_T *xp, int idx)    static char_u compl[2] = { NUL, NUL };    char *short_names = ":=@>?/";    int short_names_count = (int)STRLEN(short_names); -  int history_name_count = sizeof(history_names) / sizeof(char *) - 1; +  int history_name_count = ARRAY_SIZE(history_names) - 1;    if (idx < short_names_count) {      compl[0] = (char_u)short_names[idx]; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 9734ac07f9..9c6d7c96bb 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2839,27 +2839,25 @@ buf_write (             * Check if backup file already exists.             */            if (os_fileinfo((char *)backup, &file_info_new)) { -            /* -             * Check if backup file is same as original file. -             * May happen when modname() gave the same file back (e.g. silly -             * link). If we don't check here, we either ruin the file when -             * copying or erase it after writing. -             */              if (os_fileinfo_id_equal(&file_info_new, &file_info_old)) { +              /* +               * Backup file is same as original file. +               * May happen when modname() gave the same file back (e.g. silly +               * link). If we don't check here, we either ruin the file when +               * copying or erase it after writing. +               */                free(backup);                backup = NULL;                    /* no backup file to delete */ -            } - -            /* -             * If we are not going to keep the backup file, don't -             * delete an existing one, try to use another name. -             * Change one character, just before the extension. -             */ -            if (!p_bk) { -              wp = backup + STRLEN(backup) - 1 -                   - STRLEN(backup_ext); -              if (wp < backup)                  /* empty file name ??? */ +            } else if (!p_bk) { +              /* +               * We are not going to keep the backup file, so don't +               * delete an existing one, and try to use another name instead. +               * Change one character, just before the extension. +               */ +              wp = backup + STRLEN(backup) - 1 - STRLEN(backup_ext); +              if (wp < backup) {                /* empty file name ??? */                  wp = backup; +              }                *wp = 'z';                while (*wp > 'a'                       && os_fileinfo((char *)backup, &file_info_new)) { diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 5d9d353fc8..f1f619066a 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -945,8 +945,6 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T   * http://www.adobe.com   */ -#define NUM_ELEMENTS(arr)   (sizeof(arr)/sizeof((arr)[0])) -  #define PRT_PS_DEFAULT_DPI          (72)    /* Default user space resolution */  #define PRT_PS_DEFAULT_FONTSIZE     (10)  #define PRT_PS_DEFAULT_BUFFER_SIZE  (80) @@ -1139,33 +1137,33 @@ static struct prt_ps_charset_S k_charsets[] =  static struct prt_ps_mbfont_S prt_ps_mbfonts[] =  {    { -    NUM_ELEMENTS(j_encodings), +    ARRAY_SIZE(j_encodings),      j_encodings, -    NUM_ELEMENTS(j_charsets), +    ARRAY_SIZE(j_charsets),      j_charsets,      "jis_roman",      "JIS_X_1983"    },    { -    NUM_ELEMENTS(sc_encodings), +    ARRAY_SIZE(sc_encodings),      sc_encodings, -    NUM_ELEMENTS(sc_charsets), +    ARRAY_SIZE(sc_charsets),      sc_charsets,      "gb_roman",      "GB_2312-80"    },    { -    NUM_ELEMENTS(tc_encodings), +    ARRAY_SIZE(tc_encodings),      tc_encodings, -    NUM_ELEMENTS(tc_charsets), +    ARRAY_SIZE(tc_charsets),      tc_charsets,      "cns_roman",      "BIG5"    },    { -    NUM_ELEMENTS(k_encodings), +    ARRAY_SIZE(k_encodings),      k_encodings, -    NUM_ELEMENTS(k_charsets), +    ARRAY_SIZE(k_charsets),      k_charsets,      "ks_roman",      "KS_X_1992" @@ -1639,12 +1637,12 @@ static int prt_next_dsc(struct prt_dsc_line_S *p_dsc_line)      return FALSE;    /* Find type of DSC comment */ -  for (comment = 0; comment < (int)NUM_ELEMENTS(prt_dsc_table); comment++) +  for (comment = 0; comment < (int)ARRAY_SIZE(prt_dsc_table); comment++)      if (prt_resfile_strncmp(0, prt_dsc_table[comment].string,              prt_dsc_table[comment].len) == 0)        break; -  if (comment != NUM_ELEMENTS(prt_dsc_table)) { +  if (comment != ARRAY_SIZE(prt_dsc_table)) {      /* Return type of comment */      p_dsc_line->type = prt_dsc_table[comment].type;      offset = prt_dsc_table[comment].len; @@ -2135,7 +2133,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)    props = enc_canon_props(p_encoding);    if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) {      p_mbenc_first = NULL; -    for (cmap = 0; cmap < (int)NUM_ELEMENTS(prt_ps_mbfonts); cmap++) +    for (cmap = 0; cmap < (int)ARRAY_SIZE(prt_ps_mbfonts); cmap++)        if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],                &p_mbenc)) {          if (p_mbenc_first == NULL) diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 7090e007bf..075acc6c13 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -58,8 +58,8 @@ int get_indent_str(char_u *ptr, int ts, int list)        if (!list || lcs_tab1) {  // count a tab for what it is worth          count += ts - (count % ts);        } else { -        // in list mode, when tab is not set, count screen char width for Tab: -        // ^I +        // In list mode, when tab is not set, count screen char width +        // for Tab, displays: ^I          count += ptr2cells(ptr);        }      } else if (*ptr == ' ') { diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 6648a9f7c6..bbc0b291dc 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -210,9 +210,36 @@ static pos_T *find_line_comment(void)   /* XXX */    return NULL;  } -/* - * Check if string matches "label:"; move to character after ':' if true. - */ +/// Checks if `text` starts with "key:". +static bool cin_has_js_key(char_u *text) +{ +  char_u *s = skipwhite(text); + +  char_u quote = 0; +  if (*s == '\'' || *s == '"') { +    // can be 'key': or "key": +    quote = *s; +    ++s; +  } +  if (!vim_isIDc(*s))	{   // need at least one ID character +    return FALSE; +  } + +  while (vim_isIDc(*s)) { +    ++s; +  } +  if (*s && *s == quote) { +    ++s; +  } + +  s = cin_skipcomment(s); + +  // "::" is not a label, it's C++ +  return (*s == ':' && s[1] != ':'); +} + +/// Checks if string matches "label:"; move to character after ':' if true. +/// "*s" must point to the start of the label, if there is one.  static int cin_islabel_skip(char_u **s)  {    if (!vim_isIDc(**s))              /* need at least one ID character */ @@ -303,7 +330,7 @@ static int cin_isinit(void)    for (;; ) {      int i, l; -    for (i = 0; i < (int)(sizeof(skip) / sizeof(char *)); ++i) { +    for (i = 0; i < (int)ARRAY_SIZE(skip); ++i) {        l = (int)strlen(skip[i]);        if (cin_starts_with(s, skip[i])) {          s = cin_skipcomment(s + l); @@ -1198,21 +1225,21 @@ static pos_T *find_start_brace(void)    return trypos;  } -/* - * Find the matching '(', failing if it is in a comment. - * Return NULL if no match found. - */ -static pos_T * -find_match_paren ( /* XXX */ -    int ind_maxparen -) +/// Find the matching '(', ignoring it if it is in a comment. +/// @returns NULL or the found match. +static pos_T *find_match_paren(int ind_maxparen) +{ +  return find_match_char('(', ind_maxparen); +} + +static pos_T * find_match_char(char_u c, int ind_maxparen)  {    pos_T cursor_save;    pos_T       *trypos;    static pos_T pos_copy;    cursor_save = curwin->w_cursor; -  if ((trypos = findmatchlimit(NULL, '(', 0, ind_maxparen)) != NULL) { +  if ((trypos = findmatchlimit(NULL, c, 0, ind_maxparen)) != NULL) {      /* check if the ( is in a // comment */      if ((colnr_T)cin_skip2pos(trypos) > trypos->col)        trypos = NULL; @@ -1220,7 +1247,7 @@ find_match_paren ( /* XXX */        pos_copy = *trypos;           /* copy trypos, findmatch will change it */        trypos = &pos_copy;        curwin->w_cursor = *trypos; -      if (ind_find_start_comment() != NULL)       /* XXX */ +      if (ind_find_start_comment() != NULL)          trypos = NULL;      }    } @@ -1228,6 +1255,29 @@ find_match_paren ( /* XXX */    return trypos;  } +/// Find the matching '(', ignoring it if it is in a comment or before an +/// unmatched {. +/// @returns NULL or the found match. +static pos_T *find_match_paren_after_brace(int ind_maxparen) +{ +  pos_T *trypos = find_match_paren(ind_maxparen); +  if (trypos == NULL) { +    return NULL; +  } + +  pos_T *tryposBrace = find_start_brace(); +  // If both an unmatched '(' and '{' is found.  Ignore the '(' +  // position if the '{' is further down. +  if (tryposBrace != NULL +      && (trypos->lnum != tryposBrace->lnum +          ? trypos->lnum < tryposBrace->lnum +          : trypos->col < tryposBrace->col)) { +    trypos = NULL; +  } +  return trypos; +} + +  /*   * Return ind_maxparen corrected for the difference in line number between the   * cursor position and "startpos".  This makes sure that searching for a @@ -1517,6 +1567,8 @@ int get_c_indent(void)  #define LOOKFOR_NOBREAK         8  #define LOOKFOR_CPP_BASECLASS   9  #define LOOKFOR_ENUM_OR_INIT    10 +#define LOOKFOR_JS_KEY          11 +#define LOOKFOR_NO_COMMA        12    int whilelevel;    linenr_T lnum; @@ -1731,6 +1783,12 @@ int get_c_indent(void)        }      }    } +  // Are we looking at a ']' that has a match? +  else if (*skipwhite(theline) == ']' +           && (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL) { +    // align with the line containing the '['. +    amount = get_indent_lnum(trypos->lnum); +  }    /*     * Are we inside parentheses or braces?     */						    /* XXX */ @@ -1939,13 +1997,14 @@ int get_c_indent(void)            else {              curwin->w_cursor.lnum = our_paren_pos.lnum;              curwin->w_cursor.col = col; -            if (find_match_paren(curbuf->b_ind_maxparen) != NULL) +            if (find_match_paren_after_brace(curbuf->b_ind_maxparen)) {                amount += curbuf->b_ind_unclosed2; -            else { -              if (is_if_for_while) +            } else { +              if (is_if_for_while) {                  amount += curbuf->b_ind_if_for_while; -              else +              } else {                  amount += curbuf->b_ind_unclosed; +              }              }            }            /* @@ -1964,13 +2023,10 @@ int get_c_indent(void)        /* add extra indent for a comment */        if (cin_iscomment(theline))          amount += curbuf->b_ind_comment; -    } -    /* -     * Are we at least inside braces, then? -     */ -    else { +    } else { +      // We are inside braces, there is a { before this line at the position +      // stored in tryposBrace.        trypos = tryposBrace; -        ourscope = trypos->lnum;        start = ml_get(ourscope); @@ -1989,28 +2045,22 @@ int get_c_indent(void)          else            start_brace = BRACE_AT_START;        } else { -        /* -         * that opening brace might have been on a continuation -         * line.  if so, find the start of the line. -         */ +        // That opening brace might have been on a continuation +        // line.  If so, find the start of the line.          curwin->w_cursor.lnum = ourscope; -        /* -         * position the cursor over the rightmost paren, so that -         * matching it will take us back to the start of the line. -         */ +        // Position the cursor over the rightmost paren, so that +        // matching it will take us back to the start of the line.          lnum = ourscope;          if (find_last_paren(start, '(', ')') -            && (trypos = find_match_paren(curbuf->b_ind_maxparen)) -            != NULL) +            && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {            lnum = trypos->lnum; +        } -        /* -         * It could have been something like -         *	   case 1: if (asdf && -         *			ldfd) { -         *		    } -         */ +        // It could have been something like +        //	   case 1: if (asdf && +        //			ldfd) { +        //		    }          if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)              && cin_iscase(skipwhite(get_cursor_line_ptr()), FALSE)) {            amount = get_indent(); @@ -2023,11 +2073,12 @@ int get_c_indent(void)          start_brace = BRACE_AT_END;        } -      /* -       * if we're looking at a closing brace, that's where -       * we want to be.  otherwise, add the amount of room -       * that an indent is supposed to be. -       */ +      // For Javascript check if the line starts with "key:". +      bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key(theline) : false; + +      // If we're looking at a closing brace, that's where +      // we want to be.  Otherwise, add the amount of room +      // that an indent is supposed to be.        if (theline[0] == '}') {          /*           * they may want closing braces to line up with something @@ -2109,14 +2160,12 @@ int get_c_indent(void)          scope_amount = amount;          whilelevel = 0; -        /* -         * Search backwards.  If we find something we recognize, line up -         * with that. -         * -         * if we're looking at an open brace, indent -         * the usual amount relative to the conditional -         * that opens the block. -         */ +        // Search backwards.  If we find something we recognize, line up +        // with that. +        // +        // If we're looking at an open brace, indent +        // the usual amount relative to the conditional +        // that opens the block.          curwin->w_cursor = cur_curpos;          for (;; ) {            curwin->w_cursor.lnum--; @@ -2485,26 +2534,58 @@ int get_c_indent(void)             */            terminated = cin_isterminated(l, FALSE, TRUE); +          if (js_cur_has_key) { +            js_cur_has_key = false; // only check the first line +            if (curbuf->b_ind_js && terminated == ',') { +              // For Javascript we might be inside an object: +              //   key: something,  <- align with this +              //   key: something +              // or: +              //   key: something +  <- align with this +              //       something, +              //   key: something +              lookfor = LOOKFOR_JS_KEY; +            } +          } +          if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key(l)) { +            amount = get_indent(); +            break; +          } +          if (lookfor == LOOKFOR_NO_COMMA) { +            if (terminated != ',') { +              // Line below current line is the one that starts a +              // (possibly broken) line ending in a comma. +              break; +            } +            amount = get_indent(); +            if (curwin->w_cursor.lnum - 1 == ourscope) { +              // line above is start of the scope, thus current line +              // is the one that stars a (possibly broken) line +              // ending in a comma. +              break; +            } +          } +            if (terminated == 0 || (lookfor != LOOKFOR_UNTERM                                    && terminated == ',')) { -            /* -             * if we're in the middle of a paren thing, -             * go back to the line that starts it so -             * we can get the right prevailing indent -             *	   if ( foo && -             *		    bar ) -             */ -            /* -             * position the cursor over the rightmost paren, so that -             * matching it will take us back to the start of the line. -             */ +            // If we're in the middle of a paren thing, Go back to the line +            // that starts it so we can get the right prevailing indent +            //	   if ( foo && +            //		    bar ) + +            // Position the cursor over the rightmost paren, so that +            // matching it will take us back to the start of the line. +            // Ignore a match before the start of the block.              (void)find_last_paren(l, '(', ')');              trypos = find_match_paren(corr_ind_maxparen(&cur_curpos)); +            if (trypos != NULL && (trypos->lnum < tryposBrace->lnum +                                   || (trypos->lnum == tryposBrace->lnum +                                       && trypos->col < tryposBrace->col))) { +              trypos = NULL; +            } -            /* -             * If we are looking for ',', we also look for matching -             * braces. -             */ +            // If we are looking for ',', we also look for matching +            // braces.              if (trypos == NULL && terminated == ','                  && find_last_paren(l, '{', '}'))                trypos = find_start_brace(); @@ -2546,10 +2627,11 @@ int get_c_indent(void)               * Get indent and pointer to text for current line,               * ignoring any jump label.	    XXX               */ -            if (!curbuf->b_ind_js) -              cur_amount = skip_label(curwin->w_cursor.lnum, &l); -            else +            if (curbuf->b_ind_js) {                cur_amount = get_indent(); +            } else { +              cur_amount = skip_label(curwin->w_cursor.lnum, &l); +            }              /*               * If this is just above the line we are indenting, and it               * starts with a '{', line it up with this line. @@ -2570,7 +2652,7 @@ int get_c_indent(void)                if (*skipwhite(l) != '{')                  amount += curbuf->b_ind_open_extra; -              if (curbuf->b_ind_cpp_baseclass) { +              if (curbuf->b_ind_cpp_baseclass && !curbuf->b_ind_js) {                  /* have to look back, whether it is a cpp base                   * class declaration or initialization */                  lookfor = LOOKFOR_CPP_BASECLASS; @@ -2716,17 +2798,43 @@ int get_c_indent(void)                   * yet.                   */                  if (lookfor == LOOKFOR_INITIAL && terminated == ',') { -                  lookfor = LOOKFOR_ENUM_OR_INIT; -                  cont_amount = cin_first_id_amount(); +                  if (curbuf->b_ind_js) { +                    // Search for a line ending in a comma +                    // and line up with the line below it +                    // (could be the current line). +                    // some = [ +                    //     1,     <- line up here +                    //     2, +                    // some = [ +                    //     3 +    <- line up here +                    //       4 * +                    //        5, +                    //     6, +                    lookfor = LOOKFOR_NO_COMMA; +                    amount = get_indent();      // XXX +                    trypos = find_match_char('[', curbuf->b_ind_maxparen); +                    if (trypos != NULL) { +                      if (trypos->lnum == curwin->w_cursor.lnum - 1) { +                        // Current line is first inside +                        // [], line up with it. +                        break; +                      } +                      ourscope = trypos->lnum; +                    } +                  } else { +                    lookfor = LOOKFOR_ENUM_OR_INIT; +                    cont_amount = cin_first_id_amount(); +                  }                  } else {                    if (lookfor == LOOKFOR_INITIAL                        && *l != NUL -                      && l[STRLEN(l) - 1] == '\\') -                    /* XXX */ -                    cont_amount = cin_get_equal_amount( -                        curwin->w_cursor.lnum); -                  if (lookfor != LOOKFOR_TERM) +                      && l[STRLEN(l) - 1] == '\\') { +                    // XXX +                    cont_amount = cin_get_equal_amount( curwin->w_cursor.lnum); +                  } +                  if (lookfor != LOOKFOR_TERM && lookfor != LOOKFOR_JS_KEY) {                      lookfor = LOOKFOR_UNTERM; +                  }                  }                }              } @@ -2735,8 +2843,7 @@ int get_c_indent(void)             * Check if we are after a while (cond);             * If so: Ignore until the matching "do".             */ -          /* XXX */ -          else if (cin_iswhileofdo_end(terminated)) { +          else if (cin_iswhileofdo_end(terminated)) {  // XXX              /*               * Found an unterminated line after a while ();, line up               * with the last one. @@ -2933,21 +3040,17 @@ term_again:      if (curbuf->b_ind_jump_label > 0 && original_line_islabel)        amount -= curbuf->b_ind_jump_label;    } -  /* -   * ok -- we're not inside any sort of structure at all! -   * -   * this means we're at the top level, and everything should -   * basically just match where the previous line is, except -   * for the lines immediately following a function declaration, -   * which are K&R-style parameters and need to be indented. -   */    else { -    /* -     * if our line starts with an open brace, forget about any -     * prevailing indent and make sure it looks like the start -     * of a function -     */ - +    // Ok -- we're not inside any sort of structure at all! +    // +    // this means we're at the top level, and everything should +    // basically just match where the previous line is, except +    // for the lines immediately following a function declaration, +    // which are K&R-style parameters and need to be indented. + +    // if our line starts with an open brace, forget about any +    // prevailing indent and make sure it looks like the start +    // of a function      if (theline[0] == '{') {        amount = curbuf->b_ind_first_open;      } @@ -3081,6 +3184,15 @@ term_again:          if (cin_ends_in(l, (char_u *)"};", NULL))            break; +        // If the previous line ends on '[' we are probably in an +        // array constant: +        // something = [ +        //     234,  <- extra indent +        if (cin_ends_in(l, (char_u *)"[", NULL)) { +          amount = get_indent() + ind_continuation; +          break; +        } +          /*           * Find a line only has a semicolon that belongs to a previous           * line ending in '}', e.g. before an #endif.  Don't increase diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 45977b96ae..9c5160ffb2 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -284,8 +284,7 @@ static struct key_name_entry {    {0,                 NULL}  }; -#define KEY_NAMES_TABLE_LEN (sizeof(key_names_table) / \ -                             sizeof(struct key_name_entry)) +#define KEY_NAMES_TABLE_LEN ARRAY_SIZE(key_names_table)  static struct mousetable {    int pseudo_code;              /* Code for pseudo mouse event */ diff --git a/src/nvim/macros.h b/src/nvim/macros.h index 215ad3a1f7..7dd8120d09 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -152,4 +152,12 @@  # define RESET_BINDING(wp)  (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE +/// Calculate the length of a C array. +/// +/// This should be called with a real array. Calling this with a pointer is an +/// error. A mechanism to detect many (though not all) of those errors at compile +/// time is implemented. It works by the second division producing a division by +/// zero in those cases (-Wdiv-by-zero in GCC). +#define ARRAY_SIZE(arr) ((sizeof(arr)/sizeof((arr)[0])) / ((size_t)(!(sizeof(arr) % sizeof((arr)[0]))))) +  #endif  // NVIM_MACROS_H diff --git a/src/nvim/main.c b/src/nvim/main.c index 6c2cb2b645..1f6c8ddc81 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -208,9 +208,6 @@ int main(int argc, char **argv)    /*     * Check if we have an interactive window. -   * On the Amiga: If there is no window, we open one with a newcli command -   * (needed for :! to * work). mch_check_win() will also handle the -d or -   * -dev argument.     */    check_and_set_isatty(¶ms); @@ -1087,8 +1084,7 @@ static void command_line_scan(mparm_T *parmp)            exmode_active = EXMODE_VIM;            break; -        case 'f':                 /* "-f"  GUI: run in foreground.  Amiga: open -                                     window directly, not with newcli */ +        case 'f':                 /* "-f"  GUI: run in foreground. */            break;          case 'g':                 /* "-g" start GUI */ @@ -1489,9 +1485,6 @@ static void init_startuptime(mparm_T *paramp)  /*   * Check if we have an interactive window. - * On the Amiga: If there is no window, we open one with a newcli command - * (needed for :! to * work). mch_check_win() will also handle the -d or - * -dev argument.   */  static void check_and_set_isatty(mparm_T *paramp)  { @@ -1957,10 +1950,10 @@ static void source_startup_scripts(mparm_T *parmp)      /*       * Try to read initialization commands from the following places:       * - environment variable VIMINIT -     * - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise) +     * - user vimrc file (~/.vimrc)       * - second user vimrc file ($VIM/.vimrc for Dos)       * - environment variable EXINIT -     * - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise) +     * - user exrc file (~/.exrc)       * - second user exrc file ($VIM/.exrc for Dos)       * The first that exists is used, the rest is ignored.       */ @@ -2168,7 +2161,7 @@ static void usage(void)    for (i = 0;; ++i) {      mch_msg(_(" vim [arguments] "));      mch_msg(_(use[i])); -    if (i == (sizeof(use) / sizeof(char_u *)) - 1) +    if (i == ARRAY_SIZE(use) - 1)        break;      mch_msg(_("\n   or:"));    } diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index db4516527a..26eda01f98 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -289,11 +289,9 @@ enc_canon_table[] =  #define IDX_MACROMAN    57    {"macroman",        ENC_8BIT + ENC_MACROMAN, 0},      /* Mac OS */ -#define IDX_DECMCS      58 -  {"dec-mcs",         ENC_8BIT,               0},       /* DEC MCS */ -#define IDX_HPROMAN8    59 +#define IDX_HPROMAN8    58    {"hp-roman8",       ENC_8BIT,               0},       /* HP Roman8 */ -#define IDX_COUNT       60 +#define IDX_COUNT       59  };  /* @@ -925,9 +923,9 @@ static int dbcs_ptr2len_len(const char_u *p, int size)  }  /* - * Return true if "c" is in "table[size / sizeof(struct interval)]". + * Return true if "c" is in "table".   */ -static bool intable(const struct interval *table, size_t size, int c) +static bool intable(const struct interval *table, size_t n_items, int c)  {    int mid, bot, top; @@ -937,7 +935,7 @@ static bool intable(const struct interval *table, size_t size, int c)    /* binary search in table */    bot = 0; -  top = (int)(size / sizeof(struct interval) - 1); +  top = (int)(n_items - 1);    while (top >= bot) {      mid = (bot + top) / 2;      if (table[mid].last < c) @@ -1204,7 +1202,7 @@ int utf_char2cells(int c)  #else      if (!utf_printable(c))        return 6;                 /* unprintable, displays <xxxx> */ -    if (intable(doublewidth, sizeof(doublewidth), c)) +    if (intable(doublewidth, ARRAY_SIZE(doublewidth), c))        return 2;  #endif    } @@ -1212,7 +1210,7 @@ int utf_char2cells(int c)    else if (c >= 0x80 && !vim_isprintc(c))      return 4;                   /* unprintable, displays <xx> */ -  if (c >= 0x80 && *p_ambw == 'd' && intable(ambiguous, sizeof(ambiguous), c)) +  if (c >= 0x80 && *p_ambw == 'd' && intable(ambiguous, ARRAY_SIZE(ambiguous), c))      return 2;    return 1; @@ -2026,7 +2024,7 @@ bool utf_iscomposing(int c)      {0xe0100, 0xe01ef}    }; -  return intable(combining, sizeof(combining), c); +  return intable(combining, ARRAY_SIZE(combining), c);  }  /* @@ -2050,7 +2048,7 @@ bool utf_printable(int c)      {0xfffe, 0xffff}    }; -  return !intable(nonprint, sizeof(nonprint), c); +  return !intable(nonprint, ARRAY_SIZE(nonprint), c);  #endif  } @@ -2138,7 +2136,7 @@ int utf_class(int c)      {0x2f800, 0x2fa1f, 0x4e00},         /* CJK Ideographs */    };    int bot = 0; -  int top = sizeof(classes) / sizeof(struct clinterval) - 1; +  int top = ARRAY_SIZE(classes) - 1;    int mid;    /* First quick check for Latin1 characters, use 'iskeyword'. */ @@ -2346,13 +2344,12 @@ static convertStruct foldCase[] =   * Return the converted equivalent of "a", which is a UCS-4 character.  Use   * the given conversion "table".  Uses binary search on "table".   */ -static int utf_convert(int a, convertStruct *table, int tableSize) +static int utf_convert(int a, convertStruct *table, size_t n_items)  { -  int start, mid, end;   /* indices into table */ -  int entries = tableSize / sizeof(convertStruct); +  size_t start, mid, end;   /* indices into table */    start = 0; -  end = entries; +  end = n_items;    while (start < end) {      /* need to search further */      mid = (end + start) / 2; @@ -2361,7 +2358,7 @@ static int utf_convert(int a, convertStruct *table, int tableSize)      else        end = mid;    } -  if (start < entries +  if (start < n_items        && table[start].rangeStart <= a        && a <= table[start].rangeEnd        && (a - table[start].rangeStart) % table[start].step == 0) @@ -2376,7 +2373,7 @@ static int utf_convert(int a, convertStruct *table, int tableSize)   */  int utf_fold(int a)  { -  return utf_convert(a, foldCase, (int)sizeof(foldCase)); +  return utf_convert(a, foldCase, ARRAY_SIZE(foldCase));  }  static convertStruct toLower[] = @@ -2702,7 +2699,7 @@ int utf_toupper(int a)      return TOUPPER_LOC(a);    /* For any other characters use the above mapping table. */ -  return utf_convert(a, toUpper, (int)sizeof(toUpper)); +  return utf_convert(a, toUpper, ARRAY_SIZE(toUpper));  }  bool utf_islower(int a) @@ -2732,7 +2729,7 @@ int utf_tolower(int a)      return TOLOWER_LOC(a);    /* For any other characters use the above mapping table. */ -  return utf_convert(a, toLower, (int)sizeof(toLower)); +  return utf_convert(a, toLower, ARRAY_SIZE(toLower));  }  bool utf_isupper(int a) diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 7a2cd686c6..e1dc2b93d9 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -318,7 +318,7 @@ static const struct nv_cmd {  };  /* Number of commands in nv_cmds[]. */ -#define NV_CMDS_SIZE (sizeof(nv_cmds) / sizeof(struct nv_cmd)) +#define NV_CMDS_SIZE ARRAY_SIZE(nv_cmds)  /* Sorted index of commands in nv_cmds[]. */  static short nv_cmd_idx[NV_CMDS_SIZE]; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index a6dee2be5b..931b877a95 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -30,6 +30,7 @@  #include "nvim/fold.h"  #include "nvim/getchar.h"  #include "nvim/indent.h" +#include "nvim/log.h"  #include "nvim/mark.h"  #include "nvim/mbyte.h"  #include "nvim/memline.h" @@ -2641,7 +2642,10 @@ do_put (    /* Autocommands may be executed when saving lines for undo, which may make     * y_array invalid.  Start undo now to avoid that. */ -  u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1); +  if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { +    ELOG(_("Failed to save undo information")); +    return; +  }    if (insert_string != NULL) {      y_type = MCHAR; diff --git a/src/nvim/option.c b/src/nvim/option.c index c1ab3f2ee5..5b5570fad4 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1808,7 +1808,7 @@ static struct vimoption    }  }; -#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption)) +#define PARAM_COUNT ARRAY_SIZE(options)  static char *(p_ambw_values[]) = {"single", "double", NULL};  static char *(p_bg_values[]) = {"light", "dark", NULL}; @@ -1883,7 +1883,7 @@ void set_init_1(void)      int mustfree;      ga_init(&ga, 1, 100); -    for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) { +    for (n = 0; n < (long)ARRAY_SIZE(names); ++n) {        mustfree = FALSE;  # ifdef UNIX        if (*names[n] == NUL) @@ -4723,10 +4723,10 @@ static char_u *set_chars_option(char_u **varp)    if (varp == &p_lcs) {      tab = lcstab; -    entries = sizeof(lcstab) / sizeof(struct charstab); +    entries = ARRAY_SIZE(lcstab);    } else {      tab = filltab; -    entries = sizeof(filltab) / sizeof(struct charstab); +    entries = ARRAY_SIZE(filltab);    }    /* first round: check for valid value, second round: assign values */ @@ -6196,15 +6196,17 @@ int makeset(FILE *fd, int opt_flags, int local_only)    int pri;    /* -   * The options that don't have a default (terminal name, columns, lines) -   * are never written.  Terminal options are also not written. +   * Some options are never written: +   * - Options that don't have a default (terminal name, columns, lines). +   * - Terminal options. +   * - Hidden options. +   *     * Do the loop over "options[]" twice: once for options with the     * P_PRI_MKRC flag and once without.     */    for (pri = 1; pri >= 0; --pri) {      for (p = &options[0]; !istermoption(p); p++)        if (!(p->flags & P_NO_MKRC) -          && !istermoption(p)            && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) {          /* skip global option when only doing locals */          if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) @@ -6215,8 +6217,11 @@ int makeset(FILE *fd, int opt_flags, int local_only)          if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))            continue; -        /* Global values are only written when not at the default value. */          varp = get_varp_scope(p, opt_flags); +        /* Hidden options are never written. */ +        if (!varp) +          continue; +        /* Global values are only written when not at the default value. */          if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))            continue; @@ -7245,7 +7250,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***    for (loop = 0; loop <= 1; ++loop) {      regmatch->rm_ic = ic;      if (xp->xp_context != EXPAND_BOOL_SETTINGS) { -      for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); +      for (match = 0; match < (int)ARRAY_SIZE(names);             ++match)          if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) {            if (loop == 0) diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 39dfbe8b88..4422fbc756 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -369,7 +369,7 @@ EXTERN int p_ek;                /* 'esckeys' */  EXTERN int p_exrc;              /* 'exrc' */  EXTERN char_u   *p_fencs;       /* 'fileencodings' */  EXTERN char_u   *p_ffs;         /* 'fileformats' */ -EXTERN long p_fic;              /* 'fileignorecase' */ +EXTERN bool p_fic;              ///< 'fileignorecase'  EXTERN char_u   *p_fcl;         /* 'foldclose' */  EXTERN long p_fdls;             /* 'foldlevelstart' */  EXTERN char_u   *p_fdo;         /* 'foldopen' */ @@ -621,7 +621,7 @@ EXTERN int p_wiv;               /* 'weirdinvert' */  EXTERN char_u   *p_ww;          /* 'whichwrap' */  EXTERN long p_wc;               /* 'wildchar' */  EXTERN long p_wcm;              /* 'wildcharm' */ -EXTERN long p_wic;              /* 'wildignorecase' */ +EXTERN bool p_wic;              ///< 'wildignorecase'  EXTERN char_u   *p_wim;         /* 'wildmode' */  EXTERN int p_wmnu;              /* 'wildmenu' */  EXTERN long p_wh;               /* 'winheight' */ diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 4db84a4f12..7ec4059bce 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -1,6 +1,5 @@  /*   * VIM - Vi IMproved	by Bram Moolenaar - *	      VMS merge by Zoltan Arpadffy   *   * Do ":help uganda"  in Vim to read copying and usage conditions.   * Do ":help credits" in Vim to see a list of people who contributed. @@ -1066,10 +1065,12 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,                || pat[i][j + 1] == '`')              *p++ = '\\';            ++j; -        } else if (!intick && vim_strchr(SHELL_SPECIAL, -                       pat[i][j]) != NULL) +        } else if (!intick +            && ((flags & EW_KEEPDOLLAR) == 0 || pat[i][j] != '$') +            && vim_strchr(SHELL_SPECIAL, pat[i][j]) != NULL)            /* Put a backslash before a special character, but not -           * when inside ``. */ +           * when inside ``. And not for $var when EW_KEEPDOLLAR is +           * set. */            *p++ = '\\';          /* Copy one character. */ diff --git a/src/nvim/path.c b/src/nvim/path.c index e8d31f3f73..8af4015611 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -179,7 +179,7 @@ char_u *path_next_component(char_u *fname)  /*   * Get a pointer to one character past the head of a path name. - * Unix: after "/"; DOS: after "c:\"; Amiga: after "disk:/"; Mac: no head. + * Unix: after "/"; DOS: after "c:\"; Mac: no head.   * If there is no head, path is returned.   */  char_u *get_past_head(char_u *path) @@ -1080,7 +1080,7 @@ gen_expand_wildcards (            free(p);            ga_clear_strings(&ga);            i = mch_expand_wildcards(num_pat, pat, num_file, file, -              flags); +              flags | EW_KEEPDOLLAR);            recursive = FALSE;            return i;          } diff --git a/src/nvim/path.h b/src/nvim/path.h index 9a994f3477..628ea335ed 100644 --- a/src/nvim/path.h +++ b/src/nvim/path.h @@ -17,6 +17,7 @@  #define EW_ICASE        0x100   /* ignore case */  #define EW_NOERROR      0x200   /* no error for bad regexp */  #define EW_NOTWILD      0x400   /* add match with literal name if exists */ +#define EW_KEEPDOLLAR   0x800   /* do not escape $, $var is expanded */  /* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND  * is used when executing commands and EW_SILENT for interactive expanding. */ diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 69c2119697..dd7af63ce0 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -602,7 +602,7 @@ static int get_char_class(char_u **pp)    int i;    if ((*pp)[1] == ':') { -    for (i = 0; i < (int)(sizeof(class_names) / sizeof(*class_names)); ++i) +    for (i = 0; i < (int)ARRAY_SIZE(class_names); ++i)        if (STRNCMP(*pp + 2, class_names[i], STRLEN(class_names[i])) == 0) {          *pp += STRLEN(class_names[i]) + 2;          return i; diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h index 8aa89d22b7..1e00f14ac6 100644 --- a/src/nvim/regexp_defs.h +++ b/src/nvim/regexp_defs.h @@ -108,7 +108,7 @@ typedef struct {    regprog_T           *regprog;    char_u              *startp[NSUBEXP];    char_u              *endp[NSUBEXP]; -  int rm_ic; +  bool                 rm_ic;  } regmatch_T;  /* diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index b7a485598b..6787ca8080 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3943,7 +3943,7 @@ get_syn_options (      if (strchr(first_letters, *arg) == NULL)        break; -    for (fidx = sizeof(flagtab) / sizeof(struct flag); --fidx >= 0; ) { +    for (fidx = ARRAY_SIZE(flagtab); --fidx >= 0; ) {        p = flagtab[fidx].name;        int i;        for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) @@ -5157,22 +5157,21 @@ get_id_list (            regmatch.rm_ic = TRUE;            id = 0;            for (int i = highlight_ga.ga_len; --i >= 0; ) { -            if (!vim_regexec(®match, HL_TABLE()[i].sg_name, (colnr_T)0)) { -              continue; -            } -            if (round == 2) { -              /* Got more items than expected; can happen -               * when adding items that match: -               * "contains=a.*b,axb". -               * Go back to first round */ -              if (count >= total_count) { -                free(retval); -                round = 1; -              } else -                retval[count] = i + 1; +            if (vim_regexec(®match, HL_TABLE()[i].sg_name, (colnr_T)0)) { +              if (round == 2) { +                /* Got more items than expected; can happen +                 * when adding items that match: +                 * "contains=a.*b,axb". +                 * Go back to first round */ +                if (count >= total_count) { +                  free(retval); +                  round = 1; +                } else +                  retval[count] = i + 1; +              } +              ++count; +              id = -1;                      /* remember that we found one */              } -            ++count; -            id = -1;                      /* remember that we found one */            }            vim_regfree(regmatch.regprog);          } @@ -6296,7 +6295,7 @@ do_highlight (          attr = 0;          off = 0;          while (arg[off] != NUL) { -          for (i = sizeof(hl_attr_table) / sizeof(int); --i >= 0; ) { +          for (i = ARRAY_SIZE(hl_attr_table); --i >= 0; ) {              len = (int)STRLEN(hl_name_table[i]);              if (STRNICMP(arg + off, hl_name_table[i], len) == 0) {                attr |= hl_attr_table[i]; @@ -6417,7 +6416,7 @@ do_highlight (              /* reduce calls to STRICMP a bit, it can be slow */              off = TOUPPER_ASC(*arg); -            for (i = (sizeof(color_names) / sizeof(char *)); --i >= 0; ) +            for (i = ARRAY_SIZE(color_names); --i >= 0; )                if (off == color_names[i][0]                    && STRICMP(arg + 1, color_names[i] + 1) == 0)                  break; diff --git a/src/nvim/tempfile.c b/src/nvim/tempfile.c index 33d6f0f37d..f81aff53a1 100644 --- a/src/nvim/tempfile.c +++ b/src/nvim/tempfile.c @@ -30,7 +30,7 @@ static void vim_maketempdir(void)    // Try the entries in `TEMP_DIR_NAMES` to create the temp directory.    char_u template[TEMP_FILE_PATH_MAXLEN];    char_u path[TEMP_FILE_PATH_MAXLEN]; -  for (size_t i = 0; i < sizeof(temp_dirs) / sizeof(char *); ++i) { +  for (size_t i = 0; i < ARRAY_SIZE(temp_dirs); ++i) {      // Expand environment variables, leave room for "/nvimXXXXXX/999999999"      expand_env((char_u *)temp_dirs[i], template, TEMP_FILE_PATH_MAXLEN - 22);      if (!os_isdir(template)) {  // directory doesn't exist diff --git a/src/nvim/term.c b/src/nvim/term.c index 24969bf90f..ceec140670 100644 --- a/src/nvim/term.c +++ b/src/nvim/term.c @@ -80,7 +80,7 @@   *   * The entries are compact, therefore they normally are included even when   * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries - * can be accessed with "builtin_amiga", "builtin_ansi", "builtin_debug", etc. + * can be accessed with "builtin_ansi", "builtin_debug", etc.   *   * Each termcap is a list of builtin_term structures. It always starts with   * KS_NAME, which separates the entries.  See parse_builtin_tcap() for all diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 6bacef9778..fce0971d89 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -94,7 +94,7 @@ $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG) test1.out  RM_ON_RUN   := test.out X* viminfo  RM_ON_START := tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok -RUN_VIM     := VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(TOOL) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in +RUN_VIM     := VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(TOOL) $(VIMPROG) -u unix.vim -U NONE -i viminfo --noplugin -s dotest.in  clean:  	-rm -rf *.out          \ diff --git a/src/nvim/testdir/test100.in b/src/nvim/testdir/test100.in index 2bf931fd4f..083b4324b2 100644 --- a/src/nvim/testdir/test100.in +++ b/src/nvim/testdir/test100.in @@ -2,7 +2,7 @@ Tests for 'undolevel' setting being global-local  STARTTEST  :so small.vim -:set nocompatible viminfo+=nviminfo ul=5 +:set ul=5  :fu! FillBuffer()    :for i in range(1,13)      :put=i diff --git a/src/nvim/testdir/test12.in b/src/nvim/testdir/test12.in index 46e9c45b80..be3169a625 100644 --- a/src/nvim/testdir/test12.in +++ b/src/nvim/testdir/test12.in @@ -5,7 +5,6 @@ Tests for 'directory' option.  STARTTEST  :so small.vim -:set nocompatible viminfo+=nviminfo  :set dir=.,~  :/start of testfile/,/end of testfile/w! Xtest1  :" do an ls of the current dir to find the swap file (should not be there) diff --git a/src/nvim/testdir/test15.in b/src/nvim/testdir/test15.in index 366529a550..60d8717278 100644 --- a/src/nvim/testdir/test15.in +++ b/src/nvim/testdir/test15.in @@ -12,7 +12,6 @@ STARTTEST  :set fo+=tcroql tw=72  /xxxxxxxx$  0gq6kk -:set nocp viminfo+=nviminfo  :" undo/redo here to make the next undo only work on the following changes  u  :map gg :.,.+2s/^/x/<CR>kk:set tw=3<CR>gqq diff --git a/src/nvim/testdir/test17.in b/src/nvim/testdir/test17.in index 64534ec77c..7fef87d383 100644 --- a/src/nvim/testdir/test17.in +++ b/src/nvim/testdir/test17.in @@ -16,11 +16,7 @@ STARTTEST  :let $CDIR = "."  /CDIR  :else -:if has("amiga") -:let $TDIR = "/testdir" -:else  :let $TDIR = "." -:endif  /TDIR  :endif  :" Dummy writing for making that sure gf doesn't fail even if the current diff --git a/src/nvim/testdir/test24.in b/src/nvim/testdir/test24.inBinary files differ index 7dfc1afdc6..292f403048 100644 --- a/src/nvim/testdir/test24.in +++ b/src/nvim/testdir/test24.in diff --git a/src/nvim/testdir/test29.in b/src/nvim/testdir/test29.in index 83c6acdc1c..4cc2120814 100644 --- a/src/nvim/testdir/test29.in +++ b/src/nvim/testdir/test29.in @@ -5,7 +5,6 @@ Test for joining lines and marks in them  STARTTEST  :so small.vim -:set viminfo+=nviminfo  :set nojoinspaces  :set cpoptions-=j  /firstline/ diff --git a/src/nvim/testdir/test3.in b/src/nvim/testdir/test3.in index a7543945c4..7f6d412806 100644 --- a/src/nvim/testdir/test3.in +++ b/src/nvim/testdir/test3.in @@ -4,7 +4,7 @@ Test for 'cindent'  STARTTEST  :so small.vim -:set nocompatible viminfo+=nviminfo modeline +:set modeline  :edit                " read modeline  /start of AUTO  =/end of AUTO @@ -1432,7 +1432,7 @@ int main ()  STARTTEST  :set cino=(0,ts -2kdd=][ +2kdd2j=][  ENDTEST  void func(int a @@ -1446,7 +1446,7 @@ void func(int a  STARTTEST  :set cino=(0 -2kdd=][ +2kdd2j=][  ENDTEST  void @@ -1461,7 +1461,7 @@ func(int a  STARTTEST  :set cino& -2kdd=7][ +2kdd2j=7][  ENDTEST  void func(void) @@ -1538,7 +1538,7 @@ func6(  STARTTEST  :set cino&  :set cino+=l1 -2kdd=][ +2kdd2j=][  ENDTEST  void func(void) @@ -1567,7 +1567,7 @@ break;  STARTTEST  :set cino& -2kdd=][ +2kdd2j=][  ENDTEST  void func(void) @@ -1592,7 +1592,7 @@ void func(void)  STARTTEST  :set cino& -2kdd=][ +2kdd2j=][  ENDTEST  void func(void) @@ -1919,10 +1919,10 @@ ENDTEST  JSSTART  var foo = [ -1,  // indent 8 more +1,  2,  3 -];  // indent 8 less +];  JSEND  STARTTEST @@ -1937,7 +1937,7 @@ var foo = [  1,  2,  3 -];  // indent 16 less +];  }  JSEND @@ -1950,6 +1950,12 @@ ENDTEST  JSSTART  (function($){ +if (cond && +cond) { +stmt; +} +window.something.left = +(width - 50 + offset) + "px";  var class_name='myclass';  function private_method() { @@ -1965,15 +1971,15 @@ function init(options) {  $(this).data(class_name+'_public',$.extend({},{  foo: 'bar', -bar: 2,  // indent 8 more -foobar: [  // indent 8 more -1,  // indent 8 more -2,  // indent 16 more -3   // indent 16 more +bar: 2, +foobar: [ +1, +2, +3  ], -callback: function(){  // indent 8 more -return true;  // indent 8 more -}  // indent 8 more +callback: function(){ +return true; +}  }, options||{}));  } @@ -2014,9 +2020,9 @@ $(this).data(class_name+'_public',$.extend({},{  foo: 'bar',  bar: 2,  foobar: [ -1,  // indent 8 more -2,  // indent 8 more -3   // indent 8 more +1, +2, +3  ],  callback: function(){  return true; @@ -2036,15 +2042,15 @@ JSSTART  function init(options) {  $(this).data(class_name+'_public',$.extend({},{  foo: 'bar', -bar: 2,  // indent 8 more -foobar: [  // indent 8 more -1,  // indent 8 more -2,  // indent 16 more -3  // indent 16 more +bar: 2, +foobar: [ +1, +2, +3  ], -callback: function(){  // indent 8 more -return true;  // indent 8 more -}  // indent 8 more +callback: function(){ +return true; +}  }, options||{}));  }  })(jQuery); diff --git a/src/nvim/testdir/test3.ok b/src/nvim/testdir/test3.ok index d73a5e1230..0d0e76fce4 100644 --- a/src/nvim/testdir/test3.ok +++ b/src/nvim/testdir/test3.ok @@ -1707,10 +1707,10 @@ JSEND  JSSTART  var foo = [ -1,  // indent 8 more +	1,  	2,  	3 -	];  // indent 8 less +];  JSEND @@ -1720,7 +1720,7 @@ function bar() {  		1,  		2,  		3 -			];  // indent 16 less +	];  }  JSEND @@ -1728,6 +1728,12 @@ JSEND  JSSTART  (function($){ +	if (cond && +			cond) { +		stmt; +	} +	window.something.left = +		(width - 50 + offset) + "px";  	var class_name='myclass';  	function private_method() { @@ -1743,15 +1749,15 @@ JSSTART  		$(this).data(class_name+'_public',$.extend({},{  			foo: 'bar', -		bar: 2,  // indent 8 more -		foobar: [  // indent 8 more -			1,  // indent 8 more -		2,  // indent 16 more -		3   // indent 16 more +			bar: 2, +			foobar: [ +				1, +				2, +				3  			], -		callback: function(){  // indent 8 more -			return true;  // indent 8 more -		}  // indent 8 more +			callback: function(){ +				return true; +			}  		}, options||{}));  	} @@ -1787,9 +1793,9 @@ function init(options) {  		foo: 'bar',  		bar: 2,  		foobar: [ -		1,  // indent 8 more -		2,  // indent 8 more -		3   // indent 8 more +			1, +			2, +			3  		],  		callback: function(){  			return true; @@ -1804,15 +1810,15 @@ JSSTART  	function init(options) {  		$(this).data(class_name+'_public',$.extend({},{  			foo: 'bar', -		bar: 2,  // indent 8 more -		foobar: [  // indent 8 more -			1,  // indent 8 more -		2,  // indent 16 more -		3  // indent 16 more +			bar: 2, +			foobar: [ +				1, +				2, +				3  			], -		callback: function(){  // indent 8 more -			return true;  // indent 8 more -		}  // indent 8 more +			callback: function(){ +				return true; +			}  		}, options||{}));  	}  })(jQuery); diff --git a/src/nvim/testdir/test30.in b/src/nvim/testdir/test30.in index 4a8778d2de..3f7b9eb472 100644 --- a/src/nvim/testdir/test30.in +++ b/src/nvim/testdir/test30.in @@ -24,12 +24,7 @@ STARTTEST  :set nobin eol  :bwipe XXUnix XXDos XXMac  :" create mixed format files -:if has("vms") -: !copy XXUnix,XXDos XXUxDs. -: !copy XXUnix,XXMac XXUxMac. -: !copy XXDos,XXMac  XXDosMac. -: !copy XXUnix,XXDos,XXMac XXUxDsMc. -:elseif has("win32") +:if has("win32")  : !copy /b XXUnix+XXDos XXUxDs  : !copy /b XXUnix+XXMac XXUxMac  : !copy /b XXDos+XXMac XXDosMac diff --git a/src/nvim/testdir/test32.in b/src/nvim/testdir/test32.in index 6b399fa6c6..02a41141ab 100644 --- a/src/nvim/testdir/test32.in +++ b/src/nvim/testdir/test32.in @@ -22,7 +22,7 @@ Test for insert expansion  STARTTEST  :so small.vim -:se nocp viminfo+=nviminfo cpt=.,w ff=unix | $-2,$w!Xtestfile | set ff& +:se cpt=.,w ff=unix | $-2,$w!Xtestfile | set ff&  :se cot=  nO#include "Xtestfile"  ru diff --git a/src/nvim/testdir/test44.in b/src/nvim/testdir/test44.in index 87de1b95a4..65b08b08b8 100644 --- a/src/nvim/testdir/test44.in +++ b/src/nvim/testdir/test44.in @@ -4,7 +4,7 @@ See test99 for exactly the same test with re=2.  STARTTEST  :so mbyte.vim -:set nocompatible encoding=utf-8 termencoding=latin1 viminfo+=nviminfo +:set encoding=utf-8 termencoding=latin1  :set re=1  /^1  /a*b\{2}c\+/e diff --git a/src/nvim/testdir/test49.in b/src/nvim/testdir/test49.in index 5e1d6b461e..1ce57246ee 100644 --- a/src/nvim/testdir/test49.in +++ b/src/nvim/testdir/test49.in @@ -5,7 +5,7 @@ test49.failed, try to add one or more "G"s at the line ending in "test.out"  STARTTEST  :so small.vim -:se nocp nomore viminfo+=nviminfo +:se nomore  :lang mess C  :so test49.vim  GGGGGGGGGGGGGG"rp:.-,$w! test.out diff --git a/src/nvim/testdir/test61.in b/src/nvim/testdir/test61.in index dc24ab9804..87bb07a209 100644 --- a/src/nvim/testdir/test61.in +++ b/src/nvim/testdir/test61.in @@ -85,7 +85,6 @@ ggO---:0put b  ggO---:0put a  ggO---:w >>test.out  :so small.vim -:set nocp viminfo+=nviminfo  :enew!  oa  :set ul=100 diff --git a/src/nvim/testdir/test70.in b/src/nvim/testdir/test70.in index 9fbe818b3d..24d2e4c446 100644 --- a/src/nvim/testdir/test70.in +++ b/src/nvim/testdir/test70.in @@ -2,7 +2,6 @@ Smoke test for MzScheme interface and mzeval() function  STARTTEST  :so mzscheme.vim -:set nocompatible viminfo+=nviminfo  :function! MzRequire()  :redir => l:mzversion  :mz (version) diff --git a/src/nvim/testdir/test72.in b/src/nvim/testdir/test72.in index 4700d86981..20897f01a0 100644 --- a/src/nvim/testdir/test72.in +++ b/src/nvim/testdir/test72.in @@ -6,7 +6,7 @@ STARTTEST  :so small.vim  :"  :" Test 'undofile': first a simple one-line change. -:set nocompatible viminfo+=nviminfo visualbell +:set visualbell  :set ul=100 undofile nomore  :set ft=unix  :e! Xtestfile diff --git a/src/nvim/testdir/test73.in b/src/nvim/testdir/test73.in index 666e4d2e50..60cda2d970 100644 --- a/src/nvim/testdir/test73.in +++ b/src/nvim/testdir/test73.in @@ -7,7 +7,6 @@ STARTTEST  :"  :" This will cause a few errors, do it silently.  :set visualbell -:set nocp viminfo+=nviminfo  :"  :function! DeleteDirectory(dir)  : if has("win16") || has("win32") || has("win64") || has("dos16") || has("dos32") diff --git a/src/nvim/testdir/test74.in b/src/nvim/testdir/test74.in index 4fbe5e4d01..9fdbe771b3 100644 --- a/src/nvim/testdir/test74.in +++ b/src/nvim/testdir/test74.in @@ -7,7 +7,7 @@ STARTTEST  :"  :" This will cause a few errors, do it silently.  :set visualbell -:set nocp viminfo+=!,nviminfo +:set viminfo+=!  :let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}  :" store a really long list, so line wrapping will occur in viminfo file  :let MY_GLOBAL_LIST=range(1,100) diff --git a/src/nvim/testdir/test78.in b/src/nvim/testdir/test78.in index 1850bd9236..cb0e51edd5 100644 --- a/src/nvim/testdir/test78.in +++ b/src/nvim/testdir/test78.in @@ -6,7 +6,7 @@ blocks.  STARTTEST  :so small.vim -:set nocp fileformat=unix undolevels=-1 viminfo+=nviminfo +:set fileformat=unix undolevels=-1  :e! Xtest  ggdG  :let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789" diff --git a/src/nvim/testdir/test8.in b/src/nvim/testdir/test8.in index d9d00d97ae..0f27c813ec 100644 --- a/src/nvim/testdir/test8.in +++ b/src/nvim/testdir/test8.in @@ -32,7 +32,7 @@ endfunc    $put ='VimLeave done'    write  endfunc -:set viminfo='100,nviminfo +:set viminfo='100  :au BufUnload * call CloseAll()  :au VimLeave * call WriteToOut()  :e small.vim diff --git a/src/nvim/testdir/test85.in b/src/nvim/testdir/test85.in index c5ca873a49..f7112792e9 100644 --- a/src/nvim/testdir/test85.in +++ b/src/nvim/testdir/test85.in @@ -3,7 +3,6 @@ Test for Lua interface and luaeval() function  STARTTEST  :so small.vim  :so lua.vim -:set nocompatible viminfo+=nviminfo  :lua l = vim.list():add"item0":add"dictionary with list OK":add"item2"  :lua h = vim.dict(); h.list = l  :call garbagecollect() diff --git a/src/nvim/testdir/test89.in b/src/nvim/testdir/test89.in index 1968066198..f1f64fb41f 100644 --- a/src/nvim/testdir/test89.in +++ b/src/nvim/testdir/test89.in @@ -5,7 +5,7 @@  STARTTEST  :so small.vim -:set hidden nocp nu rnu viminfo+=nviminfo +:set hidden nu rnu  :redir @a | set nu? rnu? | redir END  :e! xx  :redir @b | set nu? rnu? | redir END diff --git a/src/nvim/testdir/test91.in b/src/nvim/testdir/test91.in index e900a522df..b66776b1e4 100644 --- a/src/nvim/testdir/test91.in +++ b/src/nvim/testdir/test91.in @@ -55,6 +55,7 @@ STARTTEST  :tabnew  :tabnew  :let t:var_list = [1, 2, 3] +:let t:other = 777  :let def_list = [4, 5, 6, 7]  :tabrewind  :$put =string(gettabvar(3, 'var_list')) diff --git a/src/nvim/testdir/test91.ok b/src/nvim/testdir/test91.ok index 22e1572209..809952b69d 100644 --- a/src/nvim/testdir/test91.ok +++ b/src/nvim/testdir/test91.ok @@ -26,8 +26,8 @@ iso-8859-2  0  [1, 2, 3]  [1, 2, 3] -'' -[4, 5, 6, 7] +{'var_list': [1, 2, 3], 'other': 777} +{'var_list': [1, 2, 3], 'other': 777}  [4, 5, 6, 7]  ''  [4, 5, 6, 7] diff --git a/src/nvim/testdir/test94.in b/src/nvim/testdir/test94.in index dfa91d8340..a8b46112d2 100644 --- a/src/nvim/testdir/test94.in +++ b/src/nvim/testdir/test94.in @@ -17,7 +17,6 @@ Test cases:  STARTTEST  :so small.vim -:set nocp viminfo+=nviminfo  :  :" User functions  :function MoveToCap() diff --git a/src/nvim/testdir/test95.in b/src/nvim/testdir/test95.in index b2b9de772e..221b550487 100644 --- a/src/nvim/testdir/test95.in +++ b/src/nvim/testdir/test95.in @@ -7,7 +7,7 @@ actually tried.  STARTTEST  :so small.vim  :so mbyte.vim -:set nocp encoding=utf-8 viminfo+=nviminfo nomore +:set encoding=utf-8 nomore  :" tl is a List of Lists with:  :"    2: test auto/old/new  0: test auto/old  1: test auto/new  :"    regexp pattern diff --git a/src/nvim/testdir/test99.in b/src/nvim/testdir/test99.in index 77828f4b68..32bc68cce4 100644 --- a/src/nvim/testdir/test99.in +++ b/src/nvim/testdir/test99.in @@ -4,7 +4,7 @@ See test44 for exactly the same test with re=1.  STARTTEST  :so mbyte.vim -:set nocompatible encoding=utf-8 termencoding=latin1 viminfo+=nviminfo +:set encoding=utf-8 termencoding=latin1  :set re=2  /^1  /a*b\{2}c\+/e diff --git a/src/nvim/testdir/test_breakindent.in b/src/nvim/testdir/test_breakindent.in index 0b00c95a85..ad12d0074d 100644 --- a/src/nvim/testdir/test_breakindent.in +++ b/src/nvim/testdir/test_breakindent.in @@ -81,7 +81,7 @@ STARTTEST  :" https://groups.google.com/d/msg/vim_dev/ZOdg2mc9c9Y/TT8EhFjEy0IJ  :only  :vert 20new -:set all& nocp breakindent briopt=min:10 +:set all& breakindent briopt=min:10  :call setline(1, ["    a\tb\tc\td\te", "    z   y       x       w       v"])  :/^\s*a  fbgjyl:let line1 = @0 diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 2ab31b6cfd..9a3da5bcdb 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -230,7 +230,7 @@ int u_save(linenr_T top, linenr_T bot)    if (top > curbuf->b_ml.ml_line_count        || top >= bot        || bot > curbuf->b_ml.ml_line_count + 1) -    return FALSE;       /* rely on caller to do error messages */ +    return FAIL;        /* rely on caller to do error messages */    if (top + 2 == bot)      u_saveline((linenr_T)(top + 1)); diff --git a/src/nvim/version.c b/src/nvim/version.c index 3460b7c6c3..245f797306 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -178,6 +178,14 @@ static char *(features[]) = {  };  static int included_patches[] = { +  //560, +  //559, +  //558 NA +  //557 NA +  //556 NA +  //555 NA +  //554, +  //553,    //552,    //551,    //550, @@ -274,7 +282,7 @@ static int included_patches[] = {    //458,    //457,    //456, -  //455, +  455,    454,    //453 NA    //452, @@ -287,7 +295,7 @@ static int included_patches[] = {    //445,    444,    //443, -  //442, +  442,    //441,    440,    439, @@ -295,7 +303,7 @@ static int included_patches[] = {    437,    436,    435, -  //434, +  434,    433,    //432 NA    //431 NA @@ -306,7 +314,7 @@ static int included_patches[] = {    //426 NA    425,    //424 NA -  //423, +  423,    //422,    421,    //420 NA @@ -339,7 +347,7 @@ static int included_patches[] = {    //393 NA    392,    391, -  //390, +  390,    //389,    388,    387, @@ -374,12 +382,12 @@ static int included_patches[] = {    358,    357,    //356 NA -  //355, +  355,    //354 NA    353,    352,    351, -  //350, +  350,    349,    348,    347, @@ -986,7 +994,7 @@ void intro_message(int colon)    };    // blanklines = screen height - # message lines -  blanklines = (int)Rows - ((sizeof(lines) / sizeof(char *)) - 1); +  blanklines = (int)Rows - (ARRAY_SIZE(lines) - 1);    // Don't overwrite a statusline.  Depends on 'cmdheight'.    if (p_ls > 1) { @@ -1006,7 +1014,7 @@ void intro_message(int colon)    row = blanklines / 2;    if (((row >= 2) && (Columns >= 50)) || colon) { -    for (i = 0; i < (int)(sizeof(lines) / sizeof(char *)); ++i) { +    for (i = 0; i < (int)ARRAY_SIZE(lines); ++i) {        p = lines[i];        if (sponsor != 0) { diff --git a/src/nvim/window.c b/src/nvim/window.c index 0ed43b0184..029fcaac8b 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1977,6 +1977,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)    tabpage_T   *ptp = NULL;    int free_tp = FALSE; +  assert(win->w_buffer);  // to avoid np dereference warning in next line    if (win->w_closing || win->w_buffer->b_closing)      return;     /* window is already being closed */ | 
