comparison src/misc1.c @ 2433:98b9a6b9e7d5 vim73

Add completion for ":ownsyntax" and improve completion for ":filetype". (Dominique Pelle)
author Bram Moolenaar <bram@vim.org>
date Thu, 29 Jul 2010 20:59:59 +0200
parents 7ce8b24450dc
children 291edb23ab17
comparison
equal deleted inserted replaced
2432:80229a724a11 2433:98b9a6b9e7d5
9236 #endif 9236 #endif
9237 9237
9238 #if defined(FEAT_SEARCHPATH) 9238 #if defined(FEAT_SEARCHPATH)
9239 static int find_previous_pathsep __ARGS((char_u *path, char_u **psep)); 9239 static int find_previous_pathsep __ARGS((char_u *path, char_u **psep));
9240 static int is_unique __ARGS((char_u *maybe_unique, garray_T *gap, int i)); 9240 static int is_unique __ARGS((char_u *maybe_unique, garray_T *gap, int i));
9241 static void remove_duplicates __ARGS((garray_T *gap));
9242 static void expand_path_option __ARGS((char_u *curdir, garray_T *gap)); 9241 static void expand_path_option __ARGS((char_u *curdir, garray_T *gap));
9243 static char_u *get_path_cutoff __ARGS((char_u *fname, garray_T *gap)); 9242 static char_u *get_path_cutoff __ARGS((char_u *fname, garray_T *gap));
9244 static void uniquefy_paths __ARGS((garray_T *gap, char_u *pattern)); 9243 static void uniquefy_paths __ARGS((garray_T *gap, char_u *pattern));
9245 static int expand_in_path __ARGS((garray_T *gap, char_u *pattern, int flags)); 9244 static int expand_in_path __ARGS((garray_T *gap, char_u *pattern, int flags));
9246 9245
9297 if (fnamecmp(maybe_unique, gettail(other_paths[j])) == 0) 9296 if (fnamecmp(maybe_unique, gettail(other_paths[j])) == 0)
9298 return FALSE; /* match */ 9297 return FALSE; /* match */
9299 } 9298 }
9300 9299
9301 return TRUE; /* no match found */ 9300 return TRUE; /* no match found */
9302 }
9303
9304 /*
9305 * Remove adjacent duplicate entries from "gap", which is a list of file names
9306 * in allocated memory.
9307 */
9308 static void
9309 remove_duplicates(gap)
9310 garray_T *gap;
9311 {
9312 int i;
9313 int j;
9314 char_u **fnames = (char_u **)gap->ga_data;
9315
9316 for (i = 1; i < gap->ga_len; ++i)
9317 if (fnamecmp(fnames[i - 1], fnames[i]) == 0)
9318 {
9319 vim_free(fnames[i]);
9320 for (j = i + 1; j < gap->ga_len; ++j)
9321 fnames[j - 1] = fnames[j];
9322 --gap->ga_len;
9323 --i;
9324 }
9325 } 9301 }
9326 9302
9327 /* 9303 /*
9328 * Split the 'path' option to a an array of strings as garray_T. Relative 9304 * Split the 'path' option to a an array of strings as garray_T. Relative
9329 * paths are expanded to their equivalent fullpath. This includes the "." 9305 * paths are expanded to their equivalent fullpath. This includes the "."
9637 9613
9638 c = gap->ga_len; 9614 c = gap->ga_len;
9639 vim_free(files); 9615 vim_free(files);
9640 9616
9641 return c; 9617 return c;
9618 }
9619 #endif
9620
9621 #if defined(FEAT_SEARCHPATH) || defined(FEAT_CMDL_COMPL) || defined(PROTO)
9622 /*
9623 * Remove adjacent duplicate entries from "gap", which is a list of file names
9624 * in allocated memory.
9625 */
9626 void
9627 remove_duplicates(gap)
9628 garray_T *gap;
9629 {
9630 int i;
9631 int j;
9632 char_u **fnames = (char_u **)gap->ga_data;
9633
9634 for (i = gap->ga_len - 1; i > 0; --i)
9635 if (fnamecmp(fnames[i - 1], fnames[i]) == 0)
9636 {
9637 vim_free(fnames[i]);
9638 for (j = i + 1; j < gap->ga_len; ++j)
9639 fnames[j - 1] = fnames[j];
9640 --gap->ga_len;
9641 }
9642 } 9642 }
9643 #endif 9643 #endif
9644 9644
9645 /* 9645 /*
9646 * Generic wildcard expansion code. 9646 * Generic wildcard expansion code.