This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: /dev/clipboard corrupted


On 29.06.2012 11:24, Corinna Vinschen wrote:
On Jun 28 20:33, Thomas Wolff wrote:
Am 28.06.2012 10:20, schrieb Corinna Vinschen:
On Jun 28 00:16, Thomas Wolff wrote:
If the clipboard contains large data, the contents retrieved from
/dev/clipboard gets corrupted.
I compared the following in a few cases:
* cat /dev/clipboard or cp /dev/clipboard (which are equal)
* mouse-paste into mintty, read with cat
* read /dev/clipboard within application

and I found all three results to be different, the correct one
sometimes being cat /dev/clipboard but not always.
In today's case, the differences occured at byte 10240 and 65536
respectively, thus 10K-1 bytes or 64K-1 bytes being equal.
I can't reprocude this.  There's also nothing in the /dev/clipboard
code which would rely on a 10K buffer or so.  64K, yes.  But still,
I tried with wordpad, vi, mintty, cat, and cp with a text file of
about 90K.  No problems.  Do you have any reproducible testcase?
Not really reproducible (maybe later) but some more observations.
I made a small test program to read /dev/clipboard directly with
different buffer sizes.
You know, we just love STCs.  Send you small test program here, plus a
short instruction how you created the clipboard content and how to call
the testcase to see the problem.
Sure, so here it is. Open clipboard.txt with notepad, ^A^C to copy all, then run the program to see bytes skipped.
Actually it seems to skip as many bytes per read() as there were additional UTF-8 bytes (more bytes than characters) in the preceding read block.
Checking the code again, variable pos seems to be used both as an index into the clipboard (WCHAR) and an offset to the resulting string length (char) which would explain the effect (not having checked all the details though as I'm not familiar with the used APIs).
------
Thomas

Attachment: clipboard.txt
Description: Text document

Attachment: rcb.c
Description: Text document

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]