]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug that created negative-length intervals.
authorAndreas Schwab <schwab@linux-m68k.org>
Wed, 18 Jul 2012 21:33:37 +0000 (14:33 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 Jul 2012 21:33:37 +0000 (14:33 -0700)
* intervals.c (merge_interval_right, merge_interval_left):
Do not zero out this interval if it is absorbed by its children,
as this interval's total length doesn't change in that case.  See
<http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00403.html>.

src/ChangeLog
src/intervals.c

index d202e1d3f38ab25c541637c05ec00aec27c27688..5a7a981926beafee8c4de4133249312687efc8b9 100644 (file)
@@ -1,3 +1,11 @@
+2012-07-18  Andreas Schwab  <schwab@linux-m68k.org>
+
+       Fix bug that created negative-length intervals.
+       * intervals.c (merge_interval_right, merge_interval_left):
+       Do not zero out this interval if it is absorbed by its children,
+       as this interval's total length doesn't change in that case.  See
+       <http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00403.html>.
+
 2012-07-18  Paul Eggert  <eggert@cs.ucla.edu>
 
        * alloc.c (Fmake_bool_vector): Fix off-by-8 bug
index 5b8d44e8ced8d2534d4974ca2ad214fb4fb2d3e7..cd1254b5e46d4d0f15b5b812051c9122f94ad986 100644 (file)
@@ -1391,10 +1391,6 @@ merge_interval_right (register INTERVAL i)
   register ptrdiff_t absorb = LENGTH (i);
   register INTERVAL successor;
 
-  /* Zero out this interval.  */
-  i->total_length -= absorb;
-  CHECK_TOTAL_LENGTH (i);
-
   /* Find the succeeding interval.  */
   if (! NULL_RIGHT_CHILD (i))      /* It's below us.  Add absorb
                                      as we descend.  */
@@ -1413,6 +1409,10 @@ merge_interval_right (register INTERVAL i)
       return successor;
     }
 
+  /* Zero out this interval.  */
+  i->total_length -= absorb;
+  CHECK_TOTAL_LENGTH (i);
+
   successor = i;
   while (! NULL_PARENT (successor))       /* It's above us.  Subtract as
                                              we ascend.  */
@@ -1447,10 +1447,6 @@ merge_interval_left (register INTERVAL i)
   register ptrdiff_t absorb = LENGTH (i);
   register INTERVAL predecessor;
 
-  /* Zero out this interval.  */
-  i->total_length -= absorb;
-  CHECK_TOTAL_LENGTH (i);
-
   /* Find the preceding interval.  */
   if (! NULL_LEFT_CHILD (i))   /* It's below us. Go down,
                                   adding ABSORB as we go.  */
@@ -1469,9 +1465,13 @@ merge_interval_left (register INTERVAL i)
       return predecessor;
     }
 
+  /* Zero out this interval.  */
+  i->total_length -= absorb;
+  CHECK_TOTAL_LENGTH (i);
+
   predecessor = i;
   while (! NULL_PARENT (predecessor))  /* It's above us.  Go up,
-                                  subtracting ABSORB.  */
+                                          subtracting ABSORB.  */
     {
       if (AM_RIGHT_CHILD (predecessor))
        {