aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/buffer.c32
-rw-r--r--src/buffer.h2
-rw-r--r--src/character.c6
-rw-r--r--src/coding.c42
-rw-r--r--src/composite.c17
-rw-r--r--src/editfns.c95
-rw-r--r--src/fns.c18
-rw-r--r--src/font.c16
-rw-r--r--src/fringe.c6
-rw-r--r--src/lisp.h8
-rw-r--r--src/search.c3
-rw-r--r--src/textprop.c15
-rw-r--r--src/window.c5
-rw-r--r--src/xdisp.c10
14 files changed, 111 insertions, 164 deletions
diff --git a/src/buffer.c b/src/buffer.c
index cc7d4e4817c..70598a7a22a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -131,6 +131,23 @@ CHECK_OVERLAY (Lisp_Object x)
131 CHECK_TYPE (OVERLAYP (x), Qoverlayp, x); 131 CHECK_TYPE (OVERLAYP (x), Qoverlayp, x);
132} 132}
133 133
134/* Convert the position POS to an EMACS_INT that fits in a fixnum.
135 Yield POS's value if POS is already a fixnum, POS's marker position
136 if POS is a marker, and MOST_NEGATIVE_FIXNUM or
137 MOST_POSITIVE_FIXNUM if POS is a negative or positive bignum.
138 Signal an error if POS is not of the proper form. */
139
140EMACS_INT
141fix_position (Lisp_Object pos)
142{
143 if (FIXNUMP (pos))
144 return XFIXNUM (pos);
145 if (MARKERP (pos))
146 return marker_position (pos);
147 CHECK_TYPE (BIGNUMP (pos), Qinteger_or_marker_p, pos);
148 return !NILP (Fnatnump (pos)) ? MOST_POSITIVE_FIXNUM : MOST_NEGATIVE_FIXNUM;
149}
150
134/* These setters are used only in this file, so they can be private. 151/* These setters are used only in this file, so they can be private.
135 The public setters are inline functions defined in buffer.h. */ 152 The public setters are inline functions defined in buffer.h. */
136static void 153static void
@@ -2257,19 +2274,20 @@ so the buffer is truly empty after this. */)
2257} 2274}
2258 2275
2259void 2276void
2260validate_region (register Lisp_Object *b, register Lisp_Object *e) 2277validate_region (Lisp_Object *b, Lisp_Object *e)
2261{ 2278{
2262 CHECK_FIXNUM_COERCE_MARKER (*b); 2279 EMACS_INT beg = fix_position (*b), end = fix_position (*e);
2263 CHECK_FIXNUM_COERCE_MARKER (*e);
2264 2280
2265 if (XFIXNUM (*b) > XFIXNUM (*e)) 2281 if (end < beg)
2266 { 2282 {
2267 Lisp_Object tem; 2283 EMACS_INT tem = beg; beg = end; end = tem;
2268 tem = *b; *b = *e; *e = tem;
2269 } 2284 }
2270 2285
2271 if (! (BEGV <= XFIXNUM (*b) && XFIXNUM (*e) <= ZV)) 2286 if (! (BEGV <= beg && end <= ZV))
2272 args_out_of_range_3 (Fcurrent_buffer (), *b, *e); 2287 args_out_of_range_3 (Fcurrent_buffer (), *b, *e);
2288
2289 *b = make_fixnum (beg);
2290 *e = make_fixnum (end);
2273} 2291}
2274 2292
2275/* Advance BYTE_POS up to a character boundary 2293/* Advance BYTE_POS up to a character boundary
diff --git a/src/buffer.h b/src/buffer.h
index fd05fdd37de..31f497ea40a 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1150,6 +1150,8 @@ extern Lisp_Object interval_insert_behind_hooks;
1150extern Lisp_Object interval_insert_in_front_hooks; 1150extern Lisp_Object interval_insert_in_front_hooks;
1151 1151
1152 1152
1153extern EMACS_INT fix_position (Lisp_Object);
1154#define CHECK_FIXNUM_COERCE_MARKER(x) ((x) = make_fixnum (fix_position (x)))
1153extern void delete_all_overlays (struct buffer *); 1155extern void delete_all_overlays (struct buffer *);
1154extern void reset_buffer (struct buffer *); 1156extern void reset_buffer (struct buffer *);
1155extern void compact_buffer (struct buffer *); 1157extern void compact_buffer (struct buffer *);
diff --git a/src/character.c b/src/character.c
index 5d419a2e836..d71cb3f145c 100644
--- a/src/character.c
+++ b/src/character.c
@@ -931,10 +931,10 @@ character is not ASCII nor 8-bit character, an error is signaled. */)
931 } 931 }
932 else 932 else
933 { 933 {
934 CHECK_FIXNUM_COERCE_MARKER (position); 934 EMACS_INT fixed_pos = fix_position (position);
935 if (XFIXNUM (position) < BEGV || XFIXNUM (position) >= ZV) 935 if (! (BEGV <= fixed_pos && fixed_pos < ZV))
936 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV)); 936 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
937 pos = XFIXNAT (position); 937 pos = fixed_pos;
938 p = CHAR_POS_ADDR (pos); 938 p = CHAR_POS_ADDR (pos);
939 } 939 }
940 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 940 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
diff --git a/src/coding.c b/src/coding.c
index 8b54281c0bf..0bea2a0c2bc 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9023,23 +9023,23 @@ DEFUN ("find-coding-systems-region-internal",
9023 } 9023 }
9024 else 9024 else
9025 { 9025 {
9026 CHECK_FIXNUM_COERCE_MARKER (start); 9026 EMACS_INT s = fix_position (start);
9027 CHECK_FIXNUM_COERCE_MARKER (end); 9027 EMACS_INT e = fix_position (end);
9028 if (XFIXNUM (start) < BEG || XFIXNUM (end) > Z || XFIXNUM (start) > XFIXNUM (end)) 9028 if (! (BEG <= s && s <= e && e <= Z))
9029 args_out_of_range (start, end); 9029 args_out_of_range (start, end);
9030 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 9030 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
9031 return Qt; 9031 return Qt;
9032 start_byte = CHAR_TO_BYTE (XFIXNUM (start)); 9032 start_byte = CHAR_TO_BYTE (s);
9033 end_byte = CHAR_TO_BYTE (XFIXNUM (end)); 9033 end_byte = CHAR_TO_BYTE (e);
9034 if (XFIXNUM (end) - XFIXNUM (start) == end_byte - start_byte) 9034 if (e - s == end_byte - start_byte)
9035 return Qt; 9035 return Qt;
9036 9036
9037 if (XFIXNUM (start) < GPT && XFIXNUM (end) > GPT) 9037 if (s < GPT && GPT < e)
9038 { 9038 {
9039 if ((GPT - XFIXNUM (start)) < (XFIXNUM (end) - GPT)) 9039 if (GPT - s < e - GPT)
9040 move_gap_both (XFIXNUM (start), start_byte); 9040 move_gap_both (s, start_byte);
9041 else 9041 else
9042 move_gap_both (XFIXNUM (end), end_byte); 9042 move_gap_both (e, end_byte);
9043 } 9043 }
9044 } 9044 }
9045 9045
@@ -9277,25 +9277,25 @@ is nil. */)
9277 } 9277 }
9278 else 9278 else
9279 { 9279 {
9280 CHECK_FIXNUM_COERCE_MARKER (start); 9280 EMACS_INT s = fix_position (start);
9281 CHECK_FIXNUM_COERCE_MARKER (end); 9281 EMACS_INT e = fix_position (end);
9282 if (XFIXNUM (start) < BEG || XFIXNUM (end) > Z || XFIXNUM (start) > XFIXNUM (end)) 9282 if (! (BEG <= s && s <= e && e <= Z))
9283 args_out_of_range (start, end); 9283 args_out_of_range (start, end);
9284 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 9284 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
9285 return Qnil; 9285 return Qnil;
9286 start_byte = CHAR_TO_BYTE (XFIXNUM (start)); 9286 start_byte = CHAR_TO_BYTE (s);
9287 end_byte = CHAR_TO_BYTE (XFIXNUM (end)); 9287 end_byte = CHAR_TO_BYTE (e);
9288 if (XFIXNUM (end) - XFIXNUM (start) == end_byte - start_byte) 9288 if (e - s == end_byte - start_byte)
9289 return Qnil; 9289 return Qnil;
9290 9290
9291 if (XFIXNUM (start) < GPT && XFIXNUM (end) > GPT) 9291 if (s < GPT && GPT < e)
9292 { 9292 {
9293 if ((GPT - XFIXNUM (start)) < (XFIXNUM (end) - GPT)) 9293 if (GPT - s < e - GPT)
9294 move_gap_both (XFIXNUM (start), start_byte); 9294 move_gap_both (s, start_byte);
9295 else 9295 else
9296 move_gap_both (XFIXNUM (end), end_byte); 9296 move_gap_both (e, end_byte);
9297 } 9297 }
9298 pos = XFIXNUM (start); 9298 pos = s;
9299 } 9299 }
9300 9300
9301 list = Qnil; 9301 list = Qnil;
diff --git a/src/composite.c b/src/composite.c
index 84de334ce0d..a00a4541f5e 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1839,27 +1839,24 @@ See `find-composition' for more details. */)
1839 ptrdiff_t start, end, from, to; 1839 ptrdiff_t start, end, from, to;
1840 int id; 1840 int id;
1841 1841
1842 CHECK_FIXNUM_COERCE_MARKER (pos); 1842 EMACS_INT fixed_pos = fix_position (pos);
1843 if (!NILP (limit)) 1843 if (!NILP (limit))
1844 { 1844 to = clip_to_bounds (PTRDIFF_MIN, fix_position (limit), ZV);
1845 CHECK_FIXNUM_COERCE_MARKER (limit);
1846 to = min (XFIXNUM (limit), ZV);
1847 }
1848 else 1845 else
1849 to = -1; 1846 to = -1;
1850 1847
1851 if (!NILP (string)) 1848 if (!NILP (string))
1852 { 1849 {
1853 CHECK_STRING (string); 1850 CHECK_STRING (string);
1854 if (XFIXNUM (pos) < 0 || XFIXNUM (pos) > SCHARS (string)) 1851 if (! (0 <= fixed_pos && fixed_pos <= SCHARS (string)))
1855 args_out_of_range (string, pos); 1852 args_out_of_range (string, pos);
1856 } 1853 }
1857 else 1854 else
1858 { 1855 {
1859 if (XFIXNUM (pos) < BEGV || XFIXNUM (pos) > ZV) 1856 if (! (BEGV <= fixed_pos && fixed_pos <= ZV))
1860 args_out_of_range (Fcurrent_buffer (), pos); 1857 args_out_of_range (Fcurrent_buffer (), pos);
1861 } 1858 }
1862 from = XFIXNUM (pos); 1859 from = fixed_pos;
1863 1860
1864 if (!find_composition (from, to, &start, &end, &prop, string)) 1861 if (!find_composition (from, to, &start, &end, &prop, string))
1865 { 1862 {
@@ -1870,12 +1867,12 @@ See `find-composition' for more details. */)
1870 return list3 (make_fixnum (start), make_fixnum (end), gstring); 1867 return list3 (make_fixnum (start), make_fixnum (end), gstring);
1871 return Qnil; 1868 return Qnil;
1872 } 1869 }
1873 if ((end <= XFIXNUM (pos) || start > XFIXNUM (pos))) 1870 if (! (start <= fixed_pos && fixed_pos < end))
1874 { 1871 {
1875 ptrdiff_t s, e; 1872 ptrdiff_t s, e;
1876 1873
1877 if (find_automatic_composition (from, to, &s, &e, &gstring, string) 1874 if (find_automatic_composition (from, to, &s, &e, &gstring, string)
1878 && (e <= XFIXNUM (pos) ? e > end : s < start)) 1875 && (e <= fixed_pos ? e > end : s < start))
1879 return list3 (make_fixnum (s), make_fixnum (e), gstring); 1876 return list3 (make_fixnum (s), make_fixnum (e), gstring);
1880 } 1877 }
1881 if (!composition_valid_p (start, end, prop)) 1878 if (!composition_valid_p (start, end, prop))
diff --git a/src/editfns.c b/src/editfns.c
index cbc1082b2cc..90520d0dced 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -948,10 +948,10 @@ DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0,
948If POSITION is out of range, the value is nil. */) 948If POSITION is out of range, the value is nil. */)
949 (Lisp_Object position) 949 (Lisp_Object position)
950{ 950{
951 CHECK_FIXNUM_COERCE_MARKER (position); 951 EMACS_INT pos = fix_position (position);
952 if (XFIXNUM (position) < BEG || XFIXNUM (position) > Z) 952 if (! (BEG <= pos && pos <= Z))
953 return Qnil; 953 return Qnil;
954 return make_fixnum (CHAR_TO_BYTE (XFIXNUM (position))); 954 return make_fixnum (CHAR_TO_BYTE (pos));
955} 955}
956 956
957DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, 957DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0,
@@ -1068,11 +1068,11 @@ If POS is out of range, the value is nil. */)
1068 } 1068 }
1069 else 1069 else
1070 { 1070 {
1071 CHECK_FIXNUM_COERCE_MARKER (pos); 1071 EMACS_INT p = fix_position (pos);
1072 if (XFIXNUM (pos) < BEGV || XFIXNUM (pos) >= ZV) 1072 if (! (BEGV <= p && p < ZV))
1073 return Qnil; 1073 return Qnil;
1074 1074
1075 pos_byte = CHAR_TO_BYTE (XFIXNUM (pos)); 1075 pos_byte = CHAR_TO_BYTE (p);
1076 } 1076 }
1077 1077
1078 return make_fixnum (FETCH_CHAR (pos_byte)); 1078 return make_fixnum (FETCH_CHAR (pos_byte));
@@ -1102,12 +1102,12 @@ If POS is out of range, the value is nil. */)
1102 } 1102 }
1103 else 1103 else
1104 { 1104 {
1105 CHECK_FIXNUM_COERCE_MARKER (pos); 1105 EMACS_INT p = fix_position (pos);
1106 1106
1107 if (XFIXNUM (pos) <= BEGV || XFIXNUM (pos) > ZV) 1107 if (! (BEGV < p && p <= ZV))
1108 return Qnil; 1108 return Qnil;
1109 1109
1110 pos_byte = CHAR_TO_BYTE (XFIXNUM (pos)); 1110 pos_byte = CHAR_TO_BYTE (p);
1111 } 1111 }
1112 1112
1113 if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) 1113 if (!NILP (BVAR (current_buffer, enable_multibyte_characters)))
@@ -1726,21 +1726,8 @@ using `string-make-multibyte' or `string-make-unibyte', which see. */)
1726 if (!BUFFER_LIVE_P (bp)) 1726 if (!BUFFER_LIVE_P (bp))
1727 error ("Selecting deleted buffer"); 1727 error ("Selecting deleted buffer");
1728 1728
1729 if (NILP (start)) 1729 b = !NILP (start) ? fix_position (start) : BUF_BEGV (bp);
1730 b = BUF_BEGV (bp); 1730 e = !NILP (end) ? fix_position (end) : BUF_ZV (bp);
1731 else
1732 {
1733 CHECK_FIXNUM_COERCE_MARKER (start);
1734 b = XFIXNUM (start);
1735 }
1736 if (NILP (end))
1737 e = BUF_ZV (bp);
1738 else
1739 {
1740 CHECK_FIXNUM_COERCE_MARKER (end);
1741 e = XFIXNUM (end);
1742 }
1743
1744 if (b > e) 1731 if (b > e)
1745 temp = b, b = e, e = temp; 1732 temp = b, b = e, e = temp;
1746 1733
@@ -1794,21 +1781,8 @@ determines whether case is significant or ignored. */)
1794 error ("Selecting deleted buffer"); 1781 error ("Selecting deleted buffer");
1795 } 1782 }
1796 1783
1797 if (NILP (start1)) 1784 begp1 = !NILP (start1) ? fix_position (start1) : BUF_BEGV (bp1);
1798 begp1 = BUF_BEGV (bp1); 1785 endp1 = !NILP (end1) ? fix_position (end1) : BUF_ZV (bp1);
1799 else
1800 {
1801 CHECK_FIXNUM_COERCE_MARKER (start1);
1802 begp1 = XFIXNUM (start1);
1803 }
1804 if (NILP (end1))
1805 endp1 = BUF_ZV (bp1);
1806 else
1807 {
1808 CHECK_FIXNUM_COERCE_MARKER (end1);
1809 endp1 = XFIXNUM (end1);
1810 }
1811
1812 if (begp1 > endp1) 1786 if (begp1 > endp1)
1813 temp = begp1, begp1 = endp1, endp1 = temp; 1787 temp = begp1, begp1 = endp1, endp1 = temp;
1814 1788
@@ -1832,21 +1806,8 @@ determines whether case is significant or ignored. */)
1832 error ("Selecting deleted buffer"); 1806 error ("Selecting deleted buffer");
1833 } 1807 }
1834 1808
1835 if (NILP (start2)) 1809 begp2 = !NILP (start2) ? fix_position (start2) : BUF_BEGV (bp2);
1836 begp2 = BUF_BEGV (bp2); 1810 endp2 = !NILP (end2) ? fix_position (end2) : BUF_ZV (bp2);
1837 else
1838 {
1839 CHECK_FIXNUM_COERCE_MARKER (start2);
1840 begp2 = XFIXNUM (start2);
1841 }
1842 if (NILP (end2))
1843 endp2 = BUF_ZV (bp2);
1844 else
1845 {
1846 CHECK_FIXNUM_COERCE_MARKER (end2);
1847 endp2 = XFIXNUM (end2);
1848 }
1849
1850 if (begp2 > endp2) 1811 if (begp2 > endp2)
1851 temp = begp2, begp2 = endp2, endp2 = temp; 1812 temp = begp2, begp2 = endp2, endp2 = temp;
1852 1813
@@ -2700,29 +2661,27 @@ See also `save-restriction'.
2700When calling from Lisp, pass two arguments START and END: 2661When calling from Lisp, pass two arguments START and END:
2701positions (integers or markers) bounding the text that should 2662positions (integers or markers) bounding the text that should
2702remain visible. */) 2663remain visible. */)
2703 (register Lisp_Object start, Lisp_Object end) 2664 (Lisp_Object start, Lisp_Object end)
2704{ 2665{
2705 CHECK_FIXNUM_COERCE_MARKER (start); 2666 EMACS_INT s = fix_position (start), e = fix_position (end);
2706 CHECK_FIXNUM_COERCE_MARKER (end);
2707 2667
2708 if (XFIXNUM (start) > XFIXNUM (end)) 2668 if (e < s)
2709 { 2669 {
2710 Lisp_Object tem; 2670 EMACS_INT tem = s; s = e; e = tem;
2711 tem = start; start = end; end = tem;
2712 } 2671 }
2713 2672
2714 if (!(BEG <= XFIXNUM (start) && XFIXNUM (start) <= XFIXNUM (end) && XFIXNUM (end) <= Z)) 2673 if (!(BEG <= s && s <= e && e <= Z))
2715 args_out_of_range (start, end); 2674 args_out_of_range (start, end);
2716 2675
2717 if (BEGV != XFIXNAT (start) || ZV != XFIXNAT (end)) 2676 if (BEGV != s || ZV != e)
2718 current_buffer->clip_changed = 1; 2677 current_buffer->clip_changed = 1;
2719 2678
2720 SET_BUF_BEGV (current_buffer, XFIXNAT (start)); 2679 SET_BUF_BEGV (current_buffer, s);
2721 SET_BUF_ZV (current_buffer, XFIXNAT (end)); 2680 SET_BUF_ZV (current_buffer, e);
2722 if (PT < XFIXNAT (start)) 2681 if (PT < s)
2723 SET_PT (XFIXNAT (start)); 2682 SET_PT (s);
2724 if (PT > XFIXNAT (end)) 2683 if (e < PT)
2725 SET_PT (XFIXNAT (end)); 2684 SET_PT (e);
2726 /* Changing the buffer bounds invalidates any recorded current column. */ 2685 /* Changing the buffer bounds invalidates any recorded current column. */
2727 invalidate_current_column (); 2686 invalidate_current_column ();
2728 return Qnil; 2687 return Qnil;
diff --git a/src/fns.c b/src/fns.c
index 80012fa9d28..138082e07c8 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5187,22 +5187,8 @@ extract_data_from_object (Lisp_Object spec,
5187 struct buffer *bp = XBUFFER (object); 5187 struct buffer *bp = XBUFFER (object);
5188 set_buffer_internal (bp); 5188 set_buffer_internal (bp);
5189 5189
5190 if (NILP (start)) 5190 b = !NILP (start) ? fix_position (start) : BEGV;
5191 b = BEGV; 5191 e = !NILP (end) ? fix_position (end) : ZV;
5192 else
5193 {
5194 CHECK_FIXNUM_COERCE_MARKER (start);
5195 b = XFIXNUM (start);
5196 }
5197
5198 if (NILP (end))
5199 e = ZV;
5200 else
5201 {
5202 CHECK_FIXNUM_COERCE_MARKER (end);
5203 e = XFIXNUM (end);
5204 }
5205
5206 if (b > e) 5192 if (b > e)
5207 { 5193 {
5208 EMACS_INT temp = b; 5194 EMACS_INT temp = b;
diff --git a/src/font.c b/src/font.c
index 2a456300619..0c9e752e089 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4606,10 +4606,10 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
4606 Lisp_Object window; 4606 Lisp_Object window;
4607 struct window *w; 4607 struct window *w;
4608 4608
4609 CHECK_FIXNUM_COERCE_MARKER (position); 4609 EMACS_INT fixed_pos = fix_position (position);
4610 if (! (BEGV <= XFIXNUM (position) && XFIXNUM (position) < ZV)) 4610 if (! (BEGV <= fixed_pos && fixed_pos < ZV))
4611 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV)); 4611 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
4612 pos = XFIXNUM (position); 4612 pos = fixed_pos;
4613 pos_byte = CHAR_TO_BYTE (pos); 4613 pos_byte = CHAR_TO_BYTE (pos);
4614 if (NILP (ch)) 4614 if (NILP (ch))
4615 c = FETCH_CHAR (pos_byte); 4615 c = FETCH_CHAR (pos_byte);
@@ -5013,24 +5013,26 @@ character at index specified by POSITION. */)
5013 (Lisp_Object position, Lisp_Object window, Lisp_Object string) 5013 (Lisp_Object position, Lisp_Object window, Lisp_Object string)
5014{ 5014{
5015 struct window *w = decode_live_window (window); 5015 struct window *w = decode_live_window (window);
5016 EMACS_INT pos;
5016 5017
5017 if (NILP (string)) 5018 if (NILP (string))
5018 { 5019 {
5019 if (XBUFFER (w->contents) != current_buffer) 5020 if (XBUFFER (w->contents) != current_buffer)
5020 error ("Specified window is not displaying the current buffer"); 5021 error ("Specified window is not displaying the current buffer");
5021 CHECK_FIXNUM_COERCE_MARKER (position); 5022 pos = fix_position (position);
5022 if (! (BEGV <= XFIXNUM (position) && XFIXNUM (position) < ZV)) 5023 if (! (BEGV <= pos && pos < ZV))
5023 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV)); 5024 args_out_of_range_3 (position, make_fixnum (BEGV), make_fixnum (ZV));
5024 } 5025 }
5025 else 5026 else
5026 { 5027 {
5027 CHECK_FIXNUM (position); 5028 CHECK_FIXNUM (position);
5028 CHECK_STRING (string); 5029 CHECK_STRING (string);
5029 if (! (0 <= XFIXNUM (position) && XFIXNUM (position) < SCHARS (string))) 5030 pos = XFIXNUM (position);
5031 if (! (0 <= pos && pos < SCHARS (string)))
5030 args_out_of_range (string, position); 5032 args_out_of_range (string, position);
5031 } 5033 }
5032 5034
5033 return font_at (-1, XFIXNUM (position), NULL, w, string); 5035 return font_at (-1, pos, NULL, w, string);
5034} 5036}
5035 5037
5036#if 0 5038#if 0
diff --git a/src/fringe.c b/src/fringe.c
index 2a46e3c34f2..d8d80bb3fe9 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1675,10 +1675,10 @@ Return nil if POS is not visible in WINDOW. */)
1675 1675
1676 if (!NILP (pos)) 1676 if (!NILP (pos))
1677 { 1677 {
1678 CHECK_FIXNUM_COERCE_MARKER (pos); 1678 EMACS_INT p = fix_position (pos);
1679 if (! (BEGV <= XFIXNUM (pos) && XFIXNUM (pos) <= ZV)) 1679 if (! (BEGV <= p && p <= ZV))
1680 args_out_of_range (window, pos); 1680 args_out_of_range (window, pos);
1681 textpos = XFIXNUM (pos); 1681 textpos = p;
1682 } 1682 }
1683 else if (w == XWINDOW (selected_window)) 1683 else if (w == XWINDOW (selected_window))
1684 textpos = PT; 1684 textpos = PT;
diff --git a/src/lisp.h b/src/lisp.h
index 49923be702a..d3b1c39c8fb 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3012,14 +3012,6 @@ CHECK_FIXNAT (Lisp_Object x)
3012 CHECK_RANGED_INTEGER (x, 0, TYPE_MAXIMUM (type)); \ 3012 CHECK_RANGED_INTEGER (x, 0, TYPE_MAXIMUM (type)); \
3013 } while (false) 3013 } while (false)
3014 3014
3015#define CHECK_FIXNUM_COERCE_MARKER(x) \
3016 do { \
3017 if (MARKERP ((x))) \
3018 XSETFASTINT (x, marker_position (x)); \
3019 else \
3020 CHECK_TYPE (FIXNUMP (x), Qinteger_or_marker_p, x); \
3021 } while (false)
3022
3023INLINE double 3015INLINE double
3024XFLOATINT (Lisp_Object n) 3016XFLOATINT (Lisp_Object n)
3025{ 3017{
diff --git a/src/search.c b/src/search.c
index 818bb4af246..7389fbef0ee 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1028,8 +1028,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
1028 } 1028 }
1029 else 1029 else
1030 { 1030 {
1031 CHECK_FIXNUM_COERCE_MARKER (bound); 1031 lim = fix_position (bound);
1032 lim = XFIXNUM (bound);
1033 if (n > 0 ? lim < PT : lim > PT) 1032 if (n > 0 ? lim < PT : lim > PT)
1034 error ("Invalid search bound (wrong side of point)"); 1033 error ("Invalid search bound (wrong side of point)");
1035 if (lim > ZV) 1034 if (lim > ZV)
diff --git a/src/textprop.c b/src/textprop.c
index ee048336ac0..960dba3f8dc 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -131,6 +131,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin,
131{ 131{
132 INTERVAL i; 132 INTERVAL i;
133 ptrdiff_t searchpos; 133 ptrdiff_t searchpos;
134 Lisp_Object begin0 = *begin, end0 = *end;
134 135
135 CHECK_STRING_OR_BUFFER (object); 136 CHECK_STRING_OR_BUFFER (object);
136 CHECK_FIXNUM_COERCE_MARKER (*begin); 137 CHECK_FIXNUM_COERCE_MARKER (*begin);
@@ -155,7 +156,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin,
155 156
156 if (!(BUF_BEGV (b) <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end) 157 if (!(BUF_BEGV (b) <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end)
157 && XFIXNUM (*end) <= BUF_ZV (b))) 158 && XFIXNUM (*end) <= BUF_ZV (b)))
158 args_out_of_range (*begin, *end); 159 args_out_of_range (begin0, end0);
159 i = buffer_intervals (b); 160 i = buffer_intervals (b);
160 161
161 /* If there's no text, there are no properties. */ 162 /* If there's no text, there are no properties. */
@@ -170,7 +171,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin,
170 171
171 if (! (0 <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end) 172 if (! (0 <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end)
172 && XFIXNUM (*end) <= len)) 173 && XFIXNUM (*end) <= len))
173 args_out_of_range (*begin, *end); 174 args_out_of_range (begin0, end0);
174 i = string_intervals (object); 175 i = string_intervals (object);
175 176
176 if (len == 0) 177 if (len == 0)
@@ -611,7 +612,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
611{ 612{
612 struct window *w = 0; 613 struct window *w = 0;
613 614
614 CHECK_FIXNUM_COERCE_MARKER (position); 615 EMACS_INT pos = fix_position (position);
615 616
616 if (NILP (object)) 617 if (NILP (object))
617 XSETBUFFER (object, current_buffer); 618 XSETBUFFER (object, current_buffer);
@@ -628,14 +629,14 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
628 Lisp_Object *overlay_vec; 629 Lisp_Object *overlay_vec;
629 struct buffer *obuf = current_buffer; 630 struct buffer *obuf = current_buffer;
630 631
631 if (XFIXNUM (position) < BUF_BEGV (XBUFFER (object)) 632 if (! (BUF_BEGV (XBUFFER (object)) <= pos
632 || XFIXNUM (position) > BUF_ZV (XBUFFER (object))) 633 && pos <= BUF_ZV (XBUFFER (object))))
633 xsignal1 (Qargs_out_of_range, position); 634 xsignal1 (Qargs_out_of_range, position);
634 635
635 set_buffer_temp (XBUFFER (object)); 636 set_buffer_temp (XBUFFER (object));
636 637
637 USE_SAFE_ALLOCA; 638 USE_SAFE_ALLOCA;
638 GET_OVERLAYS_AT (XFIXNUM (position), overlay_vec, noverlays, NULL, false); 639 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, false);
639 noverlays = sort_overlays (overlay_vec, noverlays, w); 640 noverlays = sort_overlays (overlay_vec, noverlays, w);
640 641
641 set_buffer_temp (obuf); 642 set_buffer_temp (obuf);
@@ -662,7 +663,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
662 663
663 /* Not a buffer, or no appropriate overlay, so fall through to the 664 /* Not a buffer, or no appropriate overlay, so fall through to the
664 simpler case. */ 665 simpler case. */
665 return Fget_text_property (position, prop, object); 666 return Fget_text_property (make_fixnum (pos), prop, object);
666} 667}
667 668
668DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0, 669DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
diff --git a/src/window.c b/src/window.c
index 8cdad27b664..075fd4e550c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1895,10 +1895,7 @@ POS, ROWH is the visible height of that row, and VPOS is the row number
1895 if (EQ (pos, Qt)) 1895 if (EQ (pos, Qt))
1896 posint = -1; 1896 posint = -1;
1897 else if (!NILP (pos)) 1897 else if (!NILP (pos))
1898 { 1898 posint = fix_position (pos);
1899 CHECK_FIXNUM_COERCE_MARKER (pos);
1900 posint = XFIXNUM (pos);
1901 }
1902 else if (w == XWINDOW (selected_window)) 1899 else if (w == XWINDOW (selected_window))
1903 posint = PT; 1900 posint = PT;
1904 else 1901 else
diff --git a/src/xdisp.c b/src/xdisp.c
index 58d7ca5cb71..61c798c59e8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10413,10 +10413,7 @@ include the height of both, if present, in the return value. */)
10413 start = pos; 10413 start = pos;
10414 } 10414 }
10415 else 10415 else
10416 { 10416 start = clip_to_bounds (BEGV, fix_position (from), ZV);
10417 CHECK_FIXNUM_COERCE_MARKER (from);
10418 start = min (max (XFIXNUM (from), BEGV), ZV);
10419 }
10420 10417
10421 if (NILP (to)) 10418 if (NILP (to))
10422 end = ZV; 10419 end = ZV;
@@ -10430,10 +10427,7 @@ include the height of both, if present, in the return value. */)
10430 end = pos; 10427 end = pos;
10431 } 10428 }
10432 else 10429 else
10433 { 10430 end = clip_to_bounds (start, fix_position (to), ZV);
10434 CHECK_FIXNUM_COERCE_MARKER (to);
10435 end = max (start, min (XFIXNUM (to), ZV));
10436 }
10437 10431
10438 if (!NILP (x_limit) && RANGED_FIXNUMP (0, x_limit, INT_MAX)) 10432 if (!NILP (x_limit) && RANGED_FIXNUMP (0, x_limit, INT_MAX))
10439 max_x = XFIXNUM (x_limit); 10433 max_x = XFIXNUM (x_limit);