changeset 89667:20a59c5d1d55

(kill_workbuf_unwind): Delete this function. (Finsert_file_contents): Adjust the call of detect_coding_system. Get conversion_buffer by code_conversion_save. Use the macor CODING_MAY_REQUIRE_DECODING. After decoding, update coding_system.
author Kenichi Handa <handa@m17n.org>
date Tue, 02 Dec 2003 01:45:13 +0000
parents 7d38a63951c0
children d4852c246c07
files src/fileio.c
diffstat 1 files changed, 8 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Tue Dec 02 01:42:47 2003 +0000
+++ b/src/fileio.c	Tue Dec 02 01:45:13 2003 +0000
@@ -296,16 +296,6 @@
   return Qnil;
 }
 
-/* Kill the working buffer for code conversion.  */
-
-static Lisp_Object
-kill_workbuf_unwind (workbuf)
-     Lisp_Object workbuf;
-{
-  if (! NILP (workbuf) && ! NILP (Fbuffer_live_p (workbuf)))
-    Fkill_buffer (workbuf);
-  return Qnil;
-}
 
 Lisp_Object Qexpand_file_name;
 Lisp_Object Qsubstitute_in_file_name;
@@ -3958,7 +3948,7 @@
 
 	  if (CODING_REQUIRE_DETECTION (&coding))
 	    {
-	      coding_system = detect_coding_system (buffer, nread, 1, 0,
+	      coding_system = detect_coding_system (buffer, nread, nread, 1, 0,
 						    coding_system);
 	      setup_coding_system (coding_system, &coding);
 	    }
@@ -4117,11 +4107,9 @@
       int temp;
       int this_count = SPECPDL_INDEX ();
       int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
-      Lisp_Object conversion_buffer
-	= make_conversion_work_buffer (-1, multibyte);
-      struct gcpro1;
-
-      record_unwind_protect (kill_workbuf_unwind, conversion_buffer);
+      Lisp_Object conversion_buffer;
+
+      conversion_buffer = code_conversion_save (1, multibyte);
 
       /* First read the whole file, performing code conversion into
 	 CONVERSION_BUFFER.  */
@@ -4484,8 +4472,8 @@
 	 decide it at first by detecting the file's encoding.  */
       if (CODING_REQUIRE_DETECTION (&coding))
 	{
-	  coding_system = detect_coding_system (PT_ADDR, inserted, 1, 0,
-						coding_system);
+	  coding_system = detect_coding_system (PT_ADDR, inserted, inserted,
+						1, 0, coding_system);
 	  setup_coding_system (coding_system, &coding);
 	}
 
@@ -4498,8 +4486,7 @@
     }
 
   coding.dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
-  if ((CODING_REQUIRE_DETECTION (&coding)
-       || CODING_REQUIRE_DECODING (&coding))
+  if (CODING_MAY_REQUIRE_DECODING (&coding)
       && (inserted > 0 || CODING_REQUIRE_FLUSHING (&coding)))
     {
       move_gap_both (PT, PT_BYTE);
@@ -4510,6 +4497,7 @@
       Z -= inserted;
       decode_coding_gap (&coding, inserted, inserted);
       inserted = coding.produced_char;
+      coding_system = CODING_ID_NAME (coding.id);
     }
   else if (inserted > 0)
     adjust_after_insert (PT, PT_BYTE, PT + inserted, PT_BYTE + inserted,