Karsten Hopp 37e4ea
To: vim_dev@googlegroups.com
Karsten Hopp 37e4ea
Subject: Patch 7.3.440
Karsten Hopp 37e4ea
Fcc: outbox
Karsten Hopp 37e4ea
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 37e4ea
Mime-Version: 1.0
Karsten Hopp 37e4ea
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 37e4ea
Content-Transfer-Encoding: 8bit
Karsten Hopp 37e4ea
------------
Karsten Hopp 37e4ea
Karsten Hopp 37e4ea
Patch 7.3.440
Karsten Hopp 37e4ea
Problem:    Vim does not support UTF8_STRING for the X selection.
Karsten Hopp 37e4ea
Solution:   Add UTF8_STRING atom support. (Alex Efros) Use it only when
Karsten Hopp 37e4ea
            'encoding' is set to Unicode.
Karsten Hopp 37e4ea
Files:      src/ui.c
Karsten Hopp 37e4ea
Karsten Hopp 37e4ea
Karsten Hopp 37e4ea
*** ../vim-7.3.439/src/ui.c	2012-02-04 21:57:44.000000000 +0100
Karsten Hopp 37e4ea
--- src/ui.c	2012-02-12 01:28:30.000000000 +0100
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 1917,1922 ****
Karsten Hopp 37e4ea
--- 1917,1923 ----
Karsten Hopp 37e4ea
  static Atom	vim_atom;	/* Vim's own special selection format */
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
  static Atom	vimenc_atom;	/* Vim's extended selection format */
Karsten Hopp 37e4ea
+ static Atom	utf8_atom;
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  static Atom	compound_text_atom;
Karsten Hopp 37e4ea
  static Atom	text_atom;
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 1930,1935 ****
Karsten Hopp 37e4ea
--- 1931,1937 ----
Karsten Hopp 37e4ea
      vim_atom	       = XInternAtom(dpy, VIM_ATOM_NAME,   False);
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
      vimenc_atom	       = XInternAtom(dpy, VIMENC_ATOM_NAME,False);
Karsten Hopp 37e4ea
+     utf8_atom	       = XInternAtom(dpy, "UTF8_STRING",   False);
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
      compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False);
Karsten Hopp 37e4ea
      text_atom	       = XInternAtom(dpy, "TEXT",	   False);
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 2074,2080 ****
Karsten Hopp 37e4ea
      }
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  
Karsten Hopp 37e4ea
!     else if (*type == compound_text_atom || (
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
  		enc_dbcs != 0 &&
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
--- 2076,2086 ----
Karsten Hopp 37e4ea
      }
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  
Karsten Hopp 37e4ea
!     else if (*type == compound_text_atom
Karsten Hopp 37e4ea
! #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
! 	    || *type == utf8_atom
Karsten Hopp 37e4ea
! #endif
Karsten Hopp 37e4ea
! 	    || (
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
  		enc_dbcs != 0 &&
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 2128,2134 ****
Karsten Hopp 37e4ea
  #else
Karsten Hopp 37e4ea
  	    1
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
! 	    ; i < 5; i++)
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	switch (i)
Karsten Hopp 37e4ea
  	{
Karsten Hopp 37e4ea
--- 2134,2140 ----
Karsten Hopp 37e4ea
  #else
Karsten Hopp 37e4ea
  	    1
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
! 	    ; i < 6; i++)
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	switch (i)
Karsten Hopp 37e4ea
  	{
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 2136,2145 ****
Karsten Hopp 37e4ea
  	    case 0:  type = vimenc_atom;	break;
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  	    case 1:  type = vim_atom;		break;
Karsten Hopp 37e4ea
! 	    case 2:  type = compound_text_atom; break;
Karsten Hopp 37e4ea
! 	    case 3:  type = text_atom;		break;
Karsten Hopp 37e4ea
  	    default: type = XA_STRING;
Karsten Hopp 37e4ea
  	}
Karsten Hopp 37e4ea
  	success = MAYBE;
Karsten Hopp 37e4ea
  	XtGetSelectionValue(myShell, cbd->sel_atom, type,
Karsten Hopp 37e4ea
  	    clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
Karsten Hopp 37e4ea
--- 2142,2159 ----
Karsten Hopp 37e4ea
  	    case 0:  type = vimenc_atom;	break;
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  	    case 1:  type = vim_atom;		break;
Karsten Hopp 37e4ea
! #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
! 	    case 2:  type = utf8_atom;		break;
Karsten Hopp 37e4ea
! #endif
Karsten Hopp 37e4ea
! 	    case 3:  type = compound_text_atom; break;
Karsten Hopp 37e4ea
! 	    case 4:  type = text_atom;		break;
Karsten Hopp 37e4ea
  	    default: type = XA_STRING;
Karsten Hopp 37e4ea
  	}
Karsten Hopp 37e4ea
+ #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
+ 	if (type == utf8_atom && !enc_utf8)
Karsten Hopp 37e4ea
+ 	    /* Only request utf-8 when 'encoding' is utf8. */
Karsten Hopp 37e4ea
+ 	    continue;
Karsten Hopp 37e4ea
+ #endif
Karsten Hopp 37e4ea
  	success = MAYBE;
Karsten Hopp 37e4ea
  	XtGetSelectionValue(myShell, cbd->sel_atom, type,
Karsten Hopp 37e4ea
  	    clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 2230,2247 ****
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	Atom *array;
Karsten Hopp 37e4ea
  
Karsten Hopp 37e4ea
! 	if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 6))) == NULL)
Karsten Hopp 37e4ea
  	    return False;
Karsten Hopp 37e4ea
  	*value = (XtPointer)array;
Karsten Hopp 37e4ea
  	i = 0;
Karsten Hopp 37e4ea
- 	array[i++] = XA_STRING;
Karsten Hopp 37e4ea
  	array[i++] = targets_atom;
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
  	array[i++] = vimenc_atom;
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  	array[i++] = vim_atom;
Karsten Hopp 37e4ea
  	array[i++] = text_atom;
Karsten Hopp 37e4ea
  	array[i++] = compound_text_atom;
Karsten Hopp 37e4ea
  	*type = XA_ATOM;
Karsten Hopp 37e4ea
  	/* This used to be: *format = sizeof(Atom) * 8; but that caused
Karsten Hopp 37e4ea
  	 * crashes on 64 bit machines. (Peter Derr) */
Karsten Hopp 37e4ea
--- 2244,2266 ----
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	Atom *array;
Karsten Hopp 37e4ea
  
Karsten Hopp 37e4ea
! 	if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 7))) == NULL)
Karsten Hopp 37e4ea
  	    return False;
Karsten Hopp 37e4ea
  	*value = (XtPointer)array;
Karsten Hopp 37e4ea
  	i = 0;
Karsten Hopp 37e4ea
  	array[i++] = targets_atom;
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
  	array[i++] = vimenc_atom;
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  	array[i++] = vim_atom;
Karsten Hopp 37e4ea
+ #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
+ 	if (enc_utf8)
Karsten Hopp 37e4ea
+ 	    array[i++] = utf8_atom;
Karsten Hopp 37e4ea
+ #endif
Karsten Hopp 37e4ea
+ 	array[i++] = XA_STRING;
Karsten Hopp 37e4ea
  	array[i++] = text_atom;
Karsten Hopp 37e4ea
  	array[i++] = compound_text_atom;
Karsten Hopp 37e4ea
+ 
Karsten Hopp 37e4ea
  	*type = XA_ATOM;
Karsten Hopp 37e4ea
  	/* This used to be: *format = sizeof(Atom) * 8; but that caused
Karsten Hopp 37e4ea
  	 * crashes on 64 bit machines. (Peter Derr) */
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 2253,2258 ****
Karsten Hopp 37e4ea
--- 2272,2278 ----
Karsten Hopp 37e4ea
      if (       *target != XA_STRING
Karsten Hopp 37e4ea
  #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
  	    && *target != vimenc_atom
Karsten Hopp 37e4ea
+ 	    && *target != utf8_atom
Karsten Hopp 37e4ea
  #endif
Karsten Hopp 37e4ea
  	    && *target != vim_atom
Karsten Hopp 37e4ea
  	    && *target != text_atom
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 2282,2294 ****
Karsten Hopp 37e4ea
  	return False;
Karsten Hopp 37e4ea
      }
Karsten Hopp 37e4ea
  
Karsten Hopp 37e4ea
!     if (*target == XA_STRING)
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	mch_memmove(result, string, (size_t)(*length));
Karsten Hopp 37e4ea
! 	*type = XA_STRING;
Karsten Hopp 37e4ea
      }
Karsten Hopp 37e4ea
!     else if (*target == compound_text_atom
Karsten Hopp 37e4ea
! 	    || *target == text_atom)
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	XTextProperty	text_prop;
Karsten Hopp 37e4ea
  	char		*string_nt = (char *)alloc((unsigned)*length + 1);
Karsten Hopp 37e4ea
--- 2302,2317 ----
Karsten Hopp 37e4ea
  	return False;
Karsten Hopp 37e4ea
      }
Karsten Hopp 37e4ea
  
Karsten Hopp 37e4ea
!     if (*target == XA_STRING
Karsten Hopp 37e4ea
! #ifdef FEAT_MBYTE
Karsten Hopp 37e4ea
! 	    || (*target == utf8_atom && enc_utf8)
Karsten Hopp 37e4ea
! #endif
Karsten Hopp 37e4ea
! 	    )
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	mch_memmove(result, string, (size_t)(*length));
Karsten Hopp 37e4ea
! 	*type = *target;
Karsten Hopp 37e4ea
      }
Karsten Hopp 37e4ea
!     else if (*target == compound_text_atom || *target == text_atom)
Karsten Hopp 37e4ea
      {
Karsten Hopp 37e4ea
  	XTextProperty	text_prop;
Karsten Hopp 37e4ea
  	char		*string_nt = (char *)alloc((unsigned)*length + 1);
Karsten Hopp 37e4ea
*** ../vim-7.3.439/src/version.c	2012-02-12 00:31:47.000000000 +0100
Karsten Hopp 37e4ea
--- src/version.c	2012-02-12 01:34:22.000000000 +0100
Karsten Hopp 37e4ea
***************
Karsten Hopp 37e4ea
*** 716,717 ****
Karsten Hopp 37e4ea
--- 716,719 ----
Karsten Hopp 37e4ea
  {   /* Add new patch number below this line */
Karsten Hopp 37e4ea
+ /**/
Karsten Hopp 37e4ea
+     440,
Karsten Hopp 37e4ea
  /**/
Karsten Hopp 37e4ea
Karsten Hopp 37e4ea
-- 
Karsten Hopp 37e4ea
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 37e4ea
42. Your virtual girlfriend finds a new net sweetheart with a larger bandwidth.
Karsten Hopp 37e4ea
Karsten Hopp 37e4ea
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 37e4ea
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 37e4ea
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 37e4ea
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///