diff options
| author | Paul Eggert | 2019-01-31 10:29:50 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-01-31 10:31:43 -0800 |
| commit | 05d2fc7170fb66a87601b1c76ddae2c1b7b4b934 (patch) | |
| tree | 217ddd3a45ea611069d85ac13e22e525bb965996 /src/editfns.c | |
| parent | a68eee50eb515b28b448894299334afced26ef78 (diff) | |
| download | emacs-05d2fc7170fb66a87601b1c76ddae2c1b7b4b934.tar.gz emacs-05d2fc7170fb66a87601b1c76ddae2c1b7b4b934.zip | |
Widen modiff counts to avoid wraparound
Widen modification counts to at least 64 bits, to make
wraparound practically impossible.
* doc/lispref/buffers.texi (Buffer Modification):
Don’t say the modification-count can wrap around.
* src/buffer.c (Frestore_buffer_modified_p, Fbuffer_swap_text)
(modify_overlay):
* src/insdel.c (insert_1_both, insert_from_string_1)
(insert_from_gap, insert_from_buffer_1)
(adjust_after_replace, replace_range, replace_range_2)
(del_range_2, modify_text):
* src/textprop.c (modify_text_properties):
Use modiff_incr instead of incrementing directly.
(Fbuffer_modified_tick, Fbuffer_chars_modified_tick):
Don’t assume modification counts fit into fixnums.
* src/buffer.h (struct buffer_text, struct buffer):
* src/cmds.c (internal_self_insert):
* src/fileio.c (Finsert_file_contents):
* src/indent.c (last_known_column_modified):
* src/keyboard.c (command_loop_1):
* src/marker.c (cached_modiff):
* src/syntax.c (find_start_modiff, parse_sexp_propertize)
(find_defun_start):
* src/window.h (struct window):
Use modiff_count for modification counts.
* src/editfns.c (Fsubst_char_in_region):
Copy instead of incrementing modification counts,
since integer overflow checking is not needed here.
* src/lisp.h (modiff_count): New type.
(modiff_incr, modiff_to_integer): New inline functions.
* src/pdumper.c (dump_buffer): Update hash.
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c index 3edfd1dc201..360cdbe02ee 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2291,10 +2291,11 @@ Both characters must have the same length of multi-byte form. */) | |||
| 2291 | 2291 | ||
| 2292 | if (! NILP (noundo)) | 2292 | if (! NILP (noundo)) |
| 2293 | { | 2293 | { |
| 2294 | if (MODIFF - 1 == SAVE_MODIFF) | 2294 | modiff_count m = MODIFF; |
| 2295 | SAVE_MODIFF++; | 2295 | if (SAVE_MODIFF == m - 1) |
| 2296 | if (MODIFF - 1 == BUF_AUTOSAVE_MODIFF (current_buffer)) | 2296 | SAVE_MODIFF = m; |
| 2297 | BUF_AUTOSAVE_MODIFF (current_buffer)++; | 2297 | if (BUF_AUTOSAVE_MODIFF (current_buffer) == m - 1) |
| 2298 | BUF_AUTOSAVE_MODIFF (current_buffer) = m; | ||
| 2298 | } | 2299 | } |
| 2299 | 2300 | ||
| 2300 | /* The before-change-function may have moved the gap | 2301 | /* The before-change-function may have moved the gap |