diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/fileio.c b/src/fileio.c index e1131ce8860..08632ab1ff8 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2593,14 +2593,14 @@ and (2) it puts less data in the undo list.") | |||
| 2593 | fd = -1; | 2593 | fd = -1; |
| 2594 | 2594 | ||
| 2595 | #ifndef APOLLO | 2595 | #ifndef APOLLO |
| 2596 | if (stat (XSTRING (filename)->data, &st) < 0 | 2596 | if (stat (XSTRING (filename)->data, &st) < 0) |
| 2597 | || (fd = open (XSTRING (filename)->data, 0)) < 0) | ||
| 2598 | #else | 2597 | #else |
| 2599 | if ((fd = open (XSTRING (filename)->data, 0)) < 0 | 2598 | if ((fd = open (XSTRING (filename)->data, 0)) < 0 |
| 2600 | || fstat (fd, &st) < 0) | 2599 | || fstat (fd, &st) < 0) |
| 2601 | #endif /* not APOLLO */ | 2600 | #endif /* not APOLLO */ |
| 2602 | { | 2601 | { |
| 2603 | if (fd >= 0) close (fd); | 2602 | if (fd >= 0) close (fd); |
| 2603 | badopen: | ||
| 2604 | if (NILP (visit)) | 2604 | if (NILP (visit)) |
| 2605 | report_file_error ("Opening input file", Fcons (filename, Qnil)); | 2605 | report_file_error ("Opening input file", Fcons (filename, Qnil)); |
| 2606 | st.st_mtime = -1; | 2606 | st.st_mtime = -1; |
| @@ -2608,22 +2608,26 @@ and (2) it puts less data in the undo list.") | |||
| 2608 | goto notfound; | 2608 | goto notfound; |
| 2609 | } | 2609 | } |
| 2610 | 2610 | ||
| 2611 | /* Replacement should preserve point as it preserves markers. */ | 2611 | #ifdef S_IFREG |
| 2612 | if (!NILP (replace)) | ||
| 2613 | record_unwind_protect (restore_point_unwind, Fpoint_marker ()); | ||
| 2614 | |||
| 2615 | record_unwind_protect (close_file_unwind, make_number (fd)); | ||
| 2616 | |||
| 2617 | #ifdef S_IFSOCK | ||
| 2618 | /* This code will need to be changed in order to work on named | 2612 | /* This code will need to be changed in order to work on named |
| 2619 | pipes, and it's probably just not worth it. So we should at | 2613 | pipes, and it's probably just not worth it. So we should at |
| 2620 | least signal an error. */ | 2614 | least signal an error. */ |
| 2621 | if ((st.st_mode & S_IFMT) == S_IFSOCK) | 2615 | if (!S_ISREG (st.st_mode)) |
| 2622 | Fsignal (Qfile_error, | 2616 | Fsignal (Qfile_error, |
| 2623 | Fcons (build_string ("reading from named pipe"), | 2617 | Fcons (build_string ("not a regular file"), |
| 2624 | Fcons (filename, Qnil))); | 2618 | Fcons (filename, Qnil))); |
| 2625 | #endif | 2619 | #endif |
| 2626 | 2620 | ||
| 2621 | if (fd < 0) | ||
| 2622 | if ((fd = open (XSTRING (filename)->data, 0)) < 0) | ||
| 2623 | goto badopen; | ||
| 2624 | |||
| 2625 | /* Replacement should preserve point as it preserves markers. */ | ||
| 2626 | if (!NILP (replace)) | ||
| 2627 | record_unwind_protect (restore_point_unwind, Fpoint_marker ()); | ||
| 2628 | |||
| 2629 | record_unwind_protect (close_file_unwind, make_number (fd)); | ||
| 2630 | |||
| 2627 | /* Supposedly happens on VMS. */ | 2631 | /* Supposedly happens on VMS. */ |
| 2628 | if (st.st_size < 0) | 2632 | if (st.st_size < 0) |
| 2629 | error ("File size is negative"); | 2633 | error ("File size is negative"); |