diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-01-31 10:29:50 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-01-31 10:31:43 -0800 |
commit | 05d2fc7170fb66a87601b1c76ddae2c1b7b4b934 (patch) | |
tree | 217ddd3a45ea611069d85ac13e22e525bb965996 /src/buffer.h | |
parent | a68eee50eb515b28b448894299334afced26ef78 (diff) | |
download | emacs-05d2fc7170fb66a87601b1c76ddae2c1b7b4b934.tar.gz |
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.h | 18 |
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 ptrdiff_t gpt_byte; /* Byte pos of gap in buffer. */ ptrdiff_t z_byte; /* Byte pos of end of buffer. */ ptrdiff_t gap_size; /* Size of buffer's gap. */ - EMACS_INT modiff; /* This counts buffer-modification events + modiff_count modiff; /* This counts buffer-modification events for this buffer. It is incremented for each such event, and never otherwise changed. */ - EMACS_INT chars_modiff; /* This is modified with character change + modiff_count chars_modiff; /* This is modified with character change events for this buffer. It is set to modiff for each such event, and never otherwise changed. */ - EMACS_INT save_modiff; /* Previous value of modiff, as of last + modiff_count save_modiff; /* Previous value of modiff, as of last time buffer visited or saved a file. */ - EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ + modiff_count overlay_modiff; /* Counts modifications to overlays. */ - EMACS_INT compact; /* Set to modiff each time when compact_buffer + modiff_count compact; /* Set to modiff each time when compact_buffer is called for this buffer. */ /* Minimum value of GPT - BEG since last redisplay that finished. */ @@ -446,12 +446,12 @@ struct buffer_text /* MODIFF as of last redisplay that finished; if it matches MODIFF, beg_unchanged and end_unchanged contain no useful information. */ - EMACS_INT unchanged_modified; + modiff_count unchanged_modified; /* BUF_OVERLAY_MODIFF of current buffer, as of last redisplay that finished; if it matches BUF_OVERLAY_MODIFF, beg_unchanged and end_unchanged contain no useful information. */ - EMACS_INT overlay_unchanged_modified; + modiff_count overlay_unchanged_modified; /* Properties of this buffer's text. */ INTERVAL intervals; @@ -812,11 +812,11 @@ struct buffer off_t modtime_size; /* The value of text->modiff at the last auto-save. */ - EMACS_INT auto_save_modified; + modiff_count auto_save_modified; /* The value of text->modiff at the last display error. Redisplay of this buffer is inhibited until it changes again. */ - EMACS_INT display_error_modiff; + modiff_count display_error_modiff; /* The time at which we detected a failure to auto-save, Or 0 if we didn't have a failure. */ |