aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorRichard M. Stallman1997-06-16 07:31:56 +0000
committerRichard M. Stallman1997-06-16 07:31:56 +0000
commit1b335d29088603bf020eb919efdecf90dbe34b7b (patch)
tree1dcb66ef25fedf24a7da73fc23c42f6c4dc3e2a3 /src/fileio.c
parent203cb91615709f04185e5b305af61120ce9f873e (diff)
downloademacs-1b335d29088603bf020eb919efdecf90dbe34b7b.tar.gz
emacs-1b335d29088603bf020eb919efdecf90dbe34b7b.zip
(Fdo_auto_save): Use stdio to write the save-list file.
(Finsert_file_contents): Don't give up on the fast replace method if the coding remains undecided.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/src/fileio.c b/src/fileio.c
index c0b320aea63..2b911f02ecc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA. */
24#include <fcntl.h> 24#include <fcntl.h>
25#endif 25#endif
26 26
27#include <stdio.h>
27#include <sys/types.h> 28#include <sys/types.h>
28#include <sys/stat.h> 29#include <sys/stat.h>
29 30
@@ -3202,7 +3203,8 @@ This does code conversion according to the value of\n\
3202 3203
3203 if (coding.type == coding_type_undecided) 3204 if (coding.type == coding_type_undecided)
3204 detect_coding (&coding, buffer, nread); 3205 detect_coding (&coding, buffer, nread);
3205 if (CODING_REQUIRE_TEXT_CONVERSION (&coding)) 3206 if (coding.type != coding_type_undecided
3207 && CODING_REQUIRE_TEXT_CONVERSION (&coding))
3206 /* We found that the file should be decoded somehow. 3208 /* We found that the file should be decoded somehow.
3207 Let's give up here. */ 3209 Let's give up here. */
3208 { 3210 {
@@ -3212,7 +3214,8 @@ This does code conversion according to the value of\n\
3212 3214
3213 if (coding.eol_type == CODING_EOL_UNDECIDED) 3215 if (coding.eol_type == CODING_EOL_UNDECIDED)
3214 detect_eol (&coding, buffer, nread); 3216 detect_eol (&coding, buffer, nread);
3215 if (CODING_REQUIRE_EOL_CONVERSION (&coding)) 3217 if (coding.eol_type != CODING_EOL_UNDECIDED
3218 && CODING_REQUIRE_EOL_CONVERSION (&coding))
3216 /* We found that the format of eol should be decoded. 3219 /* We found that the format of eol should be decoded.
3217 Let's give up here. */ 3220 Let's give up here. */
3218 { 3221 {
@@ -4452,12 +4455,13 @@ auto_save_1 ()
4452} 4455}
4453 4456
4454static Lisp_Object 4457static Lisp_Object
4455do_auto_save_unwind (desc) /* used as unwind-protect function */ 4458do_auto_save_unwind (stream) /* used as unwind-protect function */
4456 Lisp_Object desc; 4459 Lisp_Object stream;
4457{ 4460{
4458 auto_saving = 0; 4461 auto_saving = 0;
4459 if (XINT (desc) >= 0) 4462 if (!NILP (stream))
4460 close (XINT (desc)); 4463 fclose ((FILE *) (XFASTINT (XCONS (stream)->car) << 16
4464 | XFASTINT (XCONS (stream)->cdr)));
4461 return Qnil; 4465 return Qnil;
4462} 4466}
4463 4467
@@ -4481,7 +4485,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4481 int omessage_length = echo_area_glyphs_length; 4485 int omessage_length = echo_area_glyphs_length;
4482 int do_handled_files; 4486 int do_handled_files;
4483 Lisp_Object oquit; 4487 Lisp_Object oquit;
4484 int listdesc; 4488 FILE *stream;
4489 Lisp_Object lispstream;
4485 int count = specpdl_ptr - specpdl; 4490 int count = specpdl_ptr - specpdl;
4486 int *ptr; 4491 int *ptr;
4487 4492
@@ -4503,20 +4508,21 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4503 { 4508 {
4504 Lisp_Object listfile; 4509 Lisp_Object listfile;
4505 listfile = Fexpand_file_name (Vauto_save_list_file_name, Qnil); 4510 listfile = Fexpand_file_name (Vauto_save_list_file_name, Qnil);
4506#ifdef DOS_NT 4511 stream = fopen (XSTRING (listfile)->data, "w");
4507 listdesc = open (XSTRING (listfile)->data, 4512
4508 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, 4513 /* Arrange to close that file whether or not we get an error.
4509 S_IREAD | S_IWRITE); 4514 Also reset auto_saving to 0. */
4510#else /* not DOS_NT */ 4515 lispstream = Fcons (Qnil, Qnil);
4511 listdesc = creat (XSTRING (listfile)->data, 0666); 4516 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16);
4512#endif /* not DOS_NT */ 4517 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff);
4513 } 4518 }
4514 else 4519 else
4515 listdesc = -1; 4520 {
4521 stream = NULL;
4522 lispstream = Qnil;
4523 }
4516 4524
4517 /* Arrange to close that file whether or not we get an error. 4525 record_unwind_protect (do_auto_save_unwind, lispstream);
4518 Also reset auto_saving to 0. */
4519 record_unwind_protect (do_auto_save_unwind, make_number (listdesc));
4520 4526
4521 auto_saving = 1; 4527 auto_saving = 1;
4522 4528
@@ -4535,17 +4541,17 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4535 in the special file that lists them. For each of these buffers, 4541 in the special file that lists them. For each of these buffers,
4536 Record visited name (if any) and auto save name. */ 4542 Record visited name (if any) and auto save name. */
4537 if (STRINGP (b->auto_save_file_name) 4543 if (STRINGP (b->auto_save_file_name)
4538 && listdesc >= 0 && do_handled_files == 0) 4544 && stream != NULL && do_handled_files == 0)
4539 { 4545 {
4540 if (!NILP (b->filename)) 4546 if (!NILP (b->filename))
4541 { 4547 {
4542 write (listdesc, XSTRING (b->filename)->data, 4548 fwrite (XSTRING (b->filename)->data, 1,
4543 XSTRING (b->filename)->size); 4549 XSTRING (b->filename)->size, stream);
4544 } 4550 }
4545 write (listdesc, "\n", 1); 4551 putc ('\n', stream);
4546 write (listdesc, XSTRING (b->auto_save_file_name)->data, 4552 fwrite (XSTRING (b->auto_save_file_name)->data, 1,
4547 XSTRING (b->auto_save_file_name)->size); 4553 XSTRING (b->auto_save_file_name)->size, stream);
4548 write (listdesc, "\n", 1); 4554 putc ('\n', stream);
4549 } 4555 }
4550 4556
4551 if (!NILP (current_only) 4557 if (!NILP (current_only)