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/coding.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/coding.c')
| -rw-r--r-- | src/coding.c | 42 |
1 files changed, 21 insertions, 21 deletions
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; |