X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0f74f7850de124626d556442d22d143d85457816..6dd5a677dbf794eedaa8325c46d57ac041373361:/src/textprop.c
diff --git a/src/textprop.c b/src/textprop.c
index 29425f7a55..4562cc0bd1 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1,5 +1,5 @@
/* 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.
@@ -20,13 +20,10 @@ along with GNU Emacs. If not, see . */
#include
#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. */
@@ -75,15 +72,11 @@ Lisp_Object Qfront_sticky, Qrear_nonsticky;
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))
@@ -124,7 +117,7 @@ INTERVAL
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);
@@ -160,7 +153,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en
}
else
{
- EMACS_INT len = SCHARS (object);
+ ptrdiff_t len = SCHARS (object);
if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
&& XINT (*end) <= len))
@@ -514,10 +507,10 @@ erase_properties (INTERVAL i)
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);
@@ -775,7 +768,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
else
{
Lisp_Object initial_value, value;
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
if (! NILP (object))
CHECK_BUFFER (object);
@@ -858,7 +851,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT. */)
}
else
{
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
if (! NILP (object))
CHECK_BUFFER (object);
@@ -1140,7 +1133,7 @@ Return t if any property value actually changed, nil otherwise. */)
(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;
@@ -1170,7 +1163,7 @@ Return t if any property value actually changed, nil otherwise. */)
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;
@@ -1345,7 +1338,7 @@ 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 EMACS_INT s, len;
+ register ptrdiff_t s, len;
INTERVAL unchanged;
if (XINT (start) < XINT (end))
@@ -1438,7 +1431,7 @@ Use `set-text-properties' if you want to remove all text properties. */)
(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))
@@ -1457,7 +1450,7 @@ Use `set-text-properties' if you want to remove all text properties. */)
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;
@@ -1524,7 +1517,7 @@ Return t if any property was actually removed, nil otherwise. */)
(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;
@@ -1545,7 +1538,7 @@ Return t if any property was actually removed, nil otherwise. */)
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;
@@ -1625,7 +1618,7 @@ Return t if any property was actually removed, nil otherwise. */)
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
@@ -1634,7 +1627,7 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. */
(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);
@@ -1661,7 +1654,7 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. */
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
@@ -1670,7 +1663,7 @@ markers). If OBJECT is a string, START and END are 0-based indices into it. */
(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);
@@ -1780,7 +1773,7 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_
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;
@@ -1792,8 +1785,11 @@ copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_
{
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);
@@ -1877,12 +1873,12 @@ text_property_list (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp
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);
@@ -1960,7 +1956,7 @@ Lisp_Object
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))
{
@@ -2014,7 +2010,7 @@ call_mod_hooks (Lisp_Object list, Lisp_Object start, Lisp_Object end)
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;
@@ -2035,7 +2031,7 @@ verify_interval_modification (struct buffer *buf,
if (start > end)
{
- EMACS_INT temp = start;
+ ptrdiff_t temp = start;
start = end;
end = temp;
}
@@ -2227,7 +2223,7 @@ This also inhibits the use of the `intangible' text property. */);
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