diff options
| author | Stefan Monnier | 2022-09-25 16:15:16 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2022-09-25 16:15:16 -0400 |
| commit | 650c20f1ca4e07591a727e1cfcc74b3363d15985 (patch) | |
| tree | 85d11f6437cde22f410c25e0e5f71a3131ebd07d /src/intervals.c | |
| parent | 8869332684c2302b5ba1ead4568bbc7ba1c0183e (diff) | |
| parent | 4b85ae6a24380fb67a3315eaec9233f17a872473 (diff) | |
| download | emacs-650c20f1ca4e07591a727e1cfcc74b3363d15985.tar.gz emacs-650c20f1ca4e07591a727e1cfcc74b3363d15985.zip | |
Merge 'master' into noverlay
Diffstat (limited to 'src/intervals.c')
| -rw-r--r-- | src/intervals.c | 167 |
1 files changed, 83 insertions, 84 deletions
diff --git a/src/intervals.c b/src/intervals.c index 3db80ebed4a..78f4f6b6174 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Code for doing intervals. | 1 | /* Code for doing intervals. |
| 2 | Copyright (C) 1993-1995, 1997-1998, 2001-2017 Free Software | 2 | Copyright (C) 1993-1995, 1997-1998, 2001-2022 Free Software |
| 3 | Foundation, Inc. | 3 | Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -117,7 +117,7 @@ create_root_interval (Lisp_Object parent) | |||
| 117 | /* Make the interval TARGET have exactly the properties of SOURCE. */ | 117 | /* Make the interval TARGET have exactly the properties of SOURCE. */ |
| 118 | 118 | ||
| 119 | void | 119 | void |
| 120 | copy_properties (register INTERVAL source, register INTERVAL target) | 120 | copy_properties (INTERVAL source, INTERVAL target) |
| 121 | { | 121 | { |
| 122 | if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target)) | 122 | if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target)) |
| 123 | return; | 123 | return; |
| @@ -165,10 +165,11 @@ merge_properties (register INTERVAL source, register INTERVAL target) | |||
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /* Return true if the two intervals have the same properties. */ | 168 | /* Return true if the two intervals have the same properties. |
| 169 | If use_equal is true, use Fequal for comparisons instead of EQ. */ | ||
| 169 | 170 | ||
| 170 | bool | 171 | static bool |
| 171 | intervals_equal (INTERVAL i0, INTERVAL i1) | 172 | intervals_equal_1 (INTERVAL i0, INTERVAL i1, bool use_equal) |
| 172 | { | 173 | { |
| 173 | Lisp_Object i0_cdr, i0_sym; | 174 | Lisp_Object i0_cdr, i0_sym; |
| 174 | Lisp_Object i1_cdr, i1_val; | 175 | Lisp_Object i1_cdr, i1_val; |
| @@ -197,13 +198,14 @@ intervals_equal (INTERVAL i0, INTERVAL i1) | |||
| 197 | } | 198 | } |
| 198 | 199 | ||
| 199 | /* i0 has something i1 doesn't. */ | 200 | /* i0 has something i1 doesn't. */ |
| 200 | if (EQ (i1_val, Qnil)) | 201 | if (NILP (i1_val)) |
| 201 | return false; | 202 | return false; |
| 202 | 203 | ||
| 203 | /* i0 and i1 both have sym, but it has different values in each. */ | 204 | /* i0 and i1 both have sym, but it has different values in each. */ |
| 204 | if (!CONSP (i1_val) | 205 | if (!CONSP (i1_val) |
| 205 | || (i1_val = XCDR (i1_val), !CONSP (i1_val)) | 206 | || (i1_val = XCDR (i1_val), !CONSP (i1_val)) |
| 206 | || !EQ (XCAR (i1_val), XCAR (i0_cdr))) | 207 | || use_equal ? NILP (Fequal (XCAR (i1_val), XCAR (i0_cdr))) |
| 208 | : !EQ (XCAR (i1_val), XCAR (i0_cdr))) | ||
| 207 | return false; | 209 | return false; |
| 208 | 210 | ||
| 209 | i0_cdr = XCDR (i0_cdr); | 211 | i0_cdr = XCDR (i0_cdr); |
| @@ -217,6 +219,14 @@ intervals_equal (INTERVAL i0, INTERVAL i1) | |||
| 217 | /* Lengths of the two plists were equal. */ | 219 | /* Lengths of the two plists were equal. */ |
| 218 | return (NILP (i0_cdr) && NILP (i1_cdr)); | 220 | return (NILP (i0_cdr) && NILP (i1_cdr)); |
| 219 | } | 221 | } |
| 222 | |||
| 223 | /* Return true if the two intervals have the same properties. */ | ||
| 224 | |||
| 225 | bool | ||
| 226 | intervals_equal (INTERVAL i0, INTERVAL i1) | ||
| 227 | { | ||
| 228 | return intervals_equal_1 (i0, i1, false); | ||
| 229 | } | ||
| 220 | 230 | ||
| 221 | 231 | ||
| 222 | /* Traverse an interval tree TREE, performing FUNCTION on each node. | 232 | /* Traverse an interval tree TREE, performing FUNCTION on each node. |
| @@ -298,7 +308,7 @@ rotate_right (INTERVAL A) | |||
| 298 | set_interval_parent (c, A); | 308 | set_interval_parent (c, A); |
| 299 | 309 | ||
| 300 | /* A's total length is decreased by the length of B and its left child. */ | 310 | /* A's total length is decreased by the length of B and its left child. */ |
| 301 | A->total_length -= B->total_length - TOTAL_LENGTH (c); | 311 | A->total_length -= TOTAL_LENGTH (B) - TOTAL_LENGTH0 (c); |
| 302 | eassert (TOTAL_LENGTH (A) > 0); | 312 | eassert (TOTAL_LENGTH (A) > 0); |
| 303 | eassert (LENGTH (A) > 0); | 313 | eassert (LENGTH (A) > 0); |
| 304 | 314 | ||
| @@ -349,7 +359,7 @@ rotate_left (INTERVAL A) | |||
| 349 | set_interval_parent (c, A); | 359 | set_interval_parent (c, A); |
| 350 | 360 | ||
| 351 | /* A's total length is decreased by the length of B and its right child. */ | 361 | /* A's total length is decreased by the length of B and its right child. */ |
| 352 | A->total_length -= B->total_length - TOTAL_LENGTH (c); | 362 | A->total_length -= TOTAL_LENGTH (B) - TOTAL_LENGTH0 (c); |
| 353 | eassert (TOTAL_LENGTH (A) > 0); | 363 | eassert (TOTAL_LENGTH (A) > 0); |
| 354 | eassert (LENGTH (A) > 0); | 364 | eassert (LENGTH (A) > 0); |
| 355 | 365 | ||
| @@ -713,13 +723,23 @@ previous_interval (register INTERVAL interval) | |||
| 713 | return NULL; | 723 | return NULL; |
| 714 | } | 724 | } |
| 715 | 725 | ||
| 716 | /* Find the interval containing POS given some non-NULL INTERVAL | 726 | /* Set the ->position field of I's parent, based on I->position. */ |
| 717 | in the same tree. Note that we need to update interval->position | 727 | #define SET_PARENT_POSITION(i) \ |
| 718 | if we go down the tree. | 728 | if (AM_LEFT_CHILD (i)) \ |
| 719 | To speed up the process, we assume that the ->position of | 729 | INTERVAL_PARENT (i)->position = \ |
| 720 | I and all its parents is already uptodate. */ | 730 | i->position + TOTAL_LENGTH (i) - LEFT_TOTAL_LENGTH (i); \ |
| 731 | else \ | ||
| 732 | INTERVAL_PARENT (i)->position = \ | ||
| 733 | i->position - LEFT_TOTAL_LENGTH (i) \ | ||
| 734 | - LENGTH (INTERVAL_PARENT (i)) | ||
| 735 | |||
| 736 | /* Find the interval containing POS, given some interval I in | ||
| 737 | the same tree. Note that we update interval->position in each | ||
| 738 | interval we traverse, assuming it is already correctly set for the | ||
| 739 | argument I. We don't assume that any other interval already has a | ||
| 740 | correctly set ->position. */ | ||
| 721 | INTERVAL | 741 | INTERVAL |
| 722 | update_interval (register INTERVAL i, ptrdiff_t pos) | 742 | update_interval (INTERVAL i, ptrdiff_t pos) |
| 723 | { | 743 | { |
| 724 | if (!i) | 744 | if (!i) |
| 725 | return NULL; | 745 | return NULL; |
| @@ -729,7 +749,7 @@ update_interval (register INTERVAL i, ptrdiff_t pos) | |||
| 729 | if (pos < i->position) | 749 | if (pos < i->position) |
| 730 | { | 750 | { |
| 731 | /* Move left. */ | 751 | /* Move left. */ |
| 732 | if (pos >= i->position - TOTAL_LENGTH (i->left)) | 752 | if (pos >= i->position - LEFT_TOTAL_LENGTH (i)) |
| 733 | { | 753 | { |
| 734 | i->left->position = i->position - TOTAL_LENGTH (i->left) | 754 | i->left->position = i->position - TOTAL_LENGTH (i->left) |
| 735 | + LEFT_TOTAL_LENGTH (i->left); | 755 | + LEFT_TOTAL_LENGTH (i->left); |
| @@ -738,13 +758,16 @@ update_interval (register INTERVAL i, ptrdiff_t pos) | |||
| 738 | else if (NULL_PARENT (i)) | 758 | else if (NULL_PARENT (i)) |
| 739 | error ("Point before start of properties"); | 759 | error ("Point before start of properties"); |
| 740 | else | 760 | else |
| 741 | i = INTERVAL_PARENT (i); | 761 | { |
| 762 | SET_PARENT_POSITION (i); | ||
| 763 | i = INTERVAL_PARENT (i); | ||
| 764 | } | ||
| 742 | continue; | 765 | continue; |
| 743 | } | 766 | } |
| 744 | else if (pos >= INTERVAL_LAST_POS (i)) | 767 | else if (pos >= INTERVAL_LAST_POS (i)) |
| 745 | { | 768 | { |
| 746 | /* Move right. */ | 769 | /* Move right. */ |
| 747 | if (pos < INTERVAL_LAST_POS (i) + TOTAL_LENGTH (i->right)) | 770 | if (pos < INTERVAL_LAST_POS (i) + RIGHT_TOTAL_LENGTH (i)) |
| 748 | { | 771 | { |
| 749 | i->right->position = INTERVAL_LAST_POS (i) | 772 | i->right->position = INTERVAL_LAST_POS (i) |
| 750 | + LEFT_TOTAL_LENGTH (i->right); | 773 | + LEFT_TOTAL_LENGTH (i->right); |
| @@ -753,7 +776,10 @@ update_interval (register INTERVAL i, ptrdiff_t pos) | |||
| 753 | else if (NULL_PARENT (i)) | 776 | else if (NULL_PARENT (i)) |
| 754 | error ("Point %"pD"d after end of properties", pos); | 777 | error ("Point %"pD"d after end of properties", pos); |
| 755 | else | 778 | else |
| 756 | i = INTERVAL_PARENT (i); | 779 | { |
| 780 | SET_PARENT_POSITION (i); | ||
| 781 | i = INTERVAL_PARENT (i); | ||
| 782 | } | ||
| 757 | continue; | 783 | continue; |
| 758 | } | 784 | } |
| 759 | else | 785 | else |
| @@ -1171,7 +1197,7 @@ delete_interval (register INTERVAL i) | |||
| 1171 | register INTERVAL parent; | 1197 | register INTERVAL parent; |
| 1172 | ptrdiff_t amt = LENGTH (i); | 1198 | ptrdiff_t amt = LENGTH (i); |
| 1173 | 1199 | ||
| 1174 | eassert (amt == 0); /* Only used on zero-length intervals now. */ | 1200 | eassert (amt <= 0); /* Only used on zero total-length intervals now. */ |
| 1175 | 1201 | ||
| 1176 | if (ROOT_INTERVAL_P (i)) | 1202 | if (ROOT_INTERVAL_P (i)) |
| 1177 | { | 1203 | { |
| @@ -1557,8 +1583,8 @@ graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position, | |||
| 1557 | if (!inherit && tree && length > 0) | 1583 | if (!inherit && tree && length > 0) |
| 1558 | { | 1584 | { |
| 1559 | XSETBUFFER (buf, buffer); | 1585 | XSETBUFFER (buf, buffer); |
| 1560 | set_text_properties_1 (make_number (position), | 1586 | set_text_properties_1 (make_fixnum (position), |
| 1561 | make_number (position + length), | 1587 | make_fixnum (position + length), |
| 1562 | Qnil, buf, | 1588 | Qnil, buf, |
| 1563 | find_interval (tree, position)); | 1589 | find_interval (tree, position)); |
| 1564 | } | 1590 | } |
| @@ -1711,11 +1737,11 @@ lookup_char_property (Lisp_Object plist, Lisp_Object prop, bool textprop) | |||
| 1711 | { | 1737 | { |
| 1712 | tail = XCDR (tail); | 1738 | tail = XCDR (tail); |
| 1713 | for (; NILP (fallback) && CONSP (tail); tail = XCDR (tail)) | 1739 | for (; NILP (fallback) && CONSP (tail); tail = XCDR (tail)) |
| 1714 | fallback = Fplist_get (plist, XCAR (tail)); | 1740 | fallback = plist_get (plist, XCAR (tail)); |
| 1715 | } | 1741 | } |
| 1716 | 1742 | ||
| 1717 | if (textprop && NILP (fallback) && CONSP (Vdefault_text_properties)) | 1743 | if (textprop && NILP (fallback) && CONSP (Vdefault_text_properties)) |
| 1718 | fallback = Fplist_get (Vdefault_text_properties, prop); | 1744 | fallback = plist_get (Vdefault_text_properties, prop); |
| 1719 | return fallback; | 1745 | return fallback; |
| 1720 | } | 1746 | } |
| 1721 | 1747 | ||
| @@ -1793,7 +1819,7 @@ adjust_for_invis_intang (ptrdiff_t pos, ptrdiff_t test_offs, ptrdiff_t adj, | |||
| 1793 | /* POS + ADJ would be beyond the buffer bounds, so do no adjustment. */ | 1819 | /* POS + ADJ would be beyond the buffer bounds, so do no adjustment. */ |
| 1794 | return pos; | 1820 | return pos; |
| 1795 | 1821 | ||
| 1796 | test_pos = make_number (pos + test_offs); | 1822 | test_pos = make_fixnum (pos + test_offs); |
| 1797 | 1823 | ||
| 1798 | invis_propval | 1824 | invis_propval |
| 1799 | = get_char_property_and_overlay (test_pos, Qinvisible, Qnil, | 1825 | = get_char_property_and_overlay (test_pos, Qinvisible, Qnil, |
| @@ -1806,7 +1832,7 @@ adjust_for_invis_intang (ptrdiff_t pos, ptrdiff_t test_offs, ptrdiff_t adj, | |||
| 1806 | such that an insertion at POS would inherit it. */ | 1832 | such that an insertion at POS would inherit it. */ |
| 1807 | && (NILP (invis_overlay) | 1833 | && (NILP (invis_overlay) |
| 1808 | /* Invisible property is from a text-property. */ | 1834 | /* Invisible property is from a text-property. */ |
| 1809 | ? (text_property_stickiness (Qinvisible, make_number (pos), Qnil) | 1835 | ? (text_property_stickiness (Qinvisible, make_fixnum (pos), Qnil) |
| 1810 | == (test_offs == 0 ? 1 : -1)) | 1836 | == (test_offs == 0 ? 1 : -1)) |
| 1811 | /* Invisible property is from an overlay. */ | 1837 | /* Invisible property is from an overlay. */ |
| 1812 | : (test_offs == 0 | 1838 | : (test_offs == 0 |
| @@ -1926,8 +1952,8 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 1926 | 1952 | ||
| 1927 | if (! NILP (intangible_propval)) | 1953 | if (! NILP (intangible_propval)) |
| 1928 | { | 1954 | { |
| 1929 | while (XINT (pos) > BEGV | 1955 | while (XFIXNUM (pos) > BEGV |
| 1930 | && EQ (Fget_char_property (make_number (XINT (pos) - 1), | 1956 | && EQ (Fget_char_property (make_fixnum (XFIXNUM (pos) - 1), |
| 1931 | Qintangible, Qnil), | 1957 | Qintangible, Qnil), |
| 1932 | intangible_propval)) | 1958 | intangible_propval)) |
| 1933 | pos = Fprevious_char_property_change (pos, Qnil); | 1959 | pos = Fprevious_char_property_change (pos, Qnil); |
| @@ -1937,7 +1963,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 1937 | property is `front-sticky', perturb it to be one character | 1963 | property is `front-sticky', perturb it to be one character |
| 1938 | earlier -- this ensures that point can never move to the | 1964 | earlier -- this ensures that point can never move to the |
| 1939 | beginning of an invisible/intangible/front-sticky region. */ | 1965 | beginning of an invisible/intangible/front-sticky region. */ |
| 1940 | charpos = adjust_for_invis_intang (XINT (pos), 0, -1, 0); | 1966 | charpos = adjust_for_invis_intang (XFIXNUM (pos), 0, -1, 0); |
| 1941 | } | 1967 | } |
| 1942 | } | 1968 | } |
| 1943 | else | 1969 | else |
| @@ -1954,12 +1980,12 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 1954 | /* If preceding char is intangible, | 1980 | /* If preceding char is intangible, |
| 1955 | skip forward over all chars with matching intangible property. */ | 1981 | skip forward over all chars with matching intangible property. */ |
| 1956 | 1982 | ||
| 1957 | intangible_propval = Fget_char_property (make_number (charpos - 1), | 1983 | intangible_propval = Fget_char_property (make_fixnum (charpos - 1), |
| 1958 | Qintangible, Qnil); | 1984 | Qintangible, Qnil); |
| 1959 | 1985 | ||
| 1960 | if (! NILP (intangible_propval)) | 1986 | if (! NILP (intangible_propval)) |
| 1961 | { | 1987 | { |
| 1962 | while (XINT (pos) < ZV | 1988 | while (XFIXNUM (pos) < ZV |
| 1963 | && EQ (Fget_char_property (pos, Qintangible, Qnil), | 1989 | && EQ (Fget_char_property (pos, Qintangible, Qnil), |
| 1964 | intangible_propval)) | 1990 | intangible_propval)) |
| 1965 | pos = Fnext_char_property_change (pos, Qnil); | 1991 | pos = Fnext_char_property_change (pos, Qnil); |
| @@ -1969,7 +1995,7 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 1969 | property is `rear-sticky', perturb it to be one character | 1995 | property is `rear-sticky', perturb it to be one character |
| 1970 | later -- this ensures that point can never move to the | 1996 | later -- this ensures that point can never move to the |
| 1971 | end of an invisible/intangible/rear-sticky region. */ | 1997 | end of an invisible/intangible/rear-sticky region. */ |
| 1972 | charpos = adjust_for_invis_intang (XINT (pos), -1, 1, 0); | 1998 | charpos = adjust_for_invis_intang (XFIXNUM (pos), -1, 1, 0); |
| 1973 | } | 1999 | } |
| 1974 | } | 2000 | } |
| 1975 | 2001 | ||
| @@ -2026,18 +2052,18 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos) | |||
| 2026 | enter_after = Qnil; | 2052 | enter_after = Qnil; |
| 2027 | 2053 | ||
| 2028 | if (! EQ (leave_before, enter_before) && !NILP (leave_before)) | 2054 | if (! EQ (leave_before, enter_before) && !NILP (leave_before)) |
| 2029 | call2 (leave_before, make_number (old_position), | 2055 | call2 (leave_before, make_fixnum (old_position), |
| 2030 | make_number (charpos)); | 2056 | make_fixnum (charpos)); |
| 2031 | if (! EQ (leave_after, enter_after) && !NILP (leave_after)) | 2057 | if (! EQ (leave_after, enter_after) && !NILP (leave_after)) |
| 2032 | call2 (leave_after, make_number (old_position), | 2058 | call2 (leave_after, make_fixnum (old_position), |
| 2033 | make_number (charpos)); | 2059 | make_fixnum (charpos)); |
| 2034 | 2060 | ||
| 2035 | if (! EQ (enter_before, leave_before) && !NILP (enter_before)) | 2061 | if (! EQ (enter_before, leave_before) && !NILP (enter_before)) |
| 2036 | call2 (enter_before, make_number (old_position), | 2062 | call2 (enter_before, make_fixnum (old_position), |
| 2037 | make_number (charpos)); | 2063 | make_fixnum (charpos)); |
| 2038 | if (! EQ (enter_after, leave_after) && !NILP (enter_after)) | 2064 | if (! EQ (enter_after, leave_after) && !NILP (enter_after)) |
| 2039 | call2 (enter_after, make_number (old_position), | 2065 | call2 (enter_after, make_fixnum (old_position), |
| 2040 | make_number (charpos)); | 2066 | make_fixnum (charpos)); |
| 2041 | } | 2067 | } |
| 2042 | } | 2068 | } |
| 2043 | 2069 | ||
| @@ -2055,7 +2081,7 @@ move_if_not_intangible (ptrdiff_t position) | |||
| 2055 | if (! NILP (Vinhibit_point_motion_hooks)) | 2081 | if (! NILP (Vinhibit_point_motion_hooks)) |
| 2056 | /* If intangible is inhibited, always move point to POSITION. */ | 2082 | /* If intangible is inhibited, always move point to POSITION. */ |
| 2057 | ; | 2083 | ; |
| 2058 | else if (PT < position && XINT (pos) < ZV) | 2084 | else if (PT < position && XFIXNUM (pos) < ZV) |
| 2059 | { | 2085 | { |
| 2060 | /* We want to move forward, so check the text before POSITION. */ | 2086 | /* We want to move forward, so check the text before POSITION. */ |
| 2061 | 2087 | ||
| @@ -2065,23 +2091,23 @@ move_if_not_intangible (ptrdiff_t position) | |||
| 2065 | /* If following char is intangible, | 2091 | /* If following char is intangible, |
| 2066 | skip back over all chars with matching intangible property. */ | 2092 | skip back over all chars with matching intangible property. */ |
| 2067 | if (! NILP (intangible_propval)) | 2093 | if (! NILP (intangible_propval)) |
| 2068 | while (XINT (pos) > BEGV | 2094 | while (XFIXNUM (pos) > BEGV |
| 2069 | && EQ (Fget_char_property (make_number (XINT (pos) - 1), | 2095 | && EQ (Fget_char_property (make_fixnum (XFIXNUM (pos) - 1), |
| 2070 | Qintangible, Qnil), | 2096 | Qintangible, Qnil), |
| 2071 | intangible_propval)) | 2097 | intangible_propval)) |
| 2072 | pos = Fprevious_char_property_change (pos, Qnil); | 2098 | pos = Fprevious_char_property_change (pos, Qnil); |
| 2073 | } | 2099 | } |
| 2074 | else if (XINT (pos) > BEGV) | 2100 | else if (XFIXNUM (pos) > BEGV) |
| 2075 | { | 2101 | { |
| 2076 | /* We want to move backward, so check the text after POSITION. */ | 2102 | /* We want to move backward, so check the text after POSITION. */ |
| 2077 | 2103 | ||
| 2078 | intangible_propval = Fget_char_property (make_number (XINT (pos) - 1), | 2104 | intangible_propval = Fget_char_property (make_fixnum (XFIXNUM (pos) - 1), |
| 2079 | Qintangible, Qnil); | 2105 | Qintangible, Qnil); |
| 2080 | 2106 | ||
| 2081 | /* If following char is intangible, | 2107 | /* If following char is intangible, |
| 2082 | skip forward over all chars with matching intangible property. */ | 2108 | skip forward over all chars with matching intangible property. */ |
| 2083 | if (! NILP (intangible_propval)) | 2109 | if (! NILP (intangible_propval)) |
| 2084 | while (XINT (pos) < ZV | 2110 | while (XFIXNUM (pos) < ZV |
| 2085 | && EQ (Fget_char_property (pos, Qintangible, Qnil), | 2111 | && EQ (Fget_char_property (pos, Qintangible, Qnil), |
| 2086 | intangible_propval)) | 2112 | intangible_propval)) |
| 2087 | pos = Fnext_char_property_change (pos, Qnil); | 2113 | pos = Fnext_char_property_change (pos, Qnil); |
| @@ -2096,7 +2122,7 @@ move_if_not_intangible (ptrdiff_t position) | |||
| 2096 | try moving to POSITION (which means we actually move farther | 2122 | try moving to POSITION (which means we actually move farther |
| 2097 | if POSITION is inside of intangible text). */ | 2123 | if POSITION is inside of intangible text). */ |
| 2098 | 2124 | ||
| 2099 | if (XINT (pos) != PT) | 2125 | if (XFIXNUM (pos) != PT) |
| 2100 | SET_PT (position); | 2126 | SET_PT (position); |
| 2101 | } | 2127 | } |
| 2102 | 2128 | ||
| @@ -2145,15 +2171,15 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val, | |||
| 2145 | 2171 | ||
| 2146 | /* Return the proper local keymap TYPE for position POSITION in | 2172 | /* Return the proper local keymap TYPE for position POSITION in |
| 2147 | BUFFER; TYPE should be one of `keymap' or `local-map'. Use the map | 2173 | BUFFER; TYPE should be one of `keymap' or `local-map'. Use the map |
| 2148 | specified by the PROP property, if any. Otherwise, if TYPE is | 2174 | specified by the TYPE property, if any. Otherwise, if TYPE is |
| 2149 | `local-map' use BUFFER's local map. */ | 2175 | `local-map', use BUFFER's local map. */ |
| 2150 | 2176 | ||
| 2151 | Lisp_Object | 2177 | Lisp_Object |
| 2152 | get_local_map (ptrdiff_t position, struct buffer *buffer, Lisp_Object type) | 2178 | get_local_map (ptrdiff_t position, struct buffer *buffer, Lisp_Object type) |
| 2153 | { | 2179 | { |
| 2154 | Lisp_Object prop, lispy_position, lispy_buffer; | 2180 | Lisp_Object prop, lispy_position, lispy_buffer; |
| 2155 | ptrdiff_t old_begv, old_zv, old_begv_byte, old_zv_byte; | 2181 | ptrdiff_t old_begv, old_zv, old_begv_byte, old_zv_byte; |
| 2156 | ptrdiff_t count = SPECPDL_INDEX (); | 2182 | specpdl_ref count = SPECPDL_INDEX (); |
| 2157 | 2183 | ||
| 2158 | position = clip_to_bounds (BUF_BEGV (buffer), position, BUF_ZV (buffer)); | 2184 | position = clip_to_bounds (BUF_BEGV (buffer), position, BUF_ZV (buffer)); |
| 2159 | 2185 | ||
| @@ -2274,7 +2300,7 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2) | |||
| 2274 | 2300 | ||
| 2275 | /* If we ever find a mismatch between the strings, | 2301 | /* If we ever find a mismatch between the strings, |
| 2276 | they differ. */ | 2302 | they differ. */ |
| 2277 | if (! intervals_equal (i1, i2)) | 2303 | if (! intervals_equal_1 (i1, i2, true)) |
| 2278 | return 0; | 2304 | return 0; |
| 2279 | 2305 | ||
| 2280 | /* Advance POS till the end of the shorter interval, | 2306 | /* Advance POS till the end of the shorter interval, |
| @@ -2318,23 +2344,10 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, | |||
| 2318 | 2344 | ||
| 2319 | if (multi_flag) | 2345 | if (multi_flag) |
| 2320 | { | 2346 | { |
| 2321 | ptrdiff_t temp; | 2347 | left_end_byte |
| 2322 | left_end_byte = start_byte + LEFT_TOTAL_LENGTH (i); | 2348 | = advance_to_char_boundary (start_byte + LEFT_TOTAL_LENGTH (i)); |
| 2323 | left_end = BYTE_TO_CHAR (left_end_byte); | 2349 | left_end = BYTE_TO_CHAR (left_end_byte); |
| 2324 | 2350 | eassert (CHAR_TO_BYTE (left_end) == left_end_byte); | |
| 2325 | temp = CHAR_TO_BYTE (left_end); | ||
| 2326 | |||
| 2327 | /* If LEFT_END_BYTE is in the middle of a character, | ||
| 2328 | adjust it and LEFT_END to a char boundary. */ | ||
| 2329 | if (left_end_byte > temp) | ||
| 2330 | { | ||
| 2331 | left_end_byte = temp; | ||
| 2332 | } | ||
| 2333 | if (left_end_byte < temp) | ||
| 2334 | { | ||
| 2335 | left_end--; | ||
| 2336 | left_end_byte = CHAR_TO_BYTE (left_end); | ||
| 2337 | } | ||
| 2338 | } | 2351 | } |
| 2339 | else | 2352 | else |
| 2340 | { | 2353 | { |
| @@ -2351,24 +2364,10 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, | |||
| 2351 | 2364 | ||
| 2352 | if (multi_flag) | 2365 | if (multi_flag) |
| 2353 | { | 2366 | { |
| 2354 | ptrdiff_t temp; | 2367 | right_start_byte |
| 2355 | 2368 | = advance_to_char_boundary (end_byte - RIGHT_TOTAL_LENGTH (i)); | |
| 2356 | right_start_byte = end_byte - RIGHT_TOTAL_LENGTH (i); | ||
| 2357 | right_start = BYTE_TO_CHAR (right_start_byte); | 2369 | right_start = BYTE_TO_CHAR (right_start_byte); |
| 2358 | 2370 | eassert (CHAR_TO_BYTE (right_start) == right_start_byte); | |
| 2359 | /* If RIGHT_START_BYTE is in the middle of a character, | ||
| 2360 | adjust it and RIGHT_START to a char boundary. */ | ||
| 2361 | temp = CHAR_TO_BYTE (right_start); | ||
| 2362 | |||
| 2363 | if (right_start_byte < temp) | ||
| 2364 | { | ||
| 2365 | right_start_byte = temp; | ||
| 2366 | } | ||
| 2367 | if (right_start_byte > temp) | ||
| 2368 | { | ||
| 2369 | right_start++; | ||
| 2370 | right_start_byte = CHAR_TO_BYTE (right_start); | ||
| 2371 | } | ||
| 2372 | } | 2371 | } |
| 2373 | else | 2372 | else |
| 2374 | { | 2373 | { |