Commit ad8c997f authored by Dmitry Antipov's avatar Dmitry Antipov

Inline functions to examine and change string intervals.

* lisp.h (STRING_INTERVALS, STRING_SET_INTERVALS): Remove.
(string_get_intervals, string_set_intervals): New function.
* alloc.c, buffer.c, editfns.c, fns.c, insdel.c, intervals.c:
* lread.c, print.c, textprop.c: Adjust users.
parent ce0fcefa
2012-08-08 Dmitry Antipov <dmantipov@yandex.ru>
Inline functions to examine and change string intervals.
* lisp.h (STRING_INTERVALS, STRING_SET_INTERVALS): Remove.
(string_get_intervals, string_set_intervals): New function.
* alloc.c, buffer.c, editfns.c, fns.c, insdel.c, intervals.c:
* lread.c, print.c, textprop.c: Adjust users.
2012-08-08 Glenn Morris <rgm@gnu.org>
* lisp.mk (lisp): Remove language/persian.elc.
......
......@@ -6102,7 +6102,7 @@ mark_object (Lisp_Object arg)
}
if (!PURE_POINTER_P (XSTRING (ptr->name)))
MARK_STRING (XSTRING (ptr->name));
MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->name));
MARK_INTERVAL_TREE (string_get_intervals (ptr->name));
ptr = ptr->next;
if (ptr)
......
......@@ -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);
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);
string_set_intervals (name, NULL);
BVAR (b, name) = name;
reset_buffer (b);
......
......@@ -3933,7 +3933,7 @@ usage: (format STRING &rest OBJECTS) */)
/* If this argument has text properties, record where
in the result string it appears. */
if (STRING_INTERVALS (args[n]))
if (string_get_intervals (args[n]))
info[n].intervals = arg_intervals = 1;
continue;
......@@ -4277,7 +4277,7 @@ usage: (format STRING &rest OBJECTS) */)
arguments has text properties, set up text properties of the
result string. */
if (STRING_INTERVALS (args[0]) || arg_intervals)
if (string_get_intervals (args[0]) || arg_intervals)
{
Lisp_Object len, new_len, props;
struct gcpro gcpro1;
......
......@@ -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 (STRING_INTERVALS (this))
if (string_get_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 (STRING_INTERVALS (this))
if (string_get_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);
string_set_intervals (string, NULL);
}
return string;
}
......
......@@ -976,7 +976,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
offset_intervals (current_buffer, PT, nchars);
intervals = STRING_INTERVALS (string);
intervals = string_get_intervals (string);
/* Get the intervals for the part of the string we are inserting. */
if (nbytes < SBYTES (string))
intervals = copy_intervals (intervals, pos, nchars);
......@@ -1413,7 +1413,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
/* Get the intervals for the part of the string we are inserting--
not including the combined-before bytes. */
intervals = STRING_INTERVALS (new);
intervals = string_get_intervals (new);
/* Insert those intervals. */
graft_intervals_into_buffer (intervals, from, inschars,
current_buffer, inherit);
......
......@@ -84,7 +84,7 @@ create_root_interval (Lisp_Object parent)
{
new->total_length = SCHARS (parent);
eassert (0 <= TOTAL_LENGTH (new));
STRING_SET_INTERVALS (parent, new);
string_set_intervals (parent, new);
new->position = 0;
}
......@@ -455,7 +455,7 @@ balance_possible_root_interval (register INTERVAL interval)
if (BUFFERP (parent))
BUF_INTERVALS (XBUFFER (parent)) = interval;
else if (STRINGP (parent))
STRING_SET_INTERVALS (parent, interval);
string_set_intervals (parent, interval);
}
return interval;
......@@ -1206,7 +1206,7 @@ delete_interval (register INTERVAL i)
if (BUFFERP (owner))
BUF_INTERVALS (XBUFFER (owner)) = parent;
else if (STRINGP (owner))
STRING_SET_INTERVALS (owner, parent);
string_set_intervals (owner, parent);
else
abort ();
......@@ -2126,7 +2126,7 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val,
else if (BUFFERP (object))
i = find_interval (BUF_INTERVALS (XBUFFER (object)), pos);
else if (STRINGP (object))
i = find_interval (STRING_INTERVALS (object), pos);
i = find_interval (string_get_intervals (object), pos);
else
abort ();
......@@ -2259,7 +2259,7 @@ copy_intervals_to_string (Lisp_Object string, struct buffer *buffer,
return;
interval_set_object (interval_copy, string);
STRING_SET_INTERVALS (string, interval_copy);
string_set_intervals (string, interval_copy);
}
/* Return 1 if strings S1 and S2 have identical properties; 0 otherwise.
......@@ -2272,8 +2272,8 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
ptrdiff_t pos = 0;
ptrdiff_t end = SCHARS (s1);
i1 = find_interval (STRING_INTERVALS (s1), 0);
i2 = find_interval (STRING_INTERVALS (s2), 0);
i1 = find_interval (string_get_intervals (s1), 0);
i2 = find_interval (string_get_intervals (s2), 0);
while (pos < end)
{
......
......@@ -752,12 +752,6 @@ static ptrdiff_t const STRING_BYTES_BOUND =
(STR) = empty_multibyte_string; \
else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0)
/* Get text properties. */
#define STRING_INTERVALS(STR) (XSTRING (STR)->intervals + 0)
/* Set text properties. */
#define STRING_SET_INTERVALS(STR, INT) (XSTRING (STR)->intervals = (INT))
/* In a string or vector, the sign bit of the `size' is the gc mark bit. */
struct Lisp_String
......@@ -2420,6 +2414,22 @@ set_overlay_plist (Lisp_Object overlay, Lisp_Object plist)
XOVERLAY (overlay)->plist = plist;
}
/* Get text properties of S. */
LISP_INLINE INTERVAL
string_get_intervals (Lisp_Object s)
{
return XSTRING (s)->intervals;
}
/* Set text properties of S to I. */
LISP_INLINE void
string_set_intervals (Lisp_Object s, INTERVAL i)
{
XSTRING (s)->intervals = i;
}
/* Defined in data.c. */
extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
......
......@@ -3189,7 +3189,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj
/* Check for text properties in each interval.
substitute_in_interval contains part of the logic. */
INTERVAL root_interval = STRING_INTERVALS (subtree);
INTERVAL root_interval = string_get_intervals (subtree);
Lisp_Object arg = Fcons (object, placeholder);
traverse_intervals_noorder (root_interval,
......
......@@ -1194,7 +1194,7 @@ print_preprocess (Lisp_Object obj)
{
case Lisp_String:
/* A string may have text properties, which can be circular. */
traverse_intervals_noorder (STRING_INTERVALS (obj),
traverse_intervals_noorder (string_get_intervals (obj),
print_preprocess_string, Qnil);
break;
......@@ -1297,7 +1297,7 @@ static Lisp_Object
print_prune_string_charset (Lisp_Object string)
{
print_check_string_result = 0;
traverse_intervals (STRING_INTERVALS (string), 0,
traverse_intervals (string_get_intervals (string), 0,
print_check_string_charset_prop, string);
if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND))
{
......@@ -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 (STRING_INTERVALS (obj))
if (string_get_intervals (obj))
{
PRINTCHAR ('#');
PRINTCHAR ('(');
......@@ -1499,9 +1499,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag
}
PRINTCHAR ('\"');
if (STRING_INTERVALS (obj))
if (string_get_intervals (obj))
{
traverse_intervals (STRING_INTERVALS (obj),
traverse_intervals (string_get_intervals (obj),
0, print_interval, printcharfun);
PRINTCHAR (')');
}
......
......@@ -161,7 +161,7 @@ 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_get_intervals (object);
if (len == 0)
return NULL;
......@@ -516,7 +516,7 @@ interval_of (ptrdiff_t position, Lisp_Object object)
{
beg = 0;
end = SCHARS (object);
i = STRING_INTERVALS (object);
i = string_get_intervals (object);
}
if (!(beg <= position && position <= end))
......@@ -1274,10 +1274,10 @@ 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_get_intervals (object))
return Qnil;
STRING_SET_INTERVALS (object, NULL);
string_set_intervals (object, NULL);
return Qt;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment