3767eb8
To: vim_dev@googlegroups.com
3767eb8
Subject: Patch 7.3.237
3767eb8
Fcc: outbox
3767eb8
From: Bram Moolenaar <Bram@moolenaar.net>
3767eb8
Mime-Version: 1.0
3767eb8
Content-Type: text/plain; charset=UTF-8
3767eb8
Content-Transfer-Encoding: 8bit
3767eb8
------------
3767eb8
3767eb8
Patch 7.3.237
3767eb8
Problem:    "filetype" completion doesn't work on Windows. (Yue Wu)
3767eb8
Solution:   Don't use a glob pattern for the directories, use a list of
3767eb8
            directories. (Dominique Pelle)
3767eb8
Files:      src/ex_getln.c
3767eb8
     
3767eb8
3767eb8
*** ../vim-7.3.236/src/ex_getln.c	2011-05-19 18:26:34.000000000 +0200
3767eb8
--- src/ex_getln.c	2011-06-26 19:36:36.000000000 +0200
3767eb8
***************
3767eb8
*** 110,116 ****
3767eb8
  static int	expand_showtail __ARGS((expand_T *xp));
3767eb8
  #ifdef FEAT_CMDL_COMPL
3767eb8
  static int	expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg));
3767eb8
! static int	ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname));
3767eb8
  # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
3767eb8
  static int	ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
3767eb8
  static int	ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file));
3767eb8
--- 110,116 ----
3767eb8
  static int	expand_showtail __ARGS((expand_T *xp));
3767eb8
  #ifdef FEAT_CMDL_COMPL
3767eb8
  static int	expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg));
3767eb8
! static int	ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[]));
3767eb8
  # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
3767eb8
  static int	ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
3767eb8
  static int	ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file));
3767eb8
***************
3767eb8
*** 4536,4548 ****
3767eb8
  	    || xp->xp_context == EXPAND_TAGS_LISTFILES)
3767eb8
  	return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file);
3767eb8
      if (xp->xp_context == EXPAND_COLORS)
3767eb8
! 	return ExpandRTDir(pat, num_file, file, "colors");
3767eb8
      if (xp->xp_context == EXPAND_COMPILER)
3767eb8
! 	return ExpandRTDir(pat, num_file, file, "compiler");
3767eb8
      if (xp->xp_context == EXPAND_OWNSYNTAX)
3767eb8
! 	return ExpandRTDir(pat, num_file, file, "syntax");
3767eb8
      if (xp->xp_context == EXPAND_FILETYPE)
3767eb8
! 	return ExpandRTDir(pat, num_file, file, "{syntax,indent,ftplugin}");
3767eb8
  # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
3767eb8
      if (xp->xp_context == EXPAND_USER_LIST)
3767eb8
  	return ExpandUserList(xp, num_file, file);
3767eb8
--- 4536,4560 ----
3767eb8
  	    || xp->xp_context == EXPAND_TAGS_LISTFILES)
3767eb8
  	return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file);
3767eb8
      if (xp->xp_context == EXPAND_COLORS)
3767eb8
!     {
3767eb8
! 	char *directories[] = {"colors", NULL};
3767eb8
! 	return ExpandRTDir(pat, num_file, file, directories);
3767eb8
!     }
3767eb8
      if (xp->xp_context == EXPAND_COMPILER)
3767eb8
!     {
3767eb8
! 	char *directories[] = {"colors", NULL};
3767eb8
! 	return ExpandRTDir(pat, num_file, file, directories);
3767eb8
!     }
3767eb8
      if (xp->xp_context == EXPAND_OWNSYNTAX)
3767eb8
!     {
3767eb8
! 	char *directories[] = {"syntax", NULL};
3767eb8
! 	return ExpandRTDir(pat, num_file, file, directories);
3767eb8
!     }
3767eb8
      if (xp->xp_context == EXPAND_FILETYPE)
3767eb8
!     {
3767eb8
! 	char *directories[] = {"syntax", "indent", "ftplugin", NULL};
3767eb8
! 	return ExpandRTDir(pat, num_file, file, directories);
3767eb8
!     }
3767eb8
  # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
3767eb8
      if (xp->xp_context == EXPAND_USER_LIST)
3767eb8
  	return ExpandUserList(xp, num_file, file);
3767eb8
***************
3767eb8
*** 4995,5051 ****
3767eb8
  /*
3767eb8
   * Expand color scheme, compiler or filetype names:
3767eb8
   * 'runtimepath'/{dirnames}/{pat}.vim
3767eb8
!  * dirnames may contain one directory (ex: "colorscheme") or can be a glob
3767eb8
!  * expression matching multiple directories (ex: "{syntax,ftplugin,indent}").
3767eb8
   */
3767eb8
      static int
3767eb8
  ExpandRTDir(pat, num_file, file, dirnames)
3767eb8
      char_u	*pat;
3767eb8
      int		*num_file;
3767eb8
      char_u	***file;
3767eb8
!     char	*dirnames;
3767eb8
  {
3767eb8
!     char_u	*all;
3767eb8
      char_u	*s;
3767eb8
      char_u	*e;
3767eb8
      garray_T	ga;
3767eb8
  
3767eb8
      *num_file = 0;
3767eb8
      *file = NULL;
3767eb8
!     s = alloc((unsigned)(STRLEN(pat) + STRLEN(dirnames) + 7));
3767eb8
!     if (s == NULL)
3767eb8
! 	return FAIL;
3767eb8
!     sprintf((char *)s, "%s/%s*.vim", dirnames, pat);
3767eb8
!     all = globpath(p_rtp, s, 0);
3767eb8
!     vim_free(s);
3767eb8
!     if (all == NULL)
3767eb8
! 	return FAIL;
3767eb8
  
3767eb8
!     ga_init2(&ga, (int)sizeof(char *), 3);
3767eb8
!     for (s = all; *s != NUL; s = e)
3767eb8
      {
3767eb8
! 	e = vim_strchr(s, '\n');
3767eb8
! 	if (e == NULL)
3767eb8
! 	    e = s + STRLEN(s);
3767eb8
! 	if (ga_grow(&ga, 1) == FAIL)
3767eb8
! 	    break;
3767eb8
! 	if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0)
3767eb8
  	{
3767eb8
! 	    for (s = e - 4; s > all; mb_ptr_back(all, s))
3767eb8
! 		if (*s == '\n' || vim_ispathsep(*s))
3767eb8
! 		    break;
3767eb8
! 	    ++s;
3767eb8
! 	    ((char_u **)ga.ga_data)[ga.ga_len] =
3767eb8
  					    vim_strnsave(s, (int)(e - s - 4));
3767eb8
! 	    ++ga.ga_len;
3767eb8
  	}
3767eb8
! 	if (*e != NUL)
3767eb8
! 	    ++e;
3767eb8
      }
3767eb8
!     vim_free(all);
3767eb8
  
3767eb8
      /* Sort and remove duplicates which can happen when specifying multiple
3767eb8
!      * directories in dirnames such as "{syntax,ftplugin,indent}". */
3767eb8
      remove_duplicates(&ga);
3767eb8
  
3767eb8
      *file = ga.ga_data;
3767eb8
--- 5007,5074 ----
3767eb8
  /*
3767eb8
   * Expand color scheme, compiler or filetype names:
3767eb8
   * 'runtimepath'/{dirnames}/{pat}.vim
3767eb8
!  * "dirnames" is an array with one or more directory names.
3767eb8
   */
3767eb8
      static int
3767eb8
  ExpandRTDir(pat, num_file, file, dirnames)
3767eb8
      char_u	*pat;
3767eb8
      int		*num_file;
3767eb8
      char_u	***file;
3767eb8
!     char	*dirnames[];
3767eb8
  {
3767eb8
!     char_u	*matches;
3767eb8
      char_u	*s;
3767eb8
      char_u	*e;
3767eb8
      garray_T	ga;
3767eb8
+     int		i;
3767eb8
+     int		pat_len;
3767eb8
  
3767eb8
      *num_file = 0;
3767eb8
      *file = NULL;
3767eb8
!     pat_len = STRLEN(pat);
3767eb8
!     ga_init2(&ga, (int)sizeof(char *), 10);
3767eb8
  
3767eb8
!     for (i = 0; dirnames[i] != NULL; ++i)
3767eb8
      {
3767eb8
! 	s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 7));
3767eb8
! 	if (s == NULL)
3767eb8
  	{
3767eb8
! 	    ga_clear_strings(&ga);
3767eb8
! 	    return FAIL;
3767eb8
! 	}
3767eb8
! 	sprintf((char *)s, "%s/%s*.vim", dirnames[i], pat);
3767eb8
! 	matches = globpath(p_rtp, s, 0);
3767eb8
! 	vim_free(s);
3767eb8
! 	if (matches == NULL)
3767eb8
! 	    continue;
3767eb8
! 
3767eb8
! 	for (s = matches; *s != NUL; s = e)
3767eb8
! 	{
3767eb8
! 	    e = vim_strchr(s, '\n');
3767eb8
! 	    if (e == NULL)
3767eb8
! 		e = s + STRLEN(s);
3767eb8
! 	    if (ga_grow(&ga, 1) == FAIL)
3767eb8
! 		break;
3767eb8
! 	    if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0)
3767eb8
! 	    {
3767eb8
! 		for (s = e - 4; s > matches; mb_ptr_back(matches, s))
3767eb8
! 		    if (*s == '\n' || vim_ispathsep(*s))
3767eb8
! 			break;
3767eb8
! 		++s;
3767eb8
! 		((char_u **)ga.ga_data)[ga.ga_len] =
3767eb8
  					    vim_strnsave(s, (int)(e - s - 4));
3767eb8
! 		++ga.ga_len;
3767eb8
! 	    }
3767eb8
! 	    if (*e != NUL)
3767eb8
! 		++e;
3767eb8
  	}
3767eb8
! 	vim_free(matches);
3767eb8
      }
3767eb8
!     if (ga.ga_len == 0)
3767eb8
!         return FAIL;
3767eb8
  
3767eb8
      /* Sort and remove duplicates which can happen when specifying multiple
3767eb8
!      * directories in dirnames. */
3767eb8
      remove_duplicates(&ga);
3767eb8
  
3767eb8
      *file = ga.ga_data;
3767eb8
*** ../vim-7.3.236/src/version.c	2011-06-26 19:13:33.000000000 +0200
3767eb8
--- src/version.c	2011-06-26 19:39:39.000000000 +0200
3767eb8
***************
3767eb8
*** 711,712 ****
3767eb8
--- 711,714 ----
3767eb8
  {   /* Add new patch number below this line */
3767eb8
+ /**/
3767eb8
+     237,
3767eb8
  /**/
3767eb8
3767eb8
-- 
3767eb8
hundred-and-one symptoms of being an internet addict:
3767eb8
230. You spend your Friday nights typing away at your keyboard
3767eb8
3767eb8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3767eb8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3767eb8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3767eb8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///