aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorPaul Eggert2019-01-31 10:29:50 -0800
committerPaul Eggert2019-01-31 10:31:43 -0800
commit05d2fc7170fb66a87601b1c76ddae2c1b7b4b934 (patch)
tree217ddd3a45ea611069d85ac13e22e525bb965996 /src/fileio.c
parenta68eee50eb515b28b448894299334afced26ef78 (diff)
downloademacs-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/fileio.c')
-rw-r--r--src/fileio.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c
index aececcda305..55c9f26b753 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4618,7 +4618,7 @@ by calling `format-decode', which see. */)
4618 ptrdiff_t opoint = PT; 4618 ptrdiff_t opoint = PT;
4619 ptrdiff_t opoint_byte = PT_BYTE; 4619 ptrdiff_t opoint_byte = PT_BYTE;
4620 ptrdiff_t oinserted = ZV - BEGV; 4620 ptrdiff_t oinserted = ZV - BEGV;
4621 EMACS_INT ochars_modiff = CHARS_MODIFF; 4621 modiff_count ochars_modiff = CHARS_MODIFF;
4622 4622
4623 TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); 4623 TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
4624 insval = call3 (Qformat_decode, 4624 insval = call3 (Qformat_decode,
@@ -4658,7 +4658,7 @@ by calling `format-decode', which see. */)
4658 ptrdiff_t opoint = PT; 4658 ptrdiff_t opoint = PT;
4659 ptrdiff_t opoint_byte = PT_BYTE; 4659 ptrdiff_t opoint_byte = PT_BYTE;
4660 ptrdiff_t oinserted = ZV - BEGV; 4660 ptrdiff_t oinserted = ZV - BEGV;
4661 EMACS_INT ochars_modiff = CHARS_MODIFF; 4661 modiff_count ochars_modiff = CHARS_MODIFF;
4662 4662
4663 TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); 4663 TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
4664 insval = call1 (XCAR (p), make_fixnum (oinserted)); 4664 insval = call1 (XCAR (p), make_fixnum (oinserted));