aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorTom Tromey2012-09-04 10:10:06 -0600
committerTom Tromey2012-09-04 10:10:06 -0600
commitbf69f522a9e135f9aa483cedd53e71e915f2bf75 (patch)
tree3f73c47fb863ef87f420de1d30858da821072bd9 /src/buffer.c
parent303324a9232dbc89369faceb6b3530740d0fc1bd (diff)
parent6ec9a5a7b5efb129807f567709ca858211ed7840 (diff)
downloademacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.tar.gz
emacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.zip
merge from trunk
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c167
1 files changed, 80 insertions, 87 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 6f748158e21..ef87f40e81a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -108,10 +108,10 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
108int last_per_buffer_idx; 108int last_per_buffer_idx;
109 109
110static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, 110static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
111 int after, Lisp_Object arg1, 111 bool after, Lisp_Object arg1,
112 Lisp_Object arg2, Lisp_Object arg3); 112 Lisp_Object arg2, Lisp_Object arg3);
113static void swap_out_buffer_local_variables (struct buffer *b); 113static void swap_out_buffer_local_variables (struct buffer *b);
114static void reset_buffer_local_variables (struct buffer *b, int permanent_too); 114static void reset_buffer_local_variables (struct buffer *, bool);
115 115
116/* Alist of all buffer names vs the buffers. */ 116/* Alist of all buffer names vs the buffers. */
117/* This used to be a variable, but is no longer, 117/* This used to be a variable, but is no longer,
@@ -153,7 +153,7 @@ static void alloc_buffer_text (struct buffer *, ptrdiff_t);
153static void free_buffer_text (struct buffer *b); 153static void free_buffer_text (struct buffer *b);
154static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); 154static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *);
155static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); 155static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
156static Lisp_Object buffer_lisp_local_variables (struct buffer *, int); 156static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool);
157 157
158/* These setters are used only in this file, so they can be private. */ 158/* These setters are used only in this file, so they can be private. */
159static inline void 159static inline void
@@ -977,15 +977,13 @@ reset_buffer (register struct buffer *b)
977 it does not treat permanent locals consistently. 977 it does not treat permanent locals consistently.
978 Instead, use Fkill_all_local_variables. 978 Instead, use Fkill_all_local_variables.
979 979
980 If PERMANENT_TOO is 1, then we reset permanent 980 If PERMANENT_TOO, reset permanent buffer-local variables.
981 buffer-local variables. If PERMANENT_TOO is 0, 981 If not, preserve those. */
982 we preserve those. */
983 982
984static void 983static void
985reset_buffer_local_variables (register struct buffer *b, int permanent_too) 984reset_buffer_local_variables (struct buffer *b, bool permanent_too)
986{ 985{
987 register int offset; 986 int offset, i;
988 int i;
989 987
990 /* Reset the major mode to Fundamental, together with all the 988 /* Reset the major mode to Fundamental, together with all the
991 things that depend on the major mode. 989 things that depend on the major mode.
@@ -1251,14 +1249,14 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
1251/* Return an alist of the Lisp-level buffer-local bindings of 1249/* Return an alist of the Lisp-level buffer-local bindings of
1252 buffer BUF. That is, don't include the variables maintained 1250 buffer BUF. That is, don't include the variables maintained
1253 in special slots in the buffer object. 1251 in special slots in the buffer object.
1254 If CLONE is zero elements of the form (VAR . unbound) are replaced 1252 If not CLONE, replace elements of the form (VAR . unbound)
1255 by VAR. */ 1253 by VAR. */
1256 1254
1257static Lisp_Object 1255static Lisp_Object
1258buffer_lisp_local_variables (struct buffer *buf, int clone) 1256buffer_lisp_local_variables (struct buffer *buf, bool clone)
1259{ 1257{
1260 Lisp_Object result = Qnil; 1258 Lisp_Object result = Qnil;
1261 register Lisp_Object tail; 1259 Lisp_Object tail;
1262 for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail)) 1260 for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail))
1263 { 1261 {
1264 Lisp_Object val, elt; 1262 Lisp_Object val, elt;
@@ -1349,11 +1347,9 @@ DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p,
1349 1, 1, 0, 1347 1, 1, 0,
1350 doc: /* Mark current buffer as modified or unmodified according to FLAG. 1348 doc: /* Mark current buffer as modified or unmodified according to FLAG.
1351A non-nil FLAG means mark the buffer modified. */) 1349A non-nil FLAG means mark the buffer modified. */)
1352 (register Lisp_Object flag) 1350 (Lisp_Object flag)
1353{ 1351{
1354 register int already; 1352 Lisp_Object fn, buffer, window;
1355 register Lisp_Object fn;
1356 Lisp_Object buffer, window;
1357 1353
1358#ifdef CLASH_DETECTION 1354#ifdef CLASH_DETECTION
1359 /* If buffer becoming modified, lock the file. 1355 /* If buffer becoming modified, lock the file.
@@ -1363,7 +1359,7 @@ A non-nil FLAG means mark the buffer modified. */)
1363 /* Test buffer-file-name so that binding it to nil is effective. */ 1359 /* Test buffer-file-name so that binding it to nil is effective. */
1364 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) 1360 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
1365 { 1361 {
1366 already = SAVE_MODIFF < MODIFF; 1362 bool already = SAVE_MODIFF < MODIFF;
1367 if (!already && !NILP (flag)) 1363 if (!already && !NILP (flag))
1368 lock_file (fn); 1364 lock_file (fn);
1369 else if (already && NILP (flag)) 1365 else if (already && NILP (flag))
@@ -1430,7 +1426,7 @@ state of the current buffer. Use with care. */)
1430 /* Test buffer-file-name so that binding it to nil is effective. */ 1426 /* Test buffer-file-name so that binding it to nil is effective. */
1431 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) 1427 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
1432 { 1428 {
1433 int already = SAVE_MODIFF < MODIFF; 1429 bool already = SAVE_MODIFF < MODIFF;
1434 if (!already && !NILP (flag)) 1430 if (!already && !NILP (flag))
1435 lock_file (fn); 1431 lock_file (fn);
1436 else if (already && NILP (flag)) 1432 else if (already && NILP (flag))
@@ -1555,7 +1551,6 @@ list first, followed by the list of all buffers. If no other buffer
1555exists, return the buffer `*scratch*' (creating it if necessary). */) 1551exists, return the buffer `*scratch*' (creating it if necessary). */)
1556 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) 1552 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
1557{ 1553{
1558 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1559 Lisp_Object tail, buf, pred; 1554 Lisp_Object tail, buf, pred;
1560 Lisp_Object notsogood = Qnil; 1555 Lisp_Object notsogood = Qnil;
1561 1556
@@ -1626,7 +1621,6 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1626Lisp_Object 1621Lisp_Object
1627other_buffer_safely (Lisp_Object buffer) 1622other_buffer_safely (Lisp_Object buffer)
1628{ 1623{
1629 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1630 Lisp_Object tail, buf; 1624 Lisp_Object tail, buf;
1631 1625
1632 tail = Vbuffer_alist; 1626 tail = Vbuffer_alist;
@@ -1674,7 +1668,7 @@ No argument or nil as argument means do this for the current buffer. */)
1674 1668
1675/* Truncate undo list and shrink the gap of BUFFER. */ 1669/* Truncate undo list and shrink the gap of BUFFER. */
1676 1670
1677int 1671void
1678compact_buffer (struct buffer *buffer) 1672compact_buffer (struct buffer *buffer)
1679{ 1673{
1680 /* Verify indirection counters. */ 1674 /* Verify indirection counters. */
@@ -1716,9 +1710,7 @@ compact_buffer (struct buffer *buffer)
1716 } 1710 }
1717 } 1711 }
1718 buffer->text->compact = buffer->text->modiff; 1712 buffer->text->compact = buffer->text->modiff;
1719 return 1;
1720 } 1713 }
1721 return 0;
1722} 1714}
1723 1715
1724DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", 1716DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
@@ -2068,8 +2060,10 @@ the current buffer's major mode. */)
2068 2060
2069 CHECK_BUFFER (buffer); 2061 CHECK_BUFFER (buffer);
2070 2062
2071 if (STRINGP (BVAR (XBUFFER (buffer), name)) 2063 if (NILP (BVAR (XBUFFER (buffer), name)))
2072 && strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) 2064 error ("Attempt to set major mode for a dead buffer");
2065
2066 if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0)
2073 function = find_symbol_value (intern ("initial-major-mode")); 2067 function = find_symbol_value (intern ("initial-major-mode"));
2074 else 2068 else
2075 { 2069 {
@@ -2103,22 +2097,6 @@ DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
2103 XSETBUFFER (buf, current_buffer); 2097 XSETBUFFER (buf, current_buffer);
2104 return buf; 2098 return buf;
2105} 2099}
2106
2107/* Set the current buffer to B.
2108
2109 We previously set windows_or_buffers_changed here to invalidate
2110 global unchanged information in beg_unchanged and end_unchanged.
2111 This is no longer necessary because we now compute unchanged
2112 information on a buffer-basis. Every action affecting other
2113 windows than the selected one requires a select_window at some
2114 time, and that increments windows_or_buffers_changed. */
2115
2116void
2117set_buffer_internal (register struct buffer *b)
2118{
2119 if (current_buffer != b)
2120 set_buffer_internal_1 (b);
2121}
2122 2100
2123/* Set the current buffer to B, and do not set windows_or_buffers_changed. 2101/* Set the current buffer to B, and do not set windows_or_buffers_changed.
2124 This is used by redisplay. */ 2102 This is used by redisplay. */
@@ -2224,13 +2202,13 @@ ends when the current command terminates. Use `switch-to-buffer' or
2224 return buffer; 2202 return buffer;
2225} 2203}
2226 2204
2227/* Set the current buffer to BUFFER provided it is alive. */ 2205/* Set the current buffer to BUFFER provided if it is alive. */
2228 2206
2229Lisp_Object 2207Lisp_Object
2230set_buffer_if_live (Lisp_Object buffer) 2208set_buffer_if_live (Lisp_Object buffer)
2231{ 2209{
2232 if (! NILP (BVAR (XBUFFER (buffer), name))) 2210 if (! NILP (BVAR (XBUFFER (buffer), name)))
2233 Fset_buffer (buffer); 2211 set_buffer_internal (XBUFFER (buffer));
2234 return Qnil; 2212 return Qnil;
2235} 2213}
2236 2214
@@ -2469,8 +2447,8 @@ current buffer is cleared. */)
2469 struct Lisp_Marker *tail, *markers; 2447 struct Lisp_Marker *tail, *markers;
2470 struct buffer *other; 2448 struct buffer *other;
2471 ptrdiff_t begv, zv; 2449 ptrdiff_t begv, zv;
2472 int narrowed = (BEG != BEGV || Z != ZV); 2450 bool narrowed = (BEG != BEGV || Z != ZV);
2473 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2451 bool modified_p = !NILP (Fbuffer_modified_p (Qnil));
2474 Lisp_Object old_undo = BVAR (current_buffer, undo_list); 2452 Lisp_Object old_undo = BVAR (current_buffer, undo_list);
2475 struct gcpro gcpro1; 2453 struct gcpro gcpro1;
2476 2454
@@ -2819,19 +2797,19 @@ swap_out_buffer_local_variables (struct buffer *b)
2819 *VEC_PTR and *LEN_PTR should contain a valid vector and size 2797 *VEC_PTR and *LEN_PTR should contain a valid vector and size
2820 when this function is called. 2798 when this function is called.
2821 2799
2822 If EXTEND is non-zero, we make the vector bigger if necessary. 2800 If EXTEND, make the vector bigger if necessary.
2823 If EXTEND is zero, we never extend the vector, 2801 If not, never extend the vector,
2824 and we store only as many overlays as will fit. 2802 and store only as many overlays as will fit.
2825 But we still return the total number of overlays. 2803 But still return the total number of overlays.
2826 2804
2827 If CHANGE_REQ is true, then any position written into *PREV_PTR or 2805 If CHANGE_REQ, any position written into *PREV_PTR or
2828 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the 2806 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the
2829 default (BEGV or ZV). */ 2807 default (BEGV or ZV). */
2830 2808
2831ptrdiff_t 2809ptrdiff_t
2832overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, 2810overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr,
2833 ptrdiff_t *len_ptr, 2811 ptrdiff_t *len_ptr,
2834 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, int change_req) 2812 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req)
2835{ 2813{
2836 Lisp_Object overlay, start, end; 2814 Lisp_Object overlay, start, end;
2837 struct Lisp_Overlay *tail; 2815 struct Lisp_Overlay *tail;
@@ -2840,7 +2818,7 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
2840 Lisp_Object *vec = *vec_ptr; 2818 Lisp_Object *vec = *vec_ptr;
2841 ptrdiff_t next = ZV; 2819 ptrdiff_t next = ZV;
2842 ptrdiff_t prev = BEGV; 2820 ptrdiff_t prev = BEGV;
2843 int inhibit_storing = 0; 2821 bool inhibit_storing = 0;
2844 2822
2845 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2823 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2846 { 2824 {
@@ -2957,13 +2935,13 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
2957 *VEC_PTR and *LEN_PTR should contain a valid vector and size 2935 *VEC_PTR and *LEN_PTR should contain a valid vector and size
2958 when this function is called. 2936 when this function is called.
2959 2937
2960 If EXTEND is non-zero, we make the vector bigger if necessary. 2938 If EXTEND, make the vector bigger if necessary.
2961 If EXTEND is zero, we never extend the vector, 2939 If not, never extend the vector,
2962 and we store only as many overlays as will fit. 2940 and store only as many overlays as will fit.
2963 But we still return the total number of overlays. */ 2941 But still return the total number of overlays. */
2964 2942
2965static ptrdiff_t 2943static ptrdiff_t
2966overlays_in (EMACS_INT beg, EMACS_INT end, int extend, 2944overlays_in (EMACS_INT beg, EMACS_INT end, bool extend,
2967 Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, 2945 Lisp_Object **vec_ptr, ptrdiff_t *len_ptr,
2968 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) 2946 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr)
2969{ 2947{
@@ -2974,8 +2952,8 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
2974 Lisp_Object *vec = *vec_ptr; 2952 Lisp_Object *vec = *vec_ptr;
2975 ptrdiff_t next = ZV; 2953 ptrdiff_t next = ZV;
2976 ptrdiff_t prev = BEGV; 2954 ptrdiff_t prev = BEGV;
2977 int inhibit_storing = 0; 2955 bool inhibit_storing = 0;
2978 int end_is_Z = end == Z; 2956 bool end_is_Z = end == Z;
2979 2957
2980 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2958 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2981 { 2959 {
@@ -3076,10 +3054,10 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
3076} 3054}
3077 3055
3078 3056
3079/* Return non-zero if there exists an overlay with a non-nil 3057/* Return true if there exists an overlay with a non-nil
3080 `mouse-face' property overlapping OVERLAY. */ 3058 `mouse-face' property overlapping OVERLAY. */
3081 3059
3082int 3060bool
3083mouse_face_overlay_overlaps (Lisp_Object overlay) 3061mouse_face_overlay_overlaps (Lisp_Object overlay)
3084{ 3062{
3085 ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay)); 3063 ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay));
@@ -3108,7 +3086,7 @@ mouse_face_overlay_overlaps (Lisp_Object overlay)
3108 3086
3109 3087
3110/* Fast function to just test if we're at an overlay boundary. */ 3088/* Fast function to just test if we're at an overlay boundary. */
3111int 3089bool
3112overlay_touches_p (ptrdiff_t pos) 3090overlay_touches_p (ptrdiff_t pos)
3113{ 3091{
3114 Lisp_Object overlay; 3092 Lisp_Object overlay;
@@ -3325,7 +3303,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
3325 Lisp_Object overlay, window, str; 3303 Lisp_Object overlay, window, str;
3326 struct Lisp_Overlay *ov; 3304 struct Lisp_Overlay *ov;
3327 ptrdiff_t startpos, endpos; 3305 ptrdiff_t startpos, endpos;
3328 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 3306 bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
3329 3307
3330 overlay_heads.used = overlay_heads.bytes = 0; 3308 overlay_heads.used = overlay_heads.bytes = 0;
3331 overlay_tails.used = overlay_tails.bytes = 0; 3309 overlay_tails.used = overlay_tails.bytes = 0;
@@ -4093,6 +4071,26 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
4093 4071
4094 return unbind_to (count, Qnil); 4072 return unbind_to (count, Qnil);
4095} 4073}
4074
4075DEFUN ("delete-all-overlays", Fdelete_all_overlays, Sdelete_all_overlays, 0, 1, 0,
4076 doc: /* Delete all overlays of BUFFER.
4077BUFFER omitted or nil means delete all overlays of the current
4078buffer. */)
4079 (Lisp_Object buffer)
4080{
4081 register struct buffer *buf;
4082
4083 if (NILP (buffer))
4084 buf = current_buffer;
4085 else
4086 {
4087 CHECK_BUFFER (buffer);
4088 buf = XBUFFER (buffer);
4089 }
4090
4091 delete_all_overlays (buf);
4092 return Qnil;
4093}
4096 4094
4097/* Overlay dissection functions. */ 4095/* Overlay dissection functions. */
4098 4096
@@ -4319,7 +4317,7 @@ VALUE will be returned.*/)
4319 (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value) 4317 (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value)
4320{ 4318{
4321 Lisp_Object tail, buffer; 4319 Lisp_Object tail, buffer;
4322 int changed; 4320 bool changed;
4323 4321
4324 CHECK_OVERLAY (overlay); 4322 CHECK_OVERLAY (overlay);
4325 4323
@@ -4394,7 +4392,7 @@ add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
4394 and the insert-after-hooks of overlay ending at START. 4392 and the insert-after-hooks of overlay ending at START.
4395 4393
4396 This is called both before and after the modification. 4394 This is called both before and after the modification.
4397 AFTER is nonzero when we call after the modification. 4395 AFTER is true when we call after the modification.
4398 4396
4399 ARG1, ARG2, ARG3 are arguments to pass to the hook functions. 4397 ARG1, ARG2, ARG3 are arguments to pass to the hook functions.
4400 When AFTER is nonzero, they are the start position, 4398 When AFTER is nonzero, they are the start position,
@@ -4402,13 +4400,13 @@ add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
4402 and the length of deleted or replaced old text. */ 4400 and the length of deleted or replaced old text. */
4403 4401
4404void 4402void
4405report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, 4403report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after,
4406 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) 4404 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
4407{ 4405{
4408 Lisp_Object prop, overlay; 4406 Lisp_Object prop, overlay;
4409 struct Lisp_Overlay *tail; 4407 struct Lisp_Overlay *tail;
4410 /* 1 if this change is an insertion. */ 4408 /* True if this change is an insertion. */
4411 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); 4409 bool insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
4412 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4410 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4413 4411
4414 overlay = Qnil; 4412 overlay = Qnil;
@@ -4528,7 +4526,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4528} 4526}
4529 4527
4530static void 4528static void
4531call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, int after, 4529call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, bool after,
4532 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) 4530 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
4533{ 4531{
4534 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4532 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -4687,7 +4685,7 @@ static int mmap_page_size;
4687 4685
4688/* 1 means mmap has been initialized. */ 4686/* 1 means mmap has been initialized. */
4689 4687
4690static int mmap_initialized_p; 4688static bool mmap_initialized_p;
4691 4689
4692/* Value is X rounded up to the next multiple of N. */ 4690/* Value is X rounded up to the next multiple of N. */
4693 4691
@@ -4783,9 +4781,9 @@ mmap_find (void *start, void *end)
4783 4781
4784 4782
4785/* Unmap a region. P is a pointer to the start of the user-araa of 4783/* Unmap a region. P is a pointer to the start of the user-araa of
4786 the region. Value is non-zero if successful. */ 4784 the region. */
4787 4785
4788static int 4786static void
4789mmap_free_1 (struct mmap_region *r) 4787mmap_free_1 (struct mmap_region *r)
4790{ 4788{
4791 if (r->next) 4789 if (r->next)
@@ -4796,24 +4794,19 @@ mmap_free_1 (struct mmap_region *r)
4796 mmap_regions = r->next; 4794 mmap_regions = r->next;
4797 4795
4798 if (munmap (r, r->nbytes_mapped) == -1) 4796 if (munmap (r, r->nbytes_mapped) == -1)
4799 { 4797 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4800 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4801 return 0;
4802 }
4803
4804 return 1;
4805} 4798}
4806 4799
4807 4800
4808/* Enlarge region R by NPAGES pages. NPAGES < 0 means shrink R. 4801/* Enlarge region R by NPAGES pages. NPAGES < 0 means shrink R.
4809 Value is non-zero if successful. */ 4802 Value is true if successful. */
4810 4803
4811static int 4804static bool
4812mmap_enlarge (struct mmap_region *r, int npages) 4805mmap_enlarge (struct mmap_region *r, int npages)
4813{ 4806{
4814 char *region_end = (char *) r + r->nbytes_mapped; 4807 char *region_end = (char *) r + r->nbytes_mapped;
4815 size_t nbytes; 4808 size_t nbytes;
4816 int success = 0; 4809 bool success = 0;
4817 4810
4818 if (npages < 0) 4811 if (npages < 0)
4819 { 4812 {
@@ -4863,17 +4856,16 @@ mmap_enlarge (struct mmap_region *r, int npages)
4863} 4856}
4864 4857
4865 4858
4866/* Set or reset variables holding references to mapped regions. If 4859/* Set or reset variables holding references to mapped regions.
4867 RESTORE_P is zero, set all variables to null. If RESTORE_P is 4860 If not RESTORE_P, set all variables to null. If RESTORE_P, set all
4868 non-zero, set all variables to the start of the user-areas 4861 variables to the start of the user-areas of mapped regions.
4869 of mapped regions.
4870 4862
4871 This function is called from Fdump_emacs to ensure that the dumped 4863 This function is called from Fdump_emacs to ensure that the dumped
4872 Emacs doesn't contain references to memory that won't be mapped 4864 Emacs doesn't contain references to memory that won't be mapped
4873 when Emacs starts. */ 4865 when Emacs starts. */
4874 4866
4875void 4867void
4876mmap_set_vars (int restore_p) 4868mmap_set_vars (bool restore_p)
4877{ 4869{
4878 struct mmap_region *r; 4870 struct mmap_region *r;
4879 4871
@@ -6312,6 +6304,7 @@ and `bury-buffer-internal'. */);
6312 defsubr (&Soverlayp); 6304 defsubr (&Soverlayp);
6313 defsubr (&Smake_overlay); 6305 defsubr (&Smake_overlay);
6314 defsubr (&Sdelete_overlay); 6306 defsubr (&Sdelete_overlay);
6307 defsubr (&Sdelete_all_overlays);
6315 defsubr (&Smove_overlay); 6308 defsubr (&Smove_overlay);
6316 defsubr (&Soverlay_start); 6309 defsubr (&Soverlay_start);
6317 defsubr (&Soverlay_end); 6310 defsubr (&Soverlay_end);