diff options
| author | Nickolas Lloyd | 2017-02-01 22:31:55 -0500 |
|---|---|---|
| committer | Nickolas Lloyd | 2017-02-01 22:31:55 -0500 |
| commit | 9a15b5509abb49a11c97c1101ad216f4ef258368 (patch) | |
| tree | 7311337d92833cb8f233eaa696a967a15a306a80 /src/fileio.c | |
| parent | 5d8f2548ceaa5a0b33c08a39f1d6c11071ec63aa (diff) | |
| parent | 70d36dda26465b43c1a63e8e13153e070af86456 (diff) | |
| download | emacs-nick.lloyd-bytecode-jit.tar.gz emacs-nick.lloyd-bytecode-jit.zip | |
Merge branch 'master' into nick.lloyd-bytecode-jitnick.lloyd-bytecode-jit
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/src/fileio.c b/src/fileio.c index a46cfc7ac69..38400623793 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1960,9 +1960,7 @@ permissions. */) | |||
| 1960 | report_file_error ("Copying permissions to", newname); | 1960 | report_file_error ("Copying permissions to", newname); |
| 1961 | } | 1961 | } |
| 1962 | #else /* not WINDOWSNT */ | 1962 | #else /* not WINDOWSNT */ |
| 1963 | immediate_quit = true; | ||
| 1964 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); | 1963 | ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); |
| 1965 | immediate_quit = false; | ||
| 1966 | 1964 | ||
| 1967 | if (ifd < 0) | 1965 | if (ifd < 0) |
| 1968 | report_file_error ("Opening input file", file); | 1966 | report_file_error ("Opening input file", file); |
| @@ -2024,7 +2022,6 @@ permissions. */) | |||
| 2024 | oldsize = out_st.st_size; | 2022 | oldsize = out_st.st_size; |
| 2025 | } | 2023 | } |
| 2026 | 2024 | ||
| 2027 | immediate_quit = true; | ||
| 2028 | maybe_quit (); | 2025 | maybe_quit (); |
| 2029 | 2026 | ||
| 2030 | if (clone_file (ofd, ifd)) | 2027 | if (clone_file (ofd, ifd)) |
| @@ -2033,9 +2030,9 @@ permissions. */) | |||
| 2033 | { | 2030 | { |
| 2034 | char buf[MAX_ALLOCA]; | 2031 | char buf[MAX_ALLOCA]; |
| 2035 | ptrdiff_t n; | 2032 | ptrdiff_t n; |
| 2036 | for (newsize = 0; 0 < (n = emacs_read (ifd, buf, sizeof buf)); | 2033 | for (newsize = 0; 0 < (n = emacs_read_quit (ifd, buf, sizeof buf)); |
| 2037 | newsize += n) | 2034 | newsize += n) |
| 2038 | if (emacs_write_sig (ofd, buf, n) != n) | 2035 | if (emacs_write_quit (ofd, buf, n) != n) |
| 2039 | report_file_error ("Write error", newname); | 2036 | report_file_error ("Write error", newname); |
| 2040 | if (n < 0) | 2037 | if (n < 0) |
| 2041 | report_file_error ("Read error", file); | 2038 | report_file_error ("Read error", file); |
| @@ -2047,8 +2044,6 @@ permissions. */) | |||
| 2047 | if (newsize < oldsize && ftruncate (ofd, newsize) != 0) | 2044 | if (newsize < oldsize && ftruncate (ofd, newsize) != 0) |
| 2048 | report_file_error ("Truncating output file", newname); | 2045 | report_file_error ("Truncating output file", newname); |
| 2049 | 2046 | ||
| 2050 | immediate_quit = false; | ||
| 2051 | |||
| 2052 | #ifndef MSDOS | 2047 | #ifndef MSDOS |
| 2053 | /* Preserve the original file permissions, and if requested, also its | 2048 | /* Preserve the original file permissions, and if requested, also its |
| 2054 | owner and group. */ | 2049 | owner and group. */ |
| @@ -3401,15 +3396,10 @@ decide_coding_unwind (Lisp_Object unwind_data) | |||
| 3401 | static Lisp_Object | 3396 | static Lisp_Object |
| 3402 | read_non_regular (Lisp_Object state) | 3397 | read_non_regular (Lisp_Object state) |
| 3403 | { | 3398 | { |
| 3404 | int nbytes; | 3399 | int nbytes = emacs_read_quit (XSAVE_INTEGER (state, 0), |
| 3405 | 3400 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE | |
| 3406 | immediate_quit = true; | 3401 | + XSAVE_INTEGER (state, 1)), |
| 3407 | maybe_quit (); | 3402 | XSAVE_INTEGER (state, 2)); |
| 3408 | nbytes = emacs_read (XSAVE_INTEGER (state, 0), | ||
| 3409 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE | ||
| 3410 | + XSAVE_INTEGER (state, 1)), | ||
| 3411 | XSAVE_INTEGER (state, 2)); | ||
| 3412 | immediate_quit = false; | ||
| 3413 | /* Fast recycle this object for the likely next call. */ | 3403 | /* Fast recycle this object for the likely next call. */ |
| 3414 | free_misc (state); | 3404 | free_misc (state); |
| 3415 | return make_number (nbytes); | 3405 | return make_number (nbytes); |
| @@ -3753,17 +3743,17 @@ by calling `format-decode', which see. */) | |||
| 3753 | int nread; | 3743 | int nread; |
| 3754 | 3744 | ||
| 3755 | if (st.st_size <= (1024 * 4)) | 3745 | if (st.st_size <= (1024 * 4)) |
| 3756 | nread = emacs_read (fd, read_buf, 1024 * 4); | 3746 | nread = emacs_read_quit (fd, read_buf, 1024 * 4); |
| 3757 | else | 3747 | else |
| 3758 | { | 3748 | { |
| 3759 | nread = emacs_read (fd, read_buf, 1024); | 3749 | nread = emacs_read_quit (fd, read_buf, 1024); |
| 3760 | if (nread == 1024) | 3750 | if (nread == 1024) |
| 3761 | { | 3751 | { |
| 3762 | int ntail; | 3752 | int ntail; |
| 3763 | if (lseek (fd, - (1024 * 3), SEEK_END) < 0) | 3753 | if (lseek (fd, - (1024 * 3), SEEK_END) < 0) |
| 3764 | report_file_error ("Setting file position", | 3754 | report_file_error ("Setting file position", |
| 3765 | orig_filename); | 3755 | orig_filename); |
| 3766 | ntail = emacs_read (fd, read_buf + nread, 1024 * 3); | 3756 | ntail = emacs_read_quit (fd, read_buf + nread, 1024 * 3); |
| 3767 | nread = ntail < 0 ? ntail : nread + ntail; | 3757 | nread = ntail < 0 ? ntail : nread + ntail; |
| 3768 | } | 3758 | } |
| 3769 | } | 3759 | } |
| @@ -3868,15 +3858,11 @@ by calling `format-decode', which see. */) | |||
| 3868 | report_file_error ("Setting file position", orig_filename); | 3858 | report_file_error ("Setting file position", orig_filename); |
| 3869 | } | 3859 | } |
| 3870 | 3860 | ||
| 3871 | immediate_quit = true; | ||
| 3872 | maybe_quit (); | ||
| 3873 | /* Count how many chars at the start of the file | 3861 | /* Count how many chars at the start of the file |
| 3874 | match the text at the beginning of the buffer. */ | 3862 | match the text at the beginning of the buffer. */ |
| 3875 | while (1) | 3863 | while (true) |
| 3876 | { | 3864 | { |
| 3877 | int nread, bufpos; | 3865 | int nread = emacs_read_quit (fd, read_buf, sizeof read_buf); |
| 3878 | |||
| 3879 | nread = emacs_read (fd, read_buf, sizeof read_buf); | ||
| 3880 | if (nread < 0) | 3866 | if (nread < 0) |
| 3881 | report_file_error ("Read error", orig_filename); | 3867 | report_file_error ("Read error", orig_filename); |
| 3882 | else if (nread == 0) | 3868 | else if (nread == 0) |
| @@ -3898,7 +3884,7 @@ by calling `format-decode', which see. */) | |||
| 3898 | break; | 3884 | break; |
| 3899 | } | 3885 | } |
| 3900 | 3886 | ||
| 3901 | bufpos = 0; | 3887 | int bufpos = 0; |
| 3902 | while (bufpos < nread && same_at_start < ZV_BYTE | 3888 | while (bufpos < nread && same_at_start < ZV_BYTE |
| 3903 | && FETCH_BYTE (same_at_start) == read_buf[bufpos]) | 3889 | && FETCH_BYTE (same_at_start) == read_buf[bufpos]) |
| 3904 | same_at_start++, bufpos++; | 3890 | same_at_start++, bufpos++; |
| @@ -3907,7 +3893,6 @@ by calling `format-decode', which see. */) | |||
| 3907 | if (bufpos != nread) | 3893 | if (bufpos != nread) |
| 3908 | break; | 3894 | break; |
| 3909 | } | 3895 | } |
| 3910 | immediate_quit = false; | ||
| 3911 | /* If the file matches the buffer completely, | 3896 | /* If the file matches the buffer completely, |
| 3912 | there's no need to replace anything. */ | 3897 | there's no need to replace anything. */ |
| 3913 | if (same_at_start - BEGV_BYTE == end_offset - beg_offset) | 3898 | if (same_at_start - BEGV_BYTE == end_offset - beg_offset) |
| @@ -3919,8 +3904,7 @@ by calling `format-decode', which see. */) | |||
| 3919 | del_range_1 (same_at_start, same_at_end, 0, 0); | 3904 | del_range_1 (same_at_start, same_at_end, 0, 0); |
| 3920 | goto handled; | 3905 | goto handled; |
| 3921 | } | 3906 | } |
| 3922 | immediate_quit = true; | 3907 | |
| 3923 | maybe_quit (); | ||
| 3924 | /* Count how many chars at the end of the file | 3908 | /* Count how many chars at the end of the file |
| 3925 | match the text at the end of the buffer. But, if we have | 3909 | match the text at the end of the buffer. But, if we have |
| 3926 | already found that decoding is necessary, don't waste time. */ | 3910 | already found that decoding is necessary, don't waste time. */ |
| @@ -3942,7 +3926,8 @@ by calling `format-decode', which see. */) | |||
| 3942 | total_read = nread = 0; | 3926 | total_read = nread = 0; |
| 3943 | while (total_read < trial) | 3927 | while (total_read < trial) |
| 3944 | { | 3928 | { |
| 3945 | nread = emacs_read (fd, read_buf + total_read, trial - total_read); | 3929 | nread = emacs_read_quit (fd, read_buf + total_read, |
| 3930 | trial - total_read); | ||
| 3946 | if (nread < 0) | 3931 | if (nread < 0) |
| 3947 | report_file_error ("Read error", orig_filename); | 3932 | report_file_error ("Read error", orig_filename); |
| 3948 | else if (nread == 0) | 3933 | else if (nread == 0) |
| @@ -3977,7 +3962,6 @@ by calling `format-decode', which see. */) | |||
| 3977 | if (nread == 0) | 3962 | if (nread == 0) |
| 3978 | break; | 3963 | break; |
| 3979 | } | 3964 | } |
| 3980 | immediate_quit = false; | ||
| 3981 | 3965 | ||
| 3982 | if (! giveup_match_end) | 3966 | if (! giveup_match_end) |
| 3983 | { | 3967 | { |
| @@ -4069,18 +4053,13 @@ by calling `format-decode', which see. */) | |||
| 4069 | inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ | 4053 | inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ |
| 4070 | unprocessed = 0; /* Bytes not processed in previous loop. */ | 4054 | unprocessed = 0; /* Bytes not processed in previous loop. */ |
| 4071 | 4055 | ||
| 4072 | while (1) | 4056 | while (true) |
| 4073 | { | 4057 | { |
| 4074 | /* Read at most READ_BUF_SIZE bytes at a time, to allow | 4058 | /* Read at most READ_BUF_SIZE bytes at a time, to allow |
| 4075 | quitting while reading a huge file. */ | 4059 | quitting while reading a huge file. */ |
| 4076 | 4060 | ||
| 4077 | /* Allow quitting out of the actual I/O. */ | 4061 | this = emacs_read_quit (fd, read_buf + unprocessed, |
| 4078 | immediate_quit = true; | 4062 | READ_BUF_SIZE - unprocessed); |
| 4079 | maybe_quit (); | ||
| 4080 | this = emacs_read (fd, read_buf + unprocessed, | ||
| 4081 | READ_BUF_SIZE - unprocessed); | ||
| 4082 | immediate_quit = false; | ||
| 4083 | |||
| 4084 | if (this <= 0) | 4063 | if (this <= 0) |
| 4085 | break; | 4064 | break; |
| 4086 | 4065 | ||
| @@ -4294,13 +4273,10 @@ by calling `format-decode', which see. */) | |||
| 4294 | /* Allow quitting out of the actual I/O. We don't make text | 4273 | /* Allow quitting out of the actual I/O. We don't make text |
| 4295 | part of the buffer until all the reading is done, so a C-g | 4274 | part of the buffer until all the reading is done, so a C-g |
| 4296 | here doesn't do any harm. */ | 4275 | here doesn't do any harm. */ |
| 4297 | immediate_quit = true; | 4276 | this = emacs_read_quit (fd, |
| 4298 | maybe_quit (); | 4277 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE |
| 4299 | this = emacs_read (fd, | 4278 | + inserted), |
| 4300 | ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE | 4279 | trytry); |
| 4301 | + inserted), | ||
| 4302 | trytry); | ||
| 4303 | immediate_quit = false; | ||
| 4304 | } | 4280 | } |
| 4305 | 4281 | ||
| 4306 | if (this <= 0) | 4282 | if (this <= 0) |
| @@ -5002,8 +4978,6 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5002 | } | 4978 | } |
| 5003 | } | 4979 | } |
| 5004 | 4980 | ||
| 5005 | immediate_quit = true; | ||
| 5006 | |||
| 5007 | if (STRINGP (start)) | 4981 | if (STRINGP (start)) |
| 5008 | ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); | 4982 | ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); |
| 5009 | else if (XINT (start) != XINT (end)) | 4983 | else if (XINT (start) != XINT (end)) |
| @@ -5026,8 +5000,6 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, | |||
| 5026 | save_errno = errno; | 5000 | save_errno = errno; |
| 5027 | } | 5001 | } |
| 5028 | 5002 | ||
| 5029 | immediate_quit = false; | ||
| 5030 | |||
| 5031 | /* fsync is not crucial for temporary files. Nor for auto-save | 5003 | /* fsync is not crucial for temporary files. Nor for auto-save |
| 5032 | files, since they might lose some work anyway. */ | 5004 | files, since they might lose some work anyway. */ |
| 5033 | if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync) | 5005 | if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync) |
| @@ -5417,7 +5389,7 @@ e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, | |||
| 5417 | : (STRINGP (coding->dst_object) | 5389 | : (STRINGP (coding->dst_object) |
| 5418 | ? SSDATA (coding->dst_object) | 5390 | ? SSDATA (coding->dst_object) |
| 5419 | : (char *) BYTE_POS_ADDR (coding->dst_pos_byte))); | 5391 | : (char *) BYTE_POS_ADDR (coding->dst_pos_byte))); |
| 5420 | coding->produced -= emacs_write_sig (desc, buf, coding->produced); | 5392 | coding->produced -= emacs_write_quit (desc, buf, coding->produced); |
| 5421 | 5393 | ||
| 5422 | if (coding->raw_destination) | 5394 | if (coding->raw_destination) |
| 5423 | { | 5395 | { |