emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109503: Check total length of interv


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109503: Check total length of intervals with eassert.
Date: Wed, 08 Aug 2012 09:23:02 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109503
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2012-08-08 09:23:02 +0400
message:
  Check total length of intervals with eassert.
  * intervals.h (CHECK_TOTAL_LENGTH): Remove.
  * intervals.c: Change all users to eassert.
modified:
  src/ChangeLog
  src/intervals.c
  src/intervals.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-07 16:53:38 +0000
+++ b/src/ChangeLog     2012-08-08 05:23:02 +0000
@@ -1,3 +1,9 @@
+2012-08-08  Dmitry Antipov  <address@hidden>
+
+       Check total length of intervals with eassert.
+       * intervals.h (CHECK_TOTAL_LENGTH): Remove.
+       * intervals.c: Change all users to eassert.
+
 2012-08-07  Eli Zaretskii  <address@hidden>
 
        * .gdbinit (xframe, xwindow, nextcons, xcar, xcdr, xlist): Rename

=== modified file 'src/intervals.c'
--- a/src/intervals.c   2012-08-07 11:28:41 +0000
+++ b/src/intervals.c   2012-08-08 05:23:02 +0000
@@ -76,14 +76,14 @@
     {
       new->total_length = (BUF_Z (XBUFFER (parent))
                           - BUF_BEG (XBUFFER (parent)));
-      CHECK_TOTAL_LENGTH (new);
+      eassert (0 <= TOTAL_LENGTH (new));
       BUF_INTERVALS (XBUFFER (parent)) = new;
       new->position = BEG;
     }
   else if (STRINGP (parent))
     {
       new->total_length = SCHARS (parent);
-      CHECK_TOTAL_LENGTH (new);
+      eassert (0 <= TOTAL_LENGTH (new));
       STRING_SET_INTERVALS (parent, new);
       new->position = 0;
     }
@@ -338,11 +338,11 @@
 
   /* A's total length is decreased by the length of B and its left child.  */
   interval->total_length -= B->total_length - LEFT_TOTAL_LENGTH (interval);
-  CHECK_TOTAL_LENGTH (interval);
+  eassert (0 <= TOTAL_LENGTH (interval));
 
   /* B must have the same total length of A.  */
   B->total_length = old_total;
-  CHECK_TOTAL_LENGTH (B);
+  eassert (0 <= TOTAL_LENGTH (B));
 
   return B;
 }
@@ -385,11 +385,11 @@
 
   /* A's total length is decreased by the length of B and its right child.  */
   interval->total_length -= B->total_length - RIGHT_TOTAL_LENGTH (interval);
-  CHECK_TOTAL_LENGTH (interval);
+  eassert (0 <= TOTAL_LENGTH (interval));
 
   /* B must have the same total length of A.  */
   B->total_length = old_total;
-  CHECK_TOTAL_LENGTH (B);
+  eassert (0 <= TOTAL_LENGTH (B));
 
   return B;
 }
@@ -513,7 +513,7 @@
     {
       interval_set_right (interval, new);
       new->total_length = new_length;
-      CHECK_TOTAL_LENGTH (new);
+      eassert (0 <= TOTAL_LENGTH (new));
     }
   else
     {
@@ -522,7 +522,7 @@
       interval_set_parent (interval->right, new);
       interval_set_right (interval, new);
       new->total_length = new_length + new->right->total_length;
-      CHECK_TOTAL_LENGTH (new);
+      eassert (0 <= TOTAL_LENGTH (new));
       balance_an_interval (new);
     }
 
@@ -558,7 +558,7 @@
     {
       interval_set_left (interval, new);
       new->total_length = new_length;
-      CHECK_TOTAL_LENGTH (new);
+      eassert (0 <= TOTAL_LENGTH (new));
     }
   else
     {
@@ -567,7 +567,7 @@
       interval_set_parent (new->left, new);
       interval_set_left (interval, new);
       new->total_length = new_length + new->left->total_length;
-      CHECK_TOTAL_LENGTH (new);
+      eassert (0 <= TOTAL_LENGTH (new));
       balance_an_interval (new);
     }
 
@@ -918,7 +918,7 @@
       for (temp = prev ? prev : i; temp; temp = INTERVAL_PARENT_OR_NULL (temp))
        {
          temp->total_length += length;
-         CHECK_TOTAL_LENGTH (temp);
+         eassert (0 <= TOTAL_LENGTH (temp));
          temp = balance_possible_root_interval (temp);
        }
 
@@ -975,7 +975,7 @@
       for (temp = i; temp; temp = INTERVAL_PARENT_OR_NULL (temp))
        {
          temp->total_length += length;
-         CHECK_TOTAL_LENGTH (temp);
+         eassert (0 <= TOTAL_LENGTH (temp));
          temp = balance_possible_root_interval (temp);
        }
     }
@@ -1178,7 +1178,7 @@
       this = this->left;
       this->total_length += migrate_amt;
     }
-  CHECK_TOTAL_LENGTH (this);
+  eassert (0 <= TOTAL_LENGTH (this));
   interval_set_left (this, migrate);
   interval_set_parent (migrate, this);
 
@@ -1260,7 +1260,7 @@
                                                         relative_position,
                                                         amount);
       tree->total_length -= subtract;
-      CHECK_TOTAL_LENGTH (tree);
+      eassert (0 <= TOTAL_LENGTH (tree));
       return subtract;
     }
   /* Right branch.  */
@@ -1275,7 +1275,7 @@
                                               relative_position,
                                               amount);
       tree->total_length -= subtract;
-      CHECK_TOTAL_LENGTH (tree);
+      eassert (0 <= TOTAL_LENGTH (tree));
       return subtract;
     }
   /* Here -- this node.  */
@@ -1290,7 +1290,7 @@
        amount = my_amount;
 
       tree->total_length -= amount;
-      CHECK_TOTAL_LENGTH (tree);
+      eassert (0 <= TOTAL_LENGTH (tree));
       if (LENGTH (tree) == 0)
        delete_interval (tree);
 
@@ -1332,7 +1332,7 @@
   if (ONLY_INTERVAL_P (tree))
     {
       tree->total_length -= length;
-      CHECK_TOTAL_LENGTH (tree);
+      eassert (0 <= TOTAL_LENGTH (tree));
       return;
     }
 
@@ -1398,19 +1398,19 @@
       while (! NULL_LEFT_CHILD (successor))
        {
          successor->total_length += absorb;
-         CHECK_TOTAL_LENGTH (successor);
+         eassert (0 <= TOTAL_LENGTH (successor));
          successor = successor->left;
        }
 
       successor->total_length += absorb;
-      CHECK_TOTAL_LENGTH (successor);
+      eassert (0 <= TOTAL_LENGTH (successor));
       delete_interval (i);
       return successor;
     }
 
   /* Zero out this interval.  */
   i->total_length -= absorb;
-  CHECK_TOTAL_LENGTH (i);
+  eassert (0 <= TOTAL_LENGTH (i));
 
   successor = i;
   while (! NULL_PARENT (successor))       /* It's above us.  Subtract as
@@ -1425,7 +1425,7 @@
 
       successor = INTERVAL_PARENT (successor);
       successor->total_length -= absorb;
-      CHECK_TOTAL_LENGTH (successor);
+      eassert (0 <= TOTAL_LENGTH (successor));
     }
 
   /* This must be the rightmost or last interval and cannot
@@ -1454,19 +1454,19 @@
       while (! NULL_RIGHT_CHILD (predecessor))
        {
          predecessor->total_length += absorb;
-         CHECK_TOTAL_LENGTH (predecessor);
+         eassert (0 <= TOTAL_LENGTH (predecessor));
          predecessor = predecessor->right;
        }
 
       predecessor->total_length += absorb;
-      CHECK_TOTAL_LENGTH (predecessor);
+      eassert (0 <= TOTAL_LENGTH (predecessor));
       delete_interval (i);
       return predecessor;
     }
 
   /* Zero out this interval.  */
   i->total_length -= absorb;
-  CHECK_TOTAL_LENGTH (i);
+  eassert (0 <= TOTAL_LENGTH (i));
 
   predecessor = i;
   while (! NULL_PARENT (predecessor))  /* It's above us.  Go up,
@@ -1481,7 +1481,7 @@
 
       predecessor = INTERVAL_PARENT (predecessor);
       predecessor->total_length -= absorb;
-      CHECK_TOTAL_LENGTH (predecessor);
+      eassert (0 <= TOTAL_LENGTH (predecessor));
     }
 
   /* This must be the leftmost or first interval and cannot
@@ -2235,7 +2235,7 @@
   new->position = 0;
   got = (LENGTH (i) - (start - i->position));
   new->total_length = length;
-  CHECK_TOTAL_LENGTH (new);
+  eassert (0 <= TOTAL_LENGTH (new));
   copy_properties (i, new);
 
   t = new;
@@ -2318,7 +2318,7 @@
     i->total_length = end - start;
   else
     i->total_length = end_byte - start_byte;
-  CHECK_TOTAL_LENGTH (i);
+  eassert (0 <= TOTAL_LENGTH (i));
 
   if (TOTAL_LENGTH (i) == 0)
     {

=== modified file 'src/intervals.h'
--- a/src/intervals.h   2012-08-07 11:28:41 +0000
+++ b/src/intervals.h   2012-08-08 05:23:02 +0000
@@ -191,15 +191,6 @@
 #define INTERVAL_PARENT_OR_NULL(i) \
    (INTERVAL_HAS_PARENT (i) ? INTERVAL_PARENT (i) : 0)
 
-/* Abort if interval I's size is negative.  */
-#define CHECK_TOTAL_LENGTH(i)               \
-  do                                        \
-    {                                       \
-      if ((i)->total_length < 0)            \
-       abort ();                            \
-    }                                       \
-  while (0)
-
 /* Reset this interval to its vanilla, or no-property state.  */
 #define RESET_INTERVAL(i)                    \
 {                                            \


reply via email to

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