aboutsummaryrefslogtreecommitdiffstats
path: root/src/textprop.c
diff options
context:
space:
mode:
authorPaul Eggert2020-03-27 00:58:31 -0700
committerPaul Eggert2020-03-27 01:06:54 -0700
commitde00a933e4b35b42398582eaba58531e5fdd46ca (patch)
tree1999aba74c99e98e2b101faf65160acb45fd9b52 /src/textprop.c
parent10bedb75c915158b7662d4dfa4afa3a231714268 (diff)
downloademacs-de00a933e4b35b42398582eaba58531e5fdd46ca.tar.gz
emacs-de00a933e4b35b42398582eaba58531e5fdd46ca.zip
Treat out-of-range positions consistently
If a position argument to get-byte etc. is an out-of-range integer, treat it the same regardless of whether it is a fixnum or a bignum. * src/buffer.c (fix_position): New function. * src/buffer.c (validate_region): * src/character.c (Fget_byte): * src/coding.c (Ffind_coding_systems_region_internal) (Fcheck_coding_systems_region): * src/composite.c (Ffind_composition_internal): * src/editfns.c (Fposition_bytes, Fchar_after, Fchar_before) (Finsert_buffer_substring, Fcompare_buffer_substrings) (Fnarrow_to_region): * src/fns.c (Fsecure_hash_algorithms): * src/font.c (Finternal_char_font, Ffont_at): * src/fringe.c (Ffringe_bitmaps_at_pos): * src/search.c (search_command): * src/textprop.c (get_char_property_and_overlay): * src/window.c (Fpos_visible_in_window_p): * src/xdisp.c (Fwindow_text_pixel_size): Use it instead of CHECK_FIXNUM_COERCE_MARKER, so that the code is simpler and treats bignums consistently with fixnums. * src/buffer.h (CHECK_FIXNUM_COERCE_MARKER): Define here rather than in lisp.h, and reimplement in terms of fix_position so that it treats bignums consistently with fixnums. * src/lisp.h (CHECK_FIXNUM_COERCE_MARKER): Move to buffer.h. * src/textprop.c (validate_interval_range): Signal with original bounds rather than modified ones.
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c15
1 files changed, 8 insertions, 7 deletions
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,