Yuriy Kaminskiy wrote:
SungHyun Nam wrote:
2010-09-23 AM 12:49, Young Ho Park wrote:
Hello. I am a Vim user from South Korea. I seem to find the bug about
cut(or copy) and paste. Let me explain steps to a paste fail.

I use Vim7.2 in Gnome2.3 of Fedora13 or Ubuntu10.04 and my locale is
ko_KR.utf8 0. I executed Vim. 1. I wrote Alphabet and Hangul mixed
string. 2. I clicked a copy(or cut) button. 3. I closed Vim. 4. I
executed Vim again. 5. I clicked a paste button. 6. English
characters were well copied. But Hangul characters are changed to
question marks like: ¿?¿?¿?¿?

Is it a bug? Or didn't I turn on some options?

More info about this problem.

1.  If I don't quit select&copied-gvim, then paste to
     gnome-terminal or other-gvim works fine.

2.  If I quit select&copied-gvim:
     o   paste menu in gnome-terminal became disabled (and nothing
         happened if I click middle mouse button).
     o   when I paste in other-gvim, hangul characters are now
         corrupted.

I think this was introduced in 7.2.221 patch, that tries a bit
too much to follow standard on CUTBUFFER* encoding, rendering it
useless for any non-latin1 locales.

I revert 7.2.221 patch [*1*] and the corrupt problem gone.

With a reverted gvim-gtk2,

1.  If I don't quit select&copied-gvim, then paste to
     gnome-terminal or other-gvim works fine.

2.  If I quit select&copied-gvim:
     o   paste menu in gnome-terminal became disabled (and nothing
         happened if I click middle mouse button).
     *   PASTE IN OTHER-GVIM WORKS FINE (NO CORRUPTION).

Thanks,
namsh

*1*
    fixed reject to ui.c and ops.c manually
    ignored reject to version.c and proto/ui.pro

$ hg tip
changeset:   2587:d0049ff5969e
...

$ hg diff --git
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5603,6 +5603,8 @@
 {
     GdkAtom    target;
     unsigned   i;
+    int                nbytes;
+    char_u     *buffer;
     time_t     start;

     for (i = 0; i < N_SELECTION_TARGETS; ++i)
@@ -5628,7 +5630,22 @@
     }

     /* Final fallback position - use the X CUT_BUFFER0 store */
-    yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gui.mainwin->window), cbd);
+    nbytes = 0;
+ buffer = (char_u *)XFetchBuffer(GDK_WINDOW_XDISPLAY(gui.mainwin->window),
+                                   &nbytes, 0);
+    if (nbytes > 0)
+    {
+       /* Got something */
+       clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
+       if (p_verbose > 0)
+       {
+           verbose_enter();
+           smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
+           verbose_leave();
+       }
+    }
+    if (buffer != NULL)
+       XFree(buffer);
 }

 /*
diff --git a/src/message.c b/src/message.c
--- a/src/message.c
+++ b/src/message.c
@@ -107,7 +107,7 @@
 }

 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
-    || defined(FEAT_GUI_GTK) || defined(PROTO)
+    || defined(PROTO)
 /*
  * Like msg() but keep it silent when 'verbosefile' is set.
  */
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -5595,32 +5595,6 @@
     if (dpy != NULL && str != NULL && motion_type >= 0
                                               && len < 1024*1024 && len > 0)
     {
-#ifdef FEAT_MBYTE
-       /* The CUT_BUFFER0 is supposed to always contain latin1.  Convert from
-        * 'enc' when it is a multi-byte encoding.  When 'enc' is an 8-bit
-        * encoding conversion usually doesn't work, so keep the text as-is.
-        */
-       if (has_mbyte)
-       {
-           vimconv_T   vc;
-
-           vc.vc_type = CONV_NONE;
-           if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
-           {
-               int     intlen = len;
-               char_u  *conv_str;
-
-               conv_str = string_convert(&vc, str, &intlen);
-               len = intlen;
-               if (conv_str != NULL)
-               {
-                   vim_free(str);
-                   str = conv_str;
-               }
-               convert_setup(&vc, NULL, NULL);
-           }
-       }
-#endif
        XStoreBuffer(dpy, (char *)str, (int)len, 0);
        XFlush(dpy);
     }
diff --git a/src/ui.c b/src/ui.c
--- a/src/ui.c
+++ b/src/ui.c
@@ -2120,6 +2120,8 @@
     Atom       type;
     static int success;
     int                i;
+    int                nbytes = 0;
+    char_u     *buffer;
     time_t     start_time;
     int                timed_out = FALSE;

@@ -2199,7 +2201,15 @@
     }

     /* Final fallback position - use the X CUT_BUFFER0 store */
-    yank_cut_buffer0(dpy, cbd);
+    buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
+    if (nbytes > 0)
+    {
+       /* Got something */
+       clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
+       XFree((void *)buffer);
+       if (p_verbose > 0)
+           verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty 
selection"));
+    }
 }

     static Boolean
@@ -2389,60 +2399,6 @@
 }
 #endif

-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) \
-    || defined(FEAT_GUI_GTK) || defined(PROTO)
-/*
- * Get the contents of the X CUT_BUFFER0 and put it in "cbd".
- */
-    void
-yank_cut_buffer0(dpy, cbd)
-    Display            *dpy;
-    VimClipboard       *cbd;
-{
-    int                nbytes = 0;
-    char_u     *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
-
-    if (nbytes > 0)
-    {
-#ifdef FEAT_MBYTE
-       int  done = FALSE;
-
-       /* CUT_BUFFER0 is supposed to be always latin1.  Convert to 'enc' when
-        * using a multi-byte encoding.  Conversion between two 8-bit
-        * character sets usually fails and the text might actually be in
-        * 'enc' anyway. */
-       if (has_mbyte)
-       {
-           char_u      *conv_buf;
-           vimconv_T   vc;
-
-           vc.vc_type = CONV_NONE;
-           if (convert_setup(&vc, (char_u *)"latin1", p_enc) == OK)
-           {
-               conv_buf = string_convert(&vc, buffer, &nbytes);
-               if (conv_buf != NULL)
-               {
-                   clip_yank_selection(MCHAR, conv_buf, (long)nbytes, cbd);
-                   vim_free(conv_buf);
-                   done = TRUE;
-               }
-               convert_setup(&vc, NULL, NULL);
-           }
-       }
-       if (!done)  /* use the text without conversion */
-#endif
-           clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
-       XFree((void *)buffer);
-       if (p_verbose > 0)
-       {
-           verbose_enter();
-           verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty 
selection"));
-           verbose_leave();
-       }
-    }
-}
-#endif
-
 #if defined(FEAT_MOUSE) || defined(PROTO)

 /*

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui