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.
This commit is contained in:
parent
9c08a8d4b5
commit
77c7bcb115
13 changed files with 190 additions and 195 deletions
|
@ -1,3 +1,13 @@
|
|||
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.
|
||||
|
|
27
src/alloc.c
27
src/alloc.c
|
@ -1559,19 +1559,20 @@ mark_interval_tree (register INTERVAL tree)
|
|||
|
||||
/* 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)
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
String Allocation
|
||||
***********************************************************************/
|
||||
|
@ -2100,7 +2101,7 @@ sweep_strings (void)
|
|||
/* 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;
|
||||
|
@ -2502,7 +2503,7 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
|
|||
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;
|
||||
|
@ -5221,7 +5222,7 @@ make_pure_string (const char *data,
|
|||
}
|
||||
s->size = nchars;
|
||||
s->size_byte = multibyte ? nbytes : -1;
|
||||
s->intervals = NULL_INTERVAL;
|
||||
s->intervals = NULL;
|
||||
XSETSTRING (string, s);
|
||||
return string;
|
||||
}
|
||||
|
@ -5237,7 +5238,7 @@ make_pure_c_string (const char *data, ptrdiff_t nchars)
|
|||
s->size = nchars;
|
||||
s->size_byte = -1;
|
||||
s->data = (unsigned char *) data;
|
||||
s->intervals = NULL_INTERVAL;
|
||||
s->intervals = NULL;
|
||||
XSETSTRING (string, s);
|
||||
return string;
|
||||
}
|
||||
|
|
12
src/buffer.c
12
src/buffer.c
|
@ -360,7 +360,7 @@ even if it is dead. The return value is never nil. */)
|
|||
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;
|
||||
|
@ -384,7 +384,7 @@ even if it is dead. The return value is never nil. */)
|
|||
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;
|
||||
|
@ -589,7 +589,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
|
|||
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);
|
||||
|
@ -1688,7 +1688,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
|
|||
m = next;
|
||||
}
|
||||
BUF_MARKERS (b) = NULL;
|
||||
BUF_INTERVALS (b) = NULL_INTERVAL;
|
||||
BUF_INTERVALS (b) = NULL;
|
||||
|
||||
/* Perhaps we should explicitly free the interval tree here... */
|
||||
}
|
||||
|
@ -4904,8 +4904,8 @@ init_buffer_once (void)
|
|||
/* 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);
|
||||
|
|
|
@ -4637,7 +4637,7 @@ Transposing beyond buffer boundaries is an error. */)
|
|||
/* 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. */
|
||||
|
@ -4696,11 +4696,11 @@ Transposing beyond buffer boundaries is an error. */)
|
|||
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);
|
||||
|
@ -4729,7 +4729,7 @@ Transposing beyond buffer boundaries is an error. */)
|
|||
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 */
|
||||
|
@ -4762,7 +4762,7 @@ Transposing beyond buffer boundaries is an error. */)
|
|||
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 */
|
||||
|
|
|
@ -3145,7 +3145,7 @@ decide_coding_unwind (Lisp_Object unwind_data)
|
|||
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. */
|
||||
|
|
|
@ -628,7 +628,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
|
|||
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;
|
||||
|
@ -640,7 +640,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
|
|||
/* 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;
|
||||
|
@ -1060,7 +1060,7 @@ If you're not sure, whether to use `string-as-multibyte' or
|
|||
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;
|
||||
}
|
||||
|
|
14
src/insdel.c
14
src/insdel.c
|
@ -844,10 +844,10 @@ insert_1_both (const char *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);
|
||||
|
||||
|
@ -1017,10 +1017,10 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -1157,7 +1157,7 @@ insert_from_buffer_1 (struct buffer *buf,
|
|||
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. */
|
||||
|
@ -1225,7 +1225,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
|
|||
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);
|
||||
}
|
||||
|
@ -1823,7 +1823,7 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
|
|||
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)
|
||||
{
|
||||
|
|
105
src/intervals.c
105
src/intervals.c
|
@ -207,10 +207,10 @@ void
|
|||
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
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ void
|
|||
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);
|
||||
|
@ -262,7 +262,7 @@ search_for_interval (INTERVAL i, INTERVAL tree)
|
|||
{
|
||||
icount = 0;
|
||||
search_interval = i;
|
||||
found_interval = NULL_INTERVAL;
|
||||
found_interval = NULL;
|
||||
traverse_intervals_noorder (tree, &check_for_interval, Qnil);
|
||||
return found_interval;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ rotate_right (INTERVAL 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. */
|
||||
|
@ -380,7 +380,7 @@ rotate_left (INTERVAL interval)
|
|||
|
||||
/* 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. */
|
||||
|
@ -480,12 +480,9 @@ balance_intervals_internal (register INTERVAL tree)
|
|||
INTERVAL
|
||||
balance_intervals (INTERVAL tree)
|
||||
{
|
||||
if (tree == NULL_INTERVAL)
|
||||
return NULL_INTERVAL;
|
||||
|
||||
return balance_intervals_internal (tree);
|
||||
return tree ? balance_intervals_internal (tree) : NULL;
|
||||
}
|
||||
|
||||
|
||||
/* 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
|
||||
|
@ -589,7 +586,7 @@ interval_start_pos (INTERVAL source)
|
|||
{
|
||||
Lisp_Object parent;
|
||||
|
||||
if (NULL_INTERVAL_P (source))
|
||||
if (!source)
|
||||
return 0;
|
||||
|
||||
if (! INTERVAL_HAS_OBJECT (source))
|
||||
|
@ -617,8 +614,8 @@ find_interval (register INTERVAL tree, register ptrdiff_t position)
|
|||
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))
|
||||
|
@ -669,8 +666,8 @@ next_interval (register INTERVAL interval)
|
|||
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))
|
||||
|
@ -695,7 +692,7 @@ next_interval (register INTERVAL interval)
|
|||
i = INTERVAL_PARENT (i);
|
||||
}
|
||||
|
||||
return NULL_INTERVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find the preceding interval (lexicographically) to INTERVAL.
|
||||
|
@ -707,8 +704,8 @@ previous_interval (register INTERVAL interval)
|
|||
{
|
||||
register INTERVAL i;
|
||||
|
||||
if (NULL_INTERVAL_P (interval))
|
||||
return NULL_INTERVAL;
|
||||
if (!interval)
|
||||
return NULL;
|
||||
|
||||
if (! NULL_LEFT_CHILD (interval))
|
||||
{
|
||||
|
@ -733,7 +730,7 @@ previous_interval (register INTERVAL interval)
|
|||
i = INTERVAL_PARENT (i);
|
||||
}
|
||||
|
||||
return NULL_INTERVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find the interval containing POS given some non-NULL INTERVAL
|
||||
|
@ -744,8 +741,8 @@ previous_interval (register INTERVAL interval)
|
|||
INTERVAL
|
||||
update_interval (register INTERVAL i, ptrdiff_t pos)
|
||||
{
|
||||
if (NULL_INTERVAL_P (i))
|
||||
return NULL_INTERVAL;
|
||||
if (!i)
|
||||
return NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -938,8 +935,8 @@ adjust_intervals_for_insertion (INTERVAL tree,
|
|||
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 */
|
||||
|
@ -954,8 +951,7 @@ adjust_intervals_for_insertion (INTERVAL tree,
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1164,16 +1160,16 @@ delete_node (register INTERVAL i)
|
|||
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;
|
||||
|
@ -1204,7 +1200,7 @@ delete_interval (register INTERVAL i)
|
|||
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))
|
||||
|
@ -1221,13 +1217,13 @@ delete_interval (register INTERVAL i)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1250,7 +1246,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from,
|
|||
{
|
||||
register ptrdiff_t relative_position = from;
|
||||
|
||||
if (NULL_INTERVAL_P (tree))
|
||||
if (!tree)
|
||||
return 0;
|
||||
|
||||
/* Left branch. */
|
||||
|
@ -1317,7 +1313,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
|
|||
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)
|
||||
|
@ -1325,7 +1321,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
|
|||
|
||||
if (length == TOTAL_LENGTH (tree))
|
||||
{
|
||||
BUF_INTERVALS (buffer) = NULL_INTERVAL;
|
||||
BUF_INTERVALS (buffer) = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1345,7 +1341,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
|
|||
tree = BUF_INTERVALS (buffer);
|
||||
if (left_to_delete == tree->total_length)
|
||||
{
|
||||
BUF_INTERVALS (buffer) = NULL_INTERVAL;
|
||||
BUF_INTERVALS (buffer) = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1363,7 +1359,7 @@ adjust_intervals_for_deletion (struct buffer *buffer,
|
|||
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)
|
||||
|
@ -1580,17 +1576,17 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
|
|||
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;
|
||||
|
@ -1608,7 +1604,7 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
|
|||
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;
|
||||
|
@ -1620,7 +1616,7 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
|
|||
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.
|
||||
|
@ -1662,7 +1658,7 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
|
|||
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))
|
||||
|
@ -1695,7 +1691,7 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
|
|||
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;
|
||||
}
|
||||
|
@ -1864,7 +1860,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
|
|||
|
||||
/* 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;
|
||||
|
@ -1911,7 +1907,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
|
|||
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. */
|
||||
|
@ -2134,7 +2130,7 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val,
|
|||
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))
|
||||
|
@ -2142,14 +2138,13 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *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);
|
||||
|
||||
|
@ -2220,16 +2215,16 @@ copy_intervals (INTERVAL tree, ptrdiff_t start, ptrdiff_t length)
|
|||
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;
|
||||
|
@ -2260,7 +2255,7 @@ copy_intervals_to_string (Lisp_Object string, struct buffer *buffer,
|
|||
{
|
||||
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);
|
||||
|
|
|
@ -20,9 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
INLINE_HEADER_BEGIN
|
||||
|
||||
#define NULL_INTERVAL ((INTERVAL)0)
|
||||
#define INTERVAL_DEFAULT NULL_INTERVAL
|
||||
|
||||
/* Basic data type for use of intervals. */
|
||||
|
||||
struct interval
|
||||
|
@ -63,28 +60,25 @@ 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))
|
||||
|
@ -93,17 +87,16 @@ struct interval
|
|||
#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. */
|
||||
|
@ -115,15 +108,14 @@ struct interval
|
|||
/* 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)
|
||||
|
||||
|
@ -187,7 +179,7 @@ interval_copy_parent (INTERVAL d, INTERVAL s)
|
|||
|
||||
/* 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)
|
||||
|
||||
|
@ -195,8 +187,8 @@ interval_copy_parent (INTERVAL d, INTERVAL s)
|
|||
#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; \
|
||||
|
@ -232,39 +224,36 @@ interval_copy_parent (INTERVAL d, INTERVAL s)
|
|||
|
||||
/* 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. */
|
||||
|
|
|
@ -1408,7 +1408,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
|
|||
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 ('(');
|
||||
|
@ -1499,7 +1499,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
|
|||
}
|
||||
PRINTCHAR ('\"');
|
||||
|
||||
if (!NULL_INTERVAL_P (STRING_INTERVALS (obj)))
|
||||
if (STRING_INTERVALS (obj))
|
||||
{
|
||||
traverse_intervals (STRING_INTERVALS (obj),
|
||||
0, print_interval, printcharfun);
|
||||
|
|
12
src/syntax.c
12
src/syntax.c
|
@ -171,7 +171,7 @@ struct gl_state_s gl_state; /* Global state of syntax parser. */
|
|||
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. */
|
||||
|
||||
|
@ -192,7 +192,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init,
|
|||
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. */
|
||||
|
@ -217,7 +217,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init,
|
|||
|
||||
/* 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. */
|
||||
{
|
||||
|
@ -287,7 +287,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init,
|
|||
}
|
||||
}
|
||||
|
||||
while (!NULL_INTERVAL_P (i))
|
||||
while (i)
|
||||
{
|
||||
if (cnt && !EQ (tmp_table, textget (i->plist, Qsyntax_table)))
|
||||
{
|
||||
|
@ -313,7 +313,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init,
|
|||
/* 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
|
||||
|
@ -326,7 +326,7 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, int init,
|
|||
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
|
||||
|
|
|
@ -105,7 +105,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. */
|
||||
|
@ -126,7 +126,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))
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
|
|||
|
||||
/* If there's no text, there are no properties. */
|
||||
if (BUF_BEGV (b) == BUF_ZV (b))
|
||||
return NULL_INTERVAL;
|
||||
return NULL;
|
||||
|
||||
searchpos = XINT (*begin);
|
||||
}
|
||||
|
@ -164,12 +164,12 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
|
|||
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);
|
||||
|
@ -500,7 +500,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);
|
||||
|
||||
|
@ -521,8 +521,8 @@ interval_of (ptrdiff_t position, Lisp_Object 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);
|
||||
}
|
||||
|
@ -542,7 +542,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.
|
||||
|
@ -922,12 +922,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))));
|
||||
|
@ -936,16 +936,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)
|
||||
|
@ -983,17 +983,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)
|
||||
|
@ -1029,7 +1029,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. */
|
||||
|
@ -1037,12 +1037,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)
|
||||
|
@ -1080,21 +1080,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)
|
||||
|
@ -1130,7 +1130,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);
|
||||
|
@ -1277,13 +1277,13 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
|
|||
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))
|
||||
|
@ -1296,7 +1296,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -1321,7 +1321,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
|
|||
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;
|
||||
|
||||
|
@ -1378,7 +1378,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
|
|||
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;
|
||||
}
|
||||
|
@ -1389,7 +1389,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
|
|||
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);
|
||||
|
@ -1421,7 +1421,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);
|
||||
|
@ -1508,7 +1508,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);
|
||||
|
@ -1613,11 +1613,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;
|
||||
|
@ -1649,12 +1649,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;
|
||||
|
@ -1759,7 +1759,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);
|
||||
|
@ -1811,7 +1811,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;
|
||||
|
@ -1852,7 +1852,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);
|
||||
|
@ -1884,7 +1884,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;
|
||||
}
|
||||
|
@ -2007,7 +2007,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)
|
||||
|
@ -2048,7 +2048,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);
|
||||
|
||||
|
@ -2068,7 +2068,7 @@ verify_interval_modification (struct buffer *buf,
|
|||
}
|
||||
}
|
||||
|
||||
if (! NULL_INTERVAL_P (prev))
|
||||
if (prev)
|
||||
{
|
||||
before = textget (prev->plist, Qread_only);
|
||||
|
||||
|
@ -2088,7 +2088,7 @@ verify_interval_modification (struct buffer *buf,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (! NULL_INTERVAL_P (i))
|
||||
else if (i)
|
||||
{
|
||||
after = textget (i->plist, Qread_only);
|
||||
|
||||
|
@ -2115,10 +2115,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);
|
||||
}
|
||||
|
@ -2146,7 +2146,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)
|
||||
{
|
||||
|
|
|
@ -3321,7 +3321,7 @@ compute_stop_pos (struct it *it)
|
|||
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;
|
||||
|
@ -3333,7 +3333,7 @@ compute_stop_pos (struct it *it)
|
|||
/* 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))
|
||||
|
@ -3351,7 +3351,7 @@ compute_stop_pos (struct it *it)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!NULL_INTERVAL_P (next_iv))
|
||||
if (next_iv)
|
||||
{
|
||||
if (INTEGERP (limit)
|
||||
&& next_iv->position >= XFASTINT (limit))
|
||||
|
|
Loading…
Add table
Reference in a new issue