* intervals.h (NULL_INTERVAL, DEFAULT_INTERVAL): Remove.
(NULL_INTERVAL_P): Likewise. Adjust users.
(FRONT_STICKY_P, END_NONSTICKY_P, FRONT_NONSTICKY_P): Adjust
comment. Move under #if 0.
* alloc.c, buffer.c, editfns.c, fns.c, insdel.c, intervals.c:
* print.c, syntax.c, textprop.c, xdisp.c: Adjust users.
+2012-08-08 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Cleanup intervals.
+ * intervals.h (NULL_INTERVAL, DEFAULT_INTERVAL): Remove.
+ (NULL_INTERVAL_P): Likewise. Adjust users.
+ (FRONT_STICKY_P, END_NONSTICKY_P, FRONT_NONSTICKY_P): Adjust
+ comment. Move under #if 0.
+ * alloc.c, buffer.c, editfns.c, fns.c, insdel.c, intervals.c:
+ * print.c, syntax.c, textprop.c, xdisp.c: Adjust users.
+
2012-08-08 Dmitry Antipov <dmantipov@yandex.ru>
Check total length of intervals with eassert.
/* Mark the interval tree rooted in I. */
-#define MARK_INTERVAL_TREE(i) \
- do { \
- if (!NULL_INTERVAL_P (i) && !i->gcmarkbit) \
- mark_interval_tree (i); \
+#define MARK_INTERVAL_TREE(i) \
+ do { \
+ if (i && !i->gcmarkbit) \
+ mark_interval_tree (i); \
} while (0)
+/* Unmark and rebalance interval tree rooted in I. */
-#define UNMARK_BALANCE_INTERVALS(i) \
- do { \
- if (! NULL_INTERVAL_P (i)) \
- (i) = balance_intervals (i); \
+#define UNMARK_BALANCE_INTERVALS(i) \
+ do { \
+ if (i) \
+ (i) = balance_intervals (i); \
} while (0)
-\f
+
/***********************************************************************
String Allocation
***********************************************************************/
/* String is live; unmark it and its intervals. */
UNMARK_STRING (s);
- if (!NULL_INTERVAL_P (s->intervals))
+ if (s->intervals)
UNMARK_BALANCE_INTERVALS (s->intervals);
++total_strings;
return empty_multibyte_string;
s = allocate_string ();
- s->intervals = NULL_INTERVAL;
+ s->intervals = NULL;
allocate_string_data (s, nchars, nbytes);
XSETSTRING (string, s);
string_chars_consed += nbytes;
}
s->size = nchars;
s->size_byte = multibyte ? nbytes : -1;
- s->intervals = NULL_INTERVAL;
+ s->intervals = NULL;
XSETSTRING (string, s);
return string;
}
s->size = nchars;
s->size_byte = -1;
s->data = (unsigned char *) data;
- s->intervals = NULL_INTERVAL;
+ s->intervals = NULL;
XSETSTRING (string, s);
return string;
}
BUF_CHARS_MODIFF (b) = 1;
BUF_OVERLAY_MODIFF (b) = 1;
BUF_SAVE_MODIFF (b) = 1;
- BUF_INTERVALS (b) = 0;
+ BUF_INTERVALS (b) = NULL;
BUF_UNCHANGED_MODIFIED (b) = 1;
BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
BUF_END_UNCHANGED (b) = 0;
BVAR (b, zv_marker) = Qnil;
name = Fcopy_sequence (buffer_or_name);
- STRING_SET_INTERVALS (name, NULL_INTERVAL);
+ STRING_SET_INTERVALS (name, NULL);
BVAR (b, name) = name;
BVAR (b, undo_list) = (SREF (name, 0) != ' ') ? Qnil : Qt;
all_buffers = b;
name = Fcopy_sequence (name);
- STRING_SET_INTERVALS (name, NULL_INTERVAL);
+ STRING_SET_INTERVALS (name, NULL);
BVAR (b, name) = name;
reset_buffer (b);
m = next;
}
BUF_MARKERS (b) = NULL;
- BUF_INTERVALS (b) = NULL_INTERVAL;
+ BUF_INTERVALS (b) = NULL;
/* Perhaps we should explicitly free the interval tree here... */
}
/* No one will share the text with these buffers, but let's play it safe. */
buffer_defaults.indirections = 0;
buffer_local_symbols.indirections = 0;
- BUF_INTERVALS (&buffer_defaults) = 0;
- BUF_INTERVALS (&buffer_local_symbols) = 0;
+ BUF_INTERVALS (&buffer_defaults) = NULL;
+ BUF_INTERVALS (&buffer_local_symbols) = NULL;
XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);
XSETBUFFER (Vbuffer_defaults, &buffer_defaults);
XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize);
/* Don't use Fset_text_properties: that can cause GC, which can
clobber objects stored in the tmp_intervals. */
tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0);
- if (!NULL_INTERVAL_P (tmp_interval3))
+ if (tmp_interval3)
set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
/* First region smaller than second. */
tmp_interval2 = copy_intervals (cur_intv, start2, len2);
tmp_interval3 = validate_interval_range (buf, &startr1, &endr1, 0);
- if (!NULL_INTERVAL_P (tmp_interval3))
+ if (tmp_interval3)
set_text_properties_1 (startr1, endr1, Qnil, buf, tmp_interval3);
tmp_interval3 = validate_interval_range (buf, &startr2, &endr2, 0);
- if (!NULL_INTERVAL_P (tmp_interval3))
+ if (tmp_interval3)
set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3);
temp = SAFE_ALLOCA (len1_byte);
tmp_interval2 = copy_intervals (cur_intv, start2, len2);
tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0);
- if (!NULL_INTERVAL_P (tmp_interval3))
+ if (tmp_interval3)
set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
/* holds region 2 */
tmp_interval2 = copy_intervals (cur_intv, start2, len2);
tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0);
- if (!NULL_INTERVAL_P (tmp_interval3))
+ if (tmp_interval3)
set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
/* holds region 1 */
set_buffer_internal (XBUFFER (buffer));
adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE);
adjust_overlays_for_delete (BEG, Z - BEG);
- BUF_INTERVALS (current_buffer) = 0;
+ BUF_INTERVALS (current_buffer) = NULL;
TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
/* Now we are safe to change the buffer's multibyteness directly. */
ptrdiff_t thislen_byte = SBYTES (this);
memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this));
- if (! NULL_INTERVAL_P (STRING_INTERVALS (this)))
+ if (STRING_INTERVALS (this))
{
textprops[num_textprops].argnum = argnum;
textprops[num_textprops].from = 0;
/* Copy a single-byte string to a multibyte string. */
else if (STRINGP (this) && STRINGP (val))
{
- if (! NULL_INTERVAL_P (STRING_INTERVALS (this)))
+ if (STRING_INTERVALS (this))
{
textprops[num_textprops].argnum = argnum;
textprops[num_textprops].from = 0;
str_as_multibyte (SDATA (new_string), nbytes,
SBYTES (string), NULL);
string = new_string;
- STRING_SET_INTERVALS (string, NULL_INTERVAL);
+ STRING_SET_INTERVALS (string, NULL);
}
return string;
}
PT + nchars, PT_BYTE + nbytes,
before_markers);
- if (BUF_INTERVALS (current_buffer) != 0)
+ if (BUF_INTERVALS (current_buffer))
offset_intervals (current_buffer, PT, nchars);
- if (!inherit && BUF_INTERVALS (current_buffer) != 0)
+ if (!inherit && BUF_INTERVALS (current_buffer))
set_text_properties (make_number (PT), make_number (PT + nchars),
Qnil, Qnil, Qnil);
adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes,
GPT, GPT_BYTE, 0);
- if (BUF_INTERVALS (current_buffer) != 0)
+ if (BUF_INTERVALS (current_buffer))
{
offset_intervals (current_buffer, GPT - nchars, nchars);
- graft_intervals_into_buffer (NULL_INTERVAL, GPT - nchars, nchars,
+ graft_intervals_into_buffer (NULL, GPT - nchars, nchars,
current_buffer, 0);
}
PT_BYTE + outgoing_nbytes,
0);
- if (BUF_INTERVALS (current_buffer) != 0)
+ if (BUF_INTERVALS (current_buffer))
offset_intervals (current_buffer, PT, nchars);
/* Get the intervals for the part of the string we are inserting. */
adjust_overlays_for_insert (from, len - nchars_del);
else if (len < nchars_del)
adjust_overlays_for_delete (from, nchars_del - len);
- if (BUF_INTERVALS (current_buffer) != 0)
+ if (BUF_INTERVALS (current_buffer))
{
offset_intervals (current_buffer, from, len - nchars_del);
}
if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
++windows_or_buffers_changed;
- if (BUF_INTERVALS (current_buffer) != 0)
+ if (BUF_INTERVALS (current_buffer))
{
if (preserve_ptr)
{
traverse_intervals_noorder (INTERVAL tree, void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg)
{
/* Minimize stack usage. */
- while (!NULL_INTERVAL_P (tree))
+ while (tree)
{
(*function) (tree, arg);
- if (NULL_INTERVAL_P (tree->right))
+ if (!tree->right)
tree = tree->left;
else
{
traverse_intervals (INTERVAL tree, ptrdiff_t position,
void (*function) (INTERVAL, Lisp_Object), Lisp_Object arg)
{
- while (!NULL_INTERVAL_P (tree))
+ while (tree)
{
traverse_intervals (tree->left, position, function, arg);
position += LEFT_TOTAL_LENGTH (tree);
{
icount = 0;
search_interval = i;
- found_interval = NULL_INTERVAL;
+ found_interval = NULL;
traverse_intervals_noorder (tree, &check_for_interval, Qnil);
return found_interval;
}
/* Make A point to c */
interval_set_left (interval, i);
- if (! NULL_INTERVAL_P (i))
+ if (i)
interval_set_parent (i, interval);
/* A's total length is decreased by the length of B and its left child. */
/* Make A point to c */
interval_set_right (interval, i);
- if (! NULL_INTERVAL_P (i))
+ if (i)
interval_set_parent (i, interval);
/* A's total length is decreased by the length of B and its right child. */
INTERVAL
balance_intervals (INTERVAL tree)
{
- if (tree == NULL_INTERVAL)
- return NULL_INTERVAL;
-
- return balance_intervals_internal (tree);
+ return tree ? balance_intervals_internal (tree) : NULL;
}
-\f
+
/* Split INTERVAL into two pieces, starting the second piece at
character position OFFSET (counting from 0), relative to INTERVAL.
INTERVAL becomes the left-hand piece, and the right-hand piece
{
Lisp_Object parent;
- if (NULL_INTERVAL_P (source))
+ if (!source)
return 0;
if (! INTERVAL_HAS_OBJECT (source))
to POSITION. */
register ptrdiff_t relative_position;
- if (NULL_INTERVAL_P (tree))
- return NULL_INTERVAL;
+ if (!tree)
+ return NULL;
relative_position = position;
if (INTERVAL_HAS_OBJECT (tree))
register INTERVAL i = interval;
register ptrdiff_t next_position;
- if (NULL_INTERVAL_P (i))
- return NULL_INTERVAL;
+ if (!i)
+ return NULL;
next_position = interval->position + LENGTH (interval);
if (! NULL_RIGHT_CHILD (i))
i = INTERVAL_PARENT (i);
}
- return NULL_INTERVAL;
+ return NULL;
}
/* Find the preceding interval (lexicographically) to INTERVAL.
{
register INTERVAL i;
- if (NULL_INTERVAL_P (interval))
- return NULL_INTERVAL;
+ if (!interval)
+ return NULL;
if (! NULL_LEFT_CHILD (interval))
{
i = INTERVAL_PARENT (i);
}
- return NULL_INTERVAL;
+ return NULL;
}
/* Find the interval containing POS given some non-NULL INTERVAL
INTERVAL
update_interval (register INTERVAL i, ptrdiff_t pos)
{
- if (NULL_INTERVAL_P (i))
- return NULL_INTERVAL;
+ if (!i)
+ return NULL;
while (1)
{
struct interval newi;
RESET_INTERVAL (&newi);
- pleft = NULL_INTERVAL_P (prev) ? Qnil : prev->plist;
- pright = NULL_INTERVAL_P (i) ? Qnil : i->plist;
+ pleft = prev ? prev->plist : Qnil;
+ pright = i ? i->plist : Qnil;
interval_set_plist (&newi, merge_properties_sticky (pleft, pright));
if (! prev) /* i.e. position == BEG */
{
prev = split_interval_right (prev, position - prev->position);
interval_set_plist (prev, newi.plist);
- if (! NULL_INTERVAL_P (i)
- && intervals_equal (prev, i))
+ if (i && intervals_equal (prev, i))
merge_interval_right (prev);
}
register INTERVAL migrate, this;
register ptrdiff_t migrate_amt;
- if (NULL_INTERVAL_P (i->left))
+ if (!i->left)
return i->right;
- if (NULL_INTERVAL_P (i->right))
+ if (!i->right)
return i->left;
migrate = i->left;
migrate_amt = i->left->total_length;
this = i->right;
this->total_length += migrate_amt;
- while (! NULL_INTERVAL_P (this->left))
+ while (this->left)
{
this = this->left;
this->total_length += migrate_amt;
Lisp_Object owner;
GET_INTERVAL_OBJECT (owner, i);
parent = delete_node (i);
- if (! NULL_INTERVAL_P (parent))
+ if (parent)
interval_set_object (parent, owner);
if (BUFFERP (owner))
if (AM_LEFT_CHILD (i))
{
interval_set_left (parent, delete_node (i));
- if (! NULL_INTERVAL_P (parent->left))
+ if (parent->left)
interval_set_parent (parent->left, parent);
}
else
{
interval_set_right (parent, delete_node (i));
- if (! NULL_INTERVAL_P (parent->right))
+ if (parent->right)
interval_set_parent (parent->right, parent);
}
}
{
register ptrdiff_t relative_position = from;
- if (NULL_INTERVAL_P (tree))
+ if (!tree)
return 0;
/* Left branch. */
GET_INTERVAL_OBJECT (parent, tree);
offset = (BUFFERP (parent) ? BUF_BEG (XBUFFER (parent)) : 0);
- if (NULL_INTERVAL_P (tree))
+ if (!tree)
return;
eassert (start <= offset + TOTAL_LENGTH (tree)
if (length == TOTAL_LENGTH (tree))
{
- BUF_INTERVALS (buffer) = NULL_INTERVAL;
+ BUF_INTERVALS (buffer) = NULL;
return;
}
tree = BUF_INTERVALS (buffer);
if (left_to_delete == tree->total_length)
{
- BUF_INTERVALS (buffer) = NULL_INTERVAL;
+ BUF_INTERVALS (buffer) = NULL;
return;
}
}
void
offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length)
{
- if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0)
+ if (!BUF_INTERVALS (buffer) || length == 0)
return;
if (length > 0)
becomes part of whatever interval it was inserted into.
To prevent inheritance, we must clear out the properties
of the newly inserted text. */
- if (NULL_INTERVAL_P (source))
+ if (!source)
{
Lisp_Object buf;
- if (!inherit && !NULL_INTERVAL_P (tree) && length > 0)
+ if (!inherit && tree && length > 0)
{
XSETBUFFER (buf, buffer);
set_text_properties_1 (make_number (position),
make_number (position + length),
Qnil, buf, 0);
}
- if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer)))
+ if (BUF_INTERVALS (buffer))
/* Shouldn't be necessary. --Stef */
BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer));
return;
eassert (BUF_INTERVALS (buffer)->up_obj == 1);
return;
}
- else if (NULL_INTERVAL_P (tree))
+ else if (!tree)
{ /* Create an interval tree in which to place a copy
of the intervals of the inserted string. */
Lisp_Object buf;
eassert (TOTAL_LENGTH (tree) > 0);
this = under = find_interval (tree, position);
- eassert (!NULL_INTERVAL_P (under));
+ eassert (under);
over = find_interval (source, interval_start_pos (source));
/* Here for insertion in the middle of an interval.
have already been copied into target intervals.
UNDER is the next interval in the target. */
over_used = 0;
- while (! NULL_INTERVAL_P (over))
+ while (over)
{
/* If UNDER is longer than OVER, split it. */
if (LENGTH (over) - over_used < LENGTH (under))
under = next_interval (this);
}
- if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer)))
+ if (BUF_INTERVALS (buffer))
BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer));
return;
}
/* If we have no text properties and overlays,
then we can do it quickly. */
- if (NULL_INTERVAL_P (BUF_INTERVALS (current_buffer)) && ! have_overlays)
+ if (!BUF_INTERVALS (current_buffer) && ! have_overlays)
{
temp_set_point_both (current_buffer, charpos, bytepos);
return;
with the same intangible property value,
move forward or backward until a change in that property. */
if (NILP (Vinhibit_point_motion_hooks)
- && ((! NULL_INTERVAL_P (to) && ! NULL_INTERVAL_P (toprev))
+ && ((to && toprev)
|| have_overlays)
/* Intangibility never stops us from positioning at the beginning
or end of the buffer, so don't bother checking in that case. */
else
abort ();
- if (NULL_INTERVAL_P (i) || (i->position + LENGTH (i) <= pos))
+ if (!i || (i->position + LENGTH (i) <= pos))
return 0;
*val = textget (i->plist, prop);
if (NILP (*val))
next = i; /* remember it in advance */
prev = previous_interval (i);
- while (! NULL_INTERVAL_P (prev)
+ while (prev
&& EQ (*val, textget (prev->plist, prop)))
i = prev, prev = previous_interval (prev);
*start = i->position;
next = next_interval (i);
- while (! NULL_INTERVAL_P (next)
- && EQ (*val, textget (next->plist, prop)))
+ while (next && EQ (*val, textget (next->plist, prop)))
i = next, next = next_interval (next);
*end = i->position + LENGTH (i);
register INTERVAL i, new, t;
register ptrdiff_t got, prevlen;
- if (NULL_INTERVAL_P (tree) || length <= 0)
- return NULL_INTERVAL;
+ if (!tree || length <= 0)
+ return NULL;
i = find_interval (tree, start);
- eassert (!NULL_INTERVAL_P (i) && LENGTH (i) > 0);
+ eassert (i && LENGTH (i) > 0);
/* If there is only one interval and it's the default, return nil. */
if ((start - i->position + 1 + length) < LENGTH (i)
&& DEFAULT_INTERVAL_P (i))
- return NULL_INTERVAL;
+ return NULL;
new = make_interval ();
new->position = 0;
{
INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (buffer),
position, length);
- if (NULL_INTERVAL_P (interval_copy))
+ if (!interval_copy)
return;
interval_set_object (interval_copy, string);
INLINE_HEADER_BEGIN
-#define NULL_INTERVAL ((INTERVAL)0)
-#define INTERVAL_DEFAULT NULL_INTERVAL
-
/* Basic data type for use of intervals. */
struct interval
/* These are macros for dealing with the interval tree. */
-#define NULL_INTERVAL_P(i) ((i) == NULL_INTERVAL)
-
/* True if this interval has no right child. */
-#define NULL_RIGHT_CHILD(i) ((i)->right == NULL_INTERVAL)
+#define NULL_RIGHT_CHILD(i) ((i)->right == NULL)
/* True if this interval has no left child. */
-#define NULL_LEFT_CHILD(i) ((i)->left == NULL_INTERVAL)
+#define NULL_LEFT_CHILD(i) ((i)->left == NULL)
/* True if this interval has no parent. */
#define NULL_PARENT(i) ((i)->up_obj || (i)->up.interval == 0)
/* True if this interval is the left child of some other interval. */
-#define AM_LEFT_CHILD(i) (! NULL_PARENT (i) \
- && INTERVAL_PARENT (i)->left == (i))
+#define AM_LEFT_CHILD(i) \
+ (! NULL_PARENT (i) && INTERVAL_PARENT (i)->left == (i))
/* True if this interval is the right child of some other interval. */
-#define AM_RIGHT_CHILD(i) (! NULL_PARENT (i) \
- && INTERVAL_PARENT (i)->right == (i))
+#define AM_RIGHT_CHILD(i) \
+ (! NULL_PARENT (i) && INTERVAL_PARENT (i)->right == (i))
/* True if this interval has no children. */
-#define LEAF_INTERVAL_P(i) ((i)->left == NULL_INTERVAL \
- && (i)->right == NULL_INTERVAL)
+#define LEAF_INTERVAL_P(i) ((i)->left == NULL && (i)->right == NULL)
/* True if this interval has no parent and is therefore the root. */
#define ROOT_INTERVAL_P(i) (NULL_PARENT (i))
#define ONLY_INTERVAL_P(i) (ROOT_INTERVAL_P ((i)) && LEAF_INTERVAL_P ((i)))
/* True if this interval has both left and right children. */
-#define BOTH_KIDS_P(i) ((i)->left != NULL_INTERVAL \
- && (i)->right != NULL_INTERVAL)
+#define BOTH_KIDS_P(i) ((i)->left != NULL && (i)->right != NULL)
/* The total size of all text represented by this interval and all its
children in the tree. This is zero if the interval is null. */
-#define TOTAL_LENGTH(i) ((i) == NULL_INTERVAL ? 0 : (i)->total_length)
+#define TOTAL_LENGTH(i) ((i) == NULL ? 0 : (i)->total_length)
/* The size of text represented by this interval alone. */
-#define LENGTH(i) ((i) == NULL_INTERVAL ? 0 : (TOTAL_LENGTH ((i)) \
- - TOTAL_LENGTH ((i)->right) \
- - TOTAL_LENGTH ((i)->left)))
+#define LENGTH(i) ((i) == NULL ? 0 : (TOTAL_LENGTH ((i)) \
+ - TOTAL_LENGTH ((i)->right) \
+ - TOTAL_LENGTH ((i)->left)))
/* The position of the character just past the end of I. Note that
the position cache i->position must be valid for this to work. */
/* The total size of the right subtree of this interval. */
#define RIGHT_TOTAL_LENGTH(i) ((i)->right ? (i)->right->total_length : 0)
-
/* These macros are for dealing with the interval properties. */
/* True if this is a default interval, which is the same as being null
or having no properties. */
-#define DEFAULT_INTERVAL_P(i) (NULL_INTERVAL_P (i) || EQ ((i)->plist, Qnil))
+#define DEFAULT_INTERVAL_P(i) (!i || EQ ((i)->plist, Qnil))
/* Test what type of parent we have. Three possibilities: another
- interval, a buffer or string object, or NULL_INTERVAL. */
+ interval, a buffer or string object, or NULL. */
#define INTERVAL_HAS_PARENT(i) ((i)->up_obj == 0 && (i)->up.interval != 0)
#define INTERVAL_HAS_OBJECT(i) ((i)->up_obj)
/* Get the parent interval, if any, otherwise a null pointer. Useful
for walking up to the root in a "for" loop; use this to get the
- "next" value, and test the result to see if it's NULL_INTERVAL. */
+ "next" value, and test the result to see if it's NULL. */
#define INTERVAL_PARENT_OR_NULL(i) \
(INTERVAL_HAS_PARENT (i) ? INTERVAL_PARENT (i) : 0)
#define RESET_INTERVAL(i) \
{ \
(i)->total_length = (i)->position = 0; \
- (i)->left = (i)->right = NULL_INTERVAL; \
- interval_set_parent (i, NULL_INTERVAL); \
+ (i)->left = (i)->right = NULL; \
+ interval_set_parent (i, NULL); \
(i)->write_protect = 0; \
(i)->visible = 0; \
(i)->front_sticky = (i)->rear_sticky = 0; \
/* Is this interval visible? Replace later with cache access. */
#define INTERVAL_VISIBLE_P(i) \
- (! NULL_INTERVAL_P (i) && NILP (textget ((i)->plist, Qinvisible)))
+ (i && NILP (textget ((i)->plist, Qinvisible)))
/* Is this interval writable? Replace later with cache access. */
#define INTERVAL_WRITABLE_P(i) \
- (! NULL_INTERVAL_P (i) \
- && (NILP (textget ((i)->plist, Qread_only)) \
- || ((CONSP (Vinhibit_read_only) \
- ? !NILP (Fmemq (textget ((i)->plist, Qread_only), \
- Vinhibit_read_only)) \
- : !NILP (Vinhibit_read_only))))) \
+ (i && (NILP (textget ((i)->plist, Qread_only)) \
+ || ((CONSP (Vinhibit_read_only) \
+ ? !NILP (Fmemq (textget ((i)->plist, Qread_only), \
+ Vinhibit_read_only)) \
+ : !NILP (Vinhibit_read_only))))) \
/* Macros to tell whether insertions before or after this interval
- should stick to it. */
-/* Replace later with cache access */
-/*#define FRONT_STICKY_P(i) ((i)->front_sticky != 0)
- #define END_STICKY_P(i) ((i)->rear_sticky != 0)*/
-/* As we now have Vtext_property_default_nonsticky, these macros are
- unreliable now. Currently, they are never used. */
-#define FRONT_STICKY_P(i) \
- (! NULL_INTERVAL_P (i) && ! NILP (textget ((i)->plist, Qfront_sticky)))
-#define END_NONSTICKY_P(i) \
- (! NULL_INTERVAL_P (i) && ! NILP (textget ((i)->plist, Qrear_nonsticky)))
-#define FRONT_NONSTICKY_P(i) \
- (! NULL_INTERVAL_P (i) && ! EQ (Qt, textget ((i)->plist, Qfront_sticky)))
-
+ should stick to it. Now we have Vtext_property_default_nonsticky,
+ so these macros are unreliable now and never used. */
+
+#if 0
+#define FRONT_STICKY_P(i) \
+ (i && ! NILP (textget ((i)->plist, Qfront_sticky)))
+#define END_NONSTICKY_P(i) \
+ (i && ! NILP (textget ((i)->plist, Qrear_nonsticky)))
+#define FRONT_NONSTICKY_P(i) \
+ (i && ! EQ (Qt, textget ((i)->plist, Qfront_sticky)))
+#endif
/* If PROP is the `invisible' property of a character,
this is 1 if the character should be treated as invisible,
and 2 if it is invisible but with an ellipsis. */
-#define TEXT_PROP_MEANS_INVISIBLE(prop) \
+#define TEXT_PROP_MEANS_INVISIBLE(prop) \
(EQ (BVAR (current_buffer, invisibility_spec), Qt) \
- ? !NILP (prop) \
+ ? !NILP (prop) \
: invisible_p (prop, BVAR (current_buffer, invisibility_spec)))
/* Declared in alloc.c. */
if (! EQ (Vprint_charset_text_property, Qt))
obj = print_prune_string_charset (obj);
- if (!NULL_INTERVAL_P (STRING_INTERVALS (obj)))
+ if (STRING_INTERVALS (obj))
{
PRINTCHAR ('#');
PRINTCHAR ('(');
}
PRINTCHAR ('\"');
- if (!NULL_INTERVAL_P (STRING_INTERVALS (obj)))
+ if (STRING_INTERVALS (obj))
{
traverse_intervals (STRING_INTERVALS (obj),
0, print_interval, printcharfun);
direction than the intervals - or in an interval. We update the
current syntax-table basing on the property of this interval, and
update the interval to start further than CHARPOS - or be
- NULL_INTERVAL. We also update lim_property to be the next value of
+ NULL. We also update lim_property to be the next value of
charpos to call this subroutine again - or be before/after the
start/end of OBJECT. */
i = interval_of (charpos, object);
gl_state.backward_i = gl_state.forward_i = i;
invalidate = 0;
- if (NULL_INTERVAL_P (i))
+ if (!i)
return;
/* interval_of updates only ->position of the return value, so
update the parents manually to speed up update_interval. */
/* We are guaranteed to be called with CHARPOS either in i,
or further off. */
- if (NULL_INTERVAL_P (i))
+ if (!i)
error ("Error in syntax_table logic for to-the-end intervals");
else if (charpos < i->position) /* Move left. */
{
}
}
- while (!NULL_INTERVAL_P (i))
+ while (i)
{
if (cnt && !EQ (tmp_table, textget (i->plist, Qsyntax_table)))
{
/* e_property at EOB is not set to ZV but to ZV+1, so that
we can do INC(from);UPDATE_SYNTAX_TABLE_FORWARD without
having to check eob between the two. */
- + (NULL_INTERVAL_P (next_interval (i)) ? 1 : 0);
+ + (next_interval (i) ? 0 : 1);
gl_state.forward_i = i;
}
else
cnt++;
i = count > 0 ? next_interval (i) : previous_interval (i);
}
- eassert (NULL_INTERVAL_P (i)); /* This property goes to the end. */
+ eassert (i == NULL); /* This property goes to the end. */
if (count > 0)
gl_state.e_property = gl_state.stop;
else
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. */
/* 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))
{
/* If there's no text, there are no properties. */
if (BUF_BEGV (b) == BUF_ZV (b))
- return NULL_INTERVAL;
+ return NULL;
searchpos = XINT (*begin);
}
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);
if (NILP (object))
XSETBUFFER (object, current_buffer);
else if (EQ (object, Qt))
- return NULL_INTERVAL;
+ return NULL;
CHECK_STRING_OR_BUFFER (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);
}
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.
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))));
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)
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)
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. */
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)
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)
XSETBUFFER (object, current_buffer);
i = validate_interval_range (object, &start, &end, hard);
- if (NULL_INTERVAL_P (i))
+ if (!i)
return Qnil;
s = XINT (start);
if (! STRING_INTERVALS (object))
return Qnil;
- STRING_SET_INTERVALS (object, NULL_INTERVAL);
+ STRING_SET_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))
i = validate_interval_range (object, &start, &end, hard);
/* This can return if start == end. */
- if (NULL_INTERVAL_P (i))
+ if (!i)
return Qnil;
}
void
set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object buffer, INTERVAL i)
{
- register INTERVAL prev_changed = NULL_INTERVAL;
+ register INTERVAL prev_changed = NULL;
register ptrdiff_t s, len;
INTERVAL unchanged;
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))
+ if (prev_changed)
merge_interval_left (i);
return;
}
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))
+ if (!prev_changed)
prev_changed = i;
else
prev_changed = i = merge_interval_left (i);
XSETBUFFER (object, current_buffer);
i = validate_interval_range (object, &start, &end, soft);
- if (NULL_INTERVAL_P (i))
+ if (!i)
return Qnil;
s = XINT (start);
XSETBUFFER (object, current_buffer);
i = validate_interval_range (object, &start, &end, soft);
- if (NULL_INTERVAL_P (i))
+ if (!i)
return Qnil;
s = XINT (start);
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;
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;
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);
}
i = next_interval (i);
- if (NULL_INTERVAL_P (i))
+ if (!i)
break;
p += len;
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);
result);
i = next_interval (i);
- if (NULL_INTERVAL_P (i))
+ if (!i)
break;
s = i->position;
}
interval_insert_behind_hooks = Qnil;
interval_insert_in_front_hooks = Qnil;
- if (NULL_INTERVAL_P (intervals))
+ if (!intervals)
return;
if (start > end)
indirectly defined via the category property. */
if (i != prev)
{
- if (! NULL_INTERVAL_P (i))
+ if (i)
{
after = textget (i->plist, Qread_only);
}
}
- if (! NULL_INTERVAL_P (prev))
+ if (prev)
{
before = textget (prev->plist, Qread_only);
}
}
}
- else if (! NULL_INTERVAL_P (i))
+ else if (i)
{
after = textget (i->plist, Qread_only);
}
/* 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);
}
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)
{
interval if there isn't such an interval. */
position = make_number (charpos);
iv = validate_interval_range (object, &position, &position, 0);
- if (!NULL_INTERVAL_P (iv))
+ if (iv)
{
Lisp_Object values_here[LAST_PROP_IDX];
struct props *p;
/* Look for an interval following iv that has different
properties. */
for (next_iv = next_interval (iv);
- (!NULL_INTERVAL_P (next_iv)
+ (next_iv
&& (NILP (limit)
|| XFASTINT (limit) > next_iv->position));
next_iv = next_interval (next_iv))
break;
}
- if (!NULL_INTERVAL_P (next_iv))
+ if (next_iv)
{
if (INTEGERP (limit)
&& next_iv->position >= XFASTINT (limit))