comparison src/editfns.c @ 46921:40c8bb63c063

(save_restriction_restore): Defend from unchained marker.
author Richard M. Stallman <rms@gnu.org>
date Sat, 17 Aug 2002 04:55:17 +0000
parents 8587dd21917c
children da8405c812f2
comparison
equal deleted inserted replaced
46920:a92cb918558c 46921:40c8bb63c063
2832 { 2832 {
2833 struct Lisp_Marker *beg = XMARKER (XCAR (data)); 2833 struct Lisp_Marker *beg = XMARKER (XCAR (data));
2834 struct Lisp_Marker *end = XMARKER (XCDR (data)); 2834 struct Lisp_Marker *end = XMARKER (XCDR (data));
2835 struct buffer *buf = beg->buffer; /* END should have the same buffer. */ 2835 struct buffer *buf = beg->buffer; /* END should have the same buffer. */
2836 2836
2837 if (beg->charpos != BUF_BEGV(buf) || end->charpos != BUF_ZV(buf)) 2837 if (buf /* Verify marker still points to a buffer. */
2838 && (beg->charpos != BUF_BEGV (buf) || end->charpos != BUF_ZV (buf)))
2838 /* The restriction has changed from the saved one, so restore 2839 /* The restriction has changed from the saved one, so restore
2839 the saved restriction. */ 2840 the saved restriction. */
2840 { 2841 {
2841 int pt = BUF_PT (buf); 2842 int pt = BUF_PT (buf);
2842 2843
2845 2846
2846 if (pt < beg->charpos || pt > end->charpos) 2847 if (pt < beg->charpos || pt > end->charpos)
2847 /* The point is outside the new visible range, move it inside. */ 2848 /* The point is outside the new visible range, move it inside. */
2848 SET_BUF_PT_BOTH (buf, 2849 SET_BUF_PT_BOTH (buf,
2849 clip_to_bounds (beg->charpos, pt, end->charpos), 2850 clip_to_bounds (beg->charpos, pt, end->charpos),
2850 clip_to_bounds (beg->bytepos, BUF_PT_BYTE(buf), 2851 clip_to_bounds (beg->bytepos, BUF_PT_BYTE (buf),
2851 end->bytepos)); 2852 end->bytepos));
2852 2853
2853 buf->clip_changed = 1; /* Remember that the narrowing changed. */ 2854 buf->clip_changed = 1; /* Remember that the narrowing changed. */
2854 } 2855 }
2855 } 2856 }
2856 else 2857 else
2857 /* A buffer, which means that there was no old restriction. */ 2858 /* A buffer, which means that there was no old restriction. */
2858 { 2859 {
2859 struct buffer *buf = XBUFFER (data); 2860 struct buffer *buf = XBUFFER (data);
2860 2861
2861 if (BUF_BEGV(buf) != BUF_BEG(buf) || BUF_ZV(buf) != BUF_Z(buf)) 2862 if (buf /* Verify marker still points to a buffer. */
2863 && (BUF_BEGV (buf) != BUF_BEG (buf) || BUF_ZV (buf) != BUF_Z (buf)))
2862 /* The buffer has been narrowed, get rid of the narrowing. */ 2864 /* The buffer has been narrowed, get rid of the narrowing. */
2863 { 2865 {
2864 SET_BUF_BEGV_BOTH (buf, BUF_BEG(buf), BUF_BEG_BYTE(buf)); 2866 SET_BUF_BEGV_BOTH (buf, BUF_BEG (buf), BUF_BEG_BYTE (buf));
2865 SET_BUF_ZV_BOTH (buf, BUF_Z(buf), BUF_Z_BYTE(buf)); 2867 SET_BUF_ZV_BOTH (buf, BUF_Z (buf), BUF_Z_BYTE (buf));
2866 2868
2867 buf->clip_changed = 1; /* Remember that the narrowing changed. */ 2869 buf->clip_changed = 1; /* Remember that the narrowing changed. */
2868 } 2870 }
2869 } 2871 }
2870 2872