6584070
To: vim-dev@vim.org
6584070
Subject: Patch 7.2.051
6584070
Fcc: outbox
6584070
From: Bram Moolenaar <Bram@moolenaar.net>
6584070
Mime-Version: 1.0
6584070
Content-Type: text/plain; charset=ISO-8859-1
6584070
Content-Transfer-Encoding: 8bit
6584070
------------
6584070
6584070
Patch 7.2.051
6584070
Problem:    Can't avoid 'wildignore' and 'suffixes' for glob() and globpath().
6584070
Solution:   Add an extra argument to these functions. (Ingo Karkat)
6584070
Files:	    src/eval.c, src/ex_getln.c, src/proto/ex_getln.pro,
6584070
	    runtime/doc/eval.txt, runtime/doc/options.txt
6584070
6584070
6584070
*** ../vim-7.2.050/src/eval.c	Thu Nov 20 16:11:03 2008
6584070
--- src/eval.c	Thu Nov 27 22:15:40 2008
6584070
***************
6584070
*** 7564,7571 ****
6584070
      {"getwinposx",	0, 0, f_getwinposx},
6584070
      {"getwinposy",	0, 0, f_getwinposy},
6584070
      {"getwinvar",	2, 2, f_getwinvar},
6584070
!     {"glob",		1, 1, f_glob},
6584070
!     {"globpath",	2, 2, f_globpath},
6584070
      {"has",		1, 1, f_has},
6584070
      {"has_key",		2, 2, f_has_key},
6584070
      {"haslocaldir",	0, 0, f_haslocaldir},
6584070
--- 7564,7571 ----
6584070
      {"getwinposx",	0, 0, f_getwinposx},
6584070
      {"getwinposy",	0, 0, f_getwinposy},
6584070
      {"getwinvar",	2, 2, f_getwinvar},
6584070
!     {"glob",		1, 2, f_glob},
6584070
!     {"globpath",	2, 3, f_globpath},
6584070
      {"has",		1, 1, f_has},
6584070
      {"has_key",		2, 2, f_has_key},
6584070
      {"haslocaldir",	0, 0, f_haslocaldir},
6584070
***************
6584070
*** 9557,9563 ****
6584070
      else
6584070
      {
6584070
  	/* When the optional second argument is non-zero, don't remove matches
6584070
! 	 * for 'suffixes' and 'wildignore' */
6584070
  	if (argvars[1].v_type != VAR_UNKNOWN
6584070
  				    && get_tv_number_chk(&argvars[1], &error))
6584070
  	    flags |= WILD_KEEP_ALL;
6584070
--- 9557,9563 ----
6584070
      else
6584070
      {
6584070
  	/* When the optional second argument is non-zero, don't remove matches
6584070
! 	 * for 'wildignore' and don't put matches for 'suffixes' at the end. */
6584070
  	if (argvars[1].v_type != VAR_UNKNOWN
6584070
  				    && get_tv_number_chk(&argvars[1], &error))
6584070
  	    flags |= WILD_KEEP_ALL;
6584070
***************
6584070
*** 11323,11335 ****
6584070
      typval_T	*argvars;
6584070
      typval_T	*rettv;
6584070
  {
6584070
      expand_T	xpc;
6584070
  
6584070
!     ExpandInit(&xpc);
6584070
!     xpc.xp_context = EXPAND_FILES;
6584070
!     rettv->v_type = VAR_STRING;
6584070
!     rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
6584070
! 				     NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL);
6584070
  }
6584070
  
6584070
  /*
6584070
--- 11323,11347 ----
6584070
      typval_T	*argvars;
6584070
      typval_T	*rettv;
6584070
  {
6584070
+     int		flags = WILD_SILENT|WILD_USE_NL;
6584070
      expand_T	xpc;
6584070
+     int		error = FALSE;
6584070
  
6584070
!     /* When the optional second argument is non-zero, don't remove matches
6584070
!     * for 'wildignore' and don't put matches for 'suffixes' at the end. */
6584070
!     if (argvars[1].v_type != VAR_UNKNOWN
6584070
! 				&& get_tv_number_chk(&argvars[1], &error))
6584070
! 	flags |= WILD_KEEP_ALL;
6584070
!     rettv->v_type = VAR_STRING;
6584070
!     if (!error)
6584070
!     {
6584070
! 	ExpandInit(&xpc);
6584070
! 	xpc.xp_context = EXPAND_FILES;
6584070
! 	rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
6584070
! 						       NULL, flags, WILD_ALL);
6584070
!     }
6584070
!     else
6584070
! 	rettv->vval.v_string = NULL;
6584070
  }
6584070
  
6584070
  /*
6584070
***************
6584070
*** 11340,11353 ****
6584070
      typval_T	*argvars;
6584070
      typval_T	*rettv;
6584070
  {
6584070
      char_u	buf1[NUMBUFLEN];
6584070
      char_u	*file = get_tv_string_buf_chk(&argvars[1], buf1);
6584070
  
6584070
      rettv->v_type = VAR_STRING;
6584070
!     if (file == NULL)
6584070
  	rettv->vval.v_string = NULL;
6584070
      else
6584070
! 	rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file);
6584070
  }
6584070
  
6584070
  /*
6584070
--- 11352,11373 ----
6584070
      typval_T	*argvars;
6584070
      typval_T	*rettv;
6584070
  {
6584070
+     int		flags = 0;
6584070
      char_u	buf1[NUMBUFLEN];
6584070
      char_u	*file = get_tv_string_buf_chk(&argvars[1], buf1);
6584070
+     int		error = FALSE;
6584070
  
6584070
+     /* When the optional second argument is non-zero, don't remove matches
6584070
+     * for 'wildignore' and don't put matches for 'suffixes' at the end. */
6584070
+     if (argvars[2].v_type != VAR_UNKNOWN
6584070
+ 				&& get_tv_number_chk(&argvars[2], &error))
6584070
+ 	flags |= WILD_KEEP_ALL;
6584070
      rettv->v_type = VAR_STRING;
6584070
!     if (file == NULL || error)
6584070
  	rettv->vval.v_string = NULL;
6584070
      else
6584070
! 	rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file,
6584070
! 								       flags);
6584070
  }
6584070
  
6584070
  /*
6584070
*** ../vim-7.2.050/src/ex_getln.c	Sat Nov 15 14:10:23 2008
6584070
--- src/ex_getln.c	Thu Nov 20 18:37:20 2008
6584070
***************
6584070
*** 2524,2530 ****
6584070
  	    && ccline.xpc->xp_context != EXPAND_NOTHING
6584070
  	    && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL)
6584070
      {
6584070
! 	int i = ccline.xpc->xp_pattern - p;
6584070
  
6584070
  	/* If xp_pattern points inside the old cmdbuff it needs to be adjusted
6584070
  	 * to point into the newly allocated memory. */
6584070
--- 2524,2530 ----
6584070
  	    && ccline.xpc->xp_context != EXPAND_NOTHING
6584070
  	    && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL)
6584070
      {
6584070
! 	int i = (int)(ccline.xpc->xp_pattern - p);
6584070
  
6584070
  	/* If xp_pattern points inside the old cmdbuff it needs to be adjusted
6584070
  	 * to point into the newly allocated memory. */
6584070
***************
6584070
*** 4897,4903 ****
6584070
      if (s == NULL)
6584070
  	return FAIL;
6584070
      sprintf((char *)s, "%s/%s*.vim", dirname, pat);
6584070
!     all = globpath(p_rtp, s);
6584070
      vim_free(s);
6584070
      if (all == NULL)
6584070
  	return FAIL;
6584070
--- 4897,4903 ----
6584070
      if (s == NULL)
6584070
  	return FAIL;
6584070
      sprintf((char *)s, "%s/%s*.vim", dirname, pat);
6584070
!     all = globpath(p_rtp, s, 0);
6584070
      vim_free(s);
6584070
      if (all == NULL)
6584070
  	return FAIL;
6584070
***************
6584070
*** 4938,4946 ****
6584070
   * newlines.  Returns NULL for an error or no matches.
6584070
   */
6584070
      char_u *
6584070
! globpath(path, file)
6584070
      char_u	*path;
6584070
      char_u	*file;
6584070
  {
6584070
      expand_T	xpc;
6584070
      char_u	*buf;
6584070
--- 4938,4947 ----
6584070
   * newlines.  Returns NULL for an error or no matches.
6584070
   */
6584070
      char_u *
6584070
! globpath(path, file, expand_options)
6584070
      char_u	*path;
6584070
      char_u	*file;
6584070
+     int		expand_options;
6584070
  {
6584070
      expand_T	xpc;
6584070
      char_u	*buf;
6584070
***************
6584070
*** 4969,4978 ****
6584070
  	{
6584070
  	    add_pathsep(buf);
6584070
  	    STRCAT(buf, file);
6584070
! 	    if (ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT) != FAIL
6584070
! 								 && num_p > 0)
6584070
  	    {
6584070
! 		ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT);
6584070
  		for (len = 0, i = 0; i < num_p; ++i)
6584070
  		    len += (int)STRLEN(p[i]) + 1;
6584070
  
6584070
--- 4970,4979 ----
6584070
  	{
6584070
  	    add_pathsep(buf);
6584070
  	    STRCAT(buf, file);
6584070
! 	    if (ExpandFromContext(&xpc, buf, &num_p, &p,
6584070
! 			     WILD_SILENT|expand_options) != FAIL && num_p > 0)
6584070
  	    {
6584070
! 		ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options);
6584070
  		for (len = 0, i = 0; i < num_p; ++i)
6584070
  		    len += (int)STRLEN(p[i]) + 1;
6584070
  
6584070
*** ../vim-7.2.050/src/proto/ex_getln.pro	Wed May 28 16:49:01 2008
6584070
--- src/proto/ex_getln.pro	Thu Nov 20 18:27:57 2008
6584070
***************
6584070
*** 31,37 ****
6584070
  void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
6584070
  int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
6584070
  int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
6584070
! char_u *globpath __ARGS((char_u *path, char_u *file));
6584070
  void init_history __ARGS((void));
6584070
  int get_histtype __ARGS((char_u *name));
6584070
  void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep));
6584070
--- 31,37 ----
6584070
  void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
6584070
  int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
6584070
  int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
6584070
! char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
6584070
  void init_history __ARGS((void));
6584070
  int get_histtype __ARGS((char_u *name));
6584070
  void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep));
6584070
*** ../vim-7.2.050/runtime/doc/eval.txt	Sun Nov  9 13:43:25 2008
6584070
--- runtime/doc/eval.txt	Thu Nov 27 22:17:13 2008
6584070
***************
6584070
*** 1,4 ****
6584070
! *eval.txt*	For Vim version 7.2.  Last change: 2008 Nov 02
6584070
  
6584070
  
6584070
  		  VIM REFERENCE MANUAL	  by Bram Moolenaar
6584070
--- 1,4 ----
6584070
! *eval.txt*	For Vim version 7.2.  Last change: 2008 Nov 27
6584070
  
6584070
  
6584070
  		  VIM REFERENCE MANUAL	  by Bram Moolenaar
6584070
***************
6584070
*** 1706,1712 ****
6584070
  exists( {expr})			Number	TRUE if {expr} exists
6584070
  extend({expr1}, {expr2} [, {expr3}])
6584070
  				List/Dict insert items of {expr2} into {expr1}
6584070
! expand( {expr})			String	expand special keywords in {expr}
6584070
  feedkeys( {string} [, {mode}])	Number	add key sequence to typeahead buffer
6584070
  filereadable( {file})		Number	TRUE if {file} is a readable file
6584070
  filewritable( {file})		Number	TRUE if {file} is a writable file
6584070
--- 1709,1715 ----
6584070
  exists( {expr})			Number	TRUE if {expr} exists
6584070
  extend({expr1}, {expr2} [, {expr3}])
6584070
  				List/Dict insert items of {expr2} into {expr1}
6584070
! expand( {expr} [, {flag}])	String	expand special keywords in {expr}
6584070
  feedkeys( {string} [, {mode}])	Number	add key sequence to typeahead buffer
6584070
  filereadable( {file})		Number	TRUE if {file} is a readable file
6584070
  filewritable( {file})		Number	TRUE if {file} is a writable file
6584070
***************
6584070
*** 1758,1765 ****
6584070
  getwinposx()			Number	X coord in pixels of GUI Vim window
6584070
  getwinposy()			Number	Y coord in pixels of GUI Vim window
6584070
  getwinvar( {nr}, {varname})	any	variable {varname} in window {nr}
6584070
! glob( {expr})			String	expand file wildcards in {expr}
6584070
! globpath( {path}, {expr})	String	do glob({expr}) for all dirs in {path}
6584070
  has( {feature})			Number	TRUE if feature {feature} supported
6584070
  has_key( {dict}, {key})		Number	TRUE if {dict} has entry {key}
6584070
  haslocaldir()			Number	TRUE if current window executed |:lcd|
6584070
--- 1761,1769 ----
6584070
  getwinposx()			Number	X coord in pixels of GUI Vim window
6584070
  getwinposy()			Number	Y coord in pixels of GUI Vim window
6584070
  getwinvar( {nr}, {varname})	any	variable {varname} in window {nr}
6584070
! glob( {expr} [, {flag}])	String	expand file wildcards in {expr}
6584070
! globpath( {path}, {expr} [, {flag}])
6584070
! 				String	do glob({expr}) for all dirs in {path}
6584070
  has( {feature})			Number	TRUE if feature {feature} supported
6584070
  has_key( {dict}, {key})		Number	TRUE if {dict} has entry {key}
6584070
  haslocaldir()			Number	TRUE if current window executed |:lcd|
6584070
***************
6584070
*** 3286,3299 ****
6584070
  			:let list_is_on = getwinvar(2, '&list')
6584070
  			:echo "myvar = " . getwinvar(1, 'myvar')
6584070
  <
6584070
! 							*glob()*
6584070
! glob({expr})	Expand the file wildcards in {expr}.  See |wildcards| for the
6584070
  		use of special characters.
6584070
  		The result is a String.
6584070
  		When there are several matches, they are separated by <NL>
6584070
  		characters.
6584070
! 		The 'wildignore' option applies: Names matching one of the
6584070
! 		patterns in 'wildignore' will be skipped.
6584070
  		If the expansion fails, the result is an empty string.
6584070
  		A name for a non-existing file is not included.
6584070
  
6584070
--- 3290,3305 ----
6584070
  			:let list_is_on = getwinvar(2, '&list')
6584070
  			:echo "myvar = " . getwinvar(1, 'myvar')
6584070
  <
6584070
! glob({expr} [, {flag}])					*glob()*
6584070
! 		Expand the file wildcards in {expr}.  See |wildcards| for the
6584070
  		use of special characters.
6584070
  		The result is a String.
6584070
  		When there are several matches, they are separated by <NL>
6584070
  		characters.
6584070
! 		Unless the optional {flag} argument is given and is non-zero,
6584070
! 		the 'suffixes' and 'wildignore' options apply: Names matching
6584070
! 		one of the patterns in 'wildignore' will be skipped and
6584070
! 		'suffixes' affect the ordering of matches.
6584070
  		If the expansion fails, the result is an empty string.
6584070
  		A name for a non-existing file is not included.
6584070
  
6584070
***************
6584070
*** 3307,3326 ****
6584070
  		See |expand()| for expanding special Vim variables.  See
6584070
  		|system()| for getting the raw output of an external command.
6584070
  
6584070
! globpath({path}, {expr})				*globpath()*
6584070
  		Perform glob() on all directories in {path} and concatenate
6584070
  		the results.  Example: >
6584070
  			:echo globpath(&rtp, "syntax/c.vim")
6584070
  <		{path} is a comma-separated list of directory names.  Each
6584070
  		directory name is prepended to {expr} and expanded like with
6584070
! 		glob().  A path separator is inserted when needed.
6584070
  		To add a comma inside a directory name escape it with a
6584070
  		backslash.  Note that on MS-Windows a directory may have a
6584070
  		trailing backslash, remove it if you put a comma after it.
6584070
  		If the expansion fails for one of the directories, there is no
6584070
  		error message.
6584070
! 		The 'wildignore' option applies: Names matching one of the
6584070
! 		patterns in 'wildignore' will be skipped.
6584070
  
6584070
  		The "**" item can be used to search in a directory tree.
6584070
  		For example, to find all "README.txt" files in the directories
6584070
--- 3313,3334 ----
6584070
  		See |expand()| for expanding special Vim variables.  See
6584070
  		|system()| for getting the raw output of an external command.
6584070
  
6584070
! globpath({path}, {expr} [, {flag}])			*globpath()*
6584070
  		Perform glob() on all directories in {path} and concatenate
6584070
  		the results.  Example: >
6584070
  			:echo globpath(&rtp, "syntax/c.vim")
6584070
  <		{path} is a comma-separated list of directory names.  Each
6584070
  		directory name is prepended to {expr} and expanded like with
6584070
! 		|glob()|.  A path separator is inserted when needed.
6584070
  		To add a comma inside a directory name escape it with a
6584070
  		backslash.  Note that on MS-Windows a directory may have a
6584070
  		trailing backslash, remove it if you put a comma after it.
6584070
  		If the expansion fails for one of the directories, there is no
6584070
  		error message.
6584070
! 		Unless the optional {flag} argument is given and is non-zero,
6584070
! 		the 'suffixes' and 'wildignore' options apply: Names matching
6584070
! 		one of the patterns in 'wildignore' will be skipped and
6584070
! 		'suffixes' affect the ordering of matches.
6584070
  
6584070
  		The "**" item can be used to search in a directory tree.
6584070
  		For example, to find all "README.txt" files in the directories
6584070
*** ../vim-7.2.050/runtime/doc/options.txt	Sat Aug  9 19:36:49 2008
6584070
--- runtime/doc/options.txt	Tue Nov 25 23:43:55 2008
6584070
***************
6584070
*** 1,4 ****
6584070
! *options.txt*	For Vim version 7.2.  Last change: 2008 Aug 06
6584070
  
6584070
  
6584070
  		  VIM REFERENCE MANUAL	  by Bram Moolenaar
6584070
--- 1,4 ----
6584070
! *options.txt*	For Vim version 7.2.  Last change: 2008 Nov 25
6584070
  
6584070
  
6584070
  		  VIM REFERENCE MANUAL	  by Bram Moolenaar
6584070
***************
6584070
*** 7472,7478 ****
6584070
  			{not available when compiled without the |+wildignore|
6584070
  			feature}
6584070
  	A list of file patterns.  A file that matches with one of these
6584070
! 	patterns is ignored when completing file or directory names.
6584070
  	The pattern is used like with |:autocmd|, see |autocmd-patterns|.
6584070
  	Also see 'suffixes'.
6584070
  	Example: >
6584070
--- 7481,7489 ----
6584070
  			{not available when compiled without the |+wildignore|
6584070
  			feature}
6584070
  	A list of file patterns.  A file that matches with one of these
6584070
! 	patterns is ignored when completing file or directory names, and
6584070
! 	influences the result of |expand()|, |glob()| and |globpath()| unless
6584070
! 	a flag is passed to disable this.
6584070
  	The pattern is used like with |:autocmd|, see |autocmd-patterns|.
6584070
  	Also see 'suffixes'.
6584070
  	Example: >
6584070
*** ../vim-7.2.050/src/version.c	Fri Nov 28 10:08:05 2008
6584070
--- src/version.c	Fri Nov 28 10:55:44 2008
6584070
***************
6584070
*** 678,679 ****
6584070
--- 678,681 ----
6584070
  {   /* Add new patch number below this line */
6584070
+ /**/
6584070
+     51,
6584070
  /**/
6584070
6584070
-- 
6584070
Not too long ago, unzipping in public was illegal...
6584070
6584070
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
6584070
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
6584070
\\\        download, build and distribute -- http://www.A-A-P.org        ///
6584070
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///