From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1955) id 221963858411; Sun, 21 Nov 2021 10:16:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 221963858411 To: cygwin-apps-cvs@sourceware.org Subject: [cygutils - Chuck Wilson's collection of Cygwin utilities] branch master, updated. v1_4_16-11-g3e94e05 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: ecb76449ca233873d01feacd3dfd22cbf7e95e34 X-Git-Newrev: 3e94e050af7ad4ac84d12c18e9408e4c4f34cb56 Message-Id: <20211121101633.221963858411@sourceware.org> Date: Sun, 21 Nov 2021 10:16:33 +0000 (GMT) From: Mark Geisert X-BeenThere: cygwin-apps-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin-apps git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Nov 2021 10:16:33 -0000 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygutils.git;h=3e94e050af7ad4ac84d12c18e9408e4c4f34cb56 commit 3e94e050af7ad4ac84d12c18e9408e4c4f34cb56 Author: Mark Geisert Date: Sun Nov 21 02:15:07 2021 -0800 Fix getclip segfault on xterm selections Diff: --- src/clip/getclip.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/clip/getclip.c b/src/clip/getclip.c index 5cdb8f1..4dbaa97 100644 --- a/src/clip/getclip.c +++ b/src/clip/getclip.c @@ -399,6 +399,9 @@ getclip (FILE * out, flags_struct flags, FILE * f, char *name) return (0); } +#if DEBUGGING + fprintf (stderr, "Using format: %u\n", format); +#endif hglb = GetClipboardData (format); if (format == cygnativeformat) @@ -476,9 +479,37 @@ getclip (FILE * out, flags_struct flags, FILE * f, char *name) char *prev; char *curr; char *pos; + UINT format; OpenClipboard (0); +#if DEBUGGING + { + fprintf (stderr, "ThreadLocale: %u\nClipboardFormats:", + GetThreadLocale ()); + format = 0; + do { + format = EnumClipboardFormats (format); + fprintf (stderr, " %u", format); + if (format == CF_LOCALE) + fprintf (stderr, "(%u)", *(LCID *) GetClipboardData (CF_LOCALE)); + } while (format != 0); + fprintf (stderr, "\n"); + } +#endif +#if DEBUGGING + fprintf (stderr, "Using format: %u\n", CF_TEXT); +#endif hglb = GetClipboardData (CF_TEXT); //TODO support CF_UNICODETEXT too? + if (!hglb) + { + DWORD err = GetLastError (); +#if DEBUGGING + /* look up error code displayed here in w32api/winerror.h */ + fprintf (stderr, "GetClipboardData returns %ld\n", err); +#endif + CloseClipboard (); + return err != 0; + } lpstr = GlobalLock (hglb); lplen = strlen (lpstr); @@ -532,9 +563,37 @@ getclip (FILE * out, flags_struct flags, FILE * f, char *name) char *prev; char *curr; char *pos; + UINT format; OpenClipboard (0); +#if DEBUGGING + { + fprintf (stderr, "ThreadLocale: %u\nClipboardFormats:", + GetThreadLocale ()); + format = 0; + do { + format = EnumClipboardFormats (format); + fprintf (stderr, " %u", format); + if (format == CF_LOCALE) + fprintf (stderr, "(%u)", *(LCID *) GetClipboardData (CF_LOCALE)); + } while (format != 0); + fprintf (stderr, "\n"); + } +#endif +#if DEBUGGING + fprintf (stderr, "Using format: %u\n", CF_TEXT); +#endif hglb = GetClipboardData (CF_TEXT); //TODO support CF_UNICODETEXT too? + if (!hglb) + { + DWORD err = GetLastError (); +#if DEBUGGING + /* look up error code displayed here in w32api/winerror.h */ + fprintf (stderr, "GetClipboardData returns %ld\n", err); +#endif + CloseClipboard (); + return err != 0; + } lpstr = GlobalLock (hglb); lplen = strlen (lpstr);