Mercurial > vim
comparison src/ex_getln.c @ 2929:e3bb93df6c34 v7.3.237
updated for version 7.3.237
Problem: "filetype" completion doesn't work on Windows. (Yue Wu)
Solution: Don't use a glob pattern for the directories, use a list of
directories. (Dominique Pelle)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 26 Jun 2011 19:40:23 +0200 |
parents | b0190e93e601 |
children | f2c108f44f41 |
comparison
equal
deleted
inserted
replaced
2928:889e69c501d6 | 2929:e3bb93df6c34 |
---|---|
108 static void set_expand_context __ARGS((expand_T *xp)); | 108 static void set_expand_context __ARGS((expand_T *xp)); |
109 static int ExpandFromContext __ARGS((expand_T *xp, char_u *, int *, char_u ***, int)); | 109 static int ExpandFromContext __ARGS((expand_T *xp, char_u *, int *, char_u ***, int)); |
110 static int expand_showtail __ARGS((expand_T *xp)); | 110 static int expand_showtail __ARGS((expand_T *xp)); |
111 #ifdef FEAT_CMDL_COMPL | 111 #ifdef FEAT_CMDL_COMPL |
112 static int expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg)); | 112 static int expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg)); |
113 static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname)); | 113 static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[])); |
114 # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) | 114 # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) |
115 static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file)); | 115 static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file)); |
116 static int ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file)); | 116 static int ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file)); |
117 # endif | 117 # endif |
118 #endif | 118 #endif |
4534 return ExpandBufnames(pat, num_file, file, options); | 4534 return ExpandBufnames(pat, num_file, file, options); |
4535 if (xp->xp_context == EXPAND_TAGS | 4535 if (xp->xp_context == EXPAND_TAGS |
4536 || xp->xp_context == EXPAND_TAGS_LISTFILES) | 4536 || xp->xp_context == EXPAND_TAGS_LISTFILES) |
4537 return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file); | 4537 return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file); |
4538 if (xp->xp_context == EXPAND_COLORS) | 4538 if (xp->xp_context == EXPAND_COLORS) |
4539 return ExpandRTDir(pat, num_file, file, "colors"); | 4539 { |
4540 char *directories[] = {"colors", NULL}; | |
4541 return ExpandRTDir(pat, num_file, file, directories); | |
4542 } | |
4540 if (xp->xp_context == EXPAND_COMPILER) | 4543 if (xp->xp_context == EXPAND_COMPILER) |
4541 return ExpandRTDir(pat, num_file, file, "compiler"); | 4544 { |
4545 char *directories[] = {"colors", NULL}; | |
4546 return ExpandRTDir(pat, num_file, file, directories); | |
4547 } | |
4542 if (xp->xp_context == EXPAND_OWNSYNTAX) | 4548 if (xp->xp_context == EXPAND_OWNSYNTAX) |
4543 return ExpandRTDir(pat, num_file, file, "syntax"); | 4549 { |
4550 char *directories[] = {"syntax", NULL}; | |
4551 return ExpandRTDir(pat, num_file, file, directories); | |
4552 } | |
4544 if (xp->xp_context == EXPAND_FILETYPE) | 4553 if (xp->xp_context == EXPAND_FILETYPE) |
4545 return ExpandRTDir(pat, num_file, file, "{syntax,indent,ftplugin}"); | 4554 { |
4555 char *directories[] = {"syntax", "indent", "ftplugin", NULL}; | |
4556 return ExpandRTDir(pat, num_file, file, directories); | |
4557 } | |
4546 # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) | 4558 # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) |
4547 if (xp->xp_context == EXPAND_USER_LIST) | 4559 if (xp->xp_context == EXPAND_USER_LIST) |
4548 return ExpandUserList(xp, num_file, file); | 4560 return ExpandUserList(xp, num_file, file); |
4549 # endif | 4561 # endif |
4550 | 4562 |
4993 #endif | 5005 #endif |
4994 | 5006 |
4995 /* | 5007 /* |
4996 * Expand color scheme, compiler or filetype names: | 5008 * Expand color scheme, compiler or filetype names: |
4997 * 'runtimepath'/{dirnames}/{pat}.vim | 5009 * 'runtimepath'/{dirnames}/{pat}.vim |
4998 * dirnames may contain one directory (ex: "colorscheme") or can be a glob | 5010 * "dirnames" is an array with one or more directory names. |
4999 * expression matching multiple directories (ex: "{syntax,ftplugin,indent}"). | |
5000 */ | 5011 */ |
5001 static int | 5012 static int |
5002 ExpandRTDir(pat, num_file, file, dirnames) | 5013 ExpandRTDir(pat, num_file, file, dirnames) |
5003 char_u *pat; | 5014 char_u *pat; |
5004 int *num_file; | 5015 int *num_file; |
5005 char_u ***file; | 5016 char_u ***file; |
5006 char *dirnames; | 5017 char *dirnames[]; |
5007 { | 5018 { |
5008 char_u *all; | 5019 char_u *matches; |
5009 char_u *s; | 5020 char_u *s; |
5010 char_u *e; | 5021 char_u *e; |
5011 garray_T ga; | 5022 garray_T ga; |
5023 int i; | |
5024 int pat_len; | |
5012 | 5025 |
5013 *num_file = 0; | 5026 *num_file = 0; |
5014 *file = NULL; | 5027 *file = NULL; |
5015 s = alloc((unsigned)(STRLEN(pat) + STRLEN(dirnames) + 7)); | 5028 pat_len = STRLEN(pat); |
5016 if (s == NULL) | 5029 ga_init2(&ga, (int)sizeof(char *), 10); |
5017 return FAIL; | 5030 |
5018 sprintf((char *)s, "%s/%s*.vim", dirnames, pat); | 5031 for (i = 0; dirnames[i] != NULL; ++i) |
5019 all = globpath(p_rtp, s, 0); | 5032 { |
5020 vim_free(s); | 5033 s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 7)); |
5021 if (all == NULL) | 5034 if (s == NULL) |
5022 return FAIL; | 5035 { |
5023 | 5036 ga_clear_strings(&ga); |
5024 ga_init2(&ga, (int)sizeof(char *), 3); | 5037 return FAIL; |
5025 for (s = all; *s != NUL; s = e) | 5038 } |
5026 { | 5039 sprintf((char *)s, "%s/%s*.vim", dirnames[i], pat); |
5027 e = vim_strchr(s, '\n'); | 5040 matches = globpath(p_rtp, s, 0); |
5028 if (e == NULL) | 5041 vim_free(s); |
5029 e = s + STRLEN(s); | 5042 if (matches == NULL) |
5030 if (ga_grow(&ga, 1) == FAIL) | 5043 continue; |
5031 break; | 5044 |
5032 if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0) | 5045 for (s = matches; *s != NUL; s = e) |
5033 { | 5046 { |
5034 for (s = e - 4; s > all; mb_ptr_back(all, s)) | 5047 e = vim_strchr(s, '\n'); |
5035 if (*s == '\n' || vim_ispathsep(*s)) | 5048 if (e == NULL) |
5036 break; | 5049 e = s + STRLEN(s); |
5037 ++s; | 5050 if (ga_grow(&ga, 1) == FAIL) |
5038 ((char_u **)ga.ga_data)[ga.ga_len] = | 5051 break; |
5052 if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0) | |
5053 { | |
5054 for (s = e - 4; s > matches; mb_ptr_back(matches, s)) | |
5055 if (*s == '\n' || vim_ispathsep(*s)) | |
5056 break; | |
5057 ++s; | |
5058 ((char_u **)ga.ga_data)[ga.ga_len] = | |
5039 vim_strnsave(s, (int)(e - s - 4)); | 5059 vim_strnsave(s, (int)(e - s - 4)); |
5040 ++ga.ga_len; | 5060 ++ga.ga_len; |
5041 } | 5061 } |
5042 if (*e != NUL) | 5062 if (*e != NUL) |
5043 ++e; | 5063 ++e; |
5044 } | 5064 } |
5045 vim_free(all); | 5065 vim_free(matches); |
5066 } | |
5067 if (ga.ga_len == 0) | |
5068 return FAIL; | |
5046 | 5069 |
5047 /* Sort and remove duplicates which can happen when specifying multiple | 5070 /* Sort and remove duplicates which can happen when specifying multiple |
5048 * directories in dirnames such as "{syntax,ftplugin,indent}". */ | 5071 * directories in dirnames. */ |
5049 remove_duplicates(&ga); | 5072 remove_duplicates(&ga); |
5050 | 5073 |
5051 *file = ga.ga_data; | 5074 *file = ga.ga_data; |
5052 *num_file = ga.ga_len; | 5075 *num_file = ga.ga_len; |
5053 return OK; | 5076 return OK; |