/* Interface code for dealing with text properties.
- Copyright (C) 1993-1995, 1997, 1999-2011 Free Software Foundation, Inc.
+ Copyright (C) 1993-1995, 1997, 1999-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <setjmp.h>
#include "lisp.h"
#include "intervals.h"
+#include "character.h"
#include "buffer.h"
#include "window.h"
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
/* Test for membership, allowing for t (actually any non-cons) to mean the
universal set. */
static Lisp_Object interval_insert_behind_hooks;
static Lisp_Object interval_insert_in_front_hooks;
-static void text_read_only (Lisp_Object) NO_RETURN;
-static Lisp_Object Fprevious_property_change (Lisp_Object, Lisp_Object,
- Lisp_Object);
-
/* Signal a `text-read-only' error. This function makes it easier
to capture that error in GDB by putting a breakpoint on it. */
-static void
+static _Noreturn void
text_read_only (Lisp_Object propval)
{
if (STRINGP (propval))
validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *end, int force)
{
register INTERVAL i;
- EMACS_INT searchpos;
+ ptrdiff_t searchpos;
CHECK_STRING_OR_BUFFER (object);
CHECK_NUMBER_COERCE_MARKER (*begin);
}
else
{
- EMACS_INT len = SCHARS (object);
+ ptrdiff_t len = SCHARS (object);
if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
&& XINT (*end) <= len))
/* Go through each element of LIST. */
for (tail1 = list; CONSP (tail1); tail1 = XCDR (tail1))
{
- sym = Fcar (tail1);
+ sym = XCAR (tail1);
/* Go through i's plist, looking for tail1 */
for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2)))
i->plist = current_plist;
return changed;
}
-
-#if 0
-/* Remove all properties from interval I. Return non-zero
- if this changes the interval. */
-
-static inline int
-erase_properties (INTERVAL i)
-{
- if (NILP (i->plist))
- return 0;
-
- i->plist = Qnil;
- return 1;
-}
-#endif
\f
/* Returns the interval of POSITION in OBJECT.
POSITION is BEG-based. */
INTERVAL
-interval_of (EMACS_INT position, Lisp_Object object)
+interval_of (ptrdiff_t position, Lisp_Object object)
{
register INTERVAL i;
- EMACS_INT beg, end;
+ ptrdiff_t beg, end;
if (NILP (object))
XSETBUFFER (object, current_buffer);
if (WINDOWP (object))
{
w = XWINDOW (object);
- object = w->buffer;
+ object = WGET (w, buffer);
}
if (BUFFERP (object))
{
else
{
Lisp_Object initial_value, value;
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
if (! NILP (object))
CHECK_BUFFER (object);
}
else
{
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
if (! NILP (object))
CHECK_BUFFER (object);
(Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
{
register INTERVAL i, unchanged;
- register EMACS_INT s, len;
+ register ptrdiff_t s, len;
register int modified = 0;
struct gcpro gcpro1;
skip it. */
if (interval_has_all_properties (properties, i))
{
- EMACS_INT got = (LENGTH (i) - (s - i->position));
+ ptrdiff_t got = (LENGTH (i) - (s - i->position));
if (got >= len)
RETURN_UNGCPRO (Qnil);
len -= got;
/* We are at the beginning of interval I, with LEN chars to scan. */
for (;;)
{
- if (i == 0)
- abort ();
+ eassert (i != 0);
if (LENGTH (i) >= len)
{
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 EMACS_INT s, len;
+ register ptrdiff_t s, len;
INTERVAL unchanged;
if (XINT (start) < XINT (end))
/* We are starting at the beginning of an interval I. LEN is positive. */
do
{
- if (i == 0)
- abort ();
+ eassert (i != 0);
if (LENGTH (i) >= len)
{
(Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
{
register INTERVAL i, unchanged;
- register EMACS_INT s, len;
+ register ptrdiff_t s, len;
register int modified = 0;
if (NILP (object))
it covers the entire region. */
if (! interval_has_some_properties (properties, i))
{
- EMACS_INT got = (LENGTH (i) - (s - i->position));
+ ptrdiff_t got = (LENGTH (i) - (s - i->position));
if (got >= len)
return Qnil;
len -= got;
/* We are at the beginning of an interval, with len to scan */
for (;;)
{
- if (i == 0)
- abort ();
+ eassert (i != 0);
if (LENGTH (i) >= len)
{
(Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object)
{
register INTERVAL i, unchanged;
- register EMACS_INT s, len;
+ register ptrdiff_t s, len;
register int modified = 0;
Lisp_Object properties;
properties = list_of_properties;
it covers the entire region. */
if (! interval_has_some_properties_list (properties, i))
{
- EMACS_INT got = (LENGTH (i) - (s - i->position));
+ ptrdiff_t got = (LENGTH (i) - (s - i->position));
if (got >= len)
return Qnil;
len -= got;
and we call signal_after_change before returning if modified != 0. */
for (;;)
{
- if (i == 0)
- abort ();
+ eassert (i != 0);
if (LENGTH (i) >= len)
{
\f
DEFUN ("text-property-any", Ftext_property_any,
Stext_property_any, 4, 5, 0,
- doc: /* Check text from START to END for property PROPERTY equalling VALUE.
+ doc: /* Check text from START to END for property PROPERTY equaling VALUE.
If so, return the position of the first character whose property PROPERTY
is `eq' to VALUE. Otherwise return nil.
If the optional fifth argument OBJECT is a buffer (or nil, which means
(Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
{
register INTERVAL i;
- register EMACS_INT e, pos;
+ register ptrdiff_t e, pos;
if (NILP (object))
XSETBUFFER (object, current_buffer);
DEFUN ("text-property-not-all", Ftext_property_not_all,
Stext_property_not_all, 4, 5, 0,
- doc: /* Check text from START to END for property PROPERTY not equalling VALUE.
+ doc: /* Check text from START to END for property PROPERTY not equaling VALUE.
If so, return the position of the first character whose property PROPERTY
is not `eq' to VALUE. Otherwise, return nil.
If the optional fifth argument OBJECT is a buffer (or nil, which means
(Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
{
register INTERVAL i;
- register EMACS_INT s, e;
+ register ptrdiff_t s, e;
if (NILP (object))
XSETBUFFER (object, current_buffer);
Lisp_Object res;
Lisp_Object stuff;
Lisp_Object plist;
- EMACS_INT s, e, e2, p, len;
+ ptrdiff_t s, e, e2, p, len;
int modified = 0;
struct gcpro gcpro1, gcpro2;
{
Lisp_Object dest_start, dest_end;
+ e = XINT (pos) + (XINT (end) - XINT (start));
+ if (MOST_POSITIVE_FIXNUM < e)
+ args_out_of_range (pos, end);
dest_start = pos;
- XSETFASTINT (dest_end, XINT (dest_start) + (XINT (end) - XINT (start)));
+ XSETFASTINT (dest_end, e);
/* Apply this to a copy of pos; it will try to increment its arguments,
which we don't want. */
validate_interval_range (dest, &dest_start, &dest_end, soft);
i = validate_interval_range (object, &start, &end, soft);
if (!NULL_INTERVAL_P (i))
{
- EMACS_INT s = XINT (start);
- EMACS_INT e = XINT (end);
+ ptrdiff_t s = XINT (start);
+ ptrdiff_t e = XINT (end);
while (s < e)
{
- EMACS_INT interval_end, len;
+ ptrdiff_t interval_end, len;
Lisp_Object plist;
interval_end = i->position + LENGTH (i);
extend_property_ranges (Lisp_Object list, Lisp_Object new_end)
{
Lisp_Object prev = Qnil, head = list;
- EMACS_INT max = XINT (new_end);
+ ptrdiff_t max = XINT (new_end);
for (; CONSP (list); prev = list, list = XCDR (list))
{
void
verify_interval_modification (struct buffer *buf,
- EMACS_INT start, EMACS_INT end)
+ ptrdiff_t start, ptrdiff_t end)
{
register INTERVAL intervals = BUF_INTERVALS (buf);
register INTERVAL i;
if (start > end)
{
- EMACS_INT temp = start;
+ ptrdiff_t temp = start;
start = end;
end = temp;
}
DEFVAR_LISP ("text-property-default-nonsticky",
Vtext_property_default_nonsticky,
- doc: /* Alist of properties vs the corresponding non-stickinesses.
+ doc: /* Alist of properties vs the corresponding non-stickiness.
Each element has the form (PROPERTY . NONSTICKINESS).
If a character in a buffer has PROPERTY, new text inserted adjacent to