X-Recipient: archive-cygwin AT delorie DOT com X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF49F3856DF7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1657032602; bh=0ewoAr47Pnat4gNmxEenKkni8UdwYXim98qwfweLZdM=; h=In-Reply-To:Subject:To:From:Message-ID:References:Date:Reply-To; b=BOMjVOBpogCGzsSPHY6OhpLqdwbhH4SDd2TjEso1sabxHaMETbgHvKGtkEO4aNFjc s0MWJe0PI9L2GWoOQ5HSbWozJSpyWFnd4P0r0kULGZy7TWuWqlqN8VVa3j8+OeBeKq GnofMNdq/Jpm+/EqyVMamoZIc1l+S5JcORmQoFag= Authentication-Results: iva7-b2551a6f14a8.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Date: Tue, 5 Jul 2022 17:46:52 +0300 From: Andrey Repin X-Mailer: The Bat! (v9.3.4) Professional Message-ID: <199184658.20220705174652@yandex.ru> To: Takashi Yano , cygwin AT cygwin DOT com Subject: Re: /dev/clipboard sometimes fails to set CF_UNICODETEXT data. In-Reply-To: <20220705174058.b4d8cb5ce54f7fac8700aaa9@nifty.ne.jp> References: <20220702122056 DOT 39a6c5e49c637d028694412e AT nifty DOT ne DOT jp> <62975088-7bc3-7dde-d08c-3972126304f1 AT maxrnd DOT com> <20220705174058 DOT b4d8cb5ce54f7fac8700aaa9 AT nifty DOT ne DOT jp> MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_THEBAT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="cp1250" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 265Eod0R012190 Greetings, Takashi Yano! > On Tue, 5 Jul 2022 00:42:50 -0700 > Mark Geisert wrote: >> Hi Takashi, >> >> Takashi Yano wrote: >> > Hello, >> > >> > In one of my PCs, >> > dd if=/dev/urandom count=10 | xxd > /dev/clipboard >> > sometimes fails to set CF_UNICODETEXT data. >> > As a result, pasting clipboard to notepad does not work. >> > >> > Even in the case, cygnativeformat data is set correctly. >> > So, "cat /dev/clipboard" works. >> > >> > This problem depends on machine very much. >> > >> > My one PC with Xeon E3-1281 v3 CPU has a high probability of failure, >> > however, another machine with Core i7-6700K CPU does not. >> > >> > I looked into this problem, and found OpenClipboard() for >> > CF_UNICODETEXT fails. It seems that OpenClipboard() just >> > after CloseClipboard() has high probability of failure. >> > >> > You can see the following test case immediately stops with error. >> > Even with Core i7-6700K CPU machine above, the test case fails. > Additional information: > In the machine with Xeon E3-1281 v3 CPU, the test case fails > in a several times of the loop, while it fails after 1000 to > 3000 times of the loop in the machine with Core i7-6700K CPU. > The probability of failure depends much on machine. MFG… this might as well explain the issues OpenOffice having with clipboard content. I'll forward your findings. >> > #include >> > #include >> > >> > int main() >> > { >> > for (;;) { >> > if (!OpenClipboard(0)) { >> > printf("Open error.\n"); >> > break; >> > } >> > if (!EmptyClipboard()) { >> > printf("Empty error.\n"); >> > break; >> > } >> > if (!CloseClipboard()) { >> > printf("Cloes error.\n"); >> > break; >> > } >> > } >> > return 0; >> > } >> > >> > I also found the patch attached solves the issue. >> > >> > I would appreciate any suggestion. >> >> Would be neet if this patch wasn't needed, but, oh well. My only comment on the >> patch would be to possibly call the new wrapper function MyOpenClipboard, or >> CygOpenClipboard, to help keep the name paired with CloseClipboard. > Thanks for the comment. IIUC, the camel case name should be > used only for Win32 APIs related. However, this is the wrapper > for Win32 API. So, it might be acceptable. In other places, > some wrapper functions are named as camel case. > Corinna, WDYT? >> I suppose it might happen in the future that a faster processor will require the >> loop count to be made larger. Once again, oh well. > Maybe. In my most cases, OpenClipboard() successes after one > or two times of retrying. So, I think max_retry = 10 is enough > for the time being. >> My 2c (adjusted for inflation), > -- > Takashi Yano -- With best regards, Andrey Repin Tuesday, July 5, 2022 17:44:56 Sorry for my terrible english... -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple