diff options
Diffstat (limited to 'src/intervals.c')
| -rw-r--r-- | src/intervals.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/src/intervals.c b/src/intervals.c index ad46c17d588..f9e9c864e13 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -39,6 +39,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 39 | 39 | ||
| 40 | #include <config.h> | 40 | #include <config.h> |
| 41 | #include <setjmp.h> | 41 | #include <setjmp.h> |
| 42 | #include <intprops.h> | ||
| 42 | #include "lisp.h" | 43 | #include "lisp.h" |
| 43 | #include "intervals.h" | 44 | #include "intervals.h" |
| 44 | #include "buffer.h" | 45 | #include "buffer.h" |
| @@ -51,7 +52,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 51 | 52 | ||
| 52 | #define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set)) | 53 | #define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set)) |
| 53 | 54 | ||
| 54 | Lisp_Object merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright); | 55 | static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object); |
| 56 | static INTERVAL merge_interval_right (INTERVAL); | ||
| 55 | static INTERVAL reproduce_tree (INTERVAL, INTERVAL); | 57 | static INTERVAL reproduce_tree (INTERVAL, INTERVAL); |
| 56 | static INTERVAL reproduce_tree_obj (INTERVAL, Lisp_Object); | 58 | static INTERVAL reproduce_tree_obj (INTERVAL, Lisp_Object); |
| 57 | 59 | ||
| @@ -311,7 +313,7 @@ root_interval (interval) | |||
| 311 | c c | 313 | c c |
| 312 | */ | 314 | */ |
| 313 | 315 | ||
| 314 | static INLINE INTERVAL | 316 | static inline INTERVAL |
| 315 | rotate_right (INTERVAL interval) | 317 | rotate_right (INTERVAL interval) |
| 316 | { | 318 | { |
| 317 | INTERVAL i; | 319 | INTERVAL i; |
| @@ -358,7 +360,7 @@ rotate_right (INTERVAL interval) | |||
| 358 | c c | 360 | c c |
| 359 | */ | 361 | */ |
| 360 | 362 | ||
| 361 | static INLINE INTERVAL | 363 | static inline INTERVAL |
| 362 | rotate_left (INTERVAL interval) | 364 | rotate_left (INTERVAL interval) |
| 363 | { | 365 | { |
| 364 | INTERVAL i; | 366 | INTERVAL i; |
| @@ -436,7 +438,7 @@ balance_an_interval (INTERVAL i) | |||
| 436 | /* Balance INTERVAL, potentially stuffing it back into its parent | 438 | /* Balance INTERVAL, potentially stuffing it back into its parent |
| 437 | Lisp Object. */ | 439 | Lisp Object. */ |
| 438 | 440 | ||
| 439 | static INLINE INTERVAL | 441 | static inline INTERVAL |
| 440 | balance_possible_root_interval (register INTERVAL interval) | 442 | balance_possible_root_interval (register INTERVAL interval) |
| 441 | { | 443 | { |
| 442 | Lisp_Object parent; | 444 | Lisp_Object parent; |
| @@ -586,7 +588,7 @@ split_interval_left (INTERVAL interval, EMACS_INT offset) | |||
| 586 | Don't use this function on an interval which is the child | 588 | Don't use this function on an interval which is the child |
| 587 | of another interval! */ | 589 | of another interval! */ |
| 588 | 590 | ||
| 589 | int | 591 | static int |
| 590 | interval_start_pos (INTERVAL source) | 592 | interval_start_pos (INTERVAL source) |
| 591 | { | 593 | { |
| 592 | Lisp_Object parent; | 594 | Lisp_Object parent; |
| @@ -777,7 +779,7 @@ update_interval (register INTERVAL i, EMACS_INT pos) | |||
| 777 | i = i->right; /* Move to the right child */ | 779 | i = i->right; /* Move to the right child */ |
| 778 | } | 780 | } |
| 779 | else if (NULL_PARENT (i)) | 781 | else if (NULL_PARENT (i)) |
| 780 | error ("Point %d after end of properties", pos); | 782 | error ("Point %"pI"d after end of properties", pos); |
| 781 | else | 783 | else |
| 782 | i = INTERVAL_PARENT (i); | 784 | i = INTERVAL_PARENT (i); |
| 783 | continue; | 785 | continue; |
| @@ -804,9 +806,9 @@ update_interval (register INTERVAL i, EMACS_INT pos) | |||
| 804 | static INTERVAL | 806 | static INTERVAL |
| 805 | adjust_intervals_for_insertion (tree, position, length) | 807 | adjust_intervals_for_insertion (tree, position, length) |
| 806 | INTERVAL tree; | 808 | INTERVAL tree; |
| 807 | int position, length; | 809 | EMACS_INT position, length; |
| 808 | { | 810 | { |
| 809 | register int relative_position; | 811 | register EMACS_INT relative_position; |
| 810 | register INTERVAL this; | 812 | register INTERVAL this; |
| 811 | 813 | ||
| 812 | if (TOTAL_LENGTH (tree) == 0) /* Paranoia */ | 814 | if (TOTAL_LENGTH (tree) == 0) /* Paranoia */ |
| @@ -1089,7 +1091,7 @@ FR 8 9 A B | |||
| 1089 | left rear-nonsticky = t, right front-sticky = nil (inherit none) | 1091 | left rear-nonsticky = t, right front-sticky = nil (inherit none) |
| 1090 | */ | 1092 | */ |
| 1091 | 1093 | ||
| 1092 | Lisp_Object | 1094 | static Lisp_Object |
| 1093 | merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright) | 1095 | merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright) |
| 1094 | { | 1096 | { |
| 1095 | register Lisp_Object props, front, rear; | 1097 | register Lisp_Object props, front, rear; |
| @@ -1258,7 +1260,7 @@ delete_node (register INTERVAL i) | |||
| 1258 | I is presumed to be empty; that is, no adjustments are made | 1260 | I is presumed to be empty; that is, no adjustments are made |
| 1259 | for the length of I. */ | 1261 | for the length of I. */ |
| 1260 | 1262 | ||
| 1261 | void | 1263 | static void |
| 1262 | delete_interval (register INTERVAL i) | 1264 | delete_interval (register INTERVAL i) |
| 1263 | { | 1265 | { |
| 1264 | register INTERVAL parent; | 1266 | register INTERVAL parent; |
| @@ -1325,8 +1327,8 @@ interval_deletion_adjustment (register INTERVAL tree, register EMACS_INT from, | |||
| 1325 | if (relative_position < LEFT_TOTAL_LENGTH (tree)) | 1327 | if (relative_position < LEFT_TOTAL_LENGTH (tree)) |
| 1326 | { | 1328 | { |
| 1327 | EMACS_INT subtract = interval_deletion_adjustment (tree->left, | 1329 | EMACS_INT subtract = interval_deletion_adjustment (tree->left, |
| 1328 | relative_position, | 1330 | relative_position, |
| 1329 | amount); | 1331 | amount); |
| 1330 | tree->total_length -= subtract; | 1332 | tree->total_length -= subtract; |
| 1331 | CHECK_TOTAL_LENGTH (tree); | 1333 | CHECK_TOTAL_LENGTH (tree); |
| 1332 | return subtract; | 1334 | return subtract; |
| @@ -1425,7 +1427,7 @@ adjust_intervals_for_deletion (struct buffer *buffer, | |||
| 1425 | at position START. Addition or deletion is indicated by the sign | 1427 | at position START. Addition or deletion is indicated by the sign |
| 1426 | of LENGTH. */ | 1428 | of LENGTH. */ |
| 1427 | 1429 | ||
| 1428 | INLINE void | 1430 | inline void |
| 1429 | offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) | 1431 | offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) |
| 1430 | { | 1432 | { |
| 1431 | if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) | 1433 | if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) |
| @@ -1434,7 +1436,10 @@ offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) | |||
| 1434 | if (length > 0) | 1436 | if (length > 0) |
| 1435 | adjust_intervals_for_insertion (BUF_INTERVALS (buffer), start, length); | 1437 | adjust_intervals_for_insertion (BUF_INTERVALS (buffer), start, length); |
| 1436 | else | 1438 | else |
| 1437 | adjust_intervals_for_deletion (buffer, start, -length); | 1439 | { |
| 1440 | IF_LINT (if (length < - TYPE_MAXIMUM (EMACS_INT)) abort ();) | ||
| 1441 | adjust_intervals_for_deletion (buffer, start, -length); | ||
| 1442 | } | ||
| 1438 | } | 1443 | } |
| 1439 | 1444 | ||
| 1440 | /* Merge interval I with its lexicographic successor. The resulting | 1445 | /* Merge interval I with its lexicographic successor. The resulting |
| @@ -1446,7 +1451,7 @@ offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) | |||
| 1446 | The caller must verify that this is not the last (rightmost) | 1451 | The caller must verify that this is not the last (rightmost) |
| 1447 | interval. */ | 1452 | interval. */ |
| 1448 | 1453 | ||
| 1449 | INTERVAL | 1454 | static INTERVAL |
| 1450 | merge_interval_right (register INTERVAL i) | 1455 | merge_interval_right (register INTERVAL i) |
| 1451 | { | 1456 | { |
| 1452 | register EMACS_INT absorb = LENGTH (i); | 1457 | register EMACS_INT absorb = LENGTH (i); |
| @@ -1677,7 +1682,7 @@ graft_intervals_into_buffer (INTERVAL source, EMACS_INT position, | |||
| 1677 | EMACS_INT length, struct buffer *buffer, | 1682 | EMACS_INT length, struct buffer *buffer, |
| 1678 | int inherit) | 1683 | int inherit) |
| 1679 | { | 1684 | { |
| 1680 | register INTERVAL under, over, this, prev; | 1685 | register INTERVAL under, over, this; |
| 1681 | register INTERVAL tree; | 1686 | register INTERVAL tree; |
| 1682 | EMACS_INT over_used; | 1687 | EMACS_INT over_used; |
| 1683 | 1688 | ||
| @@ -1767,7 +1772,8 @@ graft_intervals_into_buffer (INTERVAL source, EMACS_INT position, | |||
| 1767 | /* This call may have some effect because previous_interval may | 1772 | /* This call may have some effect because previous_interval may |
| 1768 | update `position' fields of intervals. Thus, don't ignore it | 1773 | update `position' fields of intervals. Thus, don't ignore it |
| 1769 | for the moment. Someone please tell me the truth (K.Handa). */ | 1774 | for the moment. Someone please tell me the truth (K.Handa). */ |
| 1770 | prev = previous_interval (under); | 1775 | INTERVAL prev = previous_interval (under); |
| 1776 | (void) prev; | ||
| 1771 | #if 0 | 1777 | #if 0 |
| 1772 | /* But, this code surely has no effect. And, anyway, | 1778 | /* But, this code surely has no effect. And, anyway, |
| 1773 | END_NONSTICKY_P is unreliable now. */ | 1779 | END_NONSTICKY_P is unreliable now. */ |
| @@ -1877,7 +1883,7 @@ lookup_char_property (Lisp_Object plist, register Lisp_Object prop, int textprop | |||
| 1877 | /* Set point in BUFFER "temporarily" to CHARPOS, which corresponds to | 1883 | /* Set point in BUFFER "temporarily" to CHARPOS, which corresponds to |
| 1878 | byte position BYTEPOS. */ | 1884 | byte position BYTEPOS. */ |
| 1879 | 1885 | ||
| 1880 | INLINE void | 1886 | inline void |
| 1881 | temp_set_point_both (struct buffer *buffer, | 1887 | temp_set_point_both (struct buffer *buffer, |
| 1882 | EMACS_INT charpos, EMACS_INT bytepos) | 1888 | EMACS_INT charpos, EMACS_INT bytepos) |
| 1883 | { | 1889 | { |
| @@ -1892,13 +1898,12 @@ temp_set_point_both (struct buffer *buffer, | |||
| 1892 | if (charpos > BUF_ZV (buffer) || charpos < BUF_BEGV (buffer)) | 1898 | if (charpos > BUF_ZV (buffer) || charpos < BUF_BEGV (buffer)) |
| 1893 | abort (); | 1899 | abort (); |
| 1894 | 1900 | ||
| 1895 | BUF_PT_BYTE (buffer) = bytepos; | 1901 | SET_BUF_PT_BOTH (buffer, charpos, bytepos); |
| 1896 | BUF_PT (buffer) = charpos; | ||
| 1897 | } | 1902 | } |
| 1898 | 1903 | ||
| 1899 | /* Set point "temporarily", without checking any text properties. */ | 1904 | /* Set point "temporarily", without checking any text properties. */ |
| 1900 | 1905 | ||
| 1901 | INLINE void | 1906 | inline void |
| 1902 | temp_set_point (struct buffer *buffer, EMACS_INT charpos) | 1907 | temp_set_point (struct buffer *buffer, EMACS_INT charpos) |
| 1903 | { | 1908 | { |
| 1904 | temp_set_point_both (buffer, charpos, | 1909 | temp_set_point_both (buffer, charpos, |
| @@ -1978,7 +1983,7 @@ set_point_both (EMACS_INT charpos, EMACS_INT bytepos) | |||
| 1978 | int have_overlays; | 1983 | int have_overlays; |
| 1979 | EMACS_INT original_position; | 1984 | EMACS_INT original_position; |
| 1980 | 1985 | ||
| 1981 | current_buffer->point_before_scroll = Qnil; | 1986 | BVAR (current_buffer, point_before_scroll) = Qnil; |
| 1982 | 1987 | ||
| 1983 | if (charpos == PT) | 1988 | if (charpos == PT) |
| 1984 | return; | 1989 | return; |
| @@ -2312,10 +2317,9 @@ get_local_map (register EMACS_INT position, register struct buffer *buffer, | |||
| 2312 | old_zv = BUF_ZV (buffer); | 2317 | old_zv = BUF_ZV (buffer); |
| 2313 | old_begv_byte = BUF_BEGV_BYTE (buffer); | 2318 | old_begv_byte = BUF_BEGV_BYTE (buffer); |
| 2314 | old_zv_byte = BUF_ZV_BYTE (buffer); | 2319 | old_zv_byte = BUF_ZV_BYTE (buffer); |
| 2315 | BUF_BEGV (buffer) = BUF_BEG (buffer); | 2320 | |
| 2316 | BUF_ZV (buffer) = BUF_Z (buffer); | 2321 | SET_BUF_BEGV_BOTH (buffer, BUF_BEG (buffer), BUF_BEG_BYTE (buffer)); |
| 2317 | BUF_BEGV_BYTE (buffer) = BUF_BEG_BYTE (buffer); | 2322 | SET_BUF_ZV_BOTH (buffer, BUF_Z (buffer), BUF_Z_BYTE (buffer)); |
| 2318 | BUF_ZV_BYTE (buffer) = BUF_Z_BYTE (buffer); | ||
| 2319 | 2323 | ||
| 2320 | XSETFASTINT (lispy_position, position); | 2324 | XSETFASTINT (lispy_position, position); |
| 2321 | XSETBUFFER (lispy_buffer, buffer); | 2325 | XSETBUFFER (lispy_buffer, buffer); |
| @@ -2329,10 +2333,8 @@ get_local_map (register EMACS_INT position, register struct buffer *buffer, | |||
| 2329 | if (NILP (prop)) | 2333 | if (NILP (prop)) |
| 2330 | prop = get_pos_property (lispy_position, type, lispy_buffer); | 2334 | prop = get_pos_property (lispy_position, type, lispy_buffer); |
| 2331 | 2335 | ||
| 2332 | BUF_BEGV (buffer) = old_begv; | 2336 | SET_BUF_BEGV_BOTH (buffer, old_begv, old_begv_byte); |
| 2333 | BUF_ZV (buffer) = old_zv; | 2337 | SET_BUF_ZV_BOTH (buffer, old_zv, old_zv_byte); |
| 2334 | BUF_BEGV_BYTE (buffer) = old_begv_byte; | ||
| 2335 | BUF_ZV_BYTE (buffer) = old_zv_byte; | ||
| 2336 | 2338 | ||
| 2337 | /* Use the local map only if it is valid. */ | 2339 | /* Use the local map only if it is valid. */ |
| 2338 | prop = get_keymap (prop, 0, 0); | 2340 | prop = get_keymap (prop, 0, 0); |
| @@ -2342,7 +2344,7 @@ get_local_map (register EMACS_INT position, register struct buffer *buffer, | |||
| 2342 | if (EQ (type, Qkeymap)) | 2344 | if (EQ (type, Qkeymap)) |
| 2343 | return Qnil; | 2345 | return Qnil; |
| 2344 | else | 2346 | else |
| 2345 | return buffer->keymap; | 2347 | return BVAR (buffer, keymap); |
| 2346 | } | 2348 | } |
| 2347 | 2349 | ||
| 2348 | /* Produce an interval tree reflecting the intervals in | 2350 | /* Produce an interval tree reflecting the intervals in |
| @@ -2390,7 +2392,7 @@ copy_intervals (INTERVAL tree, EMACS_INT start, EMACS_INT length) | |||
| 2390 | 2392 | ||
| 2391 | /* Give STRING the properties of BUFFER from POSITION to LENGTH. */ | 2393 | /* Give STRING the properties of BUFFER from POSITION to LENGTH. */ |
| 2392 | 2394 | ||
| 2393 | INLINE void | 2395 | inline void |
| 2394 | copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, | 2396 | copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, |
| 2395 | EMACS_INT position, EMACS_INT length) | 2397 | EMACS_INT position, EMACS_INT length) |
| 2396 | { | 2398 | { |
| @@ -2563,4 +2565,3 @@ set_intervals_multibyte (int multi_flag) | |||
| 2563 | set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, | 2565 | set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, |
| 2564 | BEG, BEG_BYTE, Z, Z_BYTE); | 2566 | BEG, BEG_BYTE, Z, Z_BYTE); |
| 2565 | } | 2567 | } |
| 2566 | |||