diff options
| author | Dave Love | 2000-05-10 08:52:47 +0000 |
|---|---|---|
| committer | Dave Love | 2000-05-10 08:52:47 +0000 |
| commit | 43fb7d9afa6cbfc69cd3b10f77a2ae200516a6e8 (patch) | |
| tree | 3dd13187770be6cd583183b77becb54a71e8cd7f /src | |
| parent | 21c34da31c3aab6edaa6e892c83c39a37303a7ef (diff) | |
| download | emacs-43fb7d9afa6cbfc69cd3b10f77a2ae200516a6e8.tar.gz emacs-43fb7d9afa6cbfc69cd3b10f77a2ae200516a6e8.zip | |
(Fwrite_region): If APPEND arg is an integer, seek to
that offset before writing. Move gcpro region past call of
Ffile_regular_p.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/fileio.c b/src/fileio.c index 43110f7ece8..0fcad5d99a2 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* File IO for GNU Emacs. | 1 | /* File IO for GNU Emacs. |
| 2 | Copyright (C) 1985,86,87,88,93,94,95,96,97,98,1999 Free Software Foundation, Inc. | 2 | Copyright (C) 1985,86,87,88,93,94,95,96,97,98,99,2000 |
| 3 | Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -4317,7 +4318,8 @@ DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 7, | |||
| 4317 | When called from a program, takes three arguments:\n\ | 4318 | When called from a program, takes three arguments:\n\ |
| 4318 | START, END and FILENAME. START and END are buffer positions.\n\ | 4319 | START, END and FILENAME. START and END are buffer positions.\n\ |
| 4319 | Optional fourth argument APPEND if non-nil means\n\ | 4320 | Optional fourth argument APPEND if non-nil means\n\ |
| 4320 | append to existing file contents (if any).\n\ | 4321 | append to existing file contents (if any). If it is an integer,\n\ |
| 4322 | seek to that offset in the file before writing.\n\ | ||
| 4321 | Optional fifth argument VISIT if t means\n\ | 4323 | Optional fifth argument VISIT if t means\n\ |
| 4322 | set the last-save-file-modtime of buffer to this file's modtime\n\ | 4324 | set the last-save-file-modtime of buffer to this file's modtime\n\ |
| 4323 | and mark buffer not modified.\n\ | 4325 | and mark buffer not modified.\n\ |
| @@ -4615,8 +4617,6 @@ This does code conversion according to the value of\n\ | |||
| 4615 | #endif /* not DOS_NT */ | 4617 | #endif /* not DOS_NT */ |
| 4616 | #endif /* not VMS */ | 4618 | #endif /* not VMS */ |
| 4617 | 4619 | ||
| 4618 | UNGCPRO; | ||
| 4619 | |||
| 4620 | if (desc < 0) | 4620 | if (desc < 0) |
| 4621 | { | 4621 | { |
| 4622 | #ifdef CLASH_DETECTION | 4622 | #ifdef CLASH_DETECTION |
| @@ -4624,19 +4624,31 @@ This does code conversion according to the value of\n\ | |||
| 4624 | if (!auto_saving) unlock_file (lockname); | 4624 | if (!auto_saving) unlock_file (lockname); |
| 4625 | errno = save_errno; | 4625 | errno = save_errno; |
| 4626 | #endif /* CLASH_DETECTION */ | 4626 | #endif /* CLASH_DETECTION */ |
| 4627 | UNGCPRO; | ||
| 4627 | report_file_error ("Opening output file", Fcons (filename, Qnil)); | 4628 | report_file_error ("Opening output file", Fcons (filename, Qnil)); |
| 4628 | } | 4629 | } |
| 4629 | 4630 | ||
| 4630 | record_unwind_protect (close_file_unwind, make_number (desc)); | 4631 | record_unwind_protect (close_file_unwind, make_number (desc)); |
| 4631 | 4632 | ||
| 4632 | if (!NILP (append) && !NILP (Ffile_regular_p (filename))) | 4633 | if (!NILP (append) && !NILP (Ffile_regular_p (filename))) |
| 4633 | if (lseek (desc, 0, 2) < 0) | 4634 | { |
| 4634 | { | 4635 | long ret; |
| 4636 | |||
| 4637 | if (NUMBERP (append)) | ||
| 4638 | ret = lseek (desc, XINT (append), 1); | ||
| 4639 | else | ||
| 4640 | ret = lseek (desc, 0, 2); | ||
| 4641 | if (ret < 0) | ||
| 4642 | { | ||
| 4635 | #ifdef CLASH_DETECTION | 4643 | #ifdef CLASH_DETECTION |
| 4636 | if (!auto_saving) unlock_file (lockname); | 4644 | if (!auto_saving) unlock_file (lockname); |
| 4637 | #endif /* CLASH_DETECTION */ | 4645 | #endif /* CLASH_DETECTION */ |
| 4638 | report_file_error ("Lseek error", Fcons (filename, Qnil)); | 4646 | UNGCPRO; |
| 4639 | } | 4647 | report_file_error ("Lseek error", Fcons (filename, Qnil)); |
| 4648 | } | ||
| 4649 | } | ||
| 4650 | |||
| 4651 | UNGCPRO; | ||
| 4640 | 4652 | ||
| 4641 | #ifdef VMS | 4653 | #ifdef VMS |
| 4642 | /* | 4654 | /* |