On Sun, 21 Nov 2021 14:51:08 +0000 Jon Turney wrote: > On 21/11/2021 10:36, Mark Geisert wrote: > > Hi Denis, > > > > Denis Excoffier wrote: > >> Hello, > >> > >>> On 2021-11-03 10:59, Mark Geisert wrote: > >>> > >>> The following packages have been uploaded to the Cygwin distribution: > >>> > >>> * cygutils-1.4.16-8 > >>> * cygutils-extra-1.4.16-8 > >>> * cygutils-x11-1.4.16-8 > >> > >> > >> The '-u' or '-d' option of getclip does not seem to work properly > >> under xterm. > >> How to reproduce: > >> 1) Open an xterm > >> 2) Select a simple piece of text (with no line ending) > >> 3) getclip -u > >> 4) Observe 'Segmentation fault(core dumped)' > >> > >> If step 2 is replaced by ‘printf AAAA | putclip', no error. > >> If step 3 is replaced by ‘getclip’, no error. > >> > >> I can’t tell whether this is new or not. > > > > It appears to be old. An xterm selection is placed on the Windows > > clipboard in CF_UNICODETEXT format. 'getclip' can deal with this, > > 'getclip -u' and 'getclip -d' cannot; they always request CF_TEXT (i.e., > > ANSI) format and assume they get a buffer of data. But the formats > > don't match and there's no data supplied. That's why the segfault occurs. > > Odd... I think that Windows should convert CF_UNICODETEXT to CF_TEXT if > needed
This seems to be a problem of xorg-server. SetClipboardData(CF_TEXT, NULL) calls in xorg-server disturb the conversion from CF_UNICODETEXT to CF_TEXT. I confirmed that the default conversion gets working if the following patch is applied to xorg-server. diff --git a/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/wndproc.c b/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/wndproc.c index 63de4b9..8db89e5 100644 --- a/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/wndproc.c +++ b/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/wndproc.c @@ -424,7 +424,9 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { /* Paste no data, to satisfy required call to SetClipboardData */ SetClipboardData(CF_UNICODETEXT, NULL); +#if 0 /* Do not set CF_TEXT to NULL to allow default conversion. */ SetClipboardData(CF_TEXT, NULL); +#endif } winDebug("winClipboardWindowProc - WM_RENDERFORMAT - Returning.\n"); diff --git a/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/xevents.c b/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/xevents.c index 1fae558..6c8d481 100644 --- a/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/xevents.c +++ b/src/xserver-xserver-cygwin-21.1.0-1/hw/xwin/winclipboard/xevents.c @@ -380,7 +380,9 @@ winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_ GlobalUnlock(hGlobal); if (fSetClipboardData) { SetClipboardData(CF_UNICODETEXT, NULL); +#if 0 /* Do not set CF_TEXT to NULL to allow default conversion. */ SetClipboardData(CF_TEXT, NULL); +#endif } return WIN_XEVENTS_NOTIFY_DATA; } @@ -798,7 +800,9 @@ winClipboardFlushXEvents(HWND hwnd, /* Advertise regular text and unicode */ SetClipboardData(CF_UNICODETEXT, NULL); +#if 0 /* Do not set CF_TEXT to NULL to allow default conversion. */ SetClipboardData(CF_TEXT, NULL); +#endif /* Release the clipboard */ if (!CloseClipboard()) { However, since getclip does not support charset conversion for CF_TEXT, non-ascii string will be garbled if getclip -u/-d is used. This is the problem of cygutils side and also occurs when copying from mintty or Windows apps. -- Takashi Yano <takashi.y...@nifty.ne.jp> -- 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