changeset 20651:0de9f45a1db6

(Finsert_file_contents): When not decoding, properly calculate number of chars in the text. Fix error message. (file_name_as_directory): Error if arg is empty. (Fwrite_region): Don't flush the encoding buffer if failure is set.
author Richard M. Stallman <rms@gnu.org>
date Fri, 16 Jan 1998 18:14:58 +0000
parents 427fa7757472
children 9bdfab6be02f
files src/fileio.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Fri Jan 16 17:56:40 1998 +0000
+++ b/src/fileio.c	Fri Jan 16 18:14:58 1998 +0000
@@ -484,6 +484,9 @@
 {
   int size = strlen (in) - 1;
 
+  if (size < 0)
+    error ("Empty file name");
+
   strcpy (out, in);
 
 #ifdef VMS
@@ -3731,7 +3734,6 @@
       if (! not_regular)
 	how_much += this;
 
-      this_chars = this;
       if (CODING_REQUIRE_DECODING (&coding)
 	  || CODING_REQUIRE_DETECTION (&coding))
 	{
@@ -3777,6 +3779,11 @@
 	  this_chars = chars_in_text (BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1,
 				      produced);
 	}
+      else if (! NILP (current_buffer->enable_multibyte_characters))
+	this_chars = chars_in_text (BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1,
+				    this);
+      else
+	this_chars = this;
 
       GAP_SIZE -= this;
       GPT_BYTE += this;
@@ -3822,7 +3829,7 @@
     error ("IO error reading %s: %s",
 	   XSTRING (orig_filename)->data, strerror (errno));
   else if (how_much == -2)
-    error ("maximum buffer size exceeded");
+    error ("Maximum buffer size exceeded");
 
   set_coding_system = 1;
 
@@ -4278,7 +4285,8 @@
       save_errno = errno;
     }
 
-  if (CODING_REQUIRE_FLUSHING (&coding) && !coding.last_block)
+  if (CODING_REQUIRE_FLUSHING (&coding) && !coding.last_block
+      && ! failure)
     {
       /* We have to flush out a data. */
       coding.last_block = 1;