Loading ...
Sorry, an error occurred while loading the content.

Bug with clipboard?

Expand Messages
  • Mikolaj Machowski
    Hello, I have got a report about bug in windows version of Vim with latest patches. If in clipboard are polish diacritics and copied to clipboard eg. *yy and
    Message 1 of 10 , Apr 2 12:54 PM
    • 0 Attachment
      Hello,

      I have got a report about bug in windows version of Vim with latest
      patches.

      If in clipboard are polish diacritics and copied to clipboard eg. "*yy
      and then pasted "*p they are translated into utf-8. Obviously undesired
      behaviour.

      m.
      --
      Vim-list(s) Users Map (last change 2 Apr)
      http://skawina.eu.org/mikolaj/vimlist
      Are You There?
    • Mikolaj Machowski
      ... And now I tested it on vim-6-1-389 from Steve Hall. ... Polish letters are broken. m.
      Message 2 of 10 , Apr 2 2:36 PM
      • 0 Attachment
        On Wed, Apr 02, 2003 at 10:54:43PM +0200, Mikolaj Machowski wrote:
        > Hello,
        > I have got a report about bug in windows version of Vim with latest
        > patches.

        And now I tested it on vim-6-1-389 from Steve Hall.

        > If in clipboard are polish diacritics and copied to clipboard eg. "*yy
        > and then pasted "*p they are translated into utf-8. Obviously undesired
        > behaviour.

        Polish letters are broken.
        m.
        > --
        > Vim-list(s) Users Map (last change 2 Apr)
        > http://skawina.eu.org/mikolaj/vimlist
        > Are You There?
      • Neil Bird
        Around about 02/04/2003 23:36, Mikolaj Machowski typed ... ... -- [neil@fnx ~]# rm -f .signature [neil@fnx ~]# ls -l .signature ls: .signature: No such file or
        Message 3 of 10 , Apr 3 1:39 AM
        • 0 Attachment
          Around about 02/04/2003 23:36, Mikolaj Machowski typed ...
          >>I have got a report about bug in windows version of Vim with latest
          >>patches.
          > And now I tested it on vim-6-1-389 from Steve Hall.


          This might be:
          > Patch 6.1.421 (extra, depends on 6.1.354)
          > Problem: MS-Windows 9x: When putting text on the clipboard it can be in
          > the wrong encoding.
          > Solution: Convert text to the active codepage for CF_TEXT. (Glenn Maynard)
          > Files: src/os_mswin.c

          --
          [neil@fnx ~]# rm -f .signature
          [neil@fnx ~]# ls -l .signature
          ls: .signature: No such file or directory
          [neil@fnx ~]# exit
        • Bram Moolenaar
          ... What is your encoding set to? What is your active codepage? Which version of MS-Windows? -- WOMAN: King of the who? ARTHUR: The Britons. WOMAN: Who
          Message 4 of 10 , Apr 3 12:27 PM
          • 0 Attachment
            Mikolaj Machowski wrote:

            > I have got a report about bug in windows version of Vim with latest
            > patches.
            >
            > If in clipboard are polish diacritics and copied to clipboard eg. "*yy
            > and then pasted "*p they are translated into utf-8. Obviously undesired
            > behaviour.

            What is your 'encoding' set to?
            What is your active codepage?
            Which version of MS-Windows?

            --
            WOMAN: King of the who?
            ARTHUR: The Britons.
            WOMAN: Who are the Britons?
            ARTHUR: Well, we all are. we're all Britons and I am your king.
            The Quest for the Holy Grail (Monty Python)

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
          • Mikolaj Machowski
            ... No. I just tested with 6.1.423 from Steve and clipboard still is broken. I have also confirmation that pure Vim (without Arabic patch) also doesn t work.
            Message 5 of 10 , Apr 3 12:42 PM
            • 0 Attachment
              On Thu, Apr 03, 2003 at 10:39:39AM +0100, Neil Bird wrote:
              > Around about 02/04/2003 23:36, Mikolaj Machowski typed ...
              > >>I have got a report about bug in windows version of Vim with latest
              > >>patches.
              > >And now I tested it on vim-6-1-389 from Steve Hall.
              > This might be:
              > >Patch 6.1.421 (extra, depends on 6.1.354)
              > >Problem: MS-Windows 9x: When putting text on the clipboard it can be in
              > > the wrong encoding.
              > >Solution: Convert text to the active codepage for CF_TEXT. (Glenn
              > >Maynard)
              > >Files: src/os_mswin.c

              No. I just tested with 6.1.423 from Steve and clipboard still is broken.
              I have also confirmation that "pure" Vim (without Arabic patch) also
              doesn't work.

              m.
              --
              LaTeX + Vim = http://vim-latex.sourceforge.net/
              Learn Touch Typing with Vim:
              http://vim.sourceforge.net/script.php?script_id=461
              vim.pl - http://skawina.eu.org/mikolaj
            • Mikolaj Machowski
              ... cp1250 ... cp1250 ... ms98se m. -- Vim-list(s) Users Map (last change 2 Apr) http://skawina.eu.org/mikolaj/vimlist Are You There?
              Message 6 of 10 , Apr 3 1:03 PM
              • 0 Attachment
                On Thu, Apr 03, 2003 at 10:27:36PM +0200, Bram Moolenaar wrote:
                > Mikolaj Machowski wrote:
                > > I have got a report about bug in windows version of Vim with latest
                > > patches.
                > >
                > > If in clipboard are polish diacritics and copied to clipboard eg. "*yy
                > > and then pasted "*p they are translated into utf-8. Obviously undesired
                > > behaviour.
                > What is your 'encoding' set to?
                cp1250
                > What is your active codepage?
                cp1250
                > Which version of MS-Windows?
                ms98se

                m.
                --
                Vim-list(s) Users Map (last change 2 Apr)
                http://skawina.eu.org/mikolaj/vimlist
                Are You There?
              • Bram Moolenaar
                ... I cannot reproduce the problem (I didn t set the system to use cp1250). I looked at the code but don t see something obvious wrong with it. Can someone who
                Message 7 of 10 , Apr 4 12:32 PM
                • 0 Attachment
                  Mikolaj Machowski wrote:

                  > > > I have got a report about bug in windows version of Vim with latest
                  > > > patches.
                  > > >
                  > > > If in clipboard are polish diacritics and copied to clipboard eg. "*yy
                  > > > and then pasted "*p they are translated into utf-8. Obviously undesired
                  > > > behaviour.
                  > > What is your 'encoding' set to?
                  > cp1250
                  > > What is your active codepage?
                  > cp1250
                  > > Which version of MS-Windows?
                  > ms98se

                  I cannot reproduce the problem (I didn't set the system to use cp1250).

                  I looked at the code but don't see something obvious wrong with it.

                  Can someone who can reproduce the problem run a debugger and find out
                  what happens?

                  --
                  ARTHUR: A scratch? Your arm's off!
                  BLACK KNIGHT: No, it isn't.
                  ARTHUR: Well, what's that then?
                  BLACK KNIGHT: I've had worse.
                  The Quest for the Holy Grail (Monty Python)

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
                  \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                  \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
                • Bram Moolenaar
                  Mikolaj - ... Do you still experience this problem? If so, do you have a hint about what is different about your setup that you see this problem while it
                  Message 8 of 10 , Mar 10, 2004
                  • 0 Attachment
                    Mikolaj -

                    Almost a year ago you reported this problem:

                    > On Thu, Apr 03, 2003 at 10:27:36PM +0200, Bram Moolenaar wrote:
                    > > Mikolaj Machowski wrote:
                    > > > I have got a report about bug in windows version of Vim with latest
                    > > > patches.
                    > > >
                    > > > If in clipboard are polish diacritics and copied to clipboard eg. "*yy
                    > > > and then pasted "*p they are translated into utf-8. Obviously undesired
                    > > > behaviour.
                    > > What is your 'encoding' set to?
                    > cp1250
                    > > What is your active codepage?
                    > cp1250
                    > > Which version of MS-Windows?
                    > ms98se

                    Do you still experience this problem? If so, do you have a hint about
                    what is different about your setup that you see this problem while it
                    works fine for most people?

                    - Bram

                    --
                    For society, it's probably a good thing that engineers value function over
                    appearance. For example, you wouldn't want engineers to build nuclear power
                    plants that only _look_ like they would keep all the radiation inside.
                    (Scott Adams - The Dilbert principle)

                    /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                    /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                    \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                    \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
                  • Mikolaj Machowski
                    ... No. With latest version of Vim 6.2.327 (Ajit Thakkar - thanks!) I don t encounter this problem. I suspect bogus version of iconv.dll - person which send me
                    Message 9 of 10 , Mar 10, 2004
                    • 0 Attachment
                      Dnia Wednesday 10 of March 2004 17:40, Bram Moolenaar napisaƂ:
                      > Almost a year ago you reported this problem:
                      > > On Thu, Apr 03, 2003 at 10:27:36PM +0200, Bram Moolenaar wrote:
                      > > > Mikolaj Machowski wrote:
                      > > > > I have got a report about bug in windows version of Vim with latest
                      > > > > patches.
                      > > > > If in clipboard are polish diacritics and copied to clipboard
                      > > > > eg.
                      > > > > "*yy and then pasted "*p they are translated into utf-8. Obviously
                      > > > > undesired behaviour.
                      > > > What is your 'encoding' set to?
                      > > cp1250
                      > > > What is your active codepage?
                      > > cp1250
                      > > > Which version of MS-Windows?
                      > > ms98se
                      >
                      > Do you still experience this problem? If so, do you have a hint about
                      > what is different about your setup that you see this problem while it
                      > works fine for most people?

                      No. With latest version of Vim 6.2.327 (Ajit Thakkar - thanks!) I don't
                      encounter this problem. I suspect bogus version of iconv.dll - person
                      which send me this bug report downloaded iconv.dll in the same time
                      I did it (I "sold" him Vim :).

                      m.



                      --
                      LaTeX + Vim = http://vim-latex.sourceforge.net/
                      Vim-list(s) Users Map: (last change 9 Mar)
                      http://skawina.eu.org/mikolaj/vimlist
                      Are You There?
                    • Bram Moolenaar
                      ... I just implemented another clipboard format: Raw bytes. It will be used when you copy/paste between two Vims that use the same encoding . It avoids
                      Message 10 of 10 , Mar 11, 2004
                      • 0 Attachment
                        Mikolaj Machowski wrote:

                        > > Do you still experience this problem? If so, do you have a hint about
                        > > what is different about your setup that you see this problem while it
                        > > works fine for most people?
                        >
                        > No. With latest version of Vim 6.2.327 (Ajit Thakkar - thanks!) I don't
                        > encounter this problem. I suspect bogus version of iconv.dll - person
                        > which send me this bug report downloaded iconv.dll in the same time
                        > I did it (I "sold" him Vim :).

                        I just implemented another clipboard format: Raw bytes. It will be used
                        when you copy/paste between two Vims that use the same 'encoding'. It
                        avoids trouble with conversions when either 'encoding' wasn't set
                        properly (e.g., it's at the default "latin1" but the text is actually
                        something else) or when there are illegal bytes in the text.

                        Please try out the patch below and let me know if you spot a problem.


                        *** ../vim-6.2.339/src/os_mswin.c Tue Mar 9 14:24:17 2004
                        --- src/os_mswin.c Wed Mar 10 21:11:19 2004
                        ***************
                        *** 929,934 ****
                        --- 929,936 ----
                        int type; /* MCHAR, MBLOCK or MLINE */
                        int txtlen; /* length of CF_TEXT in bytes */
                        int ucslen; /* length of CF_UNICODETEXT in words */
                        + int rawlen; /* length of clip_star.format_raw, including encoding,
                        + excluding terminating NUL */
                        } VimClipType_t;

                        /*
                        ***************
                        *** 1123,1137 ****
                        void
                        clip_mch_request_selection(VimClipboard *cbd)
                        {
                        ! VimClipType_t metadata = { -1, -1, -1 };
                        HGLOBAL hMem = NULL;
                        char_u *str = NULL;
                        #if defined(FEAT_MBYTE) && defined(WIN3264)
                        char_u *to_free = NULL;
                        #endif
                        char_u *hMemStr = NULL;
                        int str_size = 0;
                        int maxlen;

                        /*
                        * Don't pass GetActiveWindow() as an argument to OpenClipboard() because
                        --- 1125,1143 ----
                        void
                        clip_mch_request_selection(VimClipboard *cbd)
                        {
                        ! VimClipType_t metadata = { -1, -1, -1, -1 };
                        HGLOBAL hMem = NULL;
                        char_u *str = NULL;
                        #if defined(FEAT_MBYTE) && defined(WIN3264)
                        char_u *to_free = NULL;
                        #endif
                        + #ifdef FEAT_MBYTE
                        + HGLOBAL rawh = NULL;
                        + #endif
                        char_u *hMemStr = NULL;
                        int str_size = 0;
                        int maxlen;
                        + size_t n;

                        /*
                        * Don't pass GetActiveWindow() as an argument to OpenClipboard() because
                        ***************
                        *** 1151,1162 ****
                        if ((meta_h = GetClipboardData(cbd->format)) != NULL
                        && (meta_p = (VimClipType_t *)GlobalLock(meta_h)) != NULL)
                        {
                        ! if (GlobalSize(meta_h) >= sizeof(VimClipType_t))
                        ! memcpy(&metadata, meta_p, sizeof(metadata));
                        GlobalUnlock(meta_h);
                        }
                        }

                        #if defined(FEAT_MBYTE) && defined(WIN3264)
                        /* Try to get the clipboard in Unicode if it's not an empty string. */
                        if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0)
                        --- 1157,1201 ----
                        if ((meta_h = GetClipboardData(cbd->format)) != NULL
                        && (meta_p = (VimClipType_t *)GlobalLock(meta_h)) != NULL)
                        {
                        ! /* The size of "VimClipType_t" changed, "rawlen" was added later.
                        ! * Only copy what is available for backwards compatibility. */
                        ! n = sizeof(VimClipType_t);
                        ! if (GlobalSize(meta_h) < n)
                        ! n = GlobalSize(meta_h);
                        ! memcpy(&metadata, meta_p, n);
                        GlobalUnlock(meta_h);
                        }
                        }

                        + #ifdef FEAT_MBYTE
                        + /* Check for Vim's raw clipboard format first. This is used without
                        + * conversion, but only if 'encoding' matches. */
                        + if (IsClipboardFormatAvailable(cbd->format_raw)
                        + && metadata.rawlen > (int)STRLEN(p_enc))
                        + {
                        + /* We have raw data on the clipboard; try to get it. */
                        + if ((rawh = GetClipboardData(cbd->format_raw)) != NULL)
                        + {
                        + char_u *rawp;
                        +
                        + rawp = (char_u *)GlobalLock(rawh);
                        + if (rawp != NULL && STRCMP(p_enc, rawp) == 0)
                        + {
                        + n = STRLEN(p_enc) + 1;
                        + str = rawp + n;
                        + str_size = metadata.rawlen - n;
                        + }
                        + else
                        + {
                        + GlobalUnlock(rawh);
                        + rawh = NULL;
                        + }
                        + }
                        + }
                        + if (str == NULL)
                        + {
                        + #endif
                        +
                        #if defined(FEAT_MBYTE) && defined(WIN3264)
                        /* Try to get the clipboard in Unicode if it's not an empty string. */
                        if (IsClipboardFormatAvailable(CF_UNICODETEXT) && metadata.ucslen != 0)
                        ***************
                        *** 1231,1236 ****
                        --- 1270,1278 ----
                        #endif
                        }
                        }
                        + #ifdef FEAT_MBYTE
                        + }
                        + #endif

                        if (str != NULL && *str != NUL)
                        {
                        ***************
                        *** 1250,1257 ****
                        }

                        /* unlock the global object */
                        ! if (hMemStr != NULL)
                        GlobalUnlock(hMem);
                        CloseClipboard();
                        #if defined(FEAT_MBYTE) && defined(WIN3264)
                        vim_free(to_free);
                        --- 1292,1303 ----
                        }

                        /* unlock the global object */
                        ! if (hMem != NULL)
                        GlobalUnlock(hMem);
                        + #ifdef FEAT_MBYTE
                        + if (rawh != NULL)
                        + GlobalUnlock(rawh);
                        + #endif
                        CloseClipboard();
                        #if defined(FEAT_MBYTE) && defined(WIN3264)
                        vim_free(to_free);
                        ***************
                        *** 1267,1272 ****
                        --- 1313,1319 ----
                        char_u *str = NULL;
                        VimClipType_t metadata;
                        long_u txtlen;
                        + HGLOBAL hMemRaw = NULL;
                        HGLOBAL hMem = NULL;
                        HGLOBAL hMemVim = NULL;
                        # if defined(FEAT_MBYTE) && defined(WIN3264)
                        ***************
                        *** 1284,1289 ****
                        --- 1331,1359 ----
                        return;
                        metadata.txtlen = (int)txtlen;
                        metadata.ucslen = 0;
                        + metadata.rawlen = 0;
                        +
                        + #ifdef FEAT_MBYTE
                        + /* Always set the raw bytes: 'encoding', NUL and the text. This is used
                        + * when copy/paste from/to Vim with the same 'encoding', so that illegal
                        + * bytes can also be copied and no conversion is needed. */
                        + {
                        + LPSTR lpszMemRaw;
                        +
                        + metadata.rawlen = txtlen + STRLEN(p_enc) + 1;
                        + hMemRaw = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
                        + metadata.rawlen + 1);
                        + lpszMemRaw = (LPSTR)GlobalLock(hMemRaw);
                        + if (lpszMemRaw != NULL)
                        + {
                        + STRCPY(lpszMemRaw, p_enc);
                        + memcpy(lpszMemRaw + STRLEN(p_enc) + 1, str, txtlen + 1);
                        + GlobalUnlock(hMemRaw);
                        + }
                        + else
                        + metadata.rawlen = 0;
                        + }
                        + #endif

                        # if defined(FEAT_MBYTE) && defined(WIN3264)
                        {
                        ***************
                        *** 1385,1390 ****
                        --- 1455,1462 ----

                        vim_free(str);
                        /* Free any allocations we didn't give to the clipboard: */
                        + if (hMemRaw)
                        + GlobalFree(hMemRaw);
                        if (hMem)
                        GlobalFree(hMem);
                        # if defined(FEAT_MBYTE) && defined(WIN3264)
                        *** ../vim-6.2.339/src/os_win16.c Sat May 24 17:19:47 2003
                        --- src/os_win16.c Wed Mar 10 18:32:17 2004
                        ***************
                        *** 179,184 ****
                        --- 179,185 ----
                        * character to specify MCHAR, MLINE or MBLOCK.
                        */
                        clip_star.format = RegisterClipboardFormat("VimClipboard2");
                        + clip_star.format_raw = RegisterClipboardFormat("VimRawBytes");
                        #endif
                        }

                        *** ../vim-6.2.339/src/os_win32.c Sun Mar 7 17:03:27 2004
                        --- src/os_win32.c Wed Mar 10 18:26:06 2004
                        ***************
                        *** 1540,1545 ****
                        --- 1540,1546 ----
                        * character to specify MCHAR, MLINE or MBLOCK.
                        */
                        clip_star.format = RegisterClipboardFormat("VimClipboard2");
                        + clip_star.format_raw = RegisterClipboardFormat("VimRawBytes");
                        #endif
                        }

                        ***************
                        *** 2038,2043 ****
                        --- 2039,2045 ----
                        * character to specify MCHAR, MLINE or MBLOCK.
                        */
                        clip_star.format = RegisterClipboardFormat("VimClipboard2");
                        + clip_star.format_raw = RegisterClipboardFormat("VimRawBytes");
                        #endif

                        /* This will be NULL on anything but NT 4.0 */
                        *** ../vim-6.2.339/src/vim.h Mon Mar 8 12:27:39 2004
                        --- src/vim.h Wed Mar 10 18:28:34 2004
                        ***************
                        *** 1520,1525 ****
                        --- 1520,1526 ----

                        # ifdef MSWIN
                        int_u format; /* Vim's own special clipboard format */
                        + int_u format_raw; /* Vim's raw text clipboard format */
                        # endif
                        # ifdef FEAT_GUI_BEOS
                        /* no clipboard at the moment */


                        --
                        I think that you'll agree that engineers are very effective in their social
                        interactions. It's the "normal" people who are nuts.
                        (Scott Adams - The Dilbert principle)

                        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                        \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
                      Your message has been successfully submitted and would be delivered to recipients shortly.