* 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 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.
}
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)
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;
all_buffers = b;
name = Fcopy_sequence (name);
- STRING_SET_INTERVALS (name, NULL);
+ string_set_intervals (name, NULL);
BVAR (b, name) = name;
reset_buffer (b);
/* 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;
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;
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;
/* 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;
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;
}
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);
/* 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);
{
new->total_length = SCHARS (parent);
eassert (0 <= TOTAL_LENGTH (new));
- STRING_SET_INTERVALS (parent, new);
+ string_set_intervals (parent, new);
new->position = 0;
}
if (BUFFERP (parent))
BUF_INTERVALS (XBUFFER (parent)) = interval;
else if (STRINGP (parent))
- STRING_SET_INTERVALS (parent, interval);
+ string_set_intervals (parent, interval);
}
return interval;
if (BUFFERP (owner))
BUF_INTERVALS (XBUFFER (owner)) = parent;
else if (STRINGP (owner))
- STRING_SET_INTERVALS (owner, parent);
+ string_set_intervals (owner, parent);
else
abort ();
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 ();
return;
interval_set_object (interval_copy, string);
- STRING_SET_INTERVALS (string, interval_copy);
+ string_set_intervals (string, interval_copy);
}
\f
/* Return 1 if strings S1 and S2 have identical properties; 0 otherwise.
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)
{
(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
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;
/* 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,
{
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;
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))
{
if (! EQ (Vprint_charset_text_property, Qt))
obj = print_prune_string_charset (obj);
- if (STRING_INTERVALS (obj))
+ if (string_get_intervals (obj))
{
PRINTCHAR ('#');
PRINTCHAR ('(');
}
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 (')');
}
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;
{
beg = 0;
end = SCHARS (object);
- i = STRING_INTERVALS (object);
+ i = string_get_intervals (object);
}
if (!(beg <= position && position <= end))
&& 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;
}