716f5c8
To: vim_dev@googlegroups.com
716f5c8
Subject: Patch 7.3.072
716f5c8
Fcc: outbox
716f5c8
From: Bram Moolenaar <Bram@moolenaar.net>
716f5c8
Mime-Version: 1.0
716f5c8
Content-Type: text/plain; charset=UTF-8
716f5c8
Content-Transfer-Encoding: 8bit
716f5c8
------------
716f5c8
716f5c8
Patch 7.3.072
716f5c8
Problem:    Can't complete file names while ignoring case.
716f5c8
Solution:   Add 'wildignorecase'.
716f5c8
Files:	    src/ex_docmd.c, src/ex_getln.c, src/misc1.c, src/option.c,
716f5c8
	    src/option.h, src/vim.h, runtime/doc/options.txt
716f5c8
716f5c8
716f5c8
*** ../vim-7.3.071/src/ex_docmd.c	2010-11-24 15:50:54.000000000 +0100
716f5c8
--- src/ex_docmd.c	2010-12-02 15:58:10.000000000 +0100
716f5c8
***************
716f5c8
*** 4524,4535 ****
716f5c8
  		else /* n == 2 */
716f5c8
  		{
716f5c8
  		    expand_T	xpc;
716f5c8
  
716f5c8
  		    ExpandInit(&xpc);
716f5c8
  		    xpc.xp_context = EXPAND_FILES;
716f5c8
  		    p = ExpandOne(&xpc, eap->arg, NULL,
716f5c8
! 					    WILD_LIST_NOTFOUND|WILD_ADD_SLASH,
716f5c8
! 						   WILD_EXPAND_FREE);
716f5c8
  		    if (p == NULL)
716f5c8
  			return FAIL;
716f5c8
  		}
716f5c8
--- 4524,4537 ----
716f5c8
  		else /* n == 2 */
716f5c8
  		{
716f5c8
  		    expand_T	xpc;
716f5c8
+ 		    int		options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH;
716f5c8
  
716f5c8
  		    ExpandInit(&xpc);
716f5c8
  		    xpc.xp_context = EXPAND_FILES;
716f5c8
+ 		    if (p_wic)
716f5c8
+ 			options += WILD_ICASE;
716f5c8
  		    p = ExpandOne(&xpc, eap->arg, NULL,
716f5c8
! 						   options, WILD_EXPAND_FREE);
716f5c8
  		    if (p == NULL)
716f5c8
  			return FAIL;
716f5c8
  		}
716f5c8
*** ../vim-7.3.071/src/ex_getln.c	2010-11-16 14:05:48.000000000 +0100
716f5c8
--- src/ex_getln.c	2010-11-28 15:07:49.000000000 +0100
716f5c8
***************
716f5c8
*** 3339,3348 ****
716f5c8
  	    p2 = NULL;
716f5c8
  	else
716f5c8
  	{
716f5c8
  	    p2 = ExpandOne(xp, p1,
716f5c8
  			 vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
716f5c8
! 		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
716f5c8
! 							      |options, type);
716f5c8
  	    vim_free(p1);
716f5c8
  	    /* longest match: make sure it is not shorter, happens with :help */
716f5c8
  	    if (p2 != NULL && type == WILD_LONGEST)
716f5c8
--- 3339,3352 ----
716f5c8
  	    p2 = NULL;
716f5c8
  	else
716f5c8
  	{
716f5c8
+ 	    int use_options = options |
716f5c8
+ 		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE;
716f5c8
+ 
716f5c8
+ 	    if (p_wic)
716f5c8
+ 		use_options += WILD_ICASE;
716f5c8
  	    p2 = ExpandOne(xp, p1,
716f5c8
  			 vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
716f5c8
! 							   use_options, type);
716f5c8
  	    vim_free(p1);
716f5c8
  	    /* longest match: make sure it is not shorter, happens with :help */
716f5c8
  	    if (p2 != NULL && type == WILD_LONGEST)
716f5c8
***************
716f5c8
*** 3428,3433 ****
716f5c8
--- 3432,3438 ----
716f5c8
   * options = WILD_KEEP_ALL:	    don't remove 'wildignore' entries
716f5c8
   * options = WILD_SILENT:	    don't print warning messages
716f5c8
   * options = WILD_ESCAPE:	    put backslash before special chars
716f5c8
+  * options = WILD_ICASE:	    ignore case for files
716f5c8
   *
716f5c8
   * The variables xp->xp_context and xp->xp_backslash must have been set!
716f5c8
   */
716f5c8
***************
716f5c8
*** 4361,4366 ****
716f5c8
--- 4366,4372 ----
716f5c8
      char_u	***matches;	/* return: array of pointers to matches */
716f5c8
  {
716f5c8
      char_u	*file_str = NULL;
716f5c8
+     int		options = WILD_ADD_SLASH|WILD_SILENT;
716f5c8
  
716f5c8
      if (xp->xp_context == EXPAND_UNSUCCESSFUL)
716f5c8
      {
716f5c8
***************
716f5c8
*** 4379,4387 ****
716f5c8
      if (file_str == NULL)
716f5c8
  	return EXPAND_UNSUCCESSFUL;
716f5c8
  
716f5c8
      /* find all files that match the description */
716f5c8
!     if (ExpandFromContext(xp, file_str, matchcount, matches,
716f5c8
! 					  WILD_ADD_SLASH|WILD_SILENT) == FAIL)
716f5c8
      {
716f5c8
  	*matchcount = 0;
716f5c8
  	*matches = NULL;
716f5c8
--- 4385,4395 ----
716f5c8
      if (file_str == NULL)
716f5c8
  	return EXPAND_UNSUCCESSFUL;
716f5c8
  
716f5c8
+     if (p_wic)
716f5c8
+ 	options += WILD_ICASE;
716f5c8
+ 
716f5c8
      /* find all files that match the description */
716f5c8
!     if (ExpandFromContext(xp, file_str, matchcount, matches, options) == FAIL)
716f5c8
      {
716f5c8
  	*matchcount = 0;
716f5c8
  	*matches = NULL;
716f5c8
***************
716f5c8
*** 4433,4439 ****
716f5c8
      char_u	*pat;
716f5c8
      int		*num_file;
716f5c8
      char_u	***file;
716f5c8
!     int		options;
716f5c8
  {
716f5c8
  #ifdef FEAT_CMDL_COMPL
716f5c8
      regmatch_T	regmatch;
716f5c8
--- 4441,4447 ----
716f5c8
      char_u	*pat;
716f5c8
      int		*num_file;
716f5c8
      char_u	***file;
716f5c8
!     int		options;  /* EW_ flags */
716f5c8
  {
716f5c8
  #ifdef FEAT_CMDL_COMPL
716f5c8
      regmatch_T	regmatch;
716f5c8
***************
716f5c8
*** 4487,4492 ****
716f5c8
--- 4495,4503 ----
716f5c8
  	    flags |= (EW_FILE | EW_PATH);
716f5c8
  	else
716f5c8
  	    flags = (flags | EW_DIR) & ~EW_FILE;
716f5c8
+ 	if (options & WILD_ICASE)
716f5c8
+ 	    flags |= EW_ICASE;
716f5c8
+ 
716f5c8
  	/* Expand wildcards, supporting %:h and the like. */
716f5c8
  	ret = expand_wildcards_eval(&pat, num_file, file, flags);
716f5c8
  	if (free_pat)
716f5c8
*** ../vim-7.3.071/src/misc1.c	2010-08-16 21:46:12.000000000 +0200
716f5c8
--- src/misc1.c	2010-11-28 15:02:57.000000000 +0100
716f5c8
***************
716f5c8
*** 9161,9167 ****
716f5c8
  #ifdef CASE_INSENSITIVE_FILENAME
716f5c8
      regmatch.rm_ic = TRUE;		/* Behave like Terminal.app */
716f5c8
  #else
716f5c8
!     regmatch.rm_ic = FALSE;		/* Don't ever ignore case */
716f5c8
  #endif
716f5c8
      regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
716f5c8
      vim_free(pat);
716f5c8
--- 9161,9170 ----
716f5c8
  #ifdef CASE_INSENSITIVE_FILENAME
716f5c8
      regmatch.rm_ic = TRUE;		/* Behave like Terminal.app */
716f5c8
  #else
716f5c8
!     if (flags & EW_ICASE)
716f5c8
! 	regmatch.rm_ic = TRUE;		/* 'wildignorecase' set */
716f5c8
!     else
716f5c8
! 	regmatch.rm_ic = FALSE;		/* Don't ignore case */
716f5c8
  #endif
716f5c8
      regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
716f5c8
      vim_free(pat);
716f5c8
***************
716f5c8
*** 9643,9649 ****
716f5c8
      if (paths == NULL)
716f5c8
  	return 0;
716f5c8
  
716f5c8
!     files = globpath(paths, pattern, 0);
716f5c8
      vim_free(paths);
716f5c8
      if (files == NULL)
716f5c8
  	return 0;
716f5c8
--- 9646,9652 ----
716f5c8
      if (paths == NULL)
716f5c8
  	return 0;
716f5c8
  
716f5c8
!     files = globpath(paths, pattern, (flags & EW_ICASE) ? WILD_ICASE : 0);
716f5c8
      vim_free(paths);
716f5c8
      if (files == NULL)
716f5c8
  	return 0;
716f5c8
*** ../vim-7.3.071/src/option.c	2010-12-02 15:33:10.000000000 +0100
716f5c8
--- src/option.c	2010-12-02 15:12:02.000000000 +0100
716f5c8
***************
716f5c8
*** 2740,2746 ****
716f5c8
  			    (char_u *)&p_wc, PV_NONE,
716f5c8
  			    {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
716f5c8
  			    SCRIPTID_INIT},
716f5c8
!     {"wildcharm",   "wcm",   P_NUM|P_VI_DEF,
716f5c8
  			    (char_u *)&p_wcm, PV_NONE,
716f5c8
  			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
716f5c8
      {"wildignore",  "wig",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
716f5c8
--- 2740,2746 ----
716f5c8
  			    (char_u *)&p_wc, PV_NONE,
716f5c8
  			    {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
716f5c8
  			    SCRIPTID_INIT},
716f5c8
!     {"wildcharm",   "wcm",  P_NUM|P_VI_DEF,
716f5c8
  			    (char_u *)&p_wcm, PV_NONE,
716f5c8
  			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
716f5c8
      {"wildignore",  "wig",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
716f5c8
***************
716f5c8
*** 2750,2755 ****
716f5c8
--- 2750,2758 ----
716f5c8
  			    (char_u *)NULL, PV_NONE,
716f5c8
  #endif
716f5c8
  			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
716f5c8
+     {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
716f5c8
+ 			    (char_u *)&p_wic, PV_NONE,
716f5c8
+ 			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
716f5c8
      {"wildmenu",    "wmnu", P_BOOL|P_VI_DEF,
716f5c8
  #ifdef FEAT_WILDMENU
716f5c8
  			    (char_u *)&p_wmnu, PV_NONE,
716f5c8
*** ../vim-7.3.071/src/option.h	2010-08-15 21:57:28.000000000 +0200
716f5c8
--- src/option.h	2010-11-28 14:29:18.000000000 +0100
716f5c8
***************
716f5c8
*** 872,877 ****
716f5c8
--- 872,878 ----
716f5c8
  EXTERN char_u	*p_ww;		/* 'whichwrap' */
716f5c8
  EXTERN long	p_wc;		/* 'wildchar' */
716f5c8
  EXTERN long	p_wcm;		/* 'wildcharm' */
716f5c8
+ EXTERN long	p_wic;		/* 'wildignorecase' */
716f5c8
  EXTERN char_u	*p_wim;		/* 'wildmode' */
716f5c8
  #ifdef FEAT_WILDMENU
716f5c8
  EXTERN int	p_wmnu;		/* 'wildmenu' */
716f5c8
*** ../vim-7.3.071/src/vim.h	2010-10-20 19:17:43.000000000 +0200
716f5c8
--- src/vim.h	2010-11-28 14:49:02.000000000 +0100
716f5c8
***************
716f5c8
*** 798,803 ****
716f5c8
--- 798,804 ----
716f5c8
  #define WILD_KEEP_ALL		32
716f5c8
  #define WILD_SILENT		64
716f5c8
  #define WILD_ESCAPE		128
716f5c8
+ #define WILD_ICASE		256
716f5c8
  
716f5c8
  /* Flags for expand_wildcards() */
716f5c8
  #define EW_DIR		0x01	/* include directory names */
716f5c8
***************
716f5c8
*** 808,813 ****
716f5c8
--- 809,815 ----
716f5c8
  #define EW_SILENT	0x20	/* don't print "1 returned" from shell */
716f5c8
  #define EW_EXEC		0x40	/* executable files */
716f5c8
  #define EW_PATH		0x80	/* search in 'path' too */
716f5c8
+ #define EW_ICASE	0x100	/* ignore case */
716f5c8
  /* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND
716f5c8
   * is used when executing commands and EW_SILENT for interactive expanding. */
716f5c8
  
716f5c8
*** ../vim-7.3.071/runtime/doc/options.txt	2010-10-20 17:44:01.000000000 +0200
716f5c8
--- runtime/doc/options.txt	2010-12-02 11:15:01.000000000 +0100
716f5c8
***************
716f5c8
*** 7748,7753 ****
716f5c8
--- 7756,7772 ----
716f5c8
  	a pattern from the list.  This avoids problems when a future version
716f5c8
  	uses another default.
716f5c8
  
716f5c8
+ 
716f5c8
+ 			*'wildignorecase* *'wic'* *'nowildignorecase* *'nowic'*
716f5c8
+ 'wildignorecase' 'wic'	boolean	(default off)
716f5c8
+ 			global
716f5c8
+ 			{not in Vi}
716f5c8
+ 	When set case is ignored when completing file names and directories.
716f5c8
+ 	Has no effect on systems where file name case is generally ignored.
716f5c8
+ 	Does not apply when the shell is used to expand wildcards, which
716f5c8
+ 	happens when there are special characters.
716f5c8
+ 
716f5c8
+ 
716f5c8
  				*'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'*
716f5c8
  'wildmenu' 'wmnu'	boolean	(default off)
716f5c8
  			global
716f5c8
*** ../vim-7.3.071/src/version.c	2010-12-02 15:33:10.000000000 +0100
716f5c8
--- src/version.c	2010-12-02 15:57:14.000000000 +0100
716f5c8
***************
716f5c8
*** 716,717 ****
716f5c8
--- 716,719 ----
716f5c8
  {   /* Add new patch number below this line */
716f5c8
+ /**/
716f5c8
+     72,
716f5c8
  /**/
716f5c8
716f5c8
-- 
716f5c8
I recommend ordering large cargo containers of paper towels to make up
716f5c8
whatever budget underruns you have.  Paper products are always useful and they
716f5c8
have the advantage of being completely flushable if you need to make room in
716f5c8
the storage area later.
716f5c8
				(Scott Adams - The Dilbert principle)
716f5c8
716f5c8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
716f5c8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
716f5c8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
716f5c8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///