diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 259 |
1 files changed, 130 insertions, 129 deletions
diff --git a/src/buffer.c b/src/buffer.c index 4dcdf7bae69..20260d5a5d8 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -154,7 +154,7 @@ Lisp_Object Qinsert_behind_hooks; | |||
| 154 | static void alloc_buffer_text (struct buffer *, ptrdiff_t); | 154 | static void alloc_buffer_text (struct buffer *, ptrdiff_t); |
| 155 | static void free_buffer_text (struct buffer *b); | 155 | static void free_buffer_text (struct buffer *b); |
| 156 | static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); | 156 | static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); |
| 157 | static void modify_overlay (struct buffer *, EMACS_INT, EMACS_INT); | 157 | static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); |
| 158 | static Lisp_Object buffer_lisp_local_variables (struct buffer *); | 158 | static Lisp_Object buffer_lisp_local_variables (struct buffer *); |
| 159 | 159 | ||
| 160 | /* For debugging; temporary. See set_buffer_internal. */ | 160 | /* For debugging; temporary. See set_buffer_internal. */ |
| @@ -418,7 +418,7 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list) | |||
| 418 | for (; list; list = list->next) | 418 | for (; list; list = list->next) |
| 419 | { | 419 | { |
| 420 | Lisp_Object overlay, start, end, old_overlay; | 420 | Lisp_Object overlay, start, end, old_overlay; |
| 421 | EMACS_INT charpos; | 421 | ptrdiff_t charpos; |
| 422 | 422 | ||
| 423 | XSETMISC (old_overlay, list); | 423 | XSETMISC (old_overlay, list); |
| 424 | charpos = marker_position (OVERLAY_START (old_overlay)); | 424 | charpos = marker_position (OVERLAY_START (old_overlay)); |
| @@ -852,8 +852,8 @@ it is in the sequence to be tried) even if a buffer with that name exists. */) | |||
| 852 | (register Lisp_Object name, Lisp_Object ignore) | 852 | (register Lisp_Object name, Lisp_Object ignore) |
| 853 | { | 853 | { |
| 854 | register Lisp_Object gentemp, tem; | 854 | register Lisp_Object gentemp, tem; |
| 855 | EMACS_INT count; | 855 | ptrdiff_t count; |
| 856 | char number[INT_BUFSIZE_BOUND (EMACS_INT) + sizeof "<>"]; | 856 | char number[INT_BUFSIZE_BOUND (ptrdiff_t) + sizeof "<>"]; |
| 857 | 857 | ||
| 858 | CHECK_STRING (name); | 858 | CHECK_STRING (name); |
| 859 | 859 | ||
| @@ -867,7 +867,7 @@ it is in the sequence to be tried) even if a buffer with that name exists. */) | |||
| 867 | count = 1; | 867 | count = 1; |
| 868 | while (1) | 868 | while (1) |
| 869 | { | 869 | { |
| 870 | sprintf (number, "<%"pI"d>", ++count); | 870 | sprintf (number, "<%"pD"d>", ++count); |
| 871 | gentemp = concat2 (name, build_string (number)); | 871 | gentemp = concat2 (name, build_string (number)); |
| 872 | tem = Fstring_equal (gentemp, ignore); | 872 | tem = Fstring_equal (gentemp, ignore); |
| 873 | if (!NILP (tem)) | 873 | if (!NILP (tem)) |
| @@ -1475,7 +1475,7 @@ with SIGHUP. */) | |||
| 1475 | 1475 | ||
| 1476 | /* Run hooks with the buffer to be killed the current buffer. */ | 1476 | /* Run hooks with the buffer to be killed the current buffer. */ |
| 1477 | { | 1477 | { |
| 1478 | int count = SPECPDL_INDEX (); | 1478 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1479 | Lisp_Object arglist[1]; | 1479 | Lisp_Object arglist[1]; |
| 1480 | 1480 | ||
| 1481 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1481 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| @@ -1751,7 +1751,7 @@ Use this function before selecting the buffer, since it may need to inspect | |||
| 1751 | the current buffer's major mode. */) | 1751 | the current buffer's major mode. */) |
| 1752 | (Lisp_Object buffer) | 1752 | (Lisp_Object buffer) |
| 1753 | { | 1753 | { |
| 1754 | int count; | 1754 | ptrdiff_t count; |
| 1755 | Lisp_Object function; | 1755 | Lisp_Object function; |
| 1756 | 1756 | ||
| 1757 | CHECK_BUFFER (buffer); | 1757 | CHECK_BUFFER (buffer); |
| @@ -1963,16 +1963,15 @@ validate_region (register Lisp_Object *b, register Lisp_Object *e) | |||
| 1963 | tem = *b; *b = *e; *e = tem; | 1963 | tem = *b; *b = *e; *e = tem; |
| 1964 | } | 1964 | } |
| 1965 | 1965 | ||
| 1966 | if (!(BEGV <= XINT (*b) && XINT (*b) <= XINT (*e) | 1966 | if (! (BEGV <= XINT (*b) && XINT (*e) <= ZV)) |
| 1967 | && XINT (*e) <= ZV)) | ||
| 1968 | args_out_of_range (*b, *e); | 1967 | args_out_of_range (*b, *e); |
| 1969 | } | 1968 | } |
| 1970 | 1969 | ||
| 1971 | /* Advance BYTE_POS up to a character boundary | 1970 | /* Advance BYTE_POS up to a character boundary |
| 1972 | and return the adjusted position. */ | 1971 | and return the adjusted position. */ |
| 1973 | 1972 | ||
| 1974 | static EMACS_INT | 1973 | static ptrdiff_t |
| 1975 | advance_to_char_boundary (EMACS_INT byte_pos) | 1974 | advance_to_char_boundary (ptrdiff_t byte_pos) |
| 1976 | { | 1975 | { |
| 1977 | int c; | 1976 | int c; |
| 1978 | 1977 | ||
| @@ -1985,7 +1984,7 @@ advance_to_char_boundary (EMACS_INT byte_pos) | |||
| 1985 | { | 1984 | { |
| 1986 | /* We should advance BYTE_POS only when C is a constituent of a | 1985 | /* We should advance BYTE_POS only when C is a constituent of a |
| 1987 | multibyte sequence. */ | 1986 | multibyte sequence. */ |
| 1988 | EMACS_INT orig_byte_pos = byte_pos; | 1987 | ptrdiff_t orig_byte_pos = byte_pos; |
| 1989 | 1988 | ||
| 1990 | do | 1989 | do |
| 1991 | { | 1990 | { |
| @@ -2057,12 +2056,12 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2057 | (void **) ¤t_buffer->own_text.beg); | 2056 | (void **) ¤t_buffer->own_text.beg); |
| 2058 | #endif /* REL_ALLOC */ | 2057 | #endif /* REL_ALLOC */ |
| 2059 | 2058 | ||
| 2060 | swapfield (pt, EMACS_INT); | 2059 | swapfield (pt, ptrdiff_t); |
| 2061 | swapfield (pt_byte, EMACS_INT); | 2060 | swapfield (pt_byte, ptrdiff_t); |
| 2062 | swapfield (begv, EMACS_INT); | 2061 | swapfield (begv, ptrdiff_t); |
| 2063 | swapfield (begv_byte, EMACS_INT); | 2062 | swapfield (begv_byte, ptrdiff_t); |
| 2064 | swapfield (zv, EMACS_INT); | 2063 | swapfield (zv, ptrdiff_t); |
| 2065 | swapfield (zv_byte, EMACS_INT); | 2064 | swapfield (zv_byte, ptrdiff_t); |
| 2066 | eassert (!current_buffer->base_buffer); | 2065 | eassert (!current_buffer->base_buffer); |
| 2067 | eassert (!other_buffer->base_buffer); | 2066 | eassert (!other_buffer->base_buffer); |
| 2068 | current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; | 2067 | current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; |
| @@ -2072,7 +2071,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2072 | other_buffer->prevent_redisplay_optimizations_p = 1; | 2071 | other_buffer->prevent_redisplay_optimizations_p = 1; |
| 2073 | swapfield (overlays_before, struct Lisp_Overlay *); | 2072 | swapfield (overlays_before, struct Lisp_Overlay *); |
| 2074 | swapfield (overlays_after, struct Lisp_Overlay *); | 2073 | swapfield (overlays_after, struct Lisp_Overlay *); |
| 2075 | swapfield (overlay_center, EMACS_INT); | 2074 | swapfield (overlay_center, ptrdiff_t); |
| 2076 | swapfield_ (undo_list, Lisp_Object); | 2075 | swapfield_ (undo_list, Lisp_Object); |
| 2077 | swapfield_ (mark, Lisp_Object); | 2076 | swapfield_ (mark, Lisp_Object); |
| 2078 | swapfield_ (enable_multibyte_characters, Lisp_Object); | 2077 | swapfield_ (enable_multibyte_characters, Lisp_Object); |
| @@ -2155,7 +2154,7 @@ current buffer is cleared. */) | |||
| 2155 | { | 2154 | { |
| 2156 | struct Lisp_Marker *tail, *markers; | 2155 | struct Lisp_Marker *tail, *markers; |
| 2157 | struct buffer *other; | 2156 | struct buffer *other; |
| 2158 | EMACS_INT begv, zv; | 2157 | ptrdiff_t begv, zv; |
| 2159 | int narrowed = (BEG != BEGV || Z != ZV); | 2158 | int narrowed = (BEG != BEGV || Z != ZV); |
| 2160 | int modified_p = !NILP (Fbuffer_modified_p (Qnil)); | 2159 | int modified_p = !NILP (Fbuffer_modified_p (Qnil)); |
| 2161 | Lisp_Object old_undo = BVAR (current_buffer, undo_list); | 2160 | Lisp_Object old_undo = BVAR (current_buffer, undo_list); |
| @@ -2187,7 +2186,7 @@ current buffer is cleared. */) | |||
| 2187 | 2186 | ||
| 2188 | if (NILP (flag)) | 2187 | if (NILP (flag)) |
| 2189 | { | 2188 | { |
| 2190 | EMACS_INT pos, stop; | 2189 | ptrdiff_t pos, stop; |
| 2191 | unsigned char *p; | 2190 | unsigned char *p; |
| 2192 | 2191 | ||
| 2193 | /* Do this first, so it can use CHAR_TO_BYTE | 2192 | /* Do this first, so it can use CHAR_TO_BYTE |
| @@ -2251,8 +2250,8 @@ current buffer is cleared. */) | |||
| 2251 | } | 2250 | } |
| 2252 | else | 2251 | else |
| 2253 | { | 2252 | { |
| 2254 | EMACS_INT pt = PT; | 2253 | ptrdiff_t pt = PT; |
| 2255 | EMACS_INT pos, stop; | 2254 | ptrdiff_t pos, stop; |
| 2256 | unsigned char *p, *pend; | 2255 | unsigned char *p, *pend; |
| 2257 | 2256 | ||
| 2258 | /* Be sure not to have a multibyte sequence striding over the GAP. | 2257 | /* Be sure not to have a multibyte sequence striding over the GAP. |
| @@ -2268,7 +2267,7 @@ current buffer is cleared. */) | |||
| 2268 | while (! CHAR_HEAD_P (*q) && q > BEG_ADDR) q--; | 2267 | while (! CHAR_HEAD_P (*q) && q > BEG_ADDR) q--; |
| 2269 | if (LEADING_CODE_P (*q)) | 2268 | if (LEADING_CODE_P (*q)) |
| 2270 | { | 2269 | { |
| 2271 | EMACS_INT new_gpt = GPT_BYTE - (GPT_ADDR - q); | 2270 | ptrdiff_t new_gpt = GPT_BYTE - (GPT_ADDR - q); |
| 2272 | 2271 | ||
| 2273 | move_gap_both (new_gpt, new_gpt); | 2272 | move_gap_both (new_gpt, new_gpt); |
| 2274 | } | 2273 | } |
| @@ -2352,8 +2351,8 @@ current buffer is cleared. */) | |||
| 2352 | ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG; | 2351 | ZV = chars_in_text (BEG_ADDR, ZV_BYTE - BEG_BYTE) + BEG; |
| 2353 | 2352 | ||
| 2354 | { | 2353 | { |
| 2355 | EMACS_INT byte = advance_to_char_boundary (PT_BYTE); | 2354 | ptrdiff_t byte = advance_to_char_boundary (PT_BYTE); |
| 2356 | EMACS_INT position; | 2355 | ptrdiff_t position; |
| 2357 | 2356 | ||
| 2358 | if (byte > GPT_BYTE) | 2357 | if (byte > GPT_BYTE) |
| 2359 | position = chars_in_text (GAP_END_ADDR, byte - GPT_BYTE) + GPT; | 2358 | position = chars_in_text (GAP_END_ADDR, byte - GPT_BYTE) + GPT; |
| @@ -2517,20 +2516,20 @@ swap_out_buffer_local_variables (struct buffer *b) | |||
| 2517 | ptrdiff_t | 2516 | ptrdiff_t |
| 2518 | overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | 2517 | overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, |
| 2519 | ptrdiff_t *len_ptr, | 2518 | ptrdiff_t *len_ptr, |
| 2520 | EMACS_INT *next_ptr, EMACS_INT *prev_ptr, int change_req) | 2519 | ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, int change_req) |
| 2521 | { | 2520 | { |
| 2522 | Lisp_Object overlay, start, end; | 2521 | Lisp_Object overlay, start, end; |
| 2523 | struct Lisp_Overlay *tail; | 2522 | struct Lisp_Overlay *tail; |
| 2524 | ptrdiff_t idx = 0; | 2523 | ptrdiff_t idx = 0; |
| 2525 | ptrdiff_t len = *len_ptr; | 2524 | ptrdiff_t len = *len_ptr; |
| 2526 | Lisp_Object *vec = *vec_ptr; | 2525 | Lisp_Object *vec = *vec_ptr; |
| 2527 | EMACS_INT next = ZV; | 2526 | ptrdiff_t next = ZV; |
| 2528 | EMACS_INT prev = BEGV; | 2527 | ptrdiff_t prev = BEGV; |
| 2529 | int inhibit_storing = 0; | 2528 | int inhibit_storing = 0; |
| 2530 | 2529 | ||
| 2531 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2530 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 2532 | { | 2531 | { |
| 2533 | EMACS_INT startpos, endpos; | 2532 | ptrdiff_t startpos, endpos; |
| 2534 | 2533 | ||
| 2535 | XSETMISC (overlay, tail); | 2534 | XSETMISC (overlay, tail); |
| 2536 | 2535 | ||
| @@ -2578,7 +2577,7 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | |||
| 2578 | 2577 | ||
| 2579 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 2578 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) |
| 2580 | { | 2579 | { |
| 2581 | EMACS_INT startpos, endpos; | 2580 | ptrdiff_t startpos, endpos; |
| 2582 | 2581 | ||
| 2583 | XSETMISC (overlay, tail); | 2582 | XSETMISC (overlay, tail); |
| 2584 | 2583 | ||
| @@ -2651,21 +2650,21 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | |||
| 2651 | static ptrdiff_t | 2650 | static ptrdiff_t |
| 2652 | overlays_in (EMACS_INT beg, EMACS_INT end, int extend, | 2651 | overlays_in (EMACS_INT beg, EMACS_INT end, int extend, |
| 2653 | Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, | 2652 | Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, |
| 2654 | EMACS_INT *next_ptr, EMACS_INT *prev_ptr) | 2653 | ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) |
| 2655 | { | 2654 | { |
| 2656 | Lisp_Object overlay, ostart, oend; | 2655 | Lisp_Object overlay, ostart, oend; |
| 2657 | struct Lisp_Overlay *tail; | 2656 | struct Lisp_Overlay *tail; |
| 2658 | ptrdiff_t idx = 0; | 2657 | ptrdiff_t idx = 0; |
| 2659 | ptrdiff_t len = *len_ptr; | 2658 | ptrdiff_t len = *len_ptr; |
| 2660 | Lisp_Object *vec = *vec_ptr; | 2659 | Lisp_Object *vec = *vec_ptr; |
| 2661 | EMACS_INT next = ZV; | 2660 | ptrdiff_t next = ZV; |
| 2662 | EMACS_INT prev = BEGV; | 2661 | ptrdiff_t prev = BEGV; |
| 2663 | int inhibit_storing = 0; | 2662 | int inhibit_storing = 0; |
| 2664 | int end_is_Z = end == Z; | 2663 | int end_is_Z = end == Z; |
| 2665 | 2664 | ||
| 2666 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2665 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 2667 | { | 2666 | { |
| 2668 | EMACS_INT startpos, endpos; | 2667 | ptrdiff_t startpos, endpos; |
| 2669 | 2668 | ||
| 2670 | XSETMISC (overlay, tail); | 2669 | XSETMISC (overlay, tail); |
| 2671 | 2670 | ||
| @@ -2712,7 +2711,7 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend, | |||
| 2712 | 2711 | ||
| 2713 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 2712 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) |
| 2714 | { | 2713 | { |
| 2715 | EMACS_INT startpos, endpos; | 2714 | ptrdiff_t startpos, endpos; |
| 2716 | 2715 | ||
| 2717 | XSETMISC (overlay, tail); | 2716 | XSETMISC (overlay, tail); |
| 2718 | 2717 | ||
| @@ -2768,8 +2767,8 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend, | |||
| 2768 | int | 2767 | int |
| 2769 | mouse_face_overlay_overlaps (Lisp_Object overlay) | 2768 | mouse_face_overlay_overlaps (Lisp_Object overlay) |
| 2770 | { | 2769 | { |
| 2771 | EMACS_INT start = OVERLAY_POSITION (OVERLAY_START (overlay)); | 2770 | ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 2772 | EMACS_INT end = OVERLAY_POSITION (OVERLAY_END (overlay)); | 2771 | ptrdiff_t end = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 2773 | ptrdiff_t n, i, size; | 2772 | ptrdiff_t n, i, size; |
| 2774 | Lisp_Object *v, tem; | 2773 | Lisp_Object *v, tem; |
| 2775 | 2774 | ||
| @@ -2795,14 +2794,14 @@ mouse_face_overlay_overlaps (Lisp_Object overlay) | |||
| 2795 | 2794 | ||
| 2796 | /* Fast function to just test if we're at an overlay boundary. */ | 2795 | /* Fast function to just test if we're at an overlay boundary. */ |
| 2797 | int | 2796 | int |
| 2798 | overlay_touches_p (EMACS_INT pos) | 2797 | overlay_touches_p (ptrdiff_t pos) |
| 2799 | { | 2798 | { |
| 2800 | Lisp_Object overlay; | 2799 | Lisp_Object overlay; |
| 2801 | struct Lisp_Overlay *tail; | 2800 | struct Lisp_Overlay *tail; |
| 2802 | 2801 | ||
| 2803 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2802 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 2804 | { | 2803 | { |
| 2805 | EMACS_INT endpos; | 2804 | ptrdiff_t endpos; |
| 2806 | 2805 | ||
| 2807 | XSETMISC (overlay ,tail); | 2806 | XSETMISC (overlay ,tail); |
| 2808 | if (!OVERLAYP (overlay)) | 2807 | if (!OVERLAYP (overlay)) |
| @@ -2817,7 +2816,7 @@ overlay_touches_p (EMACS_INT pos) | |||
| 2817 | 2816 | ||
| 2818 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 2817 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) |
| 2819 | { | 2818 | { |
| 2820 | EMACS_INT startpos; | 2819 | ptrdiff_t startpos; |
| 2821 | 2820 | ||
| 2822 | XSETMISC (overlay, tail); | 2821 | XSETMISC (overlay, tail); |
| 2823 | if (!OVERLAYP (overlay)) | 2822 | if (!OVERLAYP (overlay)) |
| @@ -2835,7 +2834,7 @@ overlay_touches_p (EMACS_INT pos) | |||
| 2835 | struct sortvec | 2834 | struct sortvec |
| 2836 | { | 2835 | { |
| 2837 | Lisp_Object overlay; | 2836 | Lisp_Object overlay; |
| 2838 | EMACS_INT beg, end; | 2837 | ptrdiff_t beg, end; |
| 2839 | EMACS_INT priority; | 2838 | EMACS_INT priority; |
| 2840 | }; | 2839 | }; |
| 2841 | 2840 | ||
| @@ -2958,7 +2957,7 @@ static void | |||
| 2958 | record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, | 2957 | record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, |
| 2959 | Lisp_Object str2, Lisp_Object pri, ptrdiff_t size) | 2958 | Lisp_Object str2, Lisp_Object pri, ptrdiff_t size) |
| 2960 | { | 2959 | { |
| 2961 | EMACS_INT nbytes; | 2960 | ptrdiff_t nbytes; |
| 2962 | 2961 | ||
| 2963 | if (ssl->used == ssl->size) | 2962 | if (ssl->used == ssl->size) |
| 2964 | ssl->buf = xpalloc (ssl->buf, &ssl->size, 5, -1, sizeof *ssl->buf); | 2963 | ssl->buf = xpalloc (ssl->buf, &ssl->size, 5, -1, sizeof *ssl->buf); |
| @@ -3008,12 +3007,12 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, | |||
| 3008 | PSTR, if that variable is non-null. The string may be overwritten by | 3007 | PSTR, if that variable is non-null. The string may be overwritten by |
| 3009 | subsequent calls. */ | 3008 | subsequent calls. */ |
| 3010 | 3009 | ||
| 3011 | EMACS_INT | 3010 | ptrdiff_t |
| 3012 | overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) | 3011 | overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) |
| 3013 | { | 3012 | { |
| 3014 | Lisp_Object overlay, window, str; | 3013 | Lisp_Object overlay, window, str; |
| 3015 | struct Lisp_Overlay *ov; | 3014 | struct Lisp_Overlay *ov; |
| 3016 | EMACS_INT startpos, endpos; | 3015 | ptrdiff_t startpos, endpos; |
| 3017 | int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); | 3016 | int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 3018 | 3017 | ||
| 3019 | overlay_heads.used = overlay_heads.bytes = 0; | 3018 | overlay_heads.used = overlay_heads.bytes = 0; |
| @@ -3083,7 +3082,7 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) | |||
| 3083 | if (overlay_heads.bytes || overlay_tails.bytes) | 3082 | if (overlay_heads.bytes || overlay_tails.bytes) |
| 3084 | { | 3083 | { |
| 3085 | Lisp_Object tem; | 3084 | Lisp_Object tem; |
| 3086 | EMACS_INT i; | 3085 | ptrdiff_t i; |
| 3087 | unsigned char *p; | 3086 | unsigned char *p; |
| 3088 | ptrdiff_t total; | 3087 | ptrdiff_t total; |
| 3089 | 3088 | ||
| @@ -3097,7 +3096,7 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) | |||
| 3097 | p = overlay_str_buf; | 3096 | p = overlay_str_buf; |
| 3098 | for (i = overlay_tails.used; --i >= 0;) | 3097 | for (i = overlay_tails.used; --i >= 0;) |
| 3099 | { | 3098 | { |
| 3100 | EMACS_INT nbytes; | 3099 | ptrdiff_t nbytes; |
| 3101 | tem = overlay_tails.buf[i].string; | 3100 | tem = overlay_tails.buf[i].string; |
| 3102 | nbytes = copy_text (SDATA (tem), p, | 3101 | nbytes = copy_text (SDATA (tem), p, |
| 3103 | SBYTES (tem), | 3102 | SBYTES (tem), |
| @@ -3106,7 +3105,7 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) | |||
| 3106 | } | 3105 | } |
| 3107 | for (i = 0; i < overlay_heads.used; ++i) | 3106 | for (i = 0; i < overlay_heads.used; ++i) |
| 3108 | { | 3107 | { |
| 3109 | EMACS_INT nbytes; | 3108 | ptrdiff_t nbytes; |
| 3110 | tem = overlay_heads.buf[i].string; | 3109 | tem = overlay_heads.buf[i].string; |
| 3111 | nbytes = copy_text (SDATA (tem), p, | 3110 | nbytes = copy_text (SDATA (tem), p, |
| 3112 | SBYTES (tem), | 3111 | SBYTES (tem), |
| @@ -3133,7 +3132,7 @@ overlay_strings (EMACS_INT pos, struct window *w, unsigned char **pstr) | |||
| 3133 | /* Shift overlays in BUF's overlay lists, to center the lists at POS. */ | 3132 | /* Shift overlays in BUF's overlay lists, to center the lists at POS. */ |
| 3134 | 3133 | ||
| 3135 | void | 3134 | void |
| 3136 | recenter_overlay_lists (struct buffer *buf, EMACS_INT pos) | 3135 | recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) |
| 3137 | { | 3136 | { |
| 3138 | Lisp_Object overlay, beg, end; | 3137 | Lisp_Object overlay, beg, end; |
| 3139 | struct Lisp_Overlay *prev, *tail, *next; | 3138 | struct Lisp_Overlay *prev, *tail, *next; |
| @@ -3171,7 +3170,7 @@ recenter_overlay_lists (struct buffer *buf, EMACS_INT pos) | |||
| 3171 | if (OVERLAY_POSITION (end) > pos) | 3170 | if (OVERLAY_POSITION (end) > pos) |
| 3172 | { | 3171 | { |
| 3173 | /* OVERLAY needs to be moved. */ | 3172 | /* OVERLAY needs to be moved. */ |
| 3174 | EMACS_INT where = OVERLAY_POSITION (beg); | 3173 | ptrdiff_t where = OVERLAY_POSITION (beg); |
| 3175 | struct Lisp_Overlay *other, *other_prev; | 3174 | struct Lisp_Overlay *other, *other_prev; |
| 3176 | 3175 | ||
| 3177 | /* Splice the cons cell TAIL out of overlays_before. */ | 3176 | /* Splice the cons cell TAIL out of overlays_before. */ |
| @@ -3244,7 +3243,7 @@ recenter_overlay_lists (struct buffer *buf, EMACS_INT pos) | |||
| 3244 | if (OVERLAY_POSITION (end) <= pos) | 3243 | if (OVERLAY_POSITION (end) <= pos) |
| 3245 | { | 3244 | { |
| 3246 | /* OVERLAY needs to be moved. */ | 3245 | /* OVERLAY needs to be moved. */ |
| 3247 | EMACS_INT where = OVERLAY_POSITION (end); | 3246 | ptrdiff_t where = OVERLAY_POSITION (end); |
| 3248 | struct Lisp_Overlay *other, *other_prev; | 3247 | struct Lisp_Overlay *other, *other_prev; |
| 3249 | 3248 | ||
| 3250 | /* Splice the cons cell TAIL out of overlays_after. */ | 3249 | /* Splice the cons cell TAIL out of overlays_after. */ |
| @@ -3282,7 +3281,7 @@ recenter_overlay_lists (struct buffer *buf, EMACS_INT pos) | |||
| 3282 | } | 3281 | } |
| 3283 | 3282 | ||
| 3284 | void | 3283 | void |
| 3285 | adjust_overlays_for_insert (EMACS_INT pos, EMACS_INT length) | 3284 | adjust_overlays_for_insert (ptrdiff_t pos, ptrdiff_t length) |
| 3286 | { | 3285 | { |
| 3287 | /* After an insertion, the lists are still sorted properly, | 3286 | /* After an insertion, the lists are still sorted properly, |
| 3288 | but we may need to update the value of the overlay center. */ | 3287 | but we may need to update the value of the overlay center. */ |
| @@ -3291,13 +3290,13 @@ adjust_overlays_for_insert (EMACS_INT pos, EMACS_INT length) | |||
| 3291 | } | 3290 | } |
| 3292 | 3291 | ||
| 3293 | void | 3292 | void |
| 3294 | adjust_overlays_for_delete (EMACS_INT pos, EMACS_INT length) | 3293 | adjust_overlays_for_delete (ptrdiff_t pos, ptrdiff_t length) |
| 3295 | { | 3294 | { |
| 3296 | if (current_buffer->overlay_center < pos) | 3295 | if (current_buffer->overlay_center < pos) |
| 3297 | /* The deletion was to our right. No change needed; the before- and | 3296 | /* The deletion was to our right. No change needed; the before- and |
| 3298 | after-lists are still consistent. */ | 3297 | after-lists are still consistent. */ |
| 3299 | ; | 3298 | ; |
| 3300 | else if (current_buffer->overlay_center > pos + length) | 3299 | else if (current_buffer->overlay_center - pos > length) |
| 3301 | /* The deletion was to our left. We need to adjust the center value | 3300 | /* The deletion was to our left. We need to adjust the center value |
| 3302 | to account for the change in position, but the lists are consistent | 3301 | to account for the change in position, but the lists are consistent |
| 3303 | given the new value. */ | 3302 | given the new value. */ |
| @@ -3316,7 +3315,7 @@ adjust_overlays_for_delete (EMACS_INT pos, EMACS_INT length) | |||
| 3316 | Such an overlay might even have negative size at this point. | 3315 | Such an overlay might even have negative size at this point. |
| 3317 | If so, we'll make the overlay empty. */ | 3316 | If so, we'll make the overlay empty. */ |
| 3318 | void | 3317 | void |
| 3319 | fix_start_end_in_overlays (register EMACS_INT start, register EMACS_INT end) | 3318 | fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) |
| 3320 | { | 3319 | { |
| 3321 | Lisp_Object overlay; | 3320 | Lisp_Object overlay; |
| 3322 | struct Lisp_Overlay *before_list IF_LINT (= NULL); | 3321 | struct Lisp_Overlay *before_list IF_LINT (= NULL); |
| @@ -3329,7 +3328,7 @@ fix_start_end_in_overlays (register EMACS_INT start, register EMACS_INT end) | |||
| 3329 | current_buffer->overlays_before or overlays_after, depending | 3328 | current_buffer->overlays_before or overlays_after, depending |
| 3330 | which loop we're in. */ | 3329 | which loop we're in. */ |
| 3331 | struct Lisp_Overlay *tail, *parent; | 3330 | struct Lisp_Overlay *tail, *parent; |
| 3332 | EMACS_INT startpos, endpos; | 3331 | ptrdiff_t startpos, endpos; |
| 3333 | 3332 | ||
| 3334 | /* This algorithm shifts links around instead of consing and GCing. | 3333 | /* This algorithm shifts links around instead of consing and GCing. |
| 3335 | The loop invariant is that before_list (resp. after_list) is a | 3334 | The loop invariant is that before_list (resp. after_list) is a |
| @@ -3463,12 +3462,12 @@ fix_start_end_in_overlays (register EMACS_INT start, register EMACS_INT end) | |||
| 3463 | was at PREV, and now is at POS. */ | 3462 | was at PREV, and now is at POS. */ |
| 3464 | 3463 | ||
| 3465 | void | 3464 | void |
| 3466 | fix_overlays_before (struct buffer *bp, EMACS_INT prev, EMACS_INT pos) | 3465 | fix_overlays_before (struct buffer *bp, ptrdiff_t prev, ptrdiff_t pos) |
| 3467 | { | 3466 | { |
| 3468 | /* If parent is nil, replace overlays_before; otherwise, parent->next. */ | 3467 | /* If parent is nil, replace overlays_before; otherwise, parent->next. */ |
| 3469 | struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, *right_pair; | 3468 | struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, *right_pair; |
| 3470 | Lisp_Object tem; | 3469 | Lisp_Object tem; |
| 3471 | EMACS_INT end IF_LINT (= 0); | 3470 | ptrdiff_t end IF_LINT (= 0); |
| 3472 | 3471 | ||
| 3473 | /* After the insertion, the several overlays may be in incorrect | 3472 | /* After the insertion, the several overlays may be in incorrect |
| 3474 | order. The possibility is that, in the list `overlays_before', | 3473 | order. The possibility is that, in the list `overlays_before', |
| @@ -3626,11 +3625,11 @@ for the rear of the overlay advance when text is inserted there | |||
| 3626 | /* Mark a section of BUF as needing redisplay because of overlays changes. */ | 3625 | /* Mark a section of BUF as needing redisplay because of overlays changes. */ |
| 3627 | 3626 | ||
| 3628 | static void | 3627 | static void |
| 3629 | modify_overlay (struct buffer *buf, EMACS_INT start, EMACS_INT end) | 3628 | modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) |
| 3630 | { | 3629 | { |
| 3631 | if (start > end) | 3630 | if (start > end) |
| 3632 | { | 3631 | { |
| 3633 | EMACS_INT temp = start; | 3632 | ptrdiff_t temp = start; |
| 3634 | start = end; | 3633 | start = end; |
| 3635 | end = temp; | 3634 | end = temp; |
| 3636 | } | 3635 | } |
| @@ -3677,9 +3676,10 @@ If BUFFER is omitted, and OVERLAY is in no buffer, put it in the current | |||
| 3677 | buffer. */) | 3676 | buffer. */) |
| 3678 | (Lisp_Object overlay, Lisp_Object beg, Lisp_Object end, Lisp_Object buffer) | 3677 | (Lisp_Object overlay, Lisp_Object beg, Lisp_Object end, Lisp_Object buffer) |
| 3679 | { | 3678 | { |
| 3680 | struct buffer *b, *ob; | 3679 | struct buffer *b, *ob = 0; |
| 3681 | Lisp_Object obuffer; | 3680 | Lisp_Object obuffer; |
| 3682 | int count = SPECPDL_INDEX (); | 3681 | ptrdiff_t count = SPECPDL_INDEX (); |
| 3682 | ptrdiff_t n_beg, n_end, o_beg IF_LINT (= 0), o_end IF_LINT (= 0); | ||
| 3683 | 3683 | ||
| 3684 | CHECK_OVERLAY (overlay); | 3684 | CHECK_OVERLAY (overlay); |
| 3685 | if (NILP (buffer)) | 3685 | if (NILP (buffer)) |
| @@ -3688,6 +3688,9 @@ buffer. */) | |||
| 3688 | XSETBUFFER (buffer, current_buffer); | 3688 | XSETBUFFER (buffer, current_buffer); |
| 3689 | CHECK_BUFFER (buffer); | 3689 | CHECK_BUFFER (buffer); |
| 3690 | 3690 | ||
| 3691 | if (NILP (Fbuffer_live_p (buffer))) | ||
| 3692 | error ("Attempt to move overlay to a dead buffer"); | ||
| 3693 | |||
| 3691 | if (MARKERP (beg) | 3694 | if (MARKERP (beg) |
| 3692 | && ! EQ (Fmarker_buffer (beg), buffer)) | 3695 | && ! EQ (Fmarker_buffer (beg), buffer)) |
| 3693 | error ("Marker points into wrong buffer"); | 3696 | error ("Marker points into wrong buffer"); |
| @@ -3698,9 +3701,6 @@ buffer. */) | |||
| 3698 | CHECK_NUMBER_COERCE_MARKER (beg); | 3701 | CHECK_NUMBER_COERCE_MARKER (beg); |
| 3699 | CHECK_NUMBER_COERCE_MARKER (end); | 3702 | CHECK_NUMBER_COERCE_MARKER (end); |
| 3700 | 3703 | ||
| 3701 | if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate))) | ||
| 3702 | return Fdelete_overlay (overlay); | ||
| 3703 | |||
| 3704 | if (XINT (beg) > XINT (end)) | 3704 | if (XINT (beg) > XINT (end)) |
| 3705 | { | 3705 | { |
| 3706 | Lisp_Object temp; | 3706 | Lisp_Object temp; |
| @@ -3711,61 +3711,57 @@ buffer. */) | |||
| 3711 | 3711 | ||
| 3712 | obuffer = Fmarker_buffer (OVERLAY_START (overlay)); | 3712 | obuffer = Fmarker_buffer (OVERLAY_START (overlay)); |
| 3713 | b = XBUFFER (buffer); | 3713 | b = XBUFFER (buffer); |
| 3714 | ob = BUFFERP (obuffer) ? XBUFFER (obuffer) : (struct buffer *) 0; | 3714 | |
| 3715 | if (!NILP (obuffer)) | ||
| 3716 | { | ||
| 3717 | ob = XBUFFER (obuffer); | ||
| 3718 | |||
| 3719 | o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); | ||
| 3720 | o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); | ||
| 3721 | |||
| 3722 | ob->overlays_before = | ||
| 3723 | unchain_overlay (ob->overlays_before, XOVERLAY (overlay)); | ||
| 3724 | ob->overlays_after = | ||
| 3725 | unchain_overlay (ob->overlays_after, XOVERLAY (overlay)); | ||
| 3726 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 3727 | } | ||
| 3728 | |||
| 3729 | /* Set the overlay boundaries, which may clip them. */ | ||
| 3730 | Fset_marker (OVERLAY_START (overlay), beg, buffer); | ||
| 3731 | Fset_marker (OVERLAY_END (overlay), end, buffer); | ||
| 3732 | |||
| 3733 | n_beg = marker_position (OVERLAY_START (overlay)); | ||
| 3734 | n_end = marker_position (OVERLAY_END (overlay)); | ||
| 3715 | 3735 | ||
| 3716 | /* If the overlay has changed buffers, do a thorough redisplay. */ | 3736 | /* If the overlay has changed buffers, do a thorough redisplay. */ |
| 3717 | if (!EQ (buffer, obuffer)) | 3737 | if (!EQ (buffer, obuffer)) |
| 3718 | { | 3738 | { |
| 3719 | /* Redisplay where the overlay was. */ | 3739 | /* Redisplay where the overlay was. */ |
| 3720 | if (!NILP (obuffer)) | 3740 | if (ob) |
| 3721 | { | 3741 | modify_overlay (ob, o_beg, o_end); |
| 3722 | EMACS_INT o_beg; | ||
| 3723 | EMACS_INT o_end; | ||
| 3724 | |||
| 3725 | o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); | ||
| 3726 | o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); | ||
| 3727 | |||
| 3728 | modify_overlay (ob, o_beg, o_end); | ||
| 3729 | } | ||
| 3730 | 3742 | ||
| 3731 | /* Redisplay where the overlay is going to be. */ | 3743 | /* Redisplay where the overlay is going to be. */ |
| 3732 | modify_overlay (b, XINT (beg), XINT (end)); | 3744 | modify_overlay (b, n_beg, n_end); |
| 3733 | } | 3745 | } |
| 3734 | else | 3746 | else |
| 3735 | /* Redisplay the area the overlay has just left, or just enclosed. */ | 3747 | /* Redisplay the area the overlay has just left, or just enclosed. */ |
| 3736 | { | 3748 | { |
| 3737 | EMACS_INT o_beg, o_end; | 3749 | if (o_beg == n_beg) |
| 3738 | 3750 | modify_overlay (b, o_end, n_end); | |
| 3739 | o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3751 | else if (o_end == n_end) |
| 3740 | o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3752 | modify_overlay (b, o_beg, n_beg); |
| 3741 | |||
| 3742 | if (o_beg == XINT (beg)) | ||
| 3743 | modify_overlay (b, o_end, XINT (end)); | ||
| 3744 | else if (o_end == XINT (end)) | ||
| 3745 | modify_overlay (b, o_beg, XINT (beg)); | ||
| 3746 | else | 3753 | else |
| 3747 | { | 3754 | modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end)); |
| 3748 | if (XINT (beg) < o_beg) o_beg = XINT (beg); | ||
| 3749 | if (XINT (end) > o_end) o_end = XINT (end); | ||
| 3750 | modify_overlay (b, o_beg, o_end); | ||
| 3751 | } | ||
| 3752 | } | 3755 | } |
| 3753 | 3756 | ||
| 3754 | if (!NILP (obuffer)) | 3757 | /* Delete the overlay if it is empty after clipping and has the |
| 3755 | { | 3758 | evaporate property. */ |
| 3756 | ob->overlays_before | 3759 | if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate))) |
| 3757 | = unchain_overlay (ob->overlays_before, XOVERLAY (overlay)); | 3760 | return unbind_to (count, Fdelete_overlay (overlay)); |
| 3758 | ob->overlays_after | ||
| 3759 | = unchain_overlay (ob->overlays_after, XOVERLAY (overlay)); | ||
| 3760 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 3761 | } | ||
| 3762 | |||
| 3763 | Fset_marker (OVERLAY_START (overlay), beg, buffer); | ||
| 3764 | Fset_marker (OVERLAY_END (overlay), end, buffer); | ||
| 3765 | 3761 | ||
| 3766 | /* Put the overlay on the wrong list. */ | 3762 | /* Put the overlay into the new buffer's overlay lists, first on the |
| 3767 | end = OVERLAY_END (overlay); | 3763 | wrong list. */ |
| 3768 | if (OVERLAY_POSITION (end) < b->overlay_center) | 3764 | if (n_end < b->overlay_center) |
| 3769 | { | 3765 | { |
| 3770 | XOVERLAY (overlay)->next = b->overlays_after; | 3766 | XOVERLAY (overlay)->next = b->overlays_after; |
| 3771 | b->overlays_after = XOVERLAY (overlay); | 3767 | b->overlays_after = XOVERLAY (overlay); |
| @@ -3788,7 +3784,7 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0, | |||
| 3788 | { | 3784 | { |
| 3789 | Lisp_Object buffer; | 3785 | Lisp_Object buffer; |
| 3790 | struct buffer *b; | 3786 | struct buffer *b; |
| 3791 | int count = SPECPDL_INDEX (); | 3787 | ptrdiff_t count = SPECPDL_INDEX (); |
| 3792 | 3788 | ||
| 3793 | CHECK_OVERLAY (overlay); | 3789 | CHECK_OVERLAY (overlay); |
| 3794 | 3790 | ||
| @@ -3799,9 +3795,12 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0, | |||
| 3799 | b = XBUFFER (buffer); | 3795 | b = XBUFFER (buffer); |
| 3800 | specbind (Qinhibit_quit, Qt); | 3796 | specbind (Qinhibit_quit, Qt); |
| 3801 | 3797 | ||
| 3802 | b->overlays_before = unchain_overlay (b->overlays_before,XOVERLAY (overlay)); | 3798 | b->overlays_before |
| 3803 | b->overlays_after = unchain_overlay (b->overlays_after, XOVERLAY (overlay)); | 3799 | = unchain_overlay (b->overlays_before, XOVERLAY (overlay)); |
| 3800 | b->overlays_after | ||
| 3801 | = unchain_overlay (b->overlays_after, XOVERLAY (overlay)); | ||
| 3804 | eassert (XOVERLAY (overlay)->next == NULL); | 3802 | eassert (XOVERLAY (overlay)->next == NULL); |
| 3803 | |||
| 3805 | modify_overlay (b, | 3804 | modify_overlay (b, |
| 3806 | marker_position (OVERLAY_START (overlay)), | 3805 | marker_position (OVERLAY_START (overlay)), |
| 3807 | marker_position (OVERLAY_END (overlay))); | 3806 | marker_position (OVERLAY_END (overlay))); |
| @@ -3879,7 +3878,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0, | |||
| 3879 | /* Put all the overlays we want in a vector in overlay_vec. | 3878 | /* Put all the overlays we want in a vector in overlay_vec. |
| 3880 | Store the length in len. */ | 3879 | Store the length in len. */ |
| 3881 | noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, | 3880 | noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 3882 | (EMACS_INT *) 0, (EMACS_INT *) 0, 0); | 3881 | 0, 0, 0); |
| 3883 | 3882 | ||
| 3884 | /* Make a list of them all. */ | 3883 | /* Make a list of them all. */ |
| 3885 | result = Flist (noverlays, overlay_vec); | 3884 | result = Flist (noverlays, overlay_vec); |
| @@ -3927,7 +3926,7 @@ the value is (point-max). */) | |||
| 3927 | (Lisp_Object pos) | 3926 | (Lisp_Object pos) |
| 3928 | { | 3927 | { |
| 3929 | ptrdiff_t i, len, noverlays; | 3928 | ptrdiff_t i, len, noverlays; |
| 3930 | EMACS_INT endpos; | 3929 | ptrdiff_t endpos; |
| 3931 | Lisp_Object *overlay_vec; | 3930 | Lisp_Object *overlay_vec; |
| 3932 | 3931 | ||
| 3933 | CHECK_NUMBER_COERCE_MARKER (pos); | 3932 | CHECK_NUMBER_COERCE_MARKER (pos); |
| @@ -3939,14 +3938,14 @@ the value is (point-max). */) | |||
| 3939 | Store the length in len. | 3938 | Store the length in len. |
| 3940 | endpos gets the position where the next overlay starts. */ | 3939 | endpos gets the position where the next overlay starts. */ |
| 3941 | noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, | 3940 | noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 3942 | &endpos, (EMACS_INT *) 0, 1); | 3941 | &endpos, 0, 1); |
| 3943 | 3942 | ||
| 3944 | /* If any of these overlays ends before endpos, | 3943 | /* If any of these overlays ends before endpos, |
| 3945 | use its ending point instead. */ | 3944 | use its ending point instead. */ |
| 3946 | for (i = 0; i < noverlays; i++) | 3945 | for (i = 0; i < noverlays; i++) |
| 3947 | { | 3946 | { |
| 3948 | Lisp_Object oend; | 3947 | Lisp_Object oend; |
| 3949 | EMACS_INT oendpos; | 3948 | ptrdiff_t oendpos; |
| 3950 | 3949 | ||
| 3951 | oend = OVERLAY_END (overlay_vec[i]); | 3950 | oend = OVERLAY_END (overlay_vec[i]); |
| 3952 | oendpos = OVERLAY_POSITION (oend); | 3951 | oendpos = OVERLAY_POSITION (oend); |
| @@ -3965,7 +3964,7 @@ If there are no overlay boundaries from (point-min) to POS, | |||
| 3965 | the value is (point-min). */) | 3964 | the value is (point-min). */) |
| 3966 | (Lisp_Object pos) | 3965 | (Lisp_Object pos) |
| 3967 | { | 3966 | { |
| 3968 | EMACS_INT prevpos; | 3967 | ptrdiff_t prevpos; |
| 3969 | Lisp_Object *overlay_vec; | 3968 | Lisp_Object *overlay_vec; |
| 3970 | ptrdiff_t len; | 3969 | ptrdiff_t len; |
| 3971 | 3970 | ||
| @@ -3983,7 +3982,7 @@ the value is (point-min). */) | |||
| 3983 | Store the length in len. | 3982 | Store the length in len. |
| 3984 | prevpos gets the position of the previous change. */ | 3983 | prevpos gets the position of the previous change. */ |
| 3985 | overlays_at (XINT (pos), 1, &overlay_vec, &len, | 3984 | overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 3986 | (EMACS_INT *) 0, &prevpos, 1); | 3985 | 0, &prevpos, 1); |
| 3987 | 3986 | ||
| 3988 | xfree (overlay_vec); | 3987 | xfree (overlay_vec); |
| 3989 | return make_number (prevpos); | 3988 | return make_number (prevpos); |
| @@ -4021,9 +4020,11 @@ That makes overlay lookup faster for positions near POS (but perhaps slower | |||
| 4021 | for positions far away from POS). */) | 4020 | for positions far away from POS). */) |
| 4022 | (Lisp_Object pos) | 4021 | (Lisp_Object pos) |
| 4023 | { | 4022 | { |
| 4023 | ptrdiff_t p; | ||
| 4024 | CHECK_NUMBER_COERCE_MARKER (pos); | 4024 | CHECK_NUMBER_COERCE_MARKER (pos); |
| 4025 | 4025 | ||
| 4026 | recenter_overlay_lists (current_buffer, XINT (pos)); | 4026 | p = clip_to_bounds (PTRDIFF_MIN, XINT (pos), PTRDIFF_MAX); |
| 4027 | recenter_overlay_lists (current_buffer, p); | ||
| 4027 | return Qnil; | 4028 | return Qnil; |
| 4028 | } | 4029 | } |
| 4029 | 4030 | ||
| @@ -4090,7 +4091,7 @@ VALUE will be returned.*/) | |||
| 4090 | static Lisp_Object last_overlay_modification_hooks; | 4091 | static Lisp_Object last_overlay_modification_hooks; |
| 4091 | 4092 | ||
| 4092 | /* Number of elements actually used in last_overlay_modification_hooks. */ | 4093 | /* Number of elements actually used in last_overlay_modification_hooks. */ |
| 4093 | static int last_overlay_modification_hooks_used; | 4094 | static ptrdiff_t last_overlay_modification_hooks_used; |
| 4094 | 4095 | ||
| 4095 | /* Add one functionlist/overlay pair | 4096 | /* Add one functionlist/overlay pair |
| 4096 | to the end of last_overlay_modification_hooks. */ | 4097 | to the end of last_overlay_modification_hooks. */ |
| @@ -4098,11 +4099,11 @@ static int last_overlay_modification_hooks_used; | |||
| 4098 | static void | 4099 | static void |
| 4099 | add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay) | 4100 | add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay) |
| 4100 | { | 4101 | { |
| 4101 | int oldsize = ASIZE (last_overlay_modification_hooks); | 4102 | ptrdiff_t oldsize = ASIZE (last_overlay_modification_hooks); |
| 4102 | 4103 | ||
| 4103 | if (last_overlay_modification_hooks_used == oldsize) | 4104 | if (oldsize - 1 <= last_overlay_modification_hooks_used) |
| 4104 | last_overlay_modification_hooks = larger_vector | 4105 | last_overlay_modification_hooks = |
| 4105 | (last_overlay_modification_hooks, oldsize * 2, Qnil); | 4106 | larger_vector (last_overlay_modification_hooks, 2, -1); |
| 4106 | ASET (last_overlay_modification_hooks, last_overlay_modification_hooks_used, | 4107 | ASET (last_overlay_modification_hooks, last_overlay_modification_hooks_used, |
| 4107 | functionlist); last_overlay_modification_hooks_used++; | 4108 | functionlist); last_overlay_modification_hooks_used++; |
| 4108 | ASET (last_overlay_modification_hooks, last_overlay_modification_hooks_used, | 4109 | ASET (last_overlay_modification_hooks, last_overlay_modification_hooks_used, |
| @@ -4151,7 +4152,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, | |||
| 4151 | last_overlay_modification_hooks_used = 0; | 4152 | last_overlay_modification_hooks_used = 0; |
| 4152 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 4153 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 4153 | { | 4154 | { |
| 4154 | EMACS_INT startpos, endpos; | 4155 | ptrdiff_t startpos, endpos; |
| 4155 | Lisp_Object ostart, oend; | 4156 | Lisp_Object ostart, oend; |
| 4156 | 4157 | ||
| 4157 | XSETMISC (overlay, tail); | 4158 | XSETMISC (overlay, tail); |
| @@ -4188,7 +4189,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, | |||
| 4188 | 4189 | ||
| 4189 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 4190 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) |
| 4190 | { | 4191 | { |
| 4191 | EMACS_INT startpos, endpos; | 4192 | ptrdiff_t startpos, endpos; |
| 4192 | Lisp_Object ostart, oend; | 4193 | Lisp_Object ostart, oend; |
| 4193 | 4194 | ||
| 4194 | XSETMISC (overlay, tail); | 4195 | XSETMISC (overlay, tail); |
| @@ -4229,9 +4230,9 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, | |||
| 4229 | /* Call the functions recorded in last_overlay_modification_hooks. | 4230 | /* Call the functions recorded in last_overlay_modification_hooks. |
| 4230 | First copy the vector contents, in case some of these hooks | 4231 | First copy the vector contents, in case some of these hooks |
| 4231 | do subsequent modification of the buffer. */ | 4232 | do subsequent modification of the buffer. */ |
| 4232 | int size = last_overlay_modification_hooks_used; | 4233 | ptrdiff_t size = last_overlay_modification_hooks_used; |
| 4233 | Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object)); | 4234 | Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object)); |
| 4234 | int i; | 4235 | ptrdiff_t i; |
| 4235 | 4236 | ||
| 4236 | memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, | 4237 | memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, |
| 4237 | size * sizeof (Lisp_Object)); | 4238 | size * sizeof (Lisp_Object)); |
| @@ -4271,7 +4272,7 @@ call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, int after, | |||
| 4271 | /* Delete any zero-sized overlays at position POS, if the `evaporate' | 4272 | /* Delete any zero-sized overlays at position POS, if the `evaporate' |
| 4272 | property is set. */ | 4273 | property is set. */ |
| 4273 | void | 4274 | void |
| 4274 | evaporate_overlays (EMACS_INT pos) | 4275 | evaporate_overlays (ptrdiff_t pos) |
| 4275 | { | 4276 | { |
| 4276 | Lisp_Object overlay, hit_list; | 4277 | Lisp_Object overlay, hit_list; |
| 4277 | struct Lisp_Overlay *tail; | 4278 | struct Lisp_Overlay *tail; |
| @@ -4280,7 +4281,7 @@ evaporate_overlays (EMACS_INT pos) | |||
| 4280 | if (pos <= current_buffer->overlay_center) | 4281 | if (pos <= current_buffer->overlay_center) |
| 4281 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 4282 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 4282 | { | 4283 | { |
| 4283 | EMACS_INT endpos; | 4284 | ptrdiff_t endpos; |
| 4284 | XSETMISC (overlay, tail); | 4285 | XSETMISC (overlay, tail); |
| 4285 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 4286 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 4286 | if (endpos < pos) | 4287 | if (endpos < pos) |
| @@ -4292,7 +4293,7 @@ evaporate_overlays (EMACS_INT pos) | |||
| 4292 | else | 4293 | else |
| 4293 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 4294 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) |
| 4294 | { | 4295 | { |
| 4295 | EMACS_INT startpos; | 4296 | ptrdiff_t startpos; |
| 4296 | XSETMISC (overlay, tail); | 4297 | XSETMISC (overlay, tail); |
| 4297 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 4298 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 4298 | if (startpos > pos) | 4299 | if (startpos > pos) |
| @@ -4795,7 +4796,7 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) | |||
| 4795 | shrink it. */ | 4796 | shrink it. */ |
| 4796 | 4797 | ||
| 4797 | void | 4798 | void |
| 4798 | enlarge_buffer_text (struct buffer *b, EMACS_INT delta) | 4799 | enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) |
| 4799 | { | 4800 | { |
| 4800 | void *p; | 4801 | void *p; |
| 4801 | ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 | 4802 | ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 |