unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* emacs-unicode-2 branch w32select.c patch
@ 2005-03-11  4:33 xls
  0 siblings, 0 replies; only message in thread
From: xls @ 2005-03-11  4:33 UTC (permalink / raw)


Hi All,

Compilation of latest emacs-unicode-2 branch CVS version of
w32select.c (Rev.1.29.2.5)
fails because the function "convert_to_handle_as_coded" and
"w32-get-clipboard-data"
have some stynax error.
The following patch fixes that, but i ignore the clipboard-data's eol-type .

--- w32select.c.org	2005-03-11 12:26:15.421875000 +0800
+++ w32select.c	2005-03-11 12:01:49.640625000 +0800
@@ -212,64 +212,54 @@
 static HGLOBAL
 convert_to_handle_as_coded (Lisp_Object coding_system)
 {
-  HGLOBAL htext = NULL, htext2;
-  int nbytes;
-  unsigned char *src;
-  unsigned char *dst = NULL;
-  int bufsize;
-  struct coding_system coding;
-  Lisp_Object string = Qnil;
-
-  ONTRACE (fprintf (stderr, "convert_to_handle_as_coded: %s\n",	
-		    SDATA (SYMBOL_NAME (coding_system))));
-
-  setup_coding_system (Fcheck_coding_system (coding_system), &coding);
-  coding.src_multibyte = 1;
-  coding.dst_multibyte = 0;
-  /* Need to set COMPOSITION_DISABLED, otherwise Emacs crashes in
-     encode_coding_iso2022 trying to dereference a null pointer.  */
-  coding.composing = COMPOSITION_DISABLED;
-  if (coding.type == coding_type_iso2022)
-    coding.flags |= CODING_FLAG_ISO_SAFE;
-  coding.mode |= CODING_MODE_LAST_BLOCK;
-  /* Force DOS line-ends. */
-  coding.eol_type = CODING_EOL_CRLF;
-
-  if (SYMBOLP (coding.pre_write_conversion)
-      && !NILP (Ffboundp (coding.pre_write_conversion)))
-    string = run_pre_post_conversion_on_str (current_text, &coding, 1);
-  else
-    string = current_text;
-
-  nbytes = SBYTES (string);
-  src = SDATA (string);
-
-  bufsize = encoding_buffer_size (&coding, nbytes) +2;
-  htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize);
+	HGLOBAL htext = NULL, htext2;
+	int nbytes;
+	unsigned char *src;
+	unsigned char *dst = NULL;
+	int bufsize;
+	struct coding_system coding;
+	Lisp_Object string = Qnil;
 
-  if (htext != NULL)
-    dst = (unsigned char *) GlobalLock (htext);
+	ONTRACE (fprintf (stderr, "convert_to_handle_as_coded: %s\n",	
+	SDATA (SYMBOL_NAME (coding_system))));
 
-  if (dst != NULL)
-    {
-      encode_coding (&coding, src, dst, nbytes, bufsize-2);
-      /* Add the string terminator.  Add two NULs in case we are
-	 producing Unicode here.  */
-      dst[coding.produced] = dst[coding.produced+1] = '\0';
-    }
-
-  if (dst != NULL)
-    GlobalUnlock (htext);
+	setup_coding_system (Fcheck_coding_system (coding_system), &coding);
+	coding.src_multibyte = 1;
+	coding.dst_multibyte = 0;
+	/* Need to set COMPOSITION_DISABLED, otherwise Emacs crashes in
+	   encode_coding_iso2022 trying to dereference a null pointer. */
+	coding.common_flags &= ~CODING_ANNOTATION_MASK;
+	coding.mode |= CODING_MODE_LAST_BLOCK;
 
-  if (htext != NULL)
-    {
-      /* Shrink data block to actual size.  */
-      htext2 = GlobalReAlloc (htext, coding.produced+2,
-			      GMEM_MOVEABLE | GMEM_DDESHARE);
-      if (htext2 != NULL) htext = htext2;
+  	string = current_text;
+	encode_coding_string (&coding, string, nbytes);
+	
+	bufsize = SBYTES (coding.dst_object)+2;
+	src = SDATA (coding.dst_object);
+	/* Add the string terminator.  Add two NULs in case we are
+	   producing Unicode here. */
+	src[coding.produced] = src[coding.produced+1] = '\0';
+		
+	htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize);
+	if (htext != NULL)
+    	dst = (unsigned char *) GlobalLock (htext);
+	if (dst != NULL)
+    {
+    	memcpy(dst, src, bufsize);
+    }    
+
+	if (dst != NULL)
+    	GlobalUnlock (htext);
+
+	if (htext != NULL)
+    {
+	  /* Shrink data block to actual size. */
+		htext2 = GlobalReAlloc (htext, coding.produced+2,
+		GMEM_MOVEABLE | GMEM_DDESHARE);
+		if (htext2 != NULL) htext = htext2;
     }
 
-  return htext;
+	return htext;
 }
 
 static Lisp_Object
@@ -918,7 +908,7 @@
 	   sequence.  */
 	coding.common_flags &= ~CODING_ANNOTATION_MASK;
 	/* Force DOS line-ends. */
-	coding.eol_type = CODING_EOL_CRLF;
+	/*coding.eol_type = CODING_EOL_CRLF;*/
 
 	coding.dst_bytes = nbytes * 2;
 	coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);



Sincerely,
XueLiSong

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-03-11  4:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-11  4:33 emacs-unicode-2 branch w32select.c patch xls

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).