Karsten Hopp 1f752f
To: vim-dev@vim.org
Karsten Hopp 1f752f
Subject: patch 7.1.061
Karsten Hopp 1f752f
Fcc: outbox
Karsten Hopp 1f752f
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 1f752f
Mime-Version: 1.0
Karsten Hopp 1f752f
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 1f752f
Content-Transfer-Encoding: 8bit
Karsten Hopp 1f752f
------------
Karsten Hopp 1f752f
Karsten Hopp 1f752f
Patch 7.1.061
Karsten Hopp 1f752f
Problem:    Win32: When 'encoding' is "latin1" 'ignorecase' doesn't work for
Karsten Hopp 1f752f
	    characters with umlaut. (Joachim Hofmann)
Karsten Hopp 1f752f
Solution:   Do not use islower()/isupper()/tolower()/toupper() but our own
Karsten Hopp 1f752f
	    functions. (Chris Lubinski)
Karsten Hopp 1f752f
Files:	    src/mbyte.c, src/regexp.c, src/vim.h
Karsten Hopp 1f752f
Karsten Hopp 1f752f
Karsten Hopp 1f752f
*** ../vim-7.1.060/src/mbyte.c	Thu May 10 19:45:20 2007
Karsten Hopp 1f752f
--- src/mbyte.c	Sat Aug  4 13:44:36 2007
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 2320,2326 ****
Karsten Hopp 1f752f
  		/* Single byte: first check normally, then with ignore case. */
Karsten Hopp 1f752f
  		if (s1[i] != s2[i])
Karsten Hopp 1f752f
  		{
Karsten Hopp 1f752f
! 		    cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
Karsten Hopp 1f752f
  		    if (cdiff != 0)
Karsten Hopp 1f752f
  			return cdiff;
Karsten Hopp 1f752f
  		}
Karsten Hopp 1f752f
--- 2320,2326 ----
Karsten Hopp 1f752f
  		/* Single byte: first check normally, then with ignore case. */
Karsten Hopp 1f752f
  		if (s1[i] != s2[i])
Karsten Hopp 1f752f
  		{
Karsten Hopp 1f752f
! 		    cdiff = MB_TOLOWER(s1[i]) - MB_TOLOWER(s2[i]);
Karsten Hopp 1f752f
  		    if (cdiff != 0)
Karsten Hopp 1f752f
  			return cdiff;
Karsten Hopp 1f752f
  		}
Karsten Hopp 1f752f
*** ../vim-7.1.060/src/regexp.c	Mon Aug  6 22:27:13 2007
Karsten Hopp 1f752f
--- src/regexp.c	Sun Aug  5 15:43:27 2007
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 2220,2226 ****
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_LOWER:
Karsten Hopp 1f752f
  				for (cu = 1; cu <= 255; cu++)
Karsten Hopp 1f752f
! 				    if (islower(cu))
Karsten Hopp 1f752f
  					regc(cu);
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_PRINT:
Karsten Hopp 1f752f
--- 2220,2226 ----
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_LOWER:
Karsten Hopp 1f752f
  				for (cu = 1; cu <= 255; cu++)
Karsten Hopp 1f752f
! 				    if (MB_ISLOWER(cu))
Karsten Hopp 1f752f
  					regc(cu);
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_PRINT:
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 2240,2246 ****
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_UPPER:
Karsten Hopp 1f752f
  				for (cu = 1; cu <= 255; cu++)
Karsten Hopp 1f752f
! 				    if (isupper(cu))
Karsten Hopp 1f752f
  					regc(cu);
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_XDIGIT:
Karsten Hopp 1f752f
--- 2240,2246 ----
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_UPPER:
Karsten Hopp 1f752f
  				for (cu = 1; cu <= 255; cu++)
Karsten Hopp 1f752f
! 				    if (MB_ISUPPER(cu))
Karsten Hopp 1f752f
  					regc(cu);
Karsten Hopp 1f752f
  				break;
Karsten Hopp 1f752f
  			    case CLASS_XDIGIT:
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 3465,3471 ****
Karsten Hopp 1f752f
  			(enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))
Karsten Hopp 1f752f
  			|| (c < 255 && prog->regstart < 255 &&
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
! 			    TOLOWER_LOC(prog->regstart) == TOLOWER_LOC(c)))))
Karsten Hopp 1f752f
  	    retval = regtry(prog, col);
Karsten Hopp 1f752f
  	else
Karsten Hopp 1f752f
  	    retval = 0;
Karsten Hopp 1f752f
--- 3465,3471 ----
Karsten Hopp 1f752f
  			(enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))
Karsten Hopp 1f752f
  			|| (c < 255 && prog->regstart < 255 &&
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
! 			    MB_TOLOWER(prog->regstart) == MB_TOLOWER(c)))))
Karsten Hopp 1f752f
  	    retval = regtry(prog, col);
Karsten Hopp 1f752f
  	else
Karsten Hopp 1f752f
  	    retval = 0;
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 4200,4206 ****
Karsten Hopp 1f752f
  #ifdef FEAT_MBYTE
Karsten Hopp 1f752f
  			    !enc_utf8 &&
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
! 			    TOLOWER_LOC(*opnd) != TOLOWER_LOC(*reginput))))
Karsten Hopp 1f752f
  		    status = RA_NOMATCH;
Karsten Hopp 1f752f
  		else if (*opnd == NUL)
Karsten Hopp 1f752f
  		{
Karsten Hopp 1f752f
--- 4200,4206 ----
Karsten Hopp 1f752f
  #ifdef FEAT_MBYTE
Karsten Hopp 1f752f
  			    !enc_utf8 &&
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
! 			    MB_TOLOWER(*opnd) != MB_TOLOWER(*reginput))))
Karsten Hopp 1f752f
  		    status = RA_NOMATCH;
Karsten Hopp 1f752f
  		else if (*opnd == NUL)
Karsten Hopp 1f752f
  		{
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 4733,4742 ****
Karsten Hopp 1f752f
  		    rst.nextb = *OPERAND(next);
Karsten Hopp 1f752f
  		    if (ireg_ic)
Karsten Hopp 1f752f
  		    {
Karsten Hopp 1f752f
! 			if (isupper(rst.nextb))
Karsten Hopp 1f752f
! 			    rst.nextb_ic = TOLOWER_LOC(rst.nextb);
Karsten Hopp 1f752f
  			else
Karsten Hopp 1f752f
! 			    rst.nextb_ic = TOUPPER_LOC(rst.nextb);
Karsten Hopp 1f752f
  		    }
Karsten Hopp 1f752f
  		    else
Karsten Hopp 1f752f
  			rst.nextb_ic = rst.nextb;
Karsten Hopp 1f752f
--- 4733,4742 ----
Karsten Hopp 1f752f
  		    rst.nextb = *OPERAND(next);
Karsten Hopp 1f752f
  		    if (ireg_ic)
Karsten Hopp 1f752f
  		    {
Karsten Hopp 1f752f
! 			if (MB_ISUPPER(rst.nextb))
Karsten Hopp 1f752f
! 			    rst.nextb_ic = MB_TOLOWER(rst.nextb);
Karsten Hopp 1f752f
  			else
Karsten Hopp 1f752f
! 			    rst.nextb_ic = MB_TOUPPER(rst.nextb);
Karsten Hopp 1f752f
  		    }
Karsten Hopp 1f752f
  		    else
Karsten Hopp 1f752f
  			rst.nextb_ic = rst.nextb;
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 5558,5568 ****
Karsten Hopp 1f752f
  	    int	    cu, cl;
Karsten Hopp 1f752f
  
Karsten Hopp 1f752f
  	    /* This doesn't do a multi-byte character, because a MULTIBYTECODE
Karsten Hopp 1f752f
! 	     * would have been used for it. */
Karsten Hopp 1f752f
  	    if (ireg_ic)
Karsten Hopp 1f752f
  	    {
Karsten Hopp 1f752f
! 		cu = TOUPPER_LOC(*opnd);
Karsten Hopp 1f752f
! 		cl = TOLOWER_LOC(*opnd);
Karsten Hopp 1f752f
  		while (count < maxcount && (*scan == cu || *scan == cl))
Karsten Hopp 1f752f
  		{
Karsten Hopp 1f752f
  		    count++;
Karsten Hopp 1f752f
--- 5558,5569 ----
Karsten Hopp 1f752f
  	    int	    cu, cl;
Karsten Hopp 1f752f
  
Karsten Hopp 1f752f
  	    /* This doesn't do a multi-byte character, because a MULTIBYTECODE
Karsten Hopp 1f752f
! 	     * would have been used for it.  It does handle single-byte
Karsten Hopp 1f752f
! 	     * characters, such as latin1. */
Karsten Hopp 1f752f
  	    if (ireg_ic)
Karsten Hopp 1f752f
  	    {
Karsten Hopp 1f752f
! 		cu = MB_TOUPPER(*opnd);
Karsten Hopp 1f752f
! 		cl = MB_TOLOWER(*opnd);
Karsten Hopp 1f752f
  		while (count < maxcount && (*scan == cu || *scan == cl))
Karsten Hopp 1f752f
  		{
Karsten Hopp 1f752f
  		    count++;
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 6490,6499 ****
Karsten Hopp 1f752f
  	cc = utf_fold(c);
Karsten Hopp 1f752f
      else
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
! 	 if (isupper(c))
Karsten Hopp 1f752f
! 	cc = TOLOWER_LOC(c);
Karsten Hopp 1f752f
!     else if (islower(c))
Karsten Hopp 1f752f
! 	cc = TOUPPER_LOC(c);
Karsten Hopp 1f752f
      else
Karsten Hopp 1f752f
  	return vim_strchr(s, c);
Karsten Hopp 1f752f
  
Karsten Hopp 1f752f
--- 6491,6500 ----
Karsten Hopp 1f752f
  	cc = utf_fold(c);
Karsten Hopp 1f752f
      else
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
! 	 if (MB_ISUPPER(c))
Karsten Hopp 1f752f
! 	cc = MB_TOLOWER(c);
Karsten Hopp 1f752f
!     else if (MB_ISLOWER(c))
Karsten Hopp 1f752f
! 	cc = MB_TOUPPER(c);
Karsten Hopp 1f752f
      else
Karsten Hopp 1f752f
  	return vim_strchr(s, c);
Karsten Hopp 1f752f
  
Karsten Hopp 1f752f
*** ../vim-7.1.060/src/vim.h	Sat May 12 15:08:22 2007
Karsten Hopp 1f752f
--- src/vim.h	Sat Aug  4 13:57:36 2007
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 1380,1387 ****
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
  
Karsten Hopp 1f752f
  #ifdef FEAT_MBYTE
Karsten Hopp 1f752f
! # define MB_STRICMP(d, s)	(has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL) : STRICMP((d), (s)))
Karsten Hopp 1f752f
! # define MB_STRNICMP(d, s, n)	(has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n)) : STRNICMP((d), (s), (n)))
Karsten Hopp 1f752f
  #else
Karsten Hopp 1f752f
  # define MB_STRICMP(d, s)	STRICMP((d), (s))
Karsten Hopp 1f752f
  # define MB_STRNICMP(d, s, n)	STRNICMP((d), (s), (n))
Karsten Hopp 1f752f
--- 1380,1393 ----
Karsten Hopp 1f752f
  #endif
Karsten Hopp 1f752f
  
Karsten Hopp 1f752f
  #ifdef FEAT_MBYTE
Karsten Hopp 1f752f
! /* We need to call mb_stricmp() even when we aren't dealing with a multi-byte
Karsten Hopp 1f752f
!  * encoding because mb_stricmp() takes care of all ascii and non-ascii
Karsten Hopp 1f752f
!  * encodings, including characters with umluats in latin1, etc., while
Karsten Hopp 1f752f
!  * STRICMP() only handles the system locale version, which often does not
Karsten Hopp 1f752f
!  * handle non-ascii properly. */
Karsten Hopp 1f752f
! 
Karsten Hopp 1f752f
! # define MB_STRICMP(d, s)	mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
Karsten Hopp 1f752f
! # define MB_STRNICMP(d, s, n)	mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
Karsten Hopp 1f752f
  #else
Karsten Hopp 1f752f
  # define MB_STRICMP(d, s)	STRICMP((d), (s))
Karsten Hopp 1f752f
  # define MB_STRNICMP(d, s, n)	STRNICMP((d), (s), (n))
Karsten Hopp 1f752f
*** ../vim-7.1.060/src/version.c	Sat Aug 11 13:37:36 2007
Karsten Hopp 1f752f
--- src/version.c	Sat Aug 11 13:55:24 2007
Karsten Hopp 1f752f
***************
Karsten Hopp 1f752f
*** 668,669 ****
Karsten Hopp 1f752f
--- 668,671 ----
Karsten Hopp 1f752f
  {   /* Add new patch number below this line */
Karsten Hopp 1f752f
+ /**/
Karsten Hopp 1f752f
+     61,
Karsten Hopp 1f752f
  /**/
Karsten Hopp 1f752f
Karsten Hopp 1f752f
-- 
Karsten Hopp 1f752f
Support your right to bare arms!  Wear short sleeves!
Karsten Hopp 1f752f
Karsten Hopp 1f752f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 1f752f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 1f752f
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 1f752f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///