changeset 88510:d266b8fb8761

(encode_coding_object): Give correct arguments ot pre-write-conversion. Ignore the return value of pre-write-conversion function. Pay attention for the case that pre-write-conversion change the current buffer. If dst_object is Qt, even if coding->src_bytes is zero, allocate at least one byte to coding->destination.
author Kenichi Handa <handa@m17n.org>
date Tue, 14 May 2002 13:03:23 +0000
parents 0ac97e7062f5
children 8921fa5b6ff9
files src/coding.c
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Tue May 14 13:02:54 2002 +0000
+++ b/src/coding.c	Tue May 14 13:03:23 2002 +0000
@@ -5979,8 +5979,6 @@
 
   if (! NILP (CODING_ATTR_PRE_WRITE (attrs)))
     {
-      Lisp_Object val;
-
       coding->src_object = make_conversion_work_buffer (coding->src_multibyte);
       set_buffer_internal (XBUFFER (coding->src_object));
       if (STRINGP (src_object))
@@ -5997,9 +5995,9 @@
 	  set_buffer_internal (XBUFFER (coding->src_object));
 	}
 
-      val = call2 (CODING_ATTR_PRE_WRITE (attrs),
-		   make_number (1), make_number (chars));
-      CHECK_NATNUM (val);
+      call2 (CODING_ATTR_PRE_WRITE (attrs),
+	     make_number (BEG), make_number (Z));
+      coding->src_object = Fcurrent_buffer ();
       if (BEG != GPT)
 	move_gap_both (BEG, BEG_BYTE);
       coding->src_chars = Z - BEG;
@@ -6042,8 +6040,10 @@
   else if (EQ (dst_object, Qt))
     {
       coding->dst_object = Qnil;
-      coding->destination = (unsigned char *) xmalloc (coding->src_chars);
       coding->dst_bytes = coding->src_chars;
+      if (coding->dst_bytes == 0)
+	coding->dst_bytes = 1;
+      coding->destination = (unsigned char *) xmalloc (coding->dst_bytes);
       coding->dst_multibyte = 0;
     }
   else