Merge from emacs-24; up to 2012-12-05T00:13:56Z!yamaoka@jpl.org
[bpt/emacs.git] / src / textprop.c
index f9339c6..13d772f 100644 (file)
@@ -17,16 +17,13 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
-#include <setjmp.h>
+
 #include "lisp.h"
 #include "intervals.h"
+#include "character.h"
 #include "buffer.h"
 #include "window.h"
 
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
 /* Test for membership, allowing for t (actually any non-cons) to mean the
    universal set.  */
 
@@ -75,15 +72,11 @@ Lisp_Object Qfront_sticky, Qrear_nonsticky;
 static Lisp_Object interval_insert_behind_hooks;
 static Lisp_Object interval_insert_in_front_hooks;
 
-static void text_read_only (Lisp_Object) NO_RETURN;
-static Lisp_Object Fprevious_property_change (Lisp_Object, Lisp_Object,
-                                             Lisp_Object);
-
 
 /* Signal a `text-read-only' error.  This function makes it easier
    to capture that error in GDB by putting a breakpoint on it.  */
 
-static void
+static _Noreturn void
 text_read_only (Lisp_Object propval)
 {
   if (STRINGP (propval))
@@ -92,8 +85,18 @@ text_read_only (Lisp_Object propval)
   xsignal0 (Qtext_read_only);
 }
 
+/* Prepare to modify the region of BUFFER from START to END.  */
+
+static void
+modify_region (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
+{
+  struct buffer *buf = XBUFFER (buffer), *old = current_buffer;
+
+  set_buffer_internal (buf);
+  modify_region_1 (XINT (start), XINT (end), true);
+  set_buffer_internal (old);
+}
 
-\f
 /* Extract the interval at the position pointed to by BEGIN from
    OBJECT, a string or buffer.  Additionally, check that the positions
    pointed to by BEGIN and END are within the bounds of OBJECT, and
@@ -112,7 +115,7 @@ text_read_only (Lisp_Object propval)
    Fprevious_property_change which call this function with BEGIN == END.
    Handle this case specially.
 
-   If FORCE is soft (0), it's OK to return NULL_INTERVAL.  Otherwise,
+   If FORCE is soft (0), it's OK to return NULL.  Otherwise,
    create an interval tree for OBJECT if one doesn't exist, provided
    the object actually contains text.  In the current design, if there
    is no text, there can be no text properties.  */
@@ -133,7 +136,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
   /* If we are asked for a point, but from a subr which operates
      on a range, then return nothing.  */
   if (EQ (*begin, *end) && begin != end)
-    return NULL_INTERVAL;
+    return NULL;
 
   if (XINT (*begin) > XINT (*end))
     {
@@ -150,11 +153,11 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
       if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end)
            && XINT (*end) <= BUF_ZV (b)))
        args_out_of_range (*begin, *end);
-      i = BUF_INTERVALS (b);
+      i = buffer_intervals (b);
 
       /* If there's no text, there are no properties.  */
       if (BUF_BEGV (b) == BUF_ZV (b))
-       return NULL_INTERVAL;
+       return NULL;
 
       searchpos = XINT (*begin);
     }
@@ -168,15 +171,15 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
       XSETFASTINT (*begin, XFASTINT (*begin));
       if (begin != end)
        XSETFASTINT (*end, XFASTINT (*end));
-      i = STRING_INTERVALS (object);
+      i = string_intervals (object);
 
       if (len == 0)
-       return NULL_INTERVAL;
+       return NULL;
 
       searchpos = XINT (*begin);
     }
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return (force ? create_root_interval (object) : i);
 
   return find_interval (i, searchpos);
@@ -248,7 +251,7 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL i)
 /* Return nonzero if the plist of interval I has any of the
    properties of PLIST, regardless of their values.  */
 
-static inline int
+static int
 interval_has_some_properties (Lisp_Object plist, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym;
@@ -270,7 +273,7 @@ interval_has_some_properties (Lisp_Object plist, INTERVAL i)
 /* Return nonzero if the plist of interval I has any of the
    property names in LIST, regardless of their values.  */
 
-static inline int
+static int
 interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym;
@@ -278,7 +281,7 @@ interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
   /* Go through each element of LIST.  */
   for (tail1 = list; CONSP (tail1); tail1 = XCDR (tail1))
     {
-      sym = Fcar (tail1);
+      sym = XCAR (tail1);
 
       /* Go through i's plist, looking for tail1 */
       for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2)))
@@ -345,7 +348,7 @@ set_properties (Lisp_Object properties, INTERVAL interval, Lisp_Object object)
     }
 
   /* Store new properties.  */
-  interval->plist = Fcopy_sequence (properties);
+  set_interval_plist (interval, Fcopy_sequence (properties));
 }
 
 /* Add the properties of PLIST to the interval I, or set
@@ -418,7 +421,7 @@ add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object)
              record_property_change (i->position, LENGTH (i),
                                      sym1, Qnil, object);
            }
-         i->plist = Fcons (sym1, Fcons (val1, i->plist));
+         set_interval_plist (i, Fcons (sym1, Fcons (val1, i->plist)));
          changed++;
        }
     }
@@ -491,24 +494,9 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object
     }
 
   if (changed)
-    i->plist = current_plist;
+    set_interval_plist (i, current_plist);
   return changed;
 }
-
-#if 0
-/* Remove all properties from interval I.  Return non-zero
-   if this changes the interval.  */
-
-static inline int
-erase_properties (INTERVAL i)
-{
-  if (NILP (i->plist))
-    return 0;
-
-  i->plist = Qnil;
-  return 1;
-}
-#endif
 \f
 /* Returns the interval of POSITION in OBJECT.
    POSITION is BEG-based.  */
@@ -522,7 +510,7 @@ interval_of (ptrdiff_t position, Lisp_Object object)
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   else if (EQ (object, Qt))
-    return NULL_INTERVAL;
+    return NULL;
 
   CHECK_STRING_OR_BUFFER (object);
 
@@ -532,19 +520,19 @@ interval_of (ptrdiff_t position, Lisp_Object object)
 
       beg = BUF_BEGV (b);
       end = BUF_ZV (b);
-      i = BUF_INTERVALS (b);
+      i = buffer_intervals (b);
     }
   else
     {
       beg = 0;
       end = SCHARS (object);
-      i = STRING_INTERVALS (object);
+      i = string_intervals (object);
     }
 
   if (!(beg <= position && position <= end))
     args_out_of_range (make_number (position), make_number (position));
-  if (beg == end || NULL_INTERVAL_P (i))
-    return NULL_INTERVAL;
+  if (beg == end || !i)
+    return NULL;
 
   return find_interval (i, position);
 }
@@ -564,7 +552,7 @@ If POSITION is at the end of OBJECT, the value is nil.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &position, &position, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
   /* If POSITION is at the end of the interval,
      it means it's the end of OBJECT.
@@ -578,7 +566,8 @@ If POSITION is at the end of OBJECT, the value is nil.  */)
 
 DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0,
        doc: /* Return the value of POSITION's property PROP, in OBJECT.
-OBJECT is optional and defaults to the current buffer.
+OBJECT should be a buffer or a string; if omitted or nil, it defaults
+to the current buffer.
 If POSITION is at the end of OBJECT, the value is nil.  */)
   (Lisp_Object position, Lisp_Object prop, Lisp_Object object)
 {
@@ -782,7 +771,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
 
       if (BUFFERP (object) && current_buffer != XBUFFER (object))
        {
-         record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+         record_unwind_current_buffer ();
          Fset_buffer (object);
        }
 
@@ -865,7 +854,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT.  */)
 
       if (BUFFERP (object) && current_buffer != XBUFFER (object))
        {
-         record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+         record_unwind_current_buffer ();
          Fset_buffer (object);
        }
 
@@ -944,12 +933,12 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
      bother checking further intervals.  */
   if (EQ (limit, Qt))
     {
-      if (NULL_INTERVAL_P (i))
+      if (!i)
        next = i;
       else
        next = next_interval (i);
 
-      if (NULL_INTERVAL_P (next))
+      if (!next)
        XSETFASTINT (position, (STRINGP (object)
                                ? SCHARS (object)
                                : BUF_ZV (XBUFFER (object))));
@@ -958,16 +947,16 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       return position;
     }
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   next = next_interval (i);
 
-  while (!NULL_INTERVAL_P (next) && intervals_equal (i, next)
+  while (next && intervals_equal (i, next)
         && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next)
+  if (!next
       || (next->position
          >= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1005,17 +994,17 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   here_val = textget (i->plist, prop);
   next = next_interval (i);
-  while (! NULL_INTERVAL_P (next)
+  while (next
         && EQ (here_val, textget (next->plist, prop))
         && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next)
+  if (!next
       || (next->position
          >= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1051,7 +1040,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   /* Start with the interval containing the char before point.  */
@@ -1059,12 +1048,12 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     i = previous_interval (i);
 
   previous = previous_interval (i);
-  while (!NULL_INTERVAL_P (previous) && intervals_equal (previous, i)
+  while (previous && intervals_equal (previous, i)
         && (NILP (limit)
             || (previous->position + LENGTH (previous) > XFASTINT (limit))))
     previous = previous_interval (previous);
 
-  if (NULL_INTERVAL_P (previous)
+  if (!previous
       || (previous->position + LENGTH (previous)
          <= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1102,21 +1091,21 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
   i = validate_interval_range (object, &position, &position, soft);
 
   /* Start with the interval containing the char before point.  */
-  if (!NULL_INTERVAL_P (i) && i->position == XFASTINT (position))
+  if (i && i->position == XFASTINT (position))
     i = previous_interval (i);
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   here_val = textget (i->plist, prop);
   previous = previous_interval (i);
-  while (!NULL_INTERVAL_P (previous)
+  while (previous
         && EQ (here_val, textget (previous->plist, prop))
         && (NILP (limit)
             || (previous->position + LENGTH (previous) > XFASTINT (limit))))
     previous = previous_interval (previous);
 
-  if (NULL_INTERVAL_P (previous)
+  if (!previous
       || (previous->position + LENGTH (previous)
          <= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1152,7 +1141,7 @@ Return t if any property value actually changed, nil otherwise.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &start, &end, hard);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   s = XINT (start);
@@ -1185,13 +1174,12 @@ Return t if any property value actually changed, nil otherwise.  */)
     }
 
   if (BUFFERP (object))
-    modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+    modify_region (object, start, end);
 
   /* We are at the beginning of interval I, with LEN chars to scan.  */
   for (;;)
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1297,16 +1285,16 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
       && XFASTINT (start) == 0
       && XFASTINT (end) == SCHARS (object))
     {
-      if (! STRING_INTERVALS (object))
+      if (!string_intervals (object))
        return Qnil;
 
-      STRING_SET_INTERVALS (object, NULL_INTERVAL);
+      set_string_intervals (object, NULL);
       return Qt;
     }
 
   i = validate_interval_range (object, &start, &end, soft);
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     {
       /* If buffer has no properties, and we want none, return now.  */
       if (NILP (properties))
@@ -1319,12 +1307,12 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
 
       i = validate_interval_range (object, &start, &end, hard);
       /* This can return if start == end.  */
-      if (NULL_INTERVAL_P (i))
+      if (!i)
        return Qnil;
     }
 
   if (BUFFERP (object) && !NILP (coherent_change_p))
-    modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+    modify_region (object, start, end);
 
   set_text_properties_1 (start, end, properties, object, i);
 
@@ -1335,16 +1323,15 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
 }
 
 /* Replace properties of text from START to END with new list of
-   properties PROPERTIES.  BUFFER is the buffer containing
+   properties PROPERTIES.  OBJECT is the buffer or string containing
    the text.  This does not obey any hooks.
-   You can provide the interval that START is located in as I,
-   or pass NULL for I and this function will find it.
+   You should provide the interval that START is located in as I.
    START and END can be in any order.  */
 
 void
-set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object buffer, INTERVAL i)
+set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, INTERVAL i)
 {
-  register INTERVAL prev_changed = NULL_INTERVAL;
+  register INTERVAL prev_changed = NULL;
   register ptrdiff_t s, len;
   INTERVAL unchanged;
 
@@ -1361,8 +1348,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
   else
     return;
 
-  if (i == 0)
-    i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);
+  eassert (i);
 
   if (i->position != s)
     {
@@ -1373,11 +1359,11 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
        {
          copy_properties (unchanged, i);
          i = split_interval_left (i, len);
-         set_properties (properties, i, buffer);
+         set_properties (properties, i, object);
          return;
        }
 
-      set_properties (properties, i, buffer);
+      set_properties (properties, i, object);
 
       if (LENGTH (i) == len)
        return;
@@ -1390,8 +1376,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
   /* We are starting at the beginning of an interval I.  LEN is positive.  */
   do
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1401,8 +1386,8 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
          /* We have to call set_properties even if we are going to
             merge the intervals, so as to make the undo records
             and cause redisplay to happen.  */
-         set_properties (properties, i, buffer);
-         if (!NULL_INTERVAL_P (prev_changed))
+         set_properties (properties, i, object);
+         if (prev_changed)
            merge_interval_left (i);
          return;
        }
@@ -1412,8 +1397,8 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
       /* We have to call set_properties even if we are going to
         merge the intervals, so as to make the undo records
         and cause redisplay to happen.  */
-      set_properties (properties, i, buffer);
-      if (NULL_INTERVAL_P (prev_changed))
+      set_properties (properties, i, object);
+      if (!prev_changed)
        prev_changed = i;
       else
        prev_changed = i = merge_interval_left (i);
@@ -1445,7 +1430,7 @@ Use `set-text-properties' if you want to remove all text properties.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   s = XINT (start);
@@ -1474,13 +1459,12 @@ Use `set-text-properties' if you want to remove all text properties.  */)
     }
 
   if (BUFFERP (object))
-    modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+    modify_region (object, start, end);
 
   /* We are at the beginning of an interval, with len to scan */
   for (;;)
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1533,7 +1517,7 @@ Return t if any property was actually removed, nil otherwise.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   s = XINT (start);
@@ -1569,8 +1553,7 @@ Return t if any property was actually removed, nil otherwise.  */)
      and we call signal_after_change before returning if modified != 0. */
   for (;;)
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1590,7 +1573,7 @@ Return t if any property was actually removed, nil otherwise.  */)
          else if (LENGTH (i) == len)
            {
              if (!modified && BUFFERP (object))
-               modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+               modify_region (object, start, end);
              remove_properties (Qnil, properties, i, object);
              if (BUFFERP (object))
                signal_after_change (XINT (start), XINT (end) - XINT (start),
@@ -1603,7 +1586,7 @@ Return t if any property was actually removed, nil otherwise.  */)
              i = split_interval_left (i, len);
              copy_properties (unchanged, i);
              if (!modified && BUFFERP (object))
-               modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+               modify_region (object, start, end);
              remove_properties (Qnil, properties, i, object);
              if (BUFFERP (object))
                signal_after_change (XINT (start), XINT (end) - XINT (start),
@@ -1614,7 +1597,7 @@ Return t if any property was actually removed, nil otherwise.  */)
       if (interval_has_some_properties_list (properties, i))
        {
          if (!modified && BUFFERP (object))
-           modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+           modify_region (object, start, end);
          remove_properties (Qnil, properties, i, object);
          modified = 1;
        }
@@ -1639,11 +1622,11 @@ markers).  If OBJECT is a string, START and END are 0-based indices into it.  */
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return (!NILP (value) || EQ (start, end) ? Qnil : start);
   e = XINT (end);
 
-  while (! NULL_INTERVAL_P (i))
+  while (i)
     {
       if (i->position >= e)
        break;
@@ -1675,12 +1658,12 @@ markers).  If OBJECT is a string, START and END are 0-based indices into it.  */
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return (NILP (value) || EQ (start, end)) ? Qnil : start;
   s = XINT (start);
   e = XINT (end);
 
-  while (! NULL_INTERVAL_P (i))
+  while (i)
     {
       if (i->position >= e)
        break;
@@ -1785,7 +1768,7 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_
   struct gcpro gcpro1, gcpro2;
 
   i = validate_interval_range (src, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   CHECK_NUMBER_COERCE_MARKER (pos);
@@ -1837,7 +1820,7 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_
        }
 
       i = next_interval (i);
-      if (NULL_INTERVAL_P (i))
+      if (!i)
        break;
 
       p += len;
@@ -1878,7 +1861,7 @@ text_property_list (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp
   result = Qnil;
 
   i = validate_interval_range (object, &start, &end, soft);
-  if (!NULL_INTERVAL_P (i))
+  if (i)
     {
       ptrdiff_t s = XINT (start);
       ptrdiff_t e = XINT (end);
@@ -1910,7 +1893,7 @@ text_property_list (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp
                            result);
 
          i = next_interval (i);
-         if (NULL_INTERVAL_P (i))
+         if (!i)
            break;
          s = i->position;
        }
@@ -2019,10 +2002,10 @@ void
 verify_interval_modification (struct buffer *buf,
                              ptrdiff_t start, ptrdiff_t end)
 {
-  register INTERVAL intervals = BUF_INTERVALS (buf);
-  register INTERVAL i;
+  INTERVAL intervals = buffer_intervals (buf);
+  INTERVAL i;
   Lisp_Object hooks;
-  register Lisp_Object prev_mod_hooks;
+  Lisp_Object prev_mod_hooks;
   Lisp_Object mod_hooks;
   struct gcpro gcpro1;
 
@@ -2033,7 +2016,7 @@ verify_interval_modification (struct buffer *buf,
   interval_insert_behind_hooks = Qnil;
   interval_insert_in_front_hooks = Qnil;
 
-  if (NULL_INTERVAL_P (intervals))
+  if (!intervals)
     return;
 
   if (start > end)
@@ -2074,7 +2057,7 @@ verify_interval_modification (struct buffer *buf,
             indirectly defined via the category property.  */
          if (i != prev)
            {
-             if (! NULL_INTERVAL_P (i))
+             if (i)
                {
                  after = textget (i->plist, Qread_only);
 
@@ -2094,7 +2077,7 @@ verify_interval_modification (struct buffer *buf,
                    }
                }
 
-             if (! NULL_INTERVAL_P (prev))
+             if (prev)
                {
                  before = textget (prev->plist, Qread_only);
 
@@ -2114,7 +2097,7 @@ verify_interval_modification (struct buffer *buf,
                    }
                }
            }
-         else if (! NULL_INTERVAL_P (i))
+         else if (i)
            {
              after = textget (i->plist, Qread_only);
 
@@ -2141,10 +2124,10 @@ verify_interval_modification (struct buffer *buf,
        }
 
       /* Run both insert hooks (just once if they're the same).  */
-      if (!NULL_INTERVAL_P (prev))
+      if (prev)
        interval_insert_behind_hooks
          = textget (prev->plist, Qinsert_behind_hooks);
-      if (!NULL_INTERVAL_P (i))
+      if (i)
        interval_insert_in_front_hooks
          = textget (i->plist, Qinsert_in_front_hooks);
     }
@@ -2172,7 +2155,7 @@ verify_interval_modification (struct buffer *buf,
          i = next_interval (i);
        }
       /* Keep going thru the interval containing the char before END.  */
-      while (! NULL_INTERVAL_P (i) && i->position < end);
+      while (i && i->position < end);
 
       if (!inhibit_modification_hooks)
        {