diff options
| author | Paul Eggert | 2020-03-27 00:58:31 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-03-27 01:06:54 -0700 |
| commit | de00a933e4b35b42398582eaba58531e5fdd46ca (patch) | |
| tree | 1999aba74c99e98e2b101faf65160acb45fd9b52 /src/composite.c | |
| parent | 10bedb75c915158b7662d4dfa4afa3a231714268 (diff) | |
| download | emacs-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/composite.c')
| -rw-r--r-- | src/composite.c | 17 |
1 files changed, 7 insertions, 10 deletions
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)) |