diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ex_getln.c | 2 | ||||
| -rw-r--r-- | src/garray.c | 21 | ||||
| -rw-r--r-- | src/garray.h | 1 | ||||
| -rw-r--r-- | src/path.c | 29 | ||||
| -rw-r--r-- | src/path.h | 1 | 
5 files changed, 28 insertions, 26 deletions
| diff --git a/src/ex_getln.c b/src/ex_getln.c index 7605032b58..a7a3b80222 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4207,7 +4207,7 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname    /* Sort and remove duplicates which can happen when specifying multiple     * directories in dirnames. */ -  remove_duplicates(&ga); +  ga_remove_duplicate_strings(&ga);    *file = ga.ga_data;    *num_file = ga.ga_len; diff --git a/src/garray.c b/src/garray.c index aba4d5649f..8bf2b7477e 100644 --- a/src/garray.c +++ b/src/garray.c @@ -7,6 +7,7 @@  #include "vim.h"  #include "ascii.h"  #include "misc2.h" +#include "path.h"  #include "garray.h"  // #include "globals.h" @@ -86,6 +87,26 @@ int ga_grow(garray_T *gap, int n)    return OK;  } +/// Sort "gap" and remove duplicate entries.  "gap" is expected to contain a +/// list of file names in allocated memory. +/// +/// @param gap +void ga_remove_duplicate_strings(garray_T *gap) +{ +  int i; +  int j; +  char_u  **fnames = (char_u **)gap->ga_data; + +  sort_strings(fnames, gap->ga_len); +  for (i = gap->ga_len - 1; i > 0; --i) +    if (fnamecmp(fnames[i - 1], fnames[i]) == 0) { +      vim_free(fnames[i]); +      for (j = i + 1; j < gap->ga_len; ++j) +        fnames[j - 1] = fnames[j]; +      --gap->ga_len; +    } +} +  /// For a growing array that contains a list of strings: concatenate all the  /// strings with a separating comma.  /// diff --git a/src/garray.h b/src/garray.h index c427842d93..c3631a8bd9 100644 --- a/src/garray.h +++ b/src/garray.h @@ -20,6 +20,7 @@ void ga_init(garray_T *gap);  void ga_init2(garray_T *gap, int itemsize, int growsize);  int ga_grow(garray_T *gap, int n);  char_u *ga_concat_strings(garray_T *gap); +void ga_remove_duplicate_strings(garray_T *gap);  void ga_concat(garray_T *gap, char_u *s);  void ga_append(garray_T *gap, int c);  void append_ga_line(garray_T *gap); diff --git a/src/path.c b/src/path.c index 2e8865b0c7..f643c8ec82 100644 --- a/src/path.c +++ b/src/path.c @@ -4,17 +4,17 @@  #include "eval.h"  #include "ex_getln.h"  #include "fileio.h" +#include "garray.h"  #include "memline.h"  #include "misc1.h"  #include "misc2.h" -#include "garray.h" -#include "types.h" +#include "os/os.h"  #include "os_unix.h"  #include "regexp.h"  #include "tag.h" +#include "types.h"  #include "ui.h"  #include "window.h" -#include "os/os.h"  /*   * Compare two file names and return: @@ -801,7 +801,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)    char_u      **in_curdir = NULL;    char_u      *short_name; -  remove_duplicates(gap); +  ga_remove_duplicate_strings(gap);    ga_init2(&path_ga, (int)sizeof(char_u *), 1);    /* @@ -930,7 +930,7 @@ theend:    vim_regfree(regmatch.regprog);    if (sort_again) -    remove_duplicates(gap); +    ga_remove_duplicate_strings(gap);  }  /* @@ -993,25 +993,6 @@ expand_in_path (    return gap->ga_len;  } -/* - * Sort "gap" and remove duplicate entries.  "gap" is expected to contain a - * list of file names in allocated memory. - */ -void remove_duplicates(garray_T *gap) -{ -  int i; -  int j; -  char_u  **fnames = (char_u **)gap->ga_data; - -  sort_strings(fnames, gap->ga_len); -  for (i = gap->ga_len - 1; i > 0; --i) -    if (fnamecmp(fnames[i - 1], fnames[i]) == 0) { -      vim_free(fnames[i]); -      for (j = i + 1; j < gap->ga_len; ++j) -        fnames[j - 1] = fnames[j]; -      --gap->ga_len; -    } -}  static int has_env_var(char_u *p); diff --git a/src/path.h b/src/path.h index fc6166d258..cf46b0f02f 100644 --- a/src/path.h +++ b/src/path.h @@ -10,7 +10,6 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len);  char_u *concat_fnames(char_u *fname1, char_u *fname2, int sep);  int unix_expandpath(garray_T *gap, char_u *path, int wildoff, int flags,                      int didstar); -void remove_duplicates(garray_T *gap);  int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,                           char_u ***file,                           int flags); | 
