[commit] r2152 - Add Eliot's clipboard handling fix.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[commit] r2152 - Add Eliot's clipboard handling fix.

commits-3
 
Author: andreas
Date: 2010-03-10 11:22:45 -0800 (Wed, 10 Mar 2010)
New Revision: 2152

Modified:
   trunk/platforms/win32/vm/sqWin32Window.c
Log:
Add Eliot's clipboard handling fix.

Modified: trunk/platforms/win32/vm/sqWin32Window.c
===================================================================
--- trunk/platforms/win32/vm/sqWin32Window.c 2010-02-24 13:25:07 UTC (rev 2151)
+++ trunk/platforms/win32/vm/sqWin32Window.c 2010-03-10 19:22:45 UTC (rev 2152)
@@ -2353,7 +2353,6 @@
 int clipboardSize(void) {
   HANDLE h;
   WCHAR *src;
-  unsigned char *tmp;
   int i, count, bytesNeeded;
 
   /* Do we have text in the clipboard? */
@@ -2370,18 +2369,20 @@
   /* How many bytes do we need to store those unicode chars in UTF8 format? */
   bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, src, -1,
     NULL, 0, NULL, NULL );
-  tmp = malloc(bytesNeeded+1);
+  if (bytesNeeded > 0) {
+    unsigned char *tmp = malloc(bytesNeeded+1);
 
-  /* Convert Unicode text to UTF8. */
-  WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);
+    /* Convert Unicode text to UTF8. */
+    WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);
 
-  /* Count CrLfs for which we remove the extra Lf */
-  count = bytesNeeded; /* ex. terminating zero */
-  for(i=0; i<count; i++) {
-    if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;
+    /* Count CrLfs for which we remove the extra Lf */
+    count = bytesNeeded; /* ex. terminating zero */
+    for(i=0; i<count; i++) {
+      if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;
+    }
+    bytesNeeded--; /* discount terminating zero */
+    free(tmp); /* no longer needed */
   }
-  bytesNeeded--; /* discount terminating zero */
-  free(tmp); /* no longer needed */
 
   GlobalUnlock(h);
   CloseClipboard();

Reply | Threaded
Open this post in threaded view
|

Re: [commit] r2152 - Add Eliot's clipboard handling fix.

Chris Muller-3

OMG, is the clipboard going to work in Linux now?

On Wed, Mar 10, 2010 at 1:22 PM,  <[hidden email]> wrote:

>
> Author: andreas
> Date: 2010-03-10 11:22:45 -0800 (Wed, 10 Mar 2010)
> New Revision: 2152
>
> Modified:
>   trunk/platforms/win32/vm/sqWin32Window.c
> Log:
> Add Eliot's clipboard handling fix.
>
> Modified: trunk/platforms/win32/vm/sqWin32Window.c
> ===================================================================
> --- trunk/platforms/win32/vm/sqWin32Window.c    2010-02-24 13:25:07 UTC (rev 2151)
> +++ trunk/platforms/win32/vm/sqWin32Window.c    2010-03-10 19:22:45 UTC (rev 2152)
> @@ -2353,7 +2353,6 @@
>  int clipboardSize(void) {
>   HANDLE h;
>   WCHAR *src;
> -  unsigned char *tmp;
>   int i, count, bytesNeeded;
>
>   /* Do we have text in the clipboard? */
> @@ -2370,18 +2369,20 @@
>   /* How many bytes do we need to store those unicode chars in UTF8 format? */
>   bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, src, -1,
>                                    NULL, 0, NULL, NULL );
> -  tmp = malloc(bytesNeeded+1);
> +  if (bytesNeeded > 0) {
> +    unsigned char *tmp = malloc(bytesNeeded+1);
>
> -  /* Convert Unicode text to UTF8. */
> -  WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);
> +    /* Convert Unicode text to UTF8. */
> +    WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);
>
> -  /* Count CrLfs for which we remove the extra Lf */
> -  count = bytesNeeded; /* ex. terminating zero */
> -  for(i=0; i<count; i++) {
> -    if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;
> +    /* Count CrLfs for which we remove the extra Lf */
> +    count = bytesNeeded; /* ex. terminating zero */
> +    for(i=0; i<count; i++) {
> +      if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;
> +    }
> +    bytesNeeded--; /* discount terminating zero */
> +    free(tmp); /* no longer needed */
>   }
> -  bytesNeeded--; /* discount terminating zero */
> -  free(tmp); /* no longer needed */
>
>   GlobalUnlock(h);
>   CloseClipboard();
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [commit] r2152 - Add Eliot's clipboard handling fix.

Eliot Miranda-2
 


On Wed, Mar 10, 2010 at 7:39 PM, Chris Muller <[hidden email]> wrote:

OMG, is the clipboard going to work in Linux now?

:)  No :)  This is strictly windows.
 

On Wed, Mar 10, 2010 at 1:22 PM,  <[hidden email]> wrote:
>
> Author: andreas
> Date: 2010-03-10 11:22:45 -0800 (Wed, 10 Mar 2010)
> New Revision: 2152
>
> Modified:
>   trunk/platforms/win32/vm/sqWin32Window.c
> Log:
> Add Eliot's clipboard handling fix.
>
> Modified: trunk/platforms/win32/vm/sqWin32Window.c
> ===================================================================
> --- trunk/platforms/win32/vm/sqWin32Window.c    2010-02-24 13:25:07 UTC (rev 2151)
> +++ trunk/platforms/win32/vm/sqWin32Window.c    2010-03-10 19:22:45 UTC (rev 2152)
> @@ -2353,7 +2353,6 @@
>  int clipboardSize(void) {
>   HANDLE h;
>   WCHAR *src;
> -  unsigned char *tmp;
>   int i, count, bytesNeeded;
>
>   /* Do we have text in the clipboard? */
> @@ -2370,18 +2369,20 @@
>   /* How many bytes do we need to store those unicode chars in UTF8 format? */
>   bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, src, -1,
>                                    NULL, 0, NULL, NULL );
> -  tmp = malloc(bytesNeeded+1);
> +  if (bytesNeeded > 0) {
> +    unsigned char *tmp = malloc(bytesNeeded+1);
>
> -  /* Convert Unicode text to UTF8. */
> -  WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);
> +    /* Convert Unicode text to UTF8. */
> +    WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);
>
> -  /* Count CrLfs for which we remove the extra Lf */
> -  count = bytesNeeded; /* ex. terminating zero */
> -  for(i=0; i<count; i++) {
> -    if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;
> +    /* Count CrLfs for which we remove the extra Lf */
> +    count = bytesNeeded; /* ex. terminating zero */
> +    for(i=0; i<count; i++) {
> +      if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;
> +    }
> +    bytesNeeded--; /* discount terminating zero */
> +    free(tmp); /* no longer needed */
>   }
> -  bytesNeeded--; /* discount terminating zero */
> -  free(tmp); /* no longer needed */
>
>   GlobalUnlock(h);
>   CloseClipboard();
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [commit] r2152 - Add Eliot's clipboard handling fix.

Bert Freudenberg
In reply to this post by Chris Muller-3
 
On 11.03.2010, at 04:39, Chris Muller wrote:
>
>
> OMG, is the clipboard going to work in Linux now?

Huh? What doesn't work on Linux?

- Bert -

Reply | Threaded
Open this post in threaded view
|

Re: [commit] r2152 - Add Eliot's clipboard handling fix.

Chris Muller-3
 
Well, I switched my linux vm to the latest Squeak VM today and cut and
paste seems to finally be working!

Also, *sound* is back!  And the End key seems to be working now!

What a relief.

  - Chris

On Thu, Mar 11, 2010 at 4:06 AM, Bert Freudenberg <[hidden email]> wrote:

>
> On 11.03.2010, at 04:39, Chris Muller wrote:
>>
>>
>> OMG, is the clipboard going to work in Linux now?
>
> Huh? What doesn't work on Linux?
>
> - Bert -
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [commit] r2152 - Add Eliot's clipboard handling fix.

Tapple Gao
 
On Thu, Mar 11, 2010 at 03:54:32PM -0600, Chris Muller wrote:
> And the End key seems to be working now!

really? where can I get this VM? that's really bugging me

--
Matthew Fulmer (a.k.a. Tapple)
Reply | Threaded
Open this post in threaded view
|

Re: [commit] r2152 - Add Eliot's clipboard handling fix.

Chris Muller-3
 
squeakvm.org

On Thu, Mar 11, 2010 at 4:32 PM, Matthew Fulmer <[hidden email]> wrote:
>
> On Thu, Mar 11, 2010 at 03:54:32PM -0600, Chris Muller wrote:
>> And the End key seems to be working now!
>
> really? where can I get this VM? that's really bugging me
>
> --
> Matthew Fulmer (a.k.a. Tapple)
>