jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.202

3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.202
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.202
3ef2ca
Problem:    MS-Windows: non-ASCII font names don't work.
3ef2ca
Solution:   Convert between the current code page and 'encoding'. (Ken Takata)
3ef2ca
Files:	    src/gui_w48.c, src/os_mswin.c, src/proto/winclip.pro,
3ef2ca
	    src/winclip.c
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.201/src/gui_w48.c	2013-09-22 15:43:34.000000000 +0200
3ef2ca
--- src/gui_w48.c	2014-03-12 19:18:14.264927370 +0100
3ef2ca
***************
3ef2ca
*** 3069,3083 ****
3ef2ca
      char	*p;
3ef2ca
      char	*res;
3ef2ca
      char	*charset_name;
3ef2ca
  
3ef2ca
      charset_name = charset_id2name((int)lf.lfCharSet);
3ef2ca
!     res = alloc((unsigned)(strlen(lf.lfFaceName) + 20
3ef2ca
  		    + (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
3ef2ca
      if (res != NULL)
3ef2ca
      {
3ef2ca
  	p = res;
3ef2ca
  	/* make a normal font string out of the lf thing:*/
3ef2ca
! 	sprintf((char *)p, "%s:h%d", lf.lfFaceName, pixels_to_points(
3ef2ca
  			 lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE));
3ef2ca
  	while (*p)
3ef2ca
  	{
3ef2ca
--- 3069,3094 ----
3ef2ca
      char	*p;
3ef2ca
      char	*res;
3ef2ca
      char	*charset_name;
3ef2ca
+     char	*font_name = lf.lfFaceName;
3ef2ca
  
3ef2ca
      charset_name = charset_id2name((int)lf.lfCharSet);
3ef2ca
! #ifdef FEAT_MBYTE
3ef2ca
!     /* Convert a font name from the current codepage to 'encoding'.
3ef2ca
!      * TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */
3ef2ca
!     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
3ef2ca
!     {
3ef2ca
! 	int	len;
3ef2ca
! 	acp_to_enc(lf.lfFaceName, strlen(lf.lfFaceName),
3ef2ca
! 						(char_u **)&font_name, &len;;
3ef2ca
!     }
3ef2ca
! #endif
3ef2ca
!     res = alloc((unsigned)(strlen(font_name) + 20
3ef2ca
  		    + (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
3ef2ca
      if (res != NULL)
3ef2ca
      {
3ef2ca
  	p = res;
3ef2ca
  	/* make a normal font string out of the lf thing:*/
3ef2ca
! 	sprintf((char *)p, "%s:h%d", font_name, pixels_to_points(
3ef2ca
  			 lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE));
3ef2ca
  	while (*p)
3ef2ca
  	{
3ef2ca
***************
3ef2ca
*** 3102,3107 ****
3ef2ca
--- 3113,3122 ----
3ef2ca
  	}
3ef2ca
      }
3ef2ca
  
3ef2ca
+ #ifdef FEAT_MBYTE
3ef2ca
+     if (font_name != lf.lfFaceName)
3ef2ca
+ 	vim_free(font_name);
3ef2ca
+ #endif
3ef2ca
      return res;
3ef2ca
  }
3ef2ca
  
3ef2ca
*** ../vim-7.4.201/src/os_mswin.c	2014-02-11 17:05:57.278217857 +0100
3ef2ca
--- src/os_mswin.c	2014-03-12 19:18:14.264927370 +0100
3ef2ca
***************
3ef2ca
*** 2867,2878 ****
3ef2ca
--- 2867,2893 ----
3ef2ca
  {
3ef2ca
      char_u	*p;
3ef2ca
      int		i;
3ef2ca
+     int		ret = FAIL;
3ef2ca
      static LOGFONT *lastlf = NULL;
3ef2ca
+ #ifdef FEAT_MBYTE
3ef2ca
+     char_u	*acpname = NULL;
3ef2ca
+ #endif
3ef2ca
  
3ef2ca
      *lf = s_lfDefault;
3ef2ca
      if (name == NULL)
3ef2ca
  	return OK;
3ef2ca
  
3ef2ca
+ #ifdef FEAT_MBYTE
3ef2ca
+     /* Convert 'name' from 'encoding' to the current codepage, because
3ef2ca
+      * lf->lfFaceName uses the current codepage.
3ef2ca
+      * TODO: Use Wide APIs instead of ANSI APIs. */
3ef2ca
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
3ef2ca
+     {
3ef2ca
+ 	int	len;
3ef2ca
+ 	enc_to_acp(name, strlen(name), &acpname, &len;;
3ef2ca
+ 	name = acpname;
3ef2ca
+     }
3ef2ca
+ #endif
3ef2ca
      if (STRCMP(name, "*") == 0)
3ef2ca
      {
3ef2ca
  #if defined(FEAT_GUI_W32)
3ef2ca
***************
3ef2ca
*** 2887,2896 ****
3ef2ca
  	cf.lpLogFont = lf;
3ef2ca
  	cf.nFontType = 0 ; //REGULAR_FONTTYPE;
3ef2ca
  	if (ChooseFont(&cf))
3ef2ca
! 	    goto theend;
3ef2ca
! #else
3ef2ca
! 	return FAIL;
3ef2ca
  #endif
3ef2ca
      }
3ef2ca
  
3ef2ca
      /*
3ef2ca
--- 2902,2910 ----
3ef2ca
  	cf.lpLogFont = lf;
3ef2ca
  	cf.nFontType = 0 ; //REGULAR_FONTTYPE;
3ef2ca
  	if (ChooseFont(&cf))
3ef2ca
! 	    ret = OK;
3ef2ca
  #endif
3ef2ca
+ 	goto theend;
3ef2ca
      }
3ef2ca
  
3ef2ca
      /*
3ef2ca
***************
3ef2ca
*** 2899,2905 ****
3ef2ca
      for (p = name; *p && *p != ':'; p++)
3ef2ca
      {
3ef2ca
  	if (p - name + 1 > LF_FACESIZE)
3ef2ca
! 	    return FAIL;			/* Name too long */
3ef2ca
  	lf->lfFaceName[p - name] = *p;
3ef2ca
      }
3ef2ca
      if (p != name)
3ef2ca
--- 2913,2919 ----
3ef2ca
      for (p = name; *p && *p != ':'; p++)
3ef2ca
      {
3ef2ca
  	if (p - name + 1 > LF_FACESIZE)
3ef2ca
! 	    goto theend;			/* Name too long */
3ef2ca
  	lf->lfFaceName[p - name] = *p;
3ef2ca
      }
3ef2ca
      if (p != name)
3ef2ca
***************
3ef2ca
*** 2927,2933 ****
3ef2ca
  		did_replace = TRUE;
3ef2ca
  	    }
3ef2ca
  	if (!did_replace || init_logfont(lf) == FAIL)
3ef2ca
! 	    return FAIL;
3ef2ca
      }
3ef2ca
  
3ef2ca
      while (*p == ':')
3ef2ca
--- 2941,2947 ----
3ef2ca
  		did_replace = TRUE;
3ef2ca
  	    }
3ef2ca
  	if (!did_replace || init_logfont(lf) == FAIL)
3ef2ca
! 	    goto theend;
3ef2ca
      }
3ef2ca
  
3ef2ca
      while (*p == ':')
3ef2ca
***************
3ef2ca
*** 2988,3012 ****
3ef2ca
  			    p[-1], name);
3ef2ca
  		    EMSG(IObuff);
3ef2ca
  		}
3ef2ca
! 		return FAIL;
3ef2ca
  	}
3ef2ca
  	while (*p == ':')
3ef2ca
  	    p++;
3ef2ca
      }
3ef2ca
  
3ef2ca
- #if defined(FEAT_GUI_W32)
3ef2ca
  theend:
3ef2ca
- #endif
3ef2ca
      /* ron: init lastlf */
3ef2ca
!     if (printer_dc == NULL)
3ef2ca
      {
3ef2ca
  	vim_free(lastlf);
3ef2ca
  	lastlf = (LOGFONT *)alloc(sizeof(LOGFONT));
3ef2ca
  	if (lastlf != NULL)
3ef2ca
  	    mch_memmove(lastlf, lf, sizeof(LOGFONT));
3ef2ca
      }
3ef2ca
  
3ef2ca
!     return OK;
3ef2ca
  }
3ef2ca
  
3ef2ca
  #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */
3ef2ca
--- 3002,3028 ----
3ef2ca
  			    p[-1], name);
3ef2ca
  		    EMSG(IObuff);
3ef2ca
  		}
3ef2ca
! 		goto theend;
3ef2ca
  	}
3ef2ca
  	while (*p == ':')
3ef2ca
  	    p++;
3ef2ca
      }
3ef2ca
+     ret = OK;
3ef2ca
  
3ef2ca
  theend:
3ef2ca
      /* ron: init lastlf */
3ef2ca
!     if (ret == OK && printer_dc == NULL)
3ef2ca
      {
3ef2ca
  	vim_free(lastlf);
3ef2ca
  	lastlf = (LOGFONT *)alloc(sizeof(LOGFONT));
3ef2ca
  	if (lastlf != NULL)
3ef2ca
  	    mch_memmove(lastlf, lf, sizeof(LOGFONT));
3ef2ca
      }
3ef2ca
+ #ifdef FEAT_MBYTE
3ef2ca
+     vim_free(acpname);
3ef2ca
+ #endif
3ef2ca
  
3ef2ca
!     return ret;
3ef2ca
  }
3ef2ca
  
3ef2ca
  #endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */
3ef2ca
*** ../vim-7.4.201/src/proto/winclip.pro	2013-08-10 13:37:39.000000000 +0200
3ef2ca
--- src/proto/winclip.pro	2014-03-12 19:18:14.264927370 +0100
3ef2ca
***************
3ef2ca
*** 11,14 ****
3ef2ca
--- 11,15 ----
3ef2ca
  short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp));
3ef2ca
  char_u *utf16_to_enc __ARGS((short_u *str, int *lenp));
3ef2ca
  void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
3ef2ca
+ void enc_to_acp __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
3ef2ca
  /* vim: set ft=c : */
3ef2ca
*** ../vim-7.4.201/src/winclip.c	2013-07-01 21:05:53.000000000 +0200
3ef2ca
--- src/winclip.c	2014-03-12 19:18:14.264927370 +0100
3ef2ca
***************
3ef2ca
*** 797,800 ****
3ef2ca
--- 797,825 ----
3ef2ca
  	vim_free(widestr);
3ef2ca
      }
3ef2ca
  }
3ef2ca
+ 
3ef2ca
+ /*
3ef2ca
+  * Convert from 'encoding' to the active codepage.
3ef2ca
+  * Input is "str[str_size]".
3ef2ca
+  * The result is in allocated memory: "out[outlen]".  With terminating NUL.
3ef2ca
+  */
3ef2ca
+     void
3ef2ca
+ enc_to_acp(str, str_size, out, outlen)
3ef2ca
+     char_u	*str;
3ef2ca
+     int		str_size;
3ef2ca
+     char_u	**out;
3ef2ca
+     int		*outlen;
3ef2ca
+ 
3ef2ca
+ {
3ef2ca
+     LPWSTR	widestr;
3ef2ca
+     int		len = str_size;
3ef2ca
+ 
3ef2ca
+     widestr = (WCHAR *)enc_to_utf16(str, &len;;
3ef2ca
+     if (widestr != NULL)
3ef2ca
+     {
3ef2ca
+ 	WideCharToMultiByte_alloc(GetACP(), 0, widestr, len,
3ef2ca
+ 						(LPSTR *)out, outlen, 0, 0);
3ef2ca
+ 	vim_free(widestr);
3ef2ca
+     }
3ef2ca
+ }
3ef2ca
  #endif
3ef2ca
*** ../vim-7.4.201/src/version.c	2014-03-12 18:55:52.104906804 +0100
3ef2ca
--- src/version.c	2014-03-12 19:19:01.388928092 +0100
3ef2ca
***************
3ef2ca
*** 740,741 ****
3ef2ca
--- 740,743 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     202,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
<Beeth> Girls are like internet domain names,
3ef2ca
        the ones I like are already taken.
3ef2ca
<honx>  Well, you can stil get one from a strange country :-P
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///