comparison src/fileio.c @ 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 ee017970042d
children 48745ae8daa0
comparison
equal deleted inserted replaced
20650:427fa7757472 20651:0de9f45a1db6
481 char * 481 char *
482 file_name_as_directory (out, in) 482 file_name_as_directory (out, in)
483 char *out, *in; 483 char *out, *in;
484 { 484 {
485 int size = strlen (in) - 1; 485 int size = strlen (in) - 1;
486
487 if (size < 0)
488 error ("Empty file name");
486 489
487 strcpy (out, in); 490 strcpy (out, in);
488 491
489 #ifdef VMS 492 #ifdef VMS
490 /* Is it already a directory string? */ 493 /* Is it already a directory string? */
3729 so don't bother counting in HOW_MUCH. 3732 so don't bother counting in HOW_MUCH.
3730 (INSERTED is where we count the number of characters inserted.) */ 3733 (INSERTED is where we count the number of characters inserted.) */
3731 if (! not_regular) 3734 if (! not_regular)
3732 how_much += this; 3735 how_much += this;
3733 3736
3734 this_chars = this;
3735 if (CODING_REQUIRE_DECODING (&coding) 3737 if (CODING_REQUIRE_DECODING (&coding)
3736 || CODING_REQUIRE_DETECTION (&coding)) 3738 || CODING_REQUIRE_DETECTION (&coding))
3737 { 3739 {
3738 int require, produced, consumed; 3740 int require, produced, consumed;
3739 3741
3775 bcopy (read_buf + consumed, read_buf, unprocessed); 3777 bcopy (read_buf + consumed, read_buf, unprocessed);
3776 this = produced; 3778 this = produced;
3777 this_chars = chars_in_text (BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1, 3779 this_chars = chars_in_text (BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1,
3778 produced); 3780 produced);
3779 } 3781 }
3782 else if (! NILP (current_buffer->enable_multibyte_characters))
3783 this_chars = chars_in_text (BYTE_POS_ADDR (PT_BYTE + inserted - 1) + 1,
3784 this);
3785 else
3786 this_chars = this;
3780 3787
3781 GAP_SIZE -= this; 3788 GAP_SIZE -= this;
3782 GPT_BYTE += this; 3789 GPT_BYTE += this;
3783 ZV_BYTE += this; 3790 ZV_BYTE += this;
3784 Z_BYTE += this; 3791 Z_BYTE += this;
3820 3827
3821 if (how_much == -1) 3828 if (how_much == -1)
3822 error ("IO error reading %s: %s", 3829 error ("IO error reading %s: %s",
3823 XSTRING (orig_filename)->data, strerror (errno)); 3830 XSTRING (orig_filename)->data, strerror (errno));
3824 else if (how_much == -2) 3831 else if (how_much == -2)
3825 error ("maximum buffer size exceeded"); 3832 error ("Maximum buffer size exceeded");
3826 3833
3827 set_coding_system = 1; 3834 set_coding_system = 1;
3828 3835
3829 notfound: 3836 notfound:
3830 handled: 3837 handled:
4276 coding.last_block = 1; 4283 coding.last_block = 1;
4277 failure = 0 > a_write (desc, "", 0, XINT (start), &annotations, &coding); 4284 failure = 0 > a_write (desc, "", 0, XINT (start), &annotations, &coding);
4278 save_errno = errno; 4285 save_errno = errno;
4279 } 4286 }
4280 4287
4281 if (CODING_REQUIRE_FLUSHING (&coding) && !coding.last_block) 4288 if (CODING_REQUIRE_FLUSHING (&coding) && !coding.last_block
4289 && ! failure)
4282 { 4290 {
4283 /* We have to flush out a data. */ 4291 /* We have to flush out a data. */
4284 coding.last_block = 1; 4292 coding.last_block = 1;
4285 failure = 0 > e_write (desc, "", 0, &coding); 4293 failure = 0 > e_write (desc, "", 0, &coding);
4286 save_errno = errno; 4294 save_errno = errno;