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