emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/markers-as-gap-array b5a3122e899: Misc: Fix some assertion failu


From: Stefan Monnier
Subject: scratch/markers-as-gap-array b5a3122e899: Misc: Fix some assertion failures
Date: Wed, 3 Jul 2024 19:43:38 -0400 (EDT)

branch: scratch/markers-as-gap-array
commit b5a3122e899cf70927c98cf392cdeead0013a9c1
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Misc: Fix some assertion failures
    
    * src/insdel.c (adjust_markers_bytepos): Remove left over var.
    
    * src/marker.c (markers_adjust_for_replace)
    (markers_adjust_for_delete): Refine assertion.
---
 src/insdel.c | 1 -
 src/marker.c | 8 ++++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/insdel.c b/src/insdel.c
index efe688a325e..9cb40cac844 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -347,7 +347,6 @@ void
 adjust_markers_bytepos (ptrdiff_t from, ptrdiff_t from_byte,
                        ptrdiff_t to, ptrdiff_t to_byte, int to_z)
 {
-  register struct Lisp_Marker *m;
   ptrdiff_t beg = from, begbyte = from_byte;
 
   adjust_suspend_auto_hscroll (from, to);
diff --git a/src/marker.c b/src/marker.c
index a9173a642bc..4552de549d1 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -342,7 +342,11 @@ markers_adjust_for_replace (struct Lisp_Markers *t,
                            ptrdiff_t old_chars, ptrdiff_t old_bytes,
                            ptrdiff_t new_chars, ptrdiff_t new_bytes)
 {
-  eassert (old_chars > 0);
+  /* If old_chars == 0 and new_chars > 0, this is an insertion, which
+     requires more care with 'insertion_type' than what we do here.
+     FIXME: Apparently we're sometimes called incorrectly, e.g. during
+     src/search-tests and lisp/replace-tests.  */
+  eassert (old_chars > 0 || new_chars == 0);
   markers_move_gap_to_charpos (t, from);
   m_index_t i = t->gap_end;
   m_index_t size = t->size;
@@ -367,7 +371,7 @@ markers_adjust_for_delete (struct Lisp_Markers *t,
                           ptrdiff_t from, ptrdiff_t from_byte,
                           ptrdiff_t to, ptrdiff_t to_byte)
 {
-  eassert (to > from);
+  eassert (to >= from);
   markers_adjust_for_replace (t, from, from_byte,
                              to - from, to_byte - from_byte,
                              0, 0);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]