diff options
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 135 |
1 files changed, 71 insertions, 64 deletions
diff --git a/src/fileio.c b/src/fileio.c index 08be41f9fe4..486c3d4c175 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -145,9 +145,9 @@ Lisp_Object Qfile_name_history; | |||
| 145 | static Lisp_Object Qcar_less_than_car; | 145 | static Lisp_Object Qcar_less_than_car; |
| 146 | 146 | ||
| 147 | static Lisp_Object Fmake_symbolic_link (Lisp_Object, Lisp_Object, Lisp_Object); | 147 | static Lisp_Object Fmake_symbolic_link (Lisp_Object, Lisp_Object, Lisp_Object); |
| 148 | static int a_write (int, Lisp_Object, EMACS_INT, EMACS_INT, | 148 | static int a_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 149 | Lisp_Object *, struct coding_system *); | 149 | Lisp_Object *, struct coding_system *); |
| 150 | static int e_write (int, Lisp_Object, EMACS_INT, EMACS_INT, | 150 | static int e_write (int, Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 151 | struct coding_system *); | 151 | struct coding_system *); |
| 152 | 152 | ||
| 153 | 153 | ||
| @@ -257,7 +257,7 @@ use the standard functions without calling themselves recursively. */) | |||
| 257 | { | 257 | { |
| 258 | /* This function must not munge the match data. */ | 258 | /* This function must not munge the match data. */ |
| 259 | Lisp_Object chain, inhibited_handlers, result; | 259 | Lisp_Object chain, inhibited_handlers, result; |
| 260 | int pos = -1; | 260 | ptrdiff_t pos = -1; |
| 261 | 261 | ||
| 262 | result = Qnil; | 262 | result = Qnil; |
| 263 | CHECK_STRING (filename); | 263 | CHECK_STRING (filename); |
| @@ -275,7 +275,7 @@ use the standard functions without calling themselves recursively. */) | |||
| 275 | if (CONSP (elt)) | 275 | if (CONSP (elt)) |
| 276 | { | 276 | { |
| 277 | Lisp_Object string = XCAR (elt); | 277 | Lisp_Object string = XCAR (elt); |
| 278 | EMACS_INT match_pos; | 278 | ptrdiff_t match_pos; |
| 279 | Lisp_Object handler = XCDR (elt); | 279 | Lisp_Object handler = XCDR (elt); |
| 280 | Lisp_Object operations = Qnil; | 280 | Lisp_Object operations = Qnil; |
| 281 | 281 | ||
| @@ -1813,12 +1813,12 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) | |||
| 1813 | (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists, Lisp_Object keep_time, Lisp_Object preserve_uid_gid, Lisp_Object preserve_selinux_context) | 1813 | (Lisp_Object file, Lisp_Object newname, Lisp_Object ok_if_already_exists, Lisp_Object keep_time, Lisp_Object preserve_uid_gid, Lisp_Object preserve_selinux_context) |
| 1814 | { | 1814 | { |
| 1815 | int ifd, ofd; | 1815 | int ifd, ofd; |
| 1816 | EMACS_INT n; | 1816 | int n; |
| 1817 | char buf[16 * 1024]; | 1817 | char buf[16 * 1024]; |
| 1818 | struct stat st, out_st; | 1818 | struct stat st, out_st; |
| 1819 | Lisp_Object handler; | 1819 | Lisp_Object handler; |
| 1820 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1820 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1821 | int count = SPECPDL_INDEX (); | 1821 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1822 | int input_file_statable_p; | 1822 | int input_file_statable_p; |
| 1823 | Lisp_Object encoded_file, encoded_newname; | 1823 | Lisp_Object encoded_file, encoded_newname; |
| 1824 | #if HAVE_LIBSELINUX | 1824 | #if HAVE_LIBSELINUX |
| @@ -2210,7 +2210,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2210 | { | 2210 | { |
| 2211 | if (errno == EXDEV) | 2211 | if (errno == EXDEV) |
| 2212 | { | 2212 | { |
| 2213 | int count; | 2213 | ptrdiff_t count; |
| 2214 | symlink_target = Ffile_symlink_p (file); | 2214 | symlink_target = Ffile_symlink_p (file); |
| 2215 | if (! NILP (symlink_target)) | 2215 | if (! NILP (symlink_target)) |
| 2216 | Fmake_symbolic_link (symlink_target, newname, | 2216 | Fmake_symbolic_link (symlink_target, newname, |
| @@ -3055,6 +3055,8 @@ otherwise, if FILE2 does not exist, the answer is t. */) | |||
| 3055 | #ifndef READ_BUF_SIZE | 3055 | #ifndef READ_BUF_SIZE |
| 3056 | #define READ_BUF_SIZE (64 << 10) | 3056 | #define READ_BUF_SIZE (64 << 10) |
| 3057 | #endif | 3057 | #endif |
| 3058 | /* Some buffer offsets are stored in 'int' variables. */ | ||
| 3059 | verify (READ_BUF_SIZE <= INT_MAX); | ||
| 3058 | 3060 | ||
| 3059 | /* This function is called after Lisp functions to decide a coding | 3061 | /* This function is called after Lisp functions to decide a coding |
| 3060 | system are called, or when they cause an error. Before they are | 3062 | system are called, or when they cause an error. Before they are |
| @@ -3099,8 +3101,8 @@ decide_coding_unwind (Lisp_Object unwind_data) | |||
| 3099 | /* Used to pass values from insert-file-contents to read_non_regular. */ | 3101 | /* Used to pass values from insert-file-contents to read_non_regular. */ |
| 3100 | 3102 | ||
| 3101 | static int non_regular_fd; | 3103 | static int non_regular_fd; |
| 3102 | static EMACS_INT non_regular_inserted; | 3104 | static ptrdiff_t non_regular_inserted; |
| 3103 | static EMACS_INT non_regular_nbytes; | 3105 | static int non_regular_nbytes; |
| 3104 | 3106 | ||
| 3105 | 3107 | ||
| 3106 | /* Read from a non-regular file. | 3108 | /* Read from a non-regular file. |
| @@ -3111,7 +3113,7 @@ static EMACS_INT non_regular_nbytes; | |||
| 3111 | static Lisp_Object | 3113 | static Lisp_Object |
| 3112 | read_non_regular (Lisp_Object ignore) | 3114 | read_non_regular (Lisp_Object ignore) |
| 3113 | { | 3115 | { |
| 3114 | EMACS_INT nbytes; | 3116 | int nbytes; |
| 3115 | 3117 | ||
| 3116 | immediate_quit = 1; | 3118 | immediate_quit = 1; |
| 3117 | QUIT; | 3119 | QUIT; |
| @@ -3176,16 +3178,16 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3176 | { | 3178 | { |
| 3177 | struct stat st; | 3179 | struct stat st; |
| 3178 | register int fd; | 3180 | register int fd; |
| 3179 | EMACS_INT inserted = 0; | 3181 | ptrdiff_t inserted = 0; |
| 3180 | int nochange = 0; | 3182 | int nochange = 0; |
| 3181 | register EMACS_INT how_much; | 3183 | register ptrdiff_t how_much; |
| 3182 | off_t beg_offset, end_offset; | 3184 | off_t beg_offset, end_offset; |
| 3183 | register EMACS_INT unprocessed; | 3185 | register int unprocessed; |
| 3184 | int count = SPECPDL_INDEX (); | 3186 | ptrdiff_t count = SPECPDL_INDEX (); |
| 3185 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 3187 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 3186 | Lisp_Object handler, val, insval, orig_filename, old_undo; | 3188 | Lisp_Object handler, val, insval, orig_filename, old_undo; |
| 3187 | Lisp_Object p; | 3189 | Lisp_Object p; |
| 3188 | EMACS_INT total = 0; | 3190 | ptrdiff_t total = 0; |
| 3189 | int not_regular = 0; | 3191 | int not_regular = 0; |
| 3190 | char read_buf[READ_BUF_SIZE]; | 3192 | char read_buf[READ_BUF_SIZE]; |
| 3191 | struct coding_system coding; | 3193 | struct coding_system coding; |
| @@ -3225,7 +3227,8 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3225 | { | 3227 | { |
| 3226 | val = call6 (handler, Qinsert_file_contents, filename, | 3228 | val = call6 (handler, Qinsert_file_contents, filename, |
| 3227 | visit, beg, end, replace); | 3229 | visit, beg, end, replace); |
| 3228 | if (CONSP (val) && CONSP (XCDR (val))) | 3230 | if (CONSP (val) && CONSP (XCDR (val)) |
| 3231 | && RANGED_INTEGERP (0, XCAR (XCDR (val)), ZV - PT)) | ||
| 3229 | inserted = XINT (XCAR (XCDR (val))); | 3232 | inserted = XINT (XCAR (XCDR (val))); |
| 3230 | goto handled; | 3233 | goto handled; |
| 3231 | } | 3234 | } |
| @@ -3378,7 +3381,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3378 | We assume that the 1K-byte and 3K-byte for heading | 3381 | We assume that the 1K-byte and 3K-byte for heading |
| 3379 | and tailing respectively are sufficient for this | 3382 | and tailing respectively are sufficient for this |
| 3380 | purpose. */ | 3383 | purpose. */ |
| 3381 | EMACS_INT nread; | 3384 | int nread; |
| 3382 | 3385 | ||
| 3383 | if (st.st_size <= (1024 * 4)) | 3386 | if (st.st_size <= (1024 * 4)) |
| 3384 | nread = emacs_read (fd, read_buf, 1024 * 4); | 3387 | nread = emacs_read (fd, read_buf, 1024 * 4); |
| @@ -3488,9 +3491,9 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3488 | /* same_at_start and same_at_end count bytes, | 3491 | /* same_at_start and same_at_end count bytes, |
| 3489 | because file access counts bytes | 3492 | because file access counts bytes |
| 3490 | and BEG and END count bytes. */ | 3493 | and BEG and END count bytes. */ |
| 3491 | EMACS_INT same_at_start = BEGV_BYTE; | 3494 | ptrdiff_t same_at_start = BEGV_BYTE; |
| 3492 | EMACS_INT same_at_end = ZV_BYTE; | 3495 | ptrdiff_t same_at_end = ZV_BYTE; |
| 3493 | EMACS_INT overlap; | 3496 | ptrdiff_t overlap; |
| 3494 | /* There is still a possibility we will find the need to do code | 3497 | /* There is still a possibility we will find the need to do code |
| 3495 | conversion. If that happens, we set this variable to 1 to | 3498 | conversion. If that happens, we set this variable to 1 to |
| 3496 | give up on handling REPLACE in the optimized way. */ | 3499 | give up on handling REPLACE in the optimized way. */ |
| @@ -3509,7 +3512,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3509 | match the text at the beginning of the buffer. */ | 3512 | match the text at the beginning of the buffer. */ |
| 3510 | while (1) | 3513 | while (1) |
| 3511 | { | 3514 | { |
| 3512 | EMACS_INT nread, bufpos; | 3515 | int nread, bufpos; |
| 3513 | 3516 | ||
| 3514 | nread = emacs_read (fd, buffer, sizeof buffer); | 3517 | nread = emacs_read (fd, buffer, sizeof buffer); |
| 3515 | if (nread < 0) | 3518 | if (nread < 0) |
| @@ -3618,7 +3621,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3618 | 3621 | ||
| 3619 | if (! giveup_match_end) | 3622 | if (! giveup_match_end) |
| 3620 | { | 3623 | { |
| 3621 | EMACS_INT temp; | 3624 | ptrdiff_t temp; |
| 3622 | 3625 | ||
| 3623 | /* We win! We can handle REPLACE the optimized way. */ | 3626 | /* We win! We can handle REPLACE the optimized way. */ |
| 3624 | 3627 | ||
| @@ -3672,16 +3675,16 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3672 | in a more optimized way. */ | 3675 | in a more optimized way. */ |
| 3673 | if (!NILP (replace) && ! replace_handled && BEGV < ZV) | 3676 | if (!NILP (replace) && ! replace_handled && BEGV < ZV) |
| 3674 | { | 3677 | { |
| 3675 | EMACS_INT same_at_start = BEGV_BYTE; | 3678 | ptrdiff_t same_at_start = BEGV_BYTE; |
| 3676 | EMACS_INT same_at_end = ZV_BYTE; | 3679 | ptrdiff_t same_at_end = ZV_BYTE; |
| 3677 | EMACS_INT same_at_start_charpos; | 3680 | ptrdiff_t same_at_start_charpos; |
| 3678 | EMACS_INT inserted_chars; | 3681 | ptrdiff_t inserted_chars; |
| 3679 | EMACS_INT overlap; | 3682 | ptrdiff_t overlap; |
| 3680 | EMACS_INT bufpos; | 3683 | ptrdiff_t bufpos; |
| 3681 | unsigned char *decoded; | 3684 | unsigned char *decoded; |
| 3682 | EMACS_INT temp; | 3685 | ptrdiff_t temp; |
| 3683 | EMACS_INT this = 0; | 3686 | ptrdiff_t this = 0; |
| 3684 | int this_count = SPECPDL_INDEX (); | 3687 | ptrdiff_t this_count = SPECPDL_INDEX (); |
| 3685 | int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); | 3688 | int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 3686 | Lisp_Object conversion_buffer; | 3689 | Lisp_Object conversion_buffer; |
| 3687 | 3690 | ||
| @@ -3705,8 +3708,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3705 | /* We read one bunch by one (READ_BUF_SIZE bytes) to allow | 3708 | /* We read one bunch by one (READ_BUF_SIZE bytes) to allow |
| 3706 | quitting while reading a huge while. */ | 3709 | quitting while reading a huge while. */ |
| 3707 | /* try is reserved in some compilers (Microsoft C) */ | 3710 | /* try is reserved in some compilers (Microsoft C) */ |
| 3708 | EMACS_INT trytry = min (total - how_much, | 3711 | int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed); |
| 3709 | READ_BUF_SIZE - unprocessed); | ||
| 3710 | 3712 | ||
| 3711 | /* Allow quitting out of the actual I/O. */ | 3713 | /* Allow quitting out of the actual I/O. */ |
| 3712 | immediate_quit = 1; | 3714 | immediate_quit = 1; |
| @@ -3897,13 +3899,13 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 3897 | /* Here, we don't do code conversion in the loop. It is done by | 3899 | /* Here, we don't do code conversion in the loop. It is done by |
| 3898 | decode_coding_gap after all data are read into the buffer. */ | 3900 | decode_coding_gap after all data are read into the buffer. */ |
| 3899 | { | 3901 | { |
| 3900 | EMACS_INT gap_size = GAP_SIZE; | 3902 | ptrdiff_t gap_size = GAP_SIZE; |
| 3901 | 3903 | ||
| 3902 | while (how_much < total) | 3904 | while (how_much < total) |
| 3903 | { | 3905 | { |
| 3904 | /* try is reserved in some compilers (Microsoft C) */ | 3906 | /* try is reserved in some compilers (Microsoft C) */ |
| 3905 | EMACS_INT trytry = min (total - how_much, READ_BUF_SIZE); | 3907 | int trytry = min (total - how_much, READ_BUF_SIZE); |
| 3906 | EMACS_INT this; | 3908 | ptrdiff_t this; |
| 3907 | 3909 | ||
| 3908 | if (not_regular) | 3910 | if (not_regular) |
| 3909 | { | 3911 | { |
| @@ -4022,7 +4024,7 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4022 | care of marker adjustment. By this way, we can run Lisp | 4024 | care of marker adjustment. By this way, we can run Lisp |
| 4023 | program safely before decoding the inserted text. */ | 4025 | program safely before decoding the inserted text. */ |
| 4024 | Lisp_Object unwind_data; | 4026 | Lisp_Object unwind_data; |
| 4025 | int count1 = SPECPDL_INDEX (); | 4027 | ptrdiff_t count1 = SPECPDL_INDEX (); |
| 4026 | 4028 | ||
| 4027 | unwind_data = Fcons (BVAR (current_buffer, enable_multibyte_characters), | 4029 | unwind_data = Fcons (BVAR (current_buffer, enable_multibyte_characters), |
| 4028 | Fcons (BVAR (current_buffer, undo_list), | 4030 | Fcons (BVAR (current_buffer, undo_list), |
| @@ -4143,7 +4145,8 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4143 | visit); | 4145 | visit); |
| 4144 | if (! NILP (insval)) | 4146 | if (! NILP (insval)) |
| 4145 | { | 4147 | { |
| 4146 | CHECK_NUMBER (insval); | 4148 | if (! RANGED_INTEGERP (0, insval, ZV - PT)) |
| 4149 | wrong_type_argument (intern ("inserted-chars"), insval); | ||
| 4147 | inserted = XFASTINT (insval); | 4150 | inserted = XFASTINT (insval); |
| 4148 | } | 4151 | } |
| 4149 | } | 4152 | } |
| @@ -4152,8 +4155,8 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4152 | if (inserted > 0) | 4155 | if (inserted > 0) |
| 4153 | { | 4156 | { |
| 4154 | /* Don't run point motion or modification hooks when decoding. */ | 4157 | /* Don't run point motion or modification hooks when decoding. */ |
| 4155 | int count1 = SPECPDL_INDEX (); | 4158 | ptrdiff_t count1 = SPECPDL_INDEX (); |
| 4156 | EMACS_INT old_inserted = inserted; | 4159 | ptrdiff_t old_inserted = inserted; |
| 4157 | specbind (Qinhibit_point_motion_hooks, Qt); | 4160 | specbind (Qinhibit_point_motion_hooks, Qt); |
| 4158 | specbind (Qinhibit_modification_hooks, Qt); | 4161 | specbind (Qinhibit_modification_hooks, Qt); |
| 4159 | 4162 | ||
| @@ -4165,7 +4168,8 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4165 | { | 4168 | { |
| 4166 | insval = call3 (Qformat_decode, | 4169 | insval = call3 (Qformat_decode, |
| 4167 | Qnil, make_number (inserted), visit); | 4170 | Qnil, make_number (inserted), visit); |
| 4168 | CHECK_NUMBER (insval); | 4171 | if (! RANGED_INTEGERP (0, insval, ZV - PT)) |
| 4172 | wrong_type_argument (intern ("inserted-chars"), insval); | ||
| 4169 | inserted = XFASTINT (insval); | 4173 | inserted = XFASTINT (insval); |
| 4170 | } | 4174 | } |
| 4171 | else | 4175 | else |
| @@ -4179,15 +4183,16 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4179 | Hence we temporarily save `point' and `inserted' here and | 4183 | Hence we temporarily save `point' and `inserted' here and |
| 4180 | restore `point' iff format-decode did not insert or delete | 4184 | restore `point' iff format-decode did not insert or delete |
| 4181 | any text. Otherwise we leave `point' at point-min. */ | 4185 | any text. Otherwise we leave `point' at point-min. */ |
| 4182 | EMACS_INT opoint = PT; | 4186 | ptrdiff_t opoint = PT; |
| 4183 | EMACS_INT opoint_byte = PT_BYTE; | 4187 | ptrdiff_t opoint_byte = PT_BYTE; |
| 4184 | EMACS_INT oinserted = ZV - BEGV; | 4188 | ptrdiff_t oinserted = ZV - BEGV; |
| 4185 | int ochars_modiff = CHARS_MODIFF; | 4189 | EMACS_INT ochars_modiff = CHARS_MODIFF; |
| 4186 | 4190 | ||
| 4187 | TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); | 4191 | TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); |
| 4188 | insval = call3 (Qformat_decode, | 4192 | insval = call3 (Qformat_decode, |
| 4189 | Qnil, make_number (oinserted), visit); | 4193 | Qnil, make_number (oinserted), visit); |
| 4190 | CHECK_NUMBER (insval); | 4194 | if (! RANGED_INTEGERP (0, insval, ZV - PT)) |
| 4195 | wrong_type_argument (intern ("inserted-chars"), insval); | ||
| 4191 | if (ochars_modiff == CHARS_MODIFF) | 4196 | if (ochars_modiff == CHARS_MODIFF) |
| 4192 | /* format_decode didn't modify buffer's characters => move | 4197 | /* format_decode didn't modify buffer's characters => move |
| 4193 | point back to position before inserted text and leave | 4198 | point back to position before inserted text and leave |
| @@ -4209,7 +4214,8 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4209 | insval = call1 (XCAR (p), make_number (inserted)); | 4214 | insval = call1 (XCAR (p), make_number (inserted)); |
| 4210 | if (!NILP (insval)) | 4215 | if (!NILP (insval)) |
| 4211 | { | 4216 | { |
| 4212 | CHECK_NUMBER (insval); | 4217 | if (! RANGED_INTEGERP (0, insval, ZV - PT)) |
| 4218 | wrong_type_argument (intern ("inserted-chars"), insval); | ||
| 4213 | inserted = XFASTINT (insval); | 4219 | inserted = XFASTINT (insval); |
| 4214 | } | 4220 | } |
| 4215 | } | 4221 | } |
| @@ -4217,16 +4223,17 @@ variable `last-coding-system-used' to the coding system actually used. */) | |||
| 4217 | { | 4223 | { |
| 4218 | /* For the rationale of this see the comment on | 4224 | /* For the rationale of this see the comment on |
| 4219 | format-decode above. */ | 4225 | format-decode above. */ |
| 4220 | EMACS_INT opoint = PT; | 4226 | ptrdiff_t opoint = PT; |
| 4221 | EMACS_INT opoint_byte = PT_BYTE; | 4227 | ptrdiff_t opoint_byte = PT_BYTE; |
| 4222 | EMACS_INT oinserted = ZV - BEGV; | 4228 | ptrdiff_t oinserted = ZV - BEGV; |
| 4223 | int ochars_modiff = CHARS_MODIFF; | 4229 | EMACS_INT ochars_modiff = CHARS_MODIFF; |
| 4224 | 4230 | ||
| 4225 | TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); | 4231 | TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); |
| 4226 | insval = call1 (XCAR (p), make_number (oinserted)); | 4232 | insval = call1 (XCAR (p), make_number (oinserted)); |
| 4227 | if (!NILP (insval)) | 4233 | if (!NILP (insval)) |
| 4228 | { | 4234 | { |
| 4229 | CHECK_NUMBER (insval); | 4235 | if (! RANGED_INTEGERP (0, insval, ZV - PT)) |
| 4236 | wrong_type_argument (intern ("inserted-chars"), insval); | ||
| 4230 | if (ochars_modiff == CHARS_MODIFF) | 4237 | if (ochars_modiff == CHARS_MODIFF) |
| 4231 | /* after_insert_file_functions didn't modify | 4238 | /* after_insert_file_functions didn't modify |
| 4232 | buffer's characters => move point back to | 4239 | buffer's characters => move point back to |
| @@ -4458,7 +4465,7 @@ This calls `write-region-annotate-functions' at the start, and | |||
| 4458 | int save_errno = 0; | 4465 | int save_errno = 0; |
| 4459 | const char *fn; | 4466 | const char *fn; |
| 4460 | struct stat st; | 4467 | struct stat st; |
| 4461 | int count = SPECPDL_INDEX (); | 4468 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4462 | int count1; | 4469 | int count1; |
| 4463 | Lisp_Object handler; | 4470 | Lisp_Object handler; |
| 4464 | Lisp_Object visit_file; | 4471 | Lisp_Object visit_file; |
| @@ -4856,13 +4863,13 @@ build_annotations (Lisp_Object start, Lisp_Object end) | |||
| 4856 | The return value is negative in case of system call failure. */ | 4863 | The return value is negative in case of system call failure. */ |
| 4857 | 4864 | ||
| 4858 | static int | 4865 | static int |
| 4859 | a_write (int desc, Lisp_Object string, EMACS_INT pos, | 4866 | a_write (int desc, Lisp_Object string, ptrdiff_t pos, |
| 4860 | register EMACS_INT nchars, Lisp_Object *annot, | 4867 | register ptrdiff_t nchars, Lisp_Object *annot, |
| 4861 | struct coding_system *coding) | 4868 | struct coding_system *coding) |
| 4862 | { | 4869 | { |
| 4863 | Lisp_Object tem; | 4870 | Lisp_Object tem; |
| 4864 | EMACS_INT nextpos; | 4871 | ptrdiff_t nextpos; |
| 4865 | EMACS_INT lastpos = pos + nchars; | 4872 | ptrdiff_t lastpos = pos + nchars; |
| 4866 | 4873 | ||
| 4867 | while (NILP (*annot) || CONSP (*annot)) | 4874 | while (NILP (*annot) || CONSP (*annot)) |
| 4868 | { | 4875 | { |
| @@ -4902,7 +4909,7 @@ a_write (int desc, Lisp_Object string, EMACS_INT pos, | |||
| 4902 | are indexes to the string STRING. */ | 4909 | are indexes to the string STRING. */ |
| 4903 | 4910 | ||
| 4904 | static int | 4911 | static int |
| 4905 | e_write (int desc, Lisp_Object string, EMACS_INT start, EMACS_INT end, | 4912 | e_write (int desc, Lisp_Object string, ptrdiff_t start, ptrdiff_t end, |
| 4906 | struct coding_system *coding) | 4913 | struct coding_system *coding) |
| 4907 | { | 4914 | { |
| 4908 | if (STRINGP (string)) | 4915 | if (STRINGP (string)) |
| @@ -4934,8 +4941,8 @@ e_write (int desc, Lisp_Object string, EMACS_INT start, EMACS_INT end, | |||
| 4934 | } | 4941 | } |
| 4935 | else | 4942 | else |
| 4936 | { | 4943 | { |
| 4937 | EMACS_INT start_byte = CHAR_TO_BYTE (start); | 4944 | ptrdiff_t start_byte = CHAR_TO_BYTE (start); |
| 4938 | EMACS_INT end_byte = CHAR_TO_BYTE (end); | 4945 | ptrdiff_t end_byte = CHAR_TO_BYTE (end); |
| 4939 | 4946 | ||
| 4940 | coding->src_multibyte = (end - start) < (end_byte - start_byte); | 4947 | coding->src_multibyte = (end - start) < (end_byte - start_byte); |
| 4941 | if (CODING_REQUIRE_ENCODING (coding)) | 4948 | if (CODING_REQUIRE_ENCODING (coding)) |
| @@ -5219,7 +5226,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5219 | int do_handled_files; | 5226 | int do_handled_files; |
| 5220 | Lisp_Object oquit; | 5227 | Lisp_Object oquit; |
| 5221 | FILE *stream = NULL; | 5228 | FILE *stream = NULL; |
| 5222 | int count = SPECPDL_INDEX (); | 5229 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5223 | int orig_minibuffer_auto_raise = minibuffer_auto_raise; | 5230 | int orig_minibuffer_auto_raise = minibuffer_auto_raise; |
| 5224 | int old_message_p = 0; | 5231 | int old_message_p = 0; |
| 5225 | struct gcpro gcpro1, gcpro2; | 5232 | struct gcpro gcpro1, gcpro2; |
| @@ -5339,7 +5346,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5339 | EMACS_GET_TIME (before_time); | 5346 | EMACS_GET_TIME (before_time); |
| 5340 | 5347 | ||
| 5341 | /* If we had a failure, don't try again for 20 minutes. */ | 5348 | /* If we had a failure, don't try again for 20 minutes. */ |
| 5342 | if (b->auto_save_failure_time >= 0 | 5349 | if (b->auto_save_failure_time > 0 |
| 5343 | && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200) | 5350 | && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200) |
| 5344 | continue; | 5351 | continue; |
| 5345 | 5352 | ||
| @@ -5418,7 +5425,7 @@ No auto-save file will be written until the buffer changes again. */) | |||
| 5418 | they're not autosaved. */ | 5425 | they're not autosaved. */ |
| 5419 | BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF; | 5426 | BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF; |
| 5420 | XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); | 5427 | XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); |
| 5421 | current_buffer->auto_save_failure_time = -1; | 5428 | current_buffer->auto_save_failure_time = 0; |
| 5422 | return Qnil; | 5429 | return Qnil; |
| 5423 | } | 5430 | } |
| 5424 | 5431 | ||
| @@ -5427,7 +5434,7 @@ DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure, | |||
| 5427 | doc: /* Clear any record of a recent auto-save failure in the current buffer. */) | 5434 | doc: /* Clear any record of a recent auto-save failure in the current buffer. */) |
| 5428 | (void) | 5435 | (void) |
| 5429 | { | 5436 | { |
| 5430 | current_buffer->auto_save_failure_time = -1; | 5437 | current_buffer->auto_save_failure_time = 0; |
| 5431 | return Qnil; | 5438 | return Qnil; |
| 5432 | } | 5439 | } |
| 5433 | 5440 | ||