diff options
| author | Gregory Heytings | 2023-05-12 21:56:28 +0000 |
|---|---|---|
| committer | Gregory Heytings | 2023-05-13 00:11:33 +0200 |
| commit | f0f08eeb05c79e7b7326931357e82e65262c3336 (patch) | |
| tree | e9d83000642053f9379c9ca9bafaff9f49459a14 /src | |
| parent | c0b9530862c2f27a23ad058d60171e06de3e9b50 (diff) | |
| download | emacs-f0f08eeb05c79e7b7326931357e82e65262c3336.tar.gz emacs-f0f08eeb05c79e7b7326931357e82e65262c3336.zip | |
Fix the return type of 'labeled_restrictions_get_bound'
* src/editfns.c:
(labeled_restrictions_get_bound): Return a Lisp_Object instead of
a pointer to a struct Lisp_Marker.
(unwind_reset_outermost_restriction, reset_outermost_restrictions)
(Fwiden, Fnarrow_to_region): Adapt to the new return type.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/src/editfns.c b/src/editfns.c index 4c5b691eb50..d02cce4aef3 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2687,20 +2687,19 @@ labeled_restrictions_remove (Lisp_Object buf) | |||
| 2687 | } | 2687 | } |
| 2688 | 2688 | ||
| 2689 | /* Retrieve one of the labeled restriction bounds in BUF from the | 2689 | /* Retrieve one of the labeled restriction bounds in BUF from the |
| 2690 | labeled_restrictions alist, as a pointer to a struct Lisp_Marker, | 2690 | labeled_restrictions alist, as a marker, or return nil if BUF is |
| 2691 | or return NULL if BUF is not in labeled_restrictions or is a killed | 2691 | not in labeled_restrictions or is a killed buffer. When OUTERMOST |
| 2692 | buffer. When OUTERMOST is true, the restriction bounds that were | 2692 | is true, the restriction bounds that were current when the first |
| 2693 | current when the first labeled restriction was entered are | 2693 | labeled restriction was entered are returned. Otherwise the bounds |
| 2694 | returned. Otherwise the bounds of the innermost labeled | 2694 | of the innermost labeled restriction are returned. */ |
| 2695 | restriction are returned. */ | 2695 | static Lisp_Object |
| 2696 | static struct Lisp_Marker * | ||
| 2697 | labeled_restrictions_get_bound (Lisp_Object buf, bool begv, bool outermost) | 2696 | labeled_restrictions_get_bound (Lisp_Object buf, bool begv, bool outermost) |
| 2698 | { | 2697 | { |
| 2699 | if (NILP (Fbuffer_live_p (buf))) | 2698 | if (NILP (Fbuffer_live_p (buf))) |
| 2700 | return NULL; | 2699 | return Qnil; |
| 2701 | Lisp_Object restrictions = assq_no_quit (buf, labeled_restrictions); | 2700 | Lisp_Object restrictions = assq_no_quit (buf, labeled_restrictions); |
| 2702 | if (NILP (restrictions)) | 2701 | if (NILP (restrictions)) |
| 2703 | return NULL; | 2702 | return Qnil; |
| 2704 | restrictions = XCAR (XCDR (restrictions)); | 2703 | restrictions = XCAR (XCDR (restrictions)); |
| 2705 | Lisp_Object bounds | 2704 | Lisp_Object bounds |
| 2706 | = outermost | 2705 | = outermost |
| @@ -2709,7 +2708,7 @@ labeled_restrictions_get_bound (Lisp_Object buf, bool begv, bool outermost) | |||
| 2709 | eassert (! NILP (bounds)); | 2708 | eassert (! NILP (bounds)); |
| 2710 | Lisp_Object marker = begv ? XCAR (bounds) : XCAR (XCDR (bounds)); | 2709 | Lisp_Object marker = begv ? XCAR (bounds) : XCAR (XCDR (bounds)); |
| 2711 | eassert (EQ (Fmarker_buffer (marker), buf)); | 2710 | eassert (EQ (Fmarker_buffer (marker), buf)); |
| 2712 | return XMARKER (marker); | 2711 | return marker; |
| 2713 | } | 2712 | } |
| 2714 | 2713 | ||
| 2715 | /* Retrieve the label of the innermost labeled restriction in BUF. | 2714 | /* Retrieve the label of the innermost labeled restriction in BUF. |
| @@ -2766,14 +2765,14 @@ labeled_restrictions_remove_in_current_buffer (void) | |||
| 2766 | static void | 2765 | static void |
| 2767 | unwind_reset_outermost_restriction (Lisp_Object buf) | 2766 | unwind_reset_outermost_restriction (Lisp_Object buf) |
| 2768 | { | 2767 | { |
| 2769 | struct Lisp_Marker *begv | 2768 | Lisp_Object begv = labeled_restrictions_get_bound (buf, true, false); |
| 2770 | = labeled_restrictions_get_bound (buf, true, false); | 2769 | Lisp_Object zv = labeled_restrictions_get_bound (buf, false, false); |
| 2771 | struct Lisp_Marker *zv | 2770 | if (! NILP (begv) && ! NILP (zv)) |
| 2772 | = labeled_restrictions_get_bound (buf, false, false); | ||
| 2773 | if (begv != NULL && zv != NULL) | ||
| 2774 | { | 2771 | { |
| 2775 | SET_BUF_BEGV_BOTH (XBUFFER (buf), begv->charpos, begv->bytepos); | 2772 | SET_BUF_BEGV_BOTH (XBUFFER (buf), |
| 2776 | SET_BUF_ZV_BOTH (XBUFFER (buf), zv->charpos, zv->bytepos); | 2773 | marker_position (begv), marker_byte_position (begv)); |
| 2774 | SET_BUF_ZV_BOTH (XBUFFER (buf), | ||
| 2775 | marker_position (zv), marker_byte_position (zv)); | ||
| 2777 | } | 2776 | } |
| 2778 | else | 2777 | else |
| 2779 | labeled_restrictions_remove (buf); | 2778 | labeled_restrictions_remove (buf); |
| @@ -2797,14 +2796,14 @@ reset_outermost_restrictions (void) | |||
| 2797 | { | 2796 | { |
| 2798 | buf = XCAR (XCAR (val)); | 2797 | buf = XCAR (XCAR (val)); |
| 2799 | eassert (BUFFERP (buf)); | 2798 | eassert (BUFFERP (buf)); |
| 2800 | struct Lisp_Marker *begv | 2799 | Lisp_Object begv = labeled_restrictions_get_bound (buf, true, true); |
| 2801 | = labeled_restrictions_get_bound (buf, true, true); | 2800 | Lisp_Object zv = labeled_restrictions_get_bound (buf, false, true); |
| 2802 | struct Lisp_Marker *zv | 2801 | if (! NILP (begv) && ! NILP (zv)) |
| 2803 | = labeled_restrictions_get_bound (buf, false, true); | ||
| 2804 | if (begv != NULL && zv != NULL) | ||
| 2805 | { | 2802 | { |
| 2806 | SET_BUF_BEGV_BOTH (XBUFFER (buf), begv->charpos, begv->bytepos); | 2803 | SET_BUF_BEGV_BOTH (XBUFFER (buf), |
| 2807 | SET_BUF_ZV_BOTH (XBUFFER (buf), zv->charpos, zv->bytepos); | 2804 | marker_position (begv), marker_byte_position (begv)); |
| 2805 | SET_BUF_ZV_BOTH (XBUFFER (buf), | ||
| 2806 | marker_position (zv), marker_byte_position (zv)); | ||
| 2808 | record_unwind_protect (unwind_reset_outermost_restriction, buf); | 2807 | record_unwind_protect (unwind_reset_outermost_restriction, buf); |
| 2809 | } | 2808 | } |
| 2810 | else | 2809 | else |
| @@ -2878,15 +2877,17 @@ To gain access to other portions of the buffer, use | |||
| 2878 | } | 2877 | } |
| 2879 | else | 2878 | else |
| 2880 | { | 2879 | { |
| 2881 | struct Lisp_Marker *begv | 2880 | Lisp_Object begv = labeled_restrictions_get_bound (buf, true, false); |
| 2882 | = labeled_restrictions_get_bound (buf, true, false); | 2881 | Lisp_Object zv = labeled_restrictions_get_bound (buf, false, false); |
| 2883 | struct Lisp_Marker *zv | 2882 | eassert (! NILP (begv) && ! NILP (zv)); |
| 2884 | = labeled_restrictions_get_bound (buf, false, false); | 2883 | ptrdiff_t begv_charpos = marker_position (begv); |
| 2885 | eassert (begv != NULL && zv != NULL); | 2884 | ptrdiff_t zv_charpos = marker_position (zv); |
| 2886 | if (begv->charpos != BEGV || zv->charpos != ZV) | 2885 | if (begv_charpos != BEGV || zv_charpos != ZV) |
| 2887 | current_buffer->clip_changed = 1; | 2886 | current_buffer->clip_changed = 1; |
| 2888 | SET_BUF_BEGV_BOTH (current_buffer, begv->charpos, begv->bytepos); | 2887 | SET_BUF_BEGV_BOTH (current_buffer, |
| 2889 | SET_BUF_ZV_BOTH (current_buffer, zv->charpos, zv->bytepos); | 2888 | begv_charpos, marker_byte_position (begv)); |
| 2889 | SET_BUF_ZV_BOTH (current_buffer, | ||
| 2890 | zv_charpos, marker_byte_position (zv)); | ||
| 2890 | /* If the only remaining bounds in labeled_restrictions for | 2891 | /* If the only remaining bounds in labeled_restrictions for |
| 2891 | current_buffer are the bounds that were set by the user, no | 2892 | current_buffer are the bounds that were set by the user, no |
| 2892 | labeled restriction is in effect in current_buffer anymore: | 2893 | labeled restriction is in effect in current_buffer anymore: |
| @@ -2933,15 +2934,15 @@ argument. To gain access to other portions of the buffer, use | |||
| 2933 | { | 2934 | { |
| 2934 | /* Limit the start and end positions to those of the innermost | 2935 | /* Limit the start and end positions to those of the innermost |
| 2935 | labeled restriction. */ | 2936 | labeled restriction. */ |
| 2936 | struct Lisp_Marker *begv | 2937 | Lisp_Object begv = labeled_restrictions_get_bound (buf, true, false); |
| 2937 | = labeled_restrictions_get_bound (buf, true, false); | 2938 | Lisp_Object zv = labeled_restrictions_get_bound (buf, false, false); |
| 2938 | struct Lisp_Marker *zv | 2939 | eassert (! NILP (begv) && ! NILP (zv)); |
| 2939 | = labeled_restrictions_get_bound (buf, false, false); | 2940 | ptrdiff_t begv_charpos = marker_position (begv); |
| 2940 | eassert (begv != NULL && zv != NULL); | 2941 | ptrdiff_t zv_charpos = marker_position (zv); |
| 2941 | if (s < begv->charpos) s = begv->charpos; | 2942 | if (s < begv_charpos) s = begv_charpos; |
| 2942 | if (s > zv->charpos) s = zv->charpos; | 2943 | if (s > zv_charpos) s = zv_charpos; |
| 2943 | if (e < begv->charpos) e = begv->charpos; | 2944 | if (e < begv_charpos) e = begv_charpos; |
| 2944 | if (e > zv->charpos) e = zv->charpos; | 2945 | if (e > zv_charpos) e = zv_charpos; |
| 2945 | } | 2946 | } |
| 2946 | 2947 | ||
| 2947 | /* Record the accessible range of the buffer when narrow-to-region | 2948 | /* Record the accessible range of the buffer when narrow-to-region |