Karsten Hopp bc1559
To: vim_dev@googlegroups.com
Karsten Hopp bc1559
Subject: Patch 7.3.888
Karsten Hopp bc1559
Fcc: outbox
Karsten Hopp bc1559
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp bc1559
Mime-Version: 1.0
Karsten Hopp bc1559
Content-Type: text/plain; charset=UTF-8
Karsten Hopp bc1559
Content-Transfer-Encoding: 8bit
Karsten Hopp bc1559
------------
Karsten Hopp bc1559
Karsten Hopp bc1559
Patch 7.3.888
Karsten Hopp bc1559
Problem:    Filename completion with 'fileignorecase' does not work for
Karsten Hopp bc1559
	    multi-byte characters.
Karsten Hopp bc1559
Solution:   Make 'fileignorecase' work properly. (Hirohito Higashi)
Karsten Hopp bc1559
Files:	    src/misc2.c
Karsten Hopp bc1559
Karsten Hopp bc1559
Karsten Hopp bc1559
*** ../vim-7.3.887/src/misc2.c	2013-03-19 18:31:45.000000000 +0100
Karsten Hopp bc1559
--- src/misc2.c	2013-04-12 14:15:03.000000000 +0200
Karsten Hopp bc1559
***************
Karsten Hopp bc1559
*** 6099,6150 ****
Karsten Hopp bc1559
      int maxlen;
Karsten Hopp bc1559
  {
Karsten Hopp bc1559
      int		i;
Karsten Hopp bc1559
      const char	*s = NULL;
Karsten Hopp bc1559
  
Karsten Hopp bc1559
!     for (i = 0; maxlen < 0 || i < maxlen; ++i)
Karsten Hopp bc1559
      {
Karsten Hopp bc1559
  	/* End of "p": check if "q" also ends or just has a slash. */
Karsten Hopp bc1559
! 	if (p[i] == NUL)
Karsten Hopp bc1559
  	{
Karsten Hopp bc1559
! 	    if (q[i] == NUL)  /* full match */
Karsten Hopp bc1559
  		return 0;
Karsten Hopp bc1559
  	    s = q;
Karsten Hopp bc1559
  	    break;
Karsten Hopp bc1559
  	}
Karsten Hopp bc1559
  
Karsten Hopp bc1559
  	/* End of "q": check if "p" just has a slash. */
Karsten Hopp bc1559
! 	if (q[i] == NUL)
Karsten Hopp bc1559
  	{
Karsten Hopp bc1559
  	    s = p;
Karsten Hopp bc1559
  	    break;
Karsten Hopp bc1559
  	}
Karsten Hopp bc1559
  
Karsten Hopp bc1559
! 	if ((p_fic ? TOUPPER_LOC(p[i]) != TOUPPER_LOC(q[i]) : p[i] != q[i])
Karsten Hopp bc1559
  #ifdef BACKSLASH_IN_FILENAME
Karsten Hopp bc1559
  		/* consider '/' and '\\' to be equal */
Karsten Hopp bc1559
! 		&& !((p[i] == '/' && q[i] == '\\')
Karsten Hopp bc1559
! 		    || (p[i] == '\\' && q[i] == '/'))
Karsten Hopp bc1559
  #endif
Karsten Hopp bc1559
  		)
Karsten Hopp bc1559
  	{
Karsten Hopp bc1559
! 	    if (vim_ispathsep(p[i]))
Karsten Hopp bc1559
  		return -1;
Karsten Hopp bc1559
! 	    if (vim_ispathsep(q[i]))
Karsten Hopp bc1559
  		return 1;
Karsten Hopp bc1559
! 	    return ((char_u *)p)[i] - ((char_u *)q)[i];	    /* no match */
Karsten Hopp bc1559
  	}
Karsten Hopp bc1559
      }
Karsten Hopp bc1559
      if (s == NULL)	/* "i" ran into "maxlen" */
Karsten Hopp bc1559
  	return 0;
Karsten Hopp bc1559
  
Karsten Hopp bc1559
      /* ignore a trailing slash, but not "//" or ":/" */
Karsten Hopp bc1559
!     if (s[i + 1] == NUL
Karsten Hopp bc1559
  	    && i > 0
Karsten Hopp bc1559
  	    && !after_pathsep((char_u *)s, (char_u *)s + i)
Karsten Hopp bc1559
  #ifdef BACKSLASH_IN_FILENAME
Karsten Hopp bc1559
! 	    && (s[i] == '/' || s[i] == '\\')
Karsten Hopp bc1559
  #else
Karsten Hopp bc1559
! 	    && s[i] == '/'
Karsten Hopp bc1559
  #endif
Karsten Hopp bc1559
         )
Karsten Hopp bc1559
  	return 0;   /* match with trailing slash */
Karsten Hopp bc1559
--- 6099,6157 ----
Karsten Hopp bc1559
      int maxlen;
Karsten Hopp bc1559
  {
Karsten Hopp bc1559
      int		i;
Karsten Hopp bc1559
+     int		c1, c2;
Karsten Hopp bc1559
      const char	*s = NULL;
Karsten Hopp bc1559
  
Karsten Hopp bc1559
!     for (i = 0; maxlen < 0 || i < maxlen; i += MB_PTR2LEN((char_u *)p + i))
Karsten Hopp bc1559
      {
Karsten Hopp bc1559
+ 	c1 = PTR2CHAR((char_u *)p + i);
Karsten Hopp bc1559
+ 	c2 = PTR2CHAR((char_u *)q + i);
Karsten Hopp bc1559
+ 
Karsten Hopp bc1559
  	/* End of "p": check if "q" also ends or just has a slash. */
Karsten Hopp bc1559
! 	if (c1 == NUL)
Karsten Hopp bc1559
  	{
Karsten Hopp bc1559
! 	    if (c2 == NUL)  /* full match */
Karsten Hopp bc1559
  		return 0;
Karsten Hopp bc1559
  	    s = q;
Karsten Hopp bc1559
  	    break;
Karsten Hopp bc1559
  	}
Karsten Hopp bc1559
  
Karsten Hopp bc1559
  	/* End of "q": check if "p" just has a slash. */
Karsten Hopp bc1559
! 	if (c2 == NUL)
Karsten Hopp bc1559
  	{
Karsten Hopp bc1559
  	    s = p;
Karsten Hopp bc1559
  	    break;
Karsten Hopp bc1559
  	}
Karsten Hopp bc1559
  
Karsten Hopp bc1559
! 	if ((p_fic ? MB_TOUPPER(c1) != MB_TOUPPER(c2) : c1 != c2)
Karsten Hopp bc1559
  #ifdef BACKSLASH_IN_FILENAME
Karsten Hopp bc1559
  		/* consider '/' and '\\' to be equal */
Karsten Hopp bc1559
! 		&& !((c1 == '/' && c2 == '\\')
Karsten Hopp bc1559
! 		    || (c1 == '\\' && c2 == '/'))
Karsten Hopp bc1559
  #endif
Karsten Hopp bc1559
  		)
Karsten Hopp bc1559
  	{
Karsten Hopp bc1559
! 	    if (vim_ispathsep(c1))
Karsten Hopp bc1559
  		return -1;
Karsten Hopp bc1559
! 	    if (vim_ispathsep(c2))
Karsten Hopp bc1559
  		return 1;
Karsten Hopp bc1559
! 	    return p_fic ? MB_TOUPPER(c1) - MB_TOUPPER(c2)
Karsten Hopp bc1559
! 		    : c1 - c2;  /* no match */
Karsten Hopp bc1559
  	}
Karsten Hopp bc1559
      }
Karsten Hopp bc1559
      if (s == NULL)	/* "i" ran into "maxlen" */
Karsten Hopp bc1559
  	return 0;
Karsten Hopp bc1559
  
Karsten Hopp bc1559
+     c1 = PTR2CHAR((char_u *)s + i);
Karsten Hopp bc1559
+     c2 = PTR2CHAR((char_u *)s + i + MB_PTR2LEN((char_u *)s + i));
Karsten Hopp bc1559
      /* ignore a trailing slash, but not "//" or ":/" */
Karsten Hopp bc1559
!     if (c2 == NUL
Karsten Hopp bc1559
  	    && i > 0
Karsten Hopp bc1559
  	    && !after_pathsep((char_u *)s, (char_u *)s + i)
Karsten Hopp bc1559
  #ifdef BACKSLASH_IN_FILENAME
Karsten Hopp bc1559
! 	    && (c1 == '/' || c1 == '\\')
Karsten Hopp bc1559
  #else
Karsten Hopp bc1559
! 	    && c1 == '/'
Karsten Hopp bc1559
  #endif
Karsten Hopp bc1559
         )
Karsten Hopp bc1559
  	return 0;   /* match with trailing slash */
Karsten Hopp bc1559
*** ../vim-7.3.887/src/version.c	2013-04-12 13:44:49.000000000 +0200
Karsten Hopp bc1559
--- src/version.c	2013-04-12 14:10:41.000000000 +0200
Karsten Hopp bc1559
***************
Karsten Hopp bc1559
*** 730,731 ****
Karsten Hopp bc1559
--- 730,733 ----
Karsten Hopp bc1559
  {   /* Add new patch number below this line */
Karsten Hopp bc1559
+ /**/
Karsten Hopp bc1559
+     888,
Karsten Hopp bc1559
  /**/
Karsten Hopp bc1559
Karsten Hopp bc1559
-- 
Karsten Hopp bc1559
hundred-and-one symptoms of being an internet addict:
Karsten Hopp bc1559
155. You forget to eat because you're too busy surfing the net.
Karsten Hopp bc1559
Karsten Hopp bc1559
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp bc1559
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp bc1559
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp bc1559
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///