Mercurial > emacs
comparison src/fileio.c @ 7526:bf357bdc648e
(Fdo_auto_save): Save listdesc as an integer, only if open.
(do_auto_save_unwind): Corresponding changes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 17 May 1994 09:46:59 +0000 |
parents | f4fb8b913c5d |
children | ccb8b7f8dce7 |
comparison
equal
deleted
inserted
replaced
7525:5b784d881c0f | 7526:bf357bdc648e |
---|---|
3473 current_buffer->auto_save_file_name, | 3473 current_buffer->auto_save_file_name, |
3474 Qnil, Qlambda); | 3474 Qnil, Qlambda); |
3475 } | 3475 } |
3476 | 3476 |
3477 static Lisp_Object | 3477 static Lisp_Object |
3478 do_auto_save_unwind (stream) /* used as unwind-protect function */ | 3478 do_auto_save_unwind (desc) /* used as unwind-protect function */ |
3479 Lisp_Object stream; | 3479 Lisp_Object desc; |
3480 { | 3480 { |
3481 close (*(int *)XPNTR (stream)); | 3481 close (XINT (desc)); |
3482 xfree (XPNTR (stream)); | |
3483 return Qnil; | 3482 return Qnil; |
3484 } | 3483 } |
3485 | 3484 |
3486 DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", | 3485 DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", |
3487 "Auto-save all buffers that need it.\n\ | 3486 "Auto-save all buffers that need it.\n\ |
3534 listdesc = creat (XSTRING (Vauto_save_list_file_name)->data, 0666); | 3533 listdesc = creat (XSTRING (Vauto_save_list_file_name)->data, 0666); |
3535 #endif /* not MSDOS */ | 3534 #endif /* not MSDOS */ |
3536 } | 3535 } |
3537 else | 3536 else |
3538 listdesc = -1; | 3537 listdesc = -1; |
3539 | |
3540 /* We may not be able to store STREAM itself as a Lisp_Object pointer | |
3541 since that is guaranteed to work only for data that has been malloc'd. | |
3542 So malloc a full-size pointer, and record the address of that pointer. */ | |
3543 ptr = (int *) xmalloc (sizeof (int)); | |
3544 *ptr = listdesc; | |
3545 XSET (lispstream, Lisp_Internal_Stream, (int) ptr); | |
3546 | 3538 |
3547 record_unwind_protect (do_auto_save_unwind, lispstream); | 3539 /* Arrange to close that file whether or not we get an error. */ |
3540 if (listdesc >= 0) | |
3541 record_unwind_protect (do_auto_save_unwind, make_number (listdesc)); | |
3548 | 3542 |
3549 /* First, save all files which don't have handlers. If Emacs is | 3543 /* First, save all files which don't have handlers. If Emacs is |
3550 crashing, the handlers may tweak what is causing Emacs to crash | 3544 crashing, the handlers may tweak what is causing Emacs to crash |
3551 in the first place, and it would be a shame if Emacs failed to | 3545 in the first place, and it would be a shame if Emacs failed to |
3552 autosave perfectly ordinary files because it couldn't handle some | 3546 autosave perfectly ordinary files because it couldn't handle some |