# HG changeset patch # User Richard M. Stallman # Date 884974498 0 # Node ID 0de9f45a1db6804cf47983eabf5080b93dce30a0 # Parent 427fa7757472d5c47981d0db2cc8642c6cb0133c (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. diff -r 427fa7757472 -r 0de9f45a1db6 src/fileio.c --- 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;