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