Mercurial > emacs
comparison src/fileio.c @ 5410:c96b98efb5b4
(Fwrite_region): Don't change START and END from nil
until after checking for a magic handler.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 01 Jan 1994 18:01:49 +0000 |
parents | e11486a64dab |
children | 1ea2b4351945 |
comparison
equal
deleted
inserted
replaced
5409:a5c38a92e787 | 5410:c96b98efb5b4 |
---|---|
2626 Lisp_Object visit_file; | 2626 Lisp_Object visit_file; |
2627 Lisp_Object annotations; | 2627 Lisp_Object annotations; |
2628 int visiting, quietly; | 2628 int visiting, quietly; |
2629 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 2629 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
2630 | 2630 |
2631 /* Special kludge to simplify auto-saving */ | 2631 if (!NILP (start) && !STRINGP (start)) |
2632 if (NILP (start)) | |
2633 { | |
2634 XFASTINT (start) = BEG; | |
2635 XFASTINT (end) = Z; | |
2636 } | |
2637 else if (XTYPE (start) != Lisp_String) | |
2638 validate_region (&start, &end); | 2632 validate_region (&start, &end); |
2639 | 2633 |
2640 filename = Fexpand_file_name (filename, Qnil); | 2634 filename = Fexpand_file_name (filename, Qnil); |
2641 if (XTYPE (visit) == Lisp_String) | 2635 if (STRINGP (visit)) |
2642 visit_file = Fexpand_file_name (visit, Qnil); | 2636 visit_file = Fexpand_file_name (visit, Qnil); |
2643 else | 2637 else |
2644 visit_file = filename; | 2638 visit_file = filename; |
2645 | 2639 |
2646 visiting = (EQ (visit, Qt) || XTYPE (visit) == Lisp_String); | 2640 visiting = (EQ (visit, Qt) || STRINGP (visit)); |
2647 quietly = !NILP (visit); | 2641 quietly = !NILP (visit); |
2648 | 2642 |
2649 annotations = Qnil; | 2643 annotations = Qnil; |
2650 | 2644 |
2651 GCPRO4 (start, filename, annotations, visit_file); | 2645 GCPRO4 (start, filename, annotations, visit_file); |
2666 XFASTINT (current_buffer->save_length) = Z - BEG; | 2660 XFASTINT (current_buffer->save_length) = Z - BEG; |
2667 current_buffer->filename = visit_file; | 2661 current_buffer->filename = visit_file; |
2668 } | 2662 } |
2669 UNGCPRO; | 2663 UNGCPRO; |
2670 return val; | 2664 return val; |
2665 } | |
2666 | |
2667 /* Special kludge to simplify auto-saving. */ | |
2668 if (NILP (start)) | |
2669 { | |
2670 XFASTINT (start) = BEG; | |
2671 XFASTINT (end) = Z; | |
2671 } | 2672 } |
2672 | 2673 |
2673 annotations = build_annotations (start, end); | 2674 annotations = build_annotations (start, end); |
2674 | 2675 |
2675 #ifdef CLASH_DETECTION | 2676 #ifdef CLASH_DETECTION |
2687 if (auto_saving) /* Overwrite any previous version of autosave file */ | 2688 if (auto_saving) /* Overwrite any previous version of autosave file */ |
2688 { | 2689 { |
2689 vms_truncate (fn); /* if fn exists, truncate to zero length */ | 2690 vms_truncate (fn); /* if fn exists, truncate to zero length */ |
2690 desc = open (fn, O_RDWR); | 2691 desc = open (fn, O_RDWR); |
2691 if (desc < 0) | 2692 if (desc < 0) |
2692 desc = creat_copy_attrs (XTYPE (current_buffer->filename) == Lisp_String | 2693 desc = creat_copy_attrs (STRINGP (current_buffer->filename) |
2693 ? XSTRING (current_buffer->filename)->data : 0, | 2694 ? XSTRING (current_buffer->filename)->data : 0, |
2694 fn); | 2695 fn); |
2695 } | 2696 } |
2696 else /* Write to temporary name and rename if no errors */ | 2697 else /* Write to temporary name and rename if no errors */ |
2697 { | 2698 { |
2776 #endif | 2777 #endif |
2777 | 2778 |
2778 failure = 0; | 2779 failure = 0; |
2779 immediate_quit = 1; | 2780 immediate_quit = 1; |
2780 | 2781 |
2781 if (XTYPE (start) == Lisp_String) | 2782 if (STRINGP (start)) |
2782 { | 2783 { |
2783 failure = 0 > a_write (desc, XSTRING (start)->data, | 2784 failure = 0 > a_write (desc, XSTRING (start)->data, |
2784 XSTRING (start)->size, 0, &annotations); | 2785 XSTRING (start)->size, 0, &annotations); |
2785 save_errno = errno; | 2786 save_errno = errno; |
2786 } | 2787 } |