diff options
Diffstat (limited to 'src/nvim/ex_cmds.c')
| -rw-r--r-- | src/nvim/ex_cmds.c | 90 | 
1 files changed, 40 insertions, 50 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index abed909008..a0fbde008b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -20,6 +20,7 @@  #include "nvim/ascii.h"  #include "nvim/ex_cmds.h"  #include "nvim/buffer.h" +#include "nvim/change.h"  #include "nvim/charset.h"  #include "nvim/cursor.h"  #include "nvim/diff.h" @@ -335,7 +336,7 @@ static int linelen(int *has_tab)    len = linetabsize(line);    // Check for embedded TAB.    if (has_tab != NULL) { -    *has_tab = STRRCHR(first, TAB) != NULL; +    *has_tab = vim_strchr(first, TAB) != NULL;    }    *last = save; @@ -1230,7 +1231,7 @@ static void do_filter(    /* Create the shell command in allocated memory. */    cmd_buf = make_filter_cmd(cmd, itmp, otmp); -  ui_cursor_goto((int)Rows - 1, 0); +  ui_cursor_goto(Rows - 1, 0);    if (do_out) {      if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL) { @@ -1931,11 +1932,12 @@ void do_wqall(exarg_T *eap)    int error = 0;    int save_forceit = eap->forceit; -  if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall) -    exiting = TRUE; +  if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall) { +    exiting = true; +  }    FOR_ALL_BUFFERS(buf) { -    if (!bufIsChanged(buf)) { +    if (!bufIsChanged(buf) || bt_dontwrite(buf)) {        continue;      }      /* @@ -2073,7 +2075,7 @@ int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum,      }      if (curbufIsChanged()) {        no_wait_return--; -      EMSG(_(e_nowrtmsg)); +      no_write_message();        retval = GETFILE_NOT_WRITTEN;     // File has been changed.        goto theend;      } @@ -4553,7 +4555,7 @@ void ex_help(exarg_T *eap)      } else {        // There is no help window yet.        // Try to open the file specified by the "helpfile" option. -      if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL) { +      if ((helpfd = os_fopen((char *)p_hf, READBIN)) == NULL) {          smsg(_("Sorry, help file \"%s\" not found"), p_hf);          goto erret;        } @@ -5083,7 +5085,7 @@ void fix_help_buffer(void)                  continue;                } -              FILE *const fd = mch_fopen((char *)fnames[fi], "r"); +              FILE *const fd = os_fopen((char *)fnames[fi], "r");                if (fd == NULL) {                  continue;                } @@ -5219,17 +5221,15 @@ static void helptags_one(char_u *const dir, const char_u *const ext,      return;    } -  FILE *const fd_tags = mch_fopen((char *)NameBuff, "w"); +  FILE *const fd_tags = os_fopen((char *)NameBuff, "w");    if (fd_tags == NULL) {      EMSG2(_("E152: Cannot open %s for writing"), NameBuff);      FreeWild(filecount, files);      return;    } -  /* -   * If using the "++t" argument or generating tags for "$VIMRUNTIME/doc" -   * add the "help-tags" tag. -   */ +  // If using the "++t" argument or generating tags for "$VIMRUNTIME/doc" +  // add the "help-tags" tag.    ga_init(&ga, (int)sizeof(char_u *), 100);    if (add_help_tags        || path_full_compare((char_u *)"$VIMRUNTIME/doc", @@ -5239,11 +5239,9 @@ static void helptags_one(char_u *const dir, const char_u *const ext,      GA_APPEND(char_u *, &ga, s);    } -  /* -   * Go over all the files and extract the tags. -   */ +  // Go over all the files and extract the tags.    for (int fi = 0; fi < filecount && !got_int; fi++) { -    FILE *const fd = mch_fopen((char *)files[fi], "r"); +    FILE *const fd = os_fopen((char *)files[fi], "r");      if (fd == NULL) {        EMSG2(_("E153: Unable to open %s for reading"), files[fi]);        continue; @@ -5281,21 +5279,19 @@ static void helptags_one(char_u *const dir, const char_u *const ext,          }          firstline = false;        } -      p1 = vim_strchr(IObuff, '*');             /* find first '*' */ +      p1 = vim_strchr(IObuff, '*');                        // find first '*'        while (p1 != NULL) {          p2 = (char_u *)strchr((const char *)p1 + 1, '*');  // Find second '*'. -        if (p2 != NULL && p2 > p1 + 1) {  // Skip "*" and "**". +        if (p2 != NULL && p2 > p1 + 1) {                   // Skip "*" and "**".            for (s = p1 + 1; s < p2; s++) {              if (*s == ' ' || *s == '\t' || *s == '|') {                break;              }            } -          /* -           * Only accept a *tag* when it consists of valid -           * characters, there is white space before it and is -           * followed by a white character or end-of-line. -           */ +          // Only accept a *tag* when it consists of valid +          // characters, there is white space before it and is +          // followed by a white character or end-of-line.            if (s == p2                && (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t')                && (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL @@ -5306,7 +5302,7 @@ static void helptags_one(char_u *const dir, const char_u *const ext,              GA_APPEND(char_u *, &ga, s);              sprintf((char *)s, "%s\t%s", p1, fname); -            /* find next '*' */ +            // find next '*'              p2 = vim_strchr(p2 + 1, '*');            }          } @@ -5320,18 +5316,12 @@ static void helptags_one(char_u *const dir, const char_u *const ext,    FreeWild(filecount, files); -  if (!got_int) { -    /* -     * Sort the tags. -     */ -    if (ga.ga_data != NULL) { -      sort_strings((char_u **)ga.ga_data, ga.ga_len); -    } +  if (!got_int && ga.ga_data != NULL) { +    // Sort the tags. +    sort_strings((char_u **)ga.ga_data, ga.ga_len); -    /* -     * Check for duplicates. -     */ -    for (int i = 1; i < ga.ga_len; ++i) { +    // Check for duplicates. +    for (int i = 1; i < ga.ga_len; i++) {        p1 = ((char_u **)ga.ga_data)[i - 1];        p2 = ((char_u **)ga.ga_data)[i];        while (*p1 == *p2) { @@ -5353,31 +5343,31 @@ static void helptags_one(char_u *const dir, const char_u *const ext,        fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");      } -    /* -     * Write the tags into the file. -     */ -    for (int i = 0; i < ga.ga_len; ++i) { +    // Write the tags into the file. +    for (int i = 0; i < ga.ga_len; i++) {        s = ((char_u **)ga.ga_data)[i]; -      if (STRNCMP(s, "help-tags\t", 10) == 0) -        /* help-tags entry was added in formatted form */ +      if (STRNCMP(s, "help-tags\t", 10) == 0) { +        // help-tags entry was added in formatted form          fputs((char *)s, fd_tags); -      else { -        fprintf(fd_tags, "%s\t/*", s); -        for (p1 = s; *p1 != '\t'; ++p1) { -          /* insert backslash before '\\' and '/' */ -          if (*p1 == '\\' || *p1 == '/') +      } else { +        fprintf(fd_tags, "%s\t/" "*", s); +        for (p1 = s; *p1 != '\t'; p1++) { +          // insert backslash before '\\' and '/' +          if (*p1 == '\\' || *p1 == '/') {              putc('\\', fd_tags); +          }            putc(*p1, fd_tags);          }          fprintf(fd_tags, "*\n");        }      }    } -  if (mix) -    got_int = FALSE;        /* continue with other languages */ +  if (mix) { +    got_int = false;        // continue with other languages +  }    GA_DEEP_CLEAR_PTR(&ga); -  fclose(fd_tags);          /* there is no check for an error... */ +  fclose(fd_tags);          // there is no check for an error...  }  /// Generate tags in one help directory, taking care of translations.  | 
