+ return Qnil;
+}
+
+static Lisp_Object
+mswindows_get_foreign_selection (Lisp_Object selection_symbol,
+ Lisp_Object target_type)
+{
+ if (EQ (selection_symbol, QCLIPBOARD))
+ {
+ HANDLE h;
+ unsigned char *src, *dst, *next;
+ Lisp_Object ret = Qnil;
+
+ if (!OpenClipboard (NULL))
+ return Qnil;
+
+ if ((h = GetClipboardData (CF_TEXT)) != NULL &&
+ (src = (unsigned char *) GlobalLock (h)) != NULL)
+ {
+ int i;
+ int size, rawsize;
+ size = rawsize = strlen (src);
+
+ for (i=0; i<rawsize; i++)
+ if (src[i] == '\r' && src[i+1] == '\n')
+ size--;
+
+ /* Convert CRLFs to LFs */
+ ret = make_uninit_string (size);
+ dst = XSTRING_DATA (ret);
+ do
+ {
+ /* copy next line or remaining bytes excluding '\0' */
+ next = (unsigned char *) memccpy (dst, src, '\r', rawsize);
+ if (next)
+ {
+ /* copied one line ending with '\r' */
+ int copied = next - dst;
+ rawsize -= copied;
+ src += copied;
+ if (*src == '\n')
+ dst += copied - 1; /* overwrite '\r' */
+ else
+ dst += copied;
+ }
+ }
+ while (next);
+
+ GlobalUnlock (h);
+ }
+
+ CloseClipboard ();