aboutsummaryrefslogtreecommitdiffstats
path: root/src/font.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/font.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/font.c')
-rw-r--r--src/font.c16
1 files changed, 9 insertions, 7 deletions
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