<br><br><div class="gmail_quote">On Wed, Mar 10, 2010 at 7:39 PM, Chris Muller <span dir="ltr"><<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
OMG, is the clipboard going to work in Linux now?<br></blockquote><div><br></div><div>:) No :) This is strictly windows.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
On Wed, Mar 10, 2010 at 1:22 PM, <<a href="mailto:commits@squeakvm.org">commits@squeakvm.org</a>> wrote:<br>
><br>
> Author: andreas<br>
> Date: 2010-03-10 11:22:45 -0800 (Wed, 10 Mar 2010)<br>
> New Revision: 2152<br>
><br>
> Modified:<br>
> trunk/platforms/win32/vm/sqWin32Window.c<br>
> Log:<br>
> Add Eliot's clipboard handling fix.<br>
><br>
> Modified: trunk/platforms/win32/vm/sqWin32Window.c<br>
> ===================================================================<br>
> --- trunk/platforms/win32/vm/sqWin32Window.c 2010-02-24 13:25:07 UTC (rev 2151)<br>
> +++ trunk/platforms/win32/vm/sqWin32Window.c 2010-03-10 19:22:45 UTC (rev 2152)<br>
> @@ -2353,7 +2353,6 @@<br>
> int clipboardSize(void) {<br>
> HANDLE h;<br>
> WCHAR *src;<br>
> - unsigned char *tmp;<br>
> int i, count, bytesNeeded;<br>
><br>
> /* Do we have text in the clipboard? */<br>
> @@ -2370,18 +2369,20 @@<br>
> /* How many bytes do we need to store those unicode chars in UTF8 format? */<br>
> bytesNeeded = WideCharToMultiByte(CP_UTF8, 0, src, -1,<br>
> NULL, 0, NULL, NULL );<br>
> - tmp = malloc(bytesNeeded+1);<br>
> + if (bytesNeeded > 0) {<br>
> + unsigned char *tmp = malloc(bytesNeeded+1);<br>
><br>
> - /* Convert Unicode text to UTF8. */<br>
> - WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);<br>
> + /* Convert Unicode text to UTF8. */<br>
> + WideCharToMultiByte(CP_UTF8, 0, src, -1, tmp, bytesNeeded , NULL, NULL);<br>
><br>
> - /* Count CrLfs for which we remove the extra Lf */<br>
> - count = bytesNeeded; /* ex. terminating zero */<br>
> - for(i=0; i<count; i++) {<br>
> - if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;<br>
> + /* Count CrLfs for which we remove the extra Lf */<br>
> + count = bytesNeeded; /* ex. terminating zero */<br>
> + for(i=0; i<count; i++) {<br>
> + if((tmp[i] == 13) && (tmp[i+1] == 10)) bytesNeeded--;<br>
> + }<br>
> + bytesNeeded--; /* discount terminating zero */<br>
> + free(tmp); /* no longer needed */<br>
> }<br>
> - bytesNeeded--; /* discount terminating zero */<br>
> - free(tmp); /* no longer needed */<br>
><br>
> GlobalUnlock(h);<br>
> CloseClipboard();<br>
><br>
><br>
</blockquote></div><br>