X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f46305c86cd247b2396e73ce8bb064f69373834d..657e54f709cb435a5ca93f0184e214dd9e586f29:/src/intervals.c
diff --git a/src/intervals.c b/src/intervals.c
index f65ce0ecc7..703c0cefbd 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1,5 +1,5 @@
/* Code for doing intervals.
- Copyright (C) 1993-1995, 1997-1998, 2001-2013 Free Software
+ Copyright (C) 1993-1995, 1997-1998, 2001-2014 Free Software
Foundation, Inc.
This file is part of GNU Emacs.
@@ -40,8 +40,6 @@ along with GNU Emacs. If not, see . */
#include
-#define INTERVALS_INLINE EXTERN_INLINE
-
#include
#include "lisp.h"
#include "intervals.h"
@@ -62,16 +60,7 @@ static INTERVAL reproduce_tree (INTERVAL, INTERVAL);
/* Utility functions for intervals. */
-/* Use these functions to set Lisp_Object
- or pointer slots of struct interval. */
-
-static void
-set_interval_object (INTERVAL i, Lisp_Object obj)
-{
- eassert (BUFFERP (obj) || STRINGP (obj));
- i->up_obj = 1;
- i->up.obj = obj;
-}
+/* Use these functions to set pointer slots of struct interval. */
static void
set_interval_left (INTERVAL i, INTERVAL left)
@@ -678,6 +667,7 @@ find_interval (register INTERVAL tree, register ptrdiff_t position)
while (1)
{
+ eassert (tree);
if (relative_position < LEFT_TOTAL_LENGTH (tree))
{
tree = tree->left;
@@ -1406,10 +1396,7 @@ offset_intervals (struct buffer *buffer, ptrdiff_t start, ptrdiff_t length)
adjust_intervals_for_insertion (buffer_intervals (buffer),
start, length);
else
- {
- lint_assume (- TYPE_MAXIMUM (ptrdiff_t) <= length);
- adjust_intervals_for_deletion (buffer, start, -length);
- }
+ adjust_intervals_for_deletion (buffer, start, -length);
}
/* Merge interval I with its lexicographic successor. The resulting
@@ -1794,8 +1781,7 @@ temp_set_point_both (struct buffer *buffer,
ptrdiff_t charpos, ptrdiff_t bytepos)
{
/* In a single-byte buffer, the two positions must be equal. */
- if (BUF_ZV (buffer) == BUF_ZV_BYTE (buffer))
- eassert (charpos == bytepos);
+ eassert (BUF_ZV (buffer) != BUF_ZV_BYTE (buffer) || charpos == bytepos);
eassert (charpos <= bytepos);
eassert (charpos <= BUF_ZV (buffer) || BUF_BEGV (buffer) <= charpos);
@@ -1821,6 +1807,18 @@ set_point (ptrdiff_t charpos)
set_point_both (charpos, buf_charpos_to_bytepos (current_buffer, charpos));
}
+/* Set PT from MARKER's clipped position. */
+
+void
+set_point_from_marker (Lisp_Object marker)
+{
+ if (XMARKER (marker)->buffer != current_buffer)
+ signal_error ("Marker points into wrong buffer", marker);
+ set_point_both
+ (clip_to_bounds (BEGV, marker_position (marker), ZV),
+ clip_to_bounds (BEGV_BYTE, marker_byte_position (marker), ZV_BYTE));
+}
+
/* If there's an invisible character at position POS + TEST_OFFS in the
current buffer, and the invisible property has a `stickiness' such that
inserting a character at position POS would inherit the property it,
@@ -2196,20 +2194,15 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val,
/* Return the proper local keymap TYPE for position POSITION in
BUFFER; TYPE should be one of `keymap' or `local-map'. Use the map
specified by the PROP property, if any. Otherwise, if TYPE is
- `local-map' use BUFFER's local map.
-
- POSITION must be in the accessible part of BUFFER. */
+ `local-map' use BUFFER's local map. */
Lisp_Object
-get_local_map (register ptrdiff_t position, register struct buffer *buffer,
- Lisp_Object type)
+get_local_map (ptrdiff_t position, struct buffer *buffer, Lisp_Object type)
{
Lisp_Object prop, lispy_position, lispy_buffer;
ptrdiff_t old_begv, old_zv, old_begv_byte, old_zv_byte;
- /* Perhaps we should just change `position' to the limit. */
- if (position > BUF_ZV (buffer) || position < BUF_BEGV (buffer))
- emacs_abort ();
+ position = clip_to_bounds (BUF_BEGV (buffer), position, BUF_ZV (buffer));
/* Ignore narrowing, so that a local map continues to be valid even if
the visible region contains no characters and hence no properties. */
@@ -2231,7 +2224,7 @@ get_local_map (register ptrdiff_t position, register struct buffer *buffer,
editing a field with a `local-map' property, we want insertion at the end
to obey the `local-map' property. */
if (NILP (prop))
- prop = get_pos_property (lispy_position, type, lispy_buffer);
+ prop = Fget_pos_property (lispy_position, type, lispy_buffer);
SET_BUF_BEGV_BOTH (buffer, old_begv, old_begv_byte);
SET_BUF_ZV_BOTH (buffer, old_zv, old_zv_byte);