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/syntax.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/syntax.c')
| -rw-r--r-- | src/syntax.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/syntax.c b/src/syntax.c index 4616ae296f8..dd2f56f2cfa 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -175,7 +175,7 @@ static ptrdiff_t find_start_value; | |||
| 175 | static ptrdiff_t find_start_value_byte; | 175 | static ptrdiff_t find_start_value_byte; |
| 176 | static struct buffer *find_start_buffer; | 176 | static struct buffer *find_start_buffer; |
| 177 | static ptrdiff_t find_start_begv; | 177 | static ptrdiff_t find_start_begv; |
| 178 | static EMACS_INT find_start_modiff; | 178 | static modiff_count find_start_modiff; |
| 179 | 179 | ||
| 180 | 180 | ||
| 181 | static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool); | 181 | static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool); |
| @@ -489,7 +489,7 @@ parse_sexp_propertize (ptrdiff_t charpos) | |||
| 489 | if (syntax_propertize__done <= charpos | 489 | if (syntax_propertize__done <= charpos |
| 490 | && syntax_propertize__done < zv) | 490 | && syntax_propertize__done < zv) |
| 491 | { | 491 | { |
| 492 | EMACS_INT modiffs = CHARS_MODIFF; | 492 | modiff_count modiffs = CHARS_MODIFF; |
| 493 | safe_call1 (Qinternal__syntax_propertize, | 493 | safe_call1 (Qinternal__syntax_propertize, |
| 494 | make_fixnum (min (zv, 1 + charpos))); | 494 | make_fixnum (min (zv, 1 + charpos))); |
| 495 | if (modiffs != CHARS_MODIFF) | 495 | if (modiffs != CHARS_MODIFF) |
| @@ -608,7 +608,7 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) | |||
| 608 | 608 | ||
| 609 | if (!NILP (Vcomment_use_syntax_ppss)) | 609 | if (!NILP (Vcomment_use_syntax_ppss)) |
| 610 | { | 610 | { |
| 611 | EMACS_INT modiffs = CHARS_MODIFF; | 611 | modiff_count modiffs = CHARS_MODIFF; |
| 612 | Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos)); | 612 | Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos)); |
| 613 | if (modiffs != CHARS_MODIFF) | 613 | if (modiffs != CHARS_MODIFF) |
| 614 | error ("syntax-ppss modified the buffer!"); | 614 | error ("syntax-ppss modified the buffer!"); |