aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
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/buffer.h
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/buffer.h')
-rw-r--r--src/buffer.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 82cc2ebfbf9..d3528ac50e9 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -422,20 +422,20 @@ struct buffer_text
422 ptrdiff_t gpt_byte; /* Byte pos of gap in buffer. */ 422 ptrdiff_t gpt_byte; /* Byte pos of gap in buffer. */
423 ptrdiff_t z_byte; /* Byte pos of end of buffer. */ 423 ptrdiff_t z_byte; /* Byte pos of end of buffer. */
424 ptrdiff_t gap_size; /* Size of buffer's gap. */ 424 ptrdiff_t gap_size; /* Size of buffer's gap. */
425 EMACS_INT modiff; /* This counts buffer-modification events 425 modiff_count modiff; /* This counts buffer-modification events
426 for this buffer. It is incremented for 426 for this buffer. It is incremented for
427 each such event, and never otherwise 427 each such event, and never otherwise
428 changed. */ 428 changed. */
429 EMACS_INT chars_modiff; /* This is modified with character change 429 modiff_count chars_modiff; /* This is modified with character change
430 events for this buffer. It is set to 430 events for this buffer. It is set to
431 modiff for each such event, and never 431 modiff for each such event, and never
432 otherwise changed. */ 432 otherwise changed. */
433 EMACS_INT save_modiff; /* Previous value of modiff, as of last 433 modiff_count save_modiff; /* Previous value of modiff, as of last
434 time buffer visited or saved a file. */ 434 time buffer visited or saved a file. */
435 435
436 EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ 436 modiff_count overlay_modiff; /* Counts modifications to overlays. */
437 437
438 EMACS_INT compact; /* Set to modiff each time when compact_buffer 438 modiff_count compact; /* Set to modiff each time when compact_buffer
439 is called for this buffer. */ 439 is called for this buffer. */
440 440
441 /* Minimum value of GPT - BEG since last redisplay that finished. */ 441 /* Minimum value of GPT - BEG since last redisplay that finished. */
@@ -446,12 +446,12 @@ struct buffer_text
446 446
447 /* MODIFF as of last redisplay that finished; if it matches MODIFF, 447 /* MODIFF as of last redisplay that finished; if it matches MODIFF,
448 beg_unchanged and end_unchanged contain no useful information. */ 448 beg_unchanged and end_unchanged contain no useful information. */
449 EMACS_INT unchanged_modified; 449 modiff_count unchanged_modified;
450 450
451 /* BUF_OVERLAY_MODIFF of current buffer, as of last redisplay that 451 /* BUF_OVERLAY_MODIFF of current buffer, as of last redisplay that
452 finished; if it matches BUF_OVERLAY_MODIFF, beg_unchanged and 452 finished; if it matches BUF_OVERLAY_MODIFF, beg_unchanged and
453 end_unchanged contain no useful information. */ 453 end_unchanged contain no useful information. */
454 EMACS_INT overlay_unchanged_modified; 454 modiff_count overlay_unchanged_modified;
455 455
456 /* Properties of this buffer's text. */ 456 /* Properties of this buffer's text. */
457 INTERVAL intervals; 457 INTERVAL intervals;
@@ -812,11 +812,11 @@ struct buffer
812 off_t modtime_size; 812 off_t modtime_size;
813 813
814 /* The value of text->modiff at the last auto-save. */ 814 /* The value of text->modiff at the last auto-save. */
815 EMACS_INT auto_save_modified; 815 modiff_count auto_save_modified;
816 816
817 /* The value of text->modiff at the last display error. 817 /* The value of text->modiff at the last display error.
818 Redisplay of this buffer is inhibited until it changes again. */ 818 Redisplay of this buffer is inhibited until it changes again. */
819 EMACS_INT display_error_modiff; 819 modiff_count display_error_modiff;
820 820
821 /* The time at which we detected a failure to auto-save, 821 /* The time at which we detected a failure to auto-save,
822 Or 0 if we didn't have a failure. */ 822 Or 0 if we didn't have a failure. */