aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parent303324a9232dbc89369faceb6b3530740d0fc1bd (diff)
parent6ec9a5a7b5efb129807f567709ca858211ed7840 (diff)
downloademacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.tar.gz
emacs-bf69f522a9e135f9aa483cedd53e71e915f2bf75.zip
merge from trunk
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit4
-rw-r--r--src/ChangeLog737
-rw-r--r--src/Makefile.in27
-rw-r--r--src/alloc.c121
-rw-r--r--src/atimer.c2
-rw-r--r--src/atimer.h3
-rw-r--r--src/bidi.c63
-rw-r--r--src/buffer.c167
-rw-r--r--src/buffer.h48
-rw-r--r--src/bytecode.c4
-rw-r--r--src/callint.c16
-rw-r--r--src/callproc.c36
-rw-r--r--src/casefiddle.c13
-rw-r--r--src/casetab.c4
-rw-r--r--src/category.c8
-rw-r--r--src/category.h12
-rw-r--r--src/ccl.h2
-rw-r--r--src/character.c16
-rw-r--r--src/character.h3
-rw-r--r--src/charset.c32
-rw-r--r--src/charset.h41
-rw-r--r--src/chartab.c19
-rw-r--r--src/cmds.c8
-rw-r--r--src/coding.c371
-rw-r--r--src/coding.h49
-rw-r--r--src/composite.c22
-rw-r--r--src/composite.h13
-rw-r--r--src/conf_post.h3
-rw-r--r--src/data.c55
-rw-r--r--src/dbusbind.c13
-rw-r--r--src/dired.c38
-rw-r--r--src/dispextern.h41
-rw-r--r--src/dispnew.c351
-rw-r--r--src/doc.c40
-rw-r--r--src/editfns.c108
-rw-r--r--src/emacs.c84
-rw-r--r--src/eval.c96
-rw-r--r--src/fileio.c14
-rw-r--r--src/firstfile.c5
-rw-r--r--src/fns.c54
-rw-r--r--src/font.c14
-rw-r--r--src/font.h1
-rw-r--r--src/fontset.c134
-rw-r--r--src/frame.c20
-rw-r--r--src/frame.h71
-rw-r--r--src/gtkutil.c11
-rw-r--r--src/gtkutil.h4
-rw-r--r--src/image.c43
-rw-r--r--src/insdel.c80
-rw-r--r--src/intervals.c58
-rw-r--r--src/intervals.h14
-rw-r--r--src/keyboard.c52
-rw-r--r--src/keymap.c15
-rw-r--r--src/lisp.h162
-rw-r--r--src/lread.c25
-rw-r--r--src/makefile.w32-in31
-rw-r--r--src/menu.c17
-rw-r--r--src/minibuf.c3
-rw-r--r--src/msdos.c9
-rw-r--r--src/nsmenu.m101
-rw-r--r--src/nsterm.h38
-rw-r--r--src/nsterm.m7
-rw-r--r--src/print.c11
-rw-r--r--src/process.c47
-rw-r--r--src/process.h4
-rw-r--r--src/ralloc.c45
-rw-r--r--src/sysdep.c24
-rw-r--r--src/systime.h4
-rw-r--r--src/term.c17
-rw-r--r--src/textprop.c4
-rw-r--r--src/undo.c2
-rw-r--r--src/w32.c6
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32font.h4
-rw-r--r--src/w32term.h5
-rw-r--r--src/w32uniscribe.c67
-rw-r--r--src/w32xfns.c2
-rw-r--r--src/widget.c2
-rw-r--r--src/window.c103
-rw-r--r--src/window.h1
-rw-r--r--src/xdisp.c47
-rw-r--r--src/xfaces.c72
-rw-r--r--src/xfont.c9
-rw-r--r--src/xgselect.c52
-rw-r--r--src/xgselect.h2
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c13
-rw-r--r--src/xterm.h29
88 files changed, 2452 insertions, 1777 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index b703842f4cf..de980c6345f 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -18,9 +18,9 @@
18# Boston, MA 02110-1301, USA. 18# Boston, MA 02110-1301, USA.
19 19
20# Force loading of symbols, enough to give us VALBITS etc. 20# Force loading of symbols, enough to give us VALBITS etc.
21set main 21set $dummy = main + 8
22# With some compilers, we need this to give us struct Lisp_Symbol etc.: 22# With some compilers, we need this to give us struct Lisp_Symbol etc.:
23set Fmake_symbol 23set $dummy = Fmake_symbol + 8
24 24
25# Find lwlib source files too. 25# Find lwlib source files too.
26dir ../lwlib 26dir ../lwlib
diff --git a/src/ChangeLog b/src/ChangeLog
index 1e25015da20..a8d6a4026a0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,738 @@
12012-09-04 Paul Eggert <eggert@cs.ucla.edu>
2
3 Be more systematic about _setjmp vs setjmp.
4 * alloc.c (test_setjmp, mark_stack):
5 * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]:
6 (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]:
7 (png_load, my_error_exit, jpeg_load):
8 * process.c (send_process_trap, send_process):
9 Uniformly prefer _setjmp and _longjmp to setjmp and longjmp.
10 The underscored versions are up to 30x faster on some hosts.
11 Formerly, the code used setjmp+longjmp sometimes and
12 _setjmp+_longjmp at other times, with no particular reason to
13 prefer setjmp+longjmp.
14
152012-09-03 Paul Eggert <eggert@cs.ucla.edu>
16
17 Fix minor problem found by static checking.
18 * buffer.c (Fdelete_all_overlays): Return nil.
19
202012-09-03 Martin Rudalics <rudalics@gmx.at>
21
22 * buffer.c (Fdelete_all_overlays): New function.
23
242012-09-03 Chong Yidong <cyd@gnu.org>
25
26 * gtkutil.c: Add extern decl for Qxft.
27
282012-09-02 Paul Eggert <eggert@cs.ucla.edu>
29
30 * emacs.c, eval.c: Use bool for boolean.
31 * emacs.c (initialized, inhibit_window_system, running_asynch_code):
32 (malloc_using_checking) [DOUG_LEA_MALLOC]:
33 (display_arg) [HAVE_X_WINDOWS || HAVE_NS]:
34 (noninteractive, no_site_lisp, fatal_error_in_progress, argmatch)
35 (main, decode_env_path, Fdaemon_initialized):
36 * eval.c (call_debugger, Finteractive_p, interactive_p):
37 (unwind_to_catch, Fsignal, wants_debugger, skip_debugger)
38 (maybe_call_debugger, Fbacktrace):
39 * process.c (read_process_output, exec_sentinel):
40 Use bool for booleans.
41 * emacs.c (shut_down_emacs): Omit unused boolean argument NO_X.
42 All callers changed.
43 * eval.c (interactive_p): Omit always-true boolean argument
44 EXCLUDE_SUBRS_P. All callers changed.
45 * dispextern.h, lisp.h: Reflect above API changes.
46 * firstfile.c (dummy): Use the address of 'main', whose signature
47 won't change, instead of the address of 'initialize', whose
48 signature just changed from int to bool.
49 * lisp.h (fatal_error_in_progress): New decl of boolean, moved here ...
50 * msdos.c (fatal_error_in_progress): ... from here.
51 * xdisp.c (redisplaying_p): Now a boolean. Set it to 1 instead
52 of incrementing it.
53 (redisplay_internal, unwind_redisplay): Simply clear
54 REDISPLAYING_P when unwinding, instead of saving its previous,
55 always-false value and then restoring it.
56
57 Clean up some extern decls.
58 Mostly, this hoists extern decls out of .c files and into .h files.
59 That way, we're more likely to catch errors if the interfaces change.
60 * alloc.c [USE_GTK]: Include "gtkutil.h" so that we need not
61 declare xg_mark_data.
62 * dispextern.h (x_frame_parm_handlers):
63 * font.h (Qxft):
64 * lisp.h (Qlexical_binding, Qinternal_interpreter_environment)
65 (Qextra_light, Qlight, Qsemi_light, Qsemi_bold, Qbold, Qextra_bold)
66 (Qultra_bold, Qoblique, Qitalic):
67 Move extern decl here from .c file.
68 * alloc.c (xg_mark_data) [USE_GTK]:
69 * doc.c (Qclosure):
70 * eval.c (Qlexical_binding):
71 * fns.c (time) [!HAVE_UNISTD_H]:
72 * gtkutil.c (Qxft, Qnormal, Qextra_light, Qlight, Qsemi_light)
73 (Qsemi_bold, Qbold, Qextra_bold, Qultra_bold, Qoblique, Qitalic):
74 * image.c (Vlibrary_cache, QCloaded_from) [HAVE_NTGUI]:
75 * lread.c (Qinternal_interpreter_environment):
76 * minibuf.c (Qbuffer):
77 * process.c (QCfamily, QCfilter):
78 * widget.c (free_frame_faces):
79 * xfaces.c (free_frame_menubar) [USE_X_TOOLKIT]:
80 * xfont.c (x_clear_errors):
81 * xterm.c (x_frame_parm_handlers):
82 Remove now-redundant extern decls.
83 * keyboard.c, keyboard.h (ignore_mouse_drag_p) [USE_GTK || HAVE_NS]:
84 * xfaces.c (Qultra_light, Qreverse_oblique, Qreverse_italic):
85 Now static.
86 * xfaces.c: Remove unnecessary static decls.
87 * xterm.c (updating_frame): Remove decl of nonexistent object.
88
89 * Makefile.in (gl-stamp): Don't scan $(SOME_MACHINE_OBJECTS)
90 when building globals.h, as the objects that are not built on
91 this host are not needed to compile C files on this host.
92
932012-09-02 Jan Djärv <jan.h.d@swipnet.se>
94
95 * gtkutil.h: Remove prototype for x_wm_set_size_hint.
96
97 * frame.h: Add missing prototype for x_wm_set_size_hint.
98
992012-09-02 Paul Eggert <eggert@cs.ucla.edu>
100
101 * doc.c, editfns.c, insdel.c, intervals.c: Use bool for boolean.
102 * doc.c (read_bytecode_char, get_doc_string, reread_doc_file)
103 (Fdocumentation, Fdocumentation_property, Fsnarf_documentation)
104 (Fsubstitute_command_keys):
105 * editfns.c (region_limit, find_field, Fconstrain_to_field)
106 (save_excursion_save, save_excursion_restore)
107 (disassemble_lisp_time, decode_time_components, emacs_nmemftime)
108 (format_time_string, general_insert_function)
109 (make_buffer_string, make_buffer_string_both)
110 (Fsubst_char_in_region, Ftranslate_region_internal, Fformat):
111 * insdel.c (check_markers, gap_left, adjust_markers_for_insert)
112 (copy_text, insert_1, insert_1_both, insert_from_string)
113 (insert_from_string_before_markers, insert_from_string_1)
114 (insert_from_buffer, insert_from_buffer_1, replace_range)
115 (replace_range_2, del_range_1, del_range_byte, del_range_both)
116 (del_range_2, modify_region):
117 * intervals.c (intervals_equal, balance_possible_root_interval)
118 (adjust_intervals_for_insertion, merge_properties_sticky)
119 (graft_intervals_into_buffer, lookup_char_property)
120 (adjust_for_invis_intang, set_point_both)
121 (get_property_and_range, compare_string_intervals)
122 (set_intervals_multibyte_1, set_intervals_multibyte):
123 * keyboard.c (decode_timer):
124 Use bool for boolean.
125 * intervals.h, lisp.h, systime.h: Reflect above API changes.
126 * editfns.c (struct info): Use 1-bit unsigned bitfields for booleans.
127
1282012-09-02 Chong Yidong <cyd@gnu.org>
129
130 * keymap.c (push_key_description): Print M-TAB as C-M-i
131 (Bug#11758).
132
1332012-09-02 Juanma Barranquero <lekktu@gmail.com>
134
135 * makefile.w32-in (CCL_H, W32FONT_H): New macros.
136 (ATIMER_H, FONT_H, $(BLD)/alloc.$(O), $(BLD)/callproc.$(O))
137 ($(BLD)/editfns.$(O), $(BLD)/ccl.$(O), $(BLD)/chartab.$(O))
138 ($(BLD)/coding.$(O), $(BLD)/sysdep.$(O), $(BLD)/fontset.$(O))
139 ($(BLD)/sysdep.$(O), $(BLD)/w32fns.$(O), $(BLD)/keyboard.$(O))
140 ($(BLD)/w32term.$(O), $(BLD)/w32menu.$(O), $(BLD)/process.$(O))
141 ($(BLD)/w32font.$(O), $(BLD)/w32uniscribe.$(O)): Update dependencies.
142
1432012-09-01 Eli Zaretskii <eliz@gnu.org>
144
145 * w32uniscribe.c (uniscribe_shape): Handle correctly the case of
146 more than one grapheme cluster passed to the shaper: compute the
147 offset adjustment values separately for each cluster. (Bug#11860)
148
149 * image.c: Restore mistakenly removed inclusion of w32.h. Without
150 it, GCC doesn't see prototypes of w32_delayed_load, and complains
151 about implicit conversions from integer to pointer.
152
1532012-09-01 Daniel Colascione <dancol@dancol.org>
154
155 * w32fns.c (x_display_info_for_name): Prevent crash if w32 window
156 system used too early.
157
1582012-09-01 Paul Eggert <eggert@cs.ucla.edu>
159
160 Better seed support for (random).
161 * emacs.c (main): Call init_random.
162 * fns.c (Frandom): Set the seed from a string argument, if given.
163 Remove long-obsolete Gentzel cruft.
164 * lisp.h, sysdep.c (seed_random): Now takes address and size, not long.
165 (init_random): New function.
166
1672012-09-01 Daniel Colascione <dancol@dancol.org>
168
169 * xterm.h: Add header guards. Declare x_menubar_window_to_frame.
170 Remove x_set_frame_alpha, x_bitmap_icon, x_make_frame_visible,
171 x_make_frame_invisible, x_iconify_frame, x_free_frame_resources,
172 x_wm_set_size_hint, x_query_colors, x_real_positions,
173 x_set_menu_bar_lines, x_char_width, x_char_height, x_sync,
174 x_set_tool_bar_lines, x_activate_menubar, and free_frame_menubar,
175 all of which have been moved to common code.
176
177 * xfaces.c: Include TERM_HEADER instead of listing all possible
178 window-system headers.
179
180 * w32xfns.c (x_sync): Correct definition of x_sync (a no-op here)
181 to match header.
182
183 * w32term.h (FRAME_X_WINDOW): Use FRAME_W32_WINDOW instead of
184 directly accessing frame internals.
185
186 * w32font.h: Include font.h. Define syms_of_w32font and
187 globals_of_w32font.
188
189 * process.c: Include TERM_HEADER instead of listing all possible
190 window-system headers.
191
192 * nsterm.h: Remove declarations now in frame.h. Define
193 FRAME_X_SCREEN, FRAME_X_VISUAL.
194
195 * menu.c: Include TERM_HEADER instead of listing all possible
196 window-system headers.
197
198 * keyboard.h: Declare ignore_mouse_drag_p whenever we have a
199 window system.
200
201 * keyboard.c: Include TERM_HEADER instead of listing all possible
202 window-system headers.
203
204 * image.c: Include TERM_HEADER instead of listing all possible
205 window-system headers. Declare Vlibrary_cache when compiling for
206 Windows.
207
208 * gtkutil.h (xg_list_node_): Include xterm.h to pick up needed
209 window system declarations.
210
211 * frame.h: Move common functions here: set_frame_menubar,
212 x_set_window_size, x_sync, x_get_focus_frame,
213 x_set_mouse_position, x_set_mouse_pixel_position,
214 x_make_frame_visible, x_make_frame_invisible, x_iconify_frame,
215 x_char_width, x_char_height, x_pixel_width, x_pixel_height,
216 x_set_frame_alpha, x_set_menu_bar_lines, x_set_tool_bar_lines,
217 x_activate_menubar, x_real_positions, x_bitmap_icon,
218 x_set_menu_bar_lines, free_frame_menubar, x_free_frame_resources,
219 and x_query_colors.
220
221 * frame.c: Include TERM_HEADER instead of listing all possible
222 window-system headers.
223
224 * font.c: Include TERM_HEADER instead of listing all possible
225 window-system headers.
226
227 * emacs.c: Include TERM_HEADER.
228
229 * dispnew.c: Include TERM_HEADER instead of listing all possible
230 window-system headers.
231
232 * ccl.h: Include character.h.
233
234 * Makefile.in: Define WINDOW_SYSTEM_OBJ to hold objects needed for
235 the current window system; include in list of objects to link into
236 Emacs.
237
2382012-08-31 Dmitry Antipov <dmantipov@yandex.ru>
239
240 Remove mark_ttys function and fix tty_display_info initialization.
241 * lisp.h (mark_ttys): Remove prototype.
242 * alloc.c (Fgarbage_collect): Remove redundant (and the only) call
243 to mark_ttys because all possible values of 'top_frame' slot are
244 the frames which are reachable from Vframe_list.
245 * term.c (mark_ttys): Remove.
246 (init_tty): Safely initialize 'top_frame' slot with Qnil.
247
2482012-08-31 Dmitry Antipov <dmantipov@yandex.ru>
249
250 Change struct frame bitfields from unsigned char to unsigned.
251 * frame.h (struct frame): Change type of 'display_preempted',
252 'visible', 'iconified', 'has_minibuffer', 'wants_modeline',
253 'auto_raise', 'auto_lower', 'no_split', 'explicit_name',
254 'window_sizes_changed', 'mouse_moved' and 'pointer_invisible'
255 bitfields from unsigned char to unsigned.
256
2572012-08-31 Dmitry Antipov <dmantipov@yandex.ru>
258
259 Remove unused member of struct x_output and struct w32_output.
260 * xterm.h (struct x_output): Remove unused field 'needs_exposure'.
261 * w32term.h (struct w32_output): Likewise.
262
2632012-08-30 Jan Djärv <jan.h.d@swipnet.se>
264
265 * gtkutil.c (x_wm_set_size_hint): Use 1 col for base_width so it
266 does not become zero (Bug#12234).
267
2682012-08-30 Paul Eggert <eggert@cs.ucla.edu>
269
270 * dispnew.c (update_frame_1): Pacify gcc -Wstrict-overflow
271 for GCC 4.7.1 x86-64.
272
2732012-08-30 Glenn Morris <rgm@gnu.org>
274
275 * lread.c (init_lread): For out-of-tree builds, only add the
276 source directory's site-lisp dir to the load-path if it exists,
277 consistent with in-tree builds. (Bug#12302)
278
2792012-08-28 Jan Djärv <jan.h.d@swipnet.se>
280
281 * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize
282 button_values to NULL. Call setStykeMask so dialogs get a close button.
283 (windowShouldClose:): Set window_closed.
284 (dealloc): New member, free button_values.
285 (process_dialog:): Make member function. Remove window argument,
286 replace window with self. Count buttons and allocate and store values
287 in button_values.
288 (addButton:value:row:): value is int with the name tag. Call setTag
289 with tag. Remove return self, declare return value as void.
290 (addString:row:): Remove return self, declare return value as void.
291 (addSplit): Remove return self, declare return value as void.
292 (clicked:): Remove return self, declare return value as void.
293 Set dialog_return to button_values[seltag]. Code formatting change.
294 (initFromContents:isQuestion:): Adjust call to process_dialog.
295 Code formatting change.
296 (timeout_handler:): Set timer_fired to YES.
297 (runDialogAt:): Set timer_fired to NO.
298 Handle click on close button as quit.
299
300 * nsterm.h (EmacsDialogPanel): Make timer_fired BOOL.
301 Add window_closed and button_values. Add void as return value for
302 add(Button|String|Split). addButton takes int instead of Lisp_Object.
303 Add process_dialog as new member.
304
3052012-08-28 Eli Zaretskii <eliz@gnu.org>
306
307 * ralloc.c (free_bloc): Don't dereference a 'heap' structure if it
308 is not one of the heaps we manage. (Bug#12242)
309
3102012-08-28 Glenn Morris <rgm@gnu.org>
311
312 * eval.c (Fcalled_interactively_p): Doc fix. (Bug#11747)
313
3142012-08-28 Martin Rudalics <rudalics@gmx.at>
315
316 * window.c (Fset_window_configuration): Remove handling of
317 auto-buffer-name window parameter. Install revision of reverted
318 fix.
319
3202012-08-28 Dmitry Antipov <dmantipov@yandex.ru>
321
322 Do not allow to set major mode for a dead buffer.
323 * buffer.c (Fset_buffer_major_mode): Signal an error
324 if the buffer is dead.
325 (Fother_buffer, other_buffer_safely): Remove redundant
326 nested declaration.
327
3282012-08-28 Dmitry Antipov <dmantipov@yandex.ru>
329
330 Always use set_buffer_if_live to restore original buffer at unwind.
331 * buffer.h (record_unwind_current_buffer): New function.
332 * bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c:
333 * keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c:
334 * undo.c, window.c: Adjust users.
335 * buffer.c (set_buffer_if_live): Fix comment.
336
3372012-08-28 Dmitry Antipov <dmantipov@yandex.ru>
338
339 Fix usage of set_buffer_internal.
340 * buffer.h (set_buffer_internal): Make it BUFFER_INLINE.
341 * buffer.c (set_buffer_if_live): Use set_buffer_internal.
342 * coding.c (decode_coding): Omit redundant test.
343 * fileio.c (decide_coding_unwind): Likewise.
344 * fns.c (secure_hash): Likewise.
345 * insdel.c (modify_region): Likewise.
346 * keyboard.c (command_loop_1): Likewise.
347 * print.c (PRINTFINISH): Likewise.
348 * xdisp.c (run_window_scroll_functions): Use set_buffer_internal.
349
3502012-08-27 Paul Eggert <eggert@cs.ucla.edu>
351
352 * dispnew.c: Use bool for boolean.
353 (frame_garbaged, display_completed, delayed_size_change)
354 (fonts_changed_p, add_window_display_history)
355 (add_frame_display_history, verify_row_hash)
356 (adjust_glyph_matrix, clear_window_matrices, glyph_row_slice_p)
357 (row_equal_p, realloc_glyph_pool)
358 (allocate_matrices_for_frame_redisplay)
359 (showing_window_margins_p)
360 (adjust_frame_glyphs_for_frame_redisplay)
361 (build_frame_matrix_from_leaf_window, make_current)
362 (mirrored_line_dance, mirror_line_dance, update_frame)
363 (update_window_tree, update_single_window)
364 (check_current_matrix_flags, update_window, update_text_area)
365 (update_window_line, set_window_update_flags, scrolling_window)
366 (update_frame_1, scrolling, buffer_posn_from_coords)
367 (do_pending_window_change, change_frame_size)
368 (change_frame_size_1, sit_for):
369 Use bool for boolean.
370 (clear_glyph_matrix_rows): Rename from enable_glyph_matrix_rows,
371 and remove last int (actually boolean) argument, which was always 0.
372 All callers changed.
373 * dispextern.h, frame.h, lisp.h: Reflect above API changes.
374 * dispextern.h (struct composition_it): Use bool for boolean.
375 (struct glyph_matrix): Don't assume buffer sizes can fit in 'int'.
376 (struct bidi_it): Use unsigned:1, not int, for boolean prev_was_pdf.
377 * dired.c (file_name_completion):
378 Use bool for boolean. (This was missed in an earlier change.)
379
3802012-08-27 Martin Rudalics <rudalics@gmx.at>
381
382 * window.c (Fset_window_configuration): Revert first part of
383 last change.
384
3852012-08-27 Jan Djärv <jan.h.d@swipnet.se>
386
387 * nsterm.h (NSPanel): New class variable dialog_return.
388
389 * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize
390 dialog_return.
391 (windowShouldClose:): Use stop instead of stopModalWithCode.
392 (clicked:): Ditto, and also set dialog_return (Bug#12258).
393 (timeout_handler:): Use stop instead of abortModal. Send a dummy
394 event.
395 (runDialogAt:): Make ret Lisp_Object. Set it from dialog_return when
396 modal loop returns.
397
3982012-08-27 Paul Eggert <eggert@cs.ucla.edu>
399
400 * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans.
401 * composite.c (find_composition, composition_gstring_p)
402 (composition_reseat_it, find_automatic_composition):
403 * data.c (let_shadows_buffer_binding_p)
404 (let_shadows_global_binding_p, set_internal, make_blv)
405 (Fmake_variable_buffer_local, Fmake_local_variable)
406 (Fmake_variable_frame_local, arithcompare, cons_to_unsigned)
407 (cons_to_signed, arith_driver):
408 * dbusbind.c (xd_in_read_queued_messages):
409 * dired.c (directory_files_internal, file_name_completion):
410 Use bool for booleans.
411 * dired.c (file_name_completion):
412 * process.h (fd_callback):
413 Omit int (actually boolean) argument. It wasn't being used.
414 All uses changed.
415 * composite.h, lisp.h: Reflect above API changes.
416
417 * cmds.c, coding.c: Use bool for booleans.
418 * cmds.c (move_point, Fself_insert_command):
419 * coding.h (struct composition status, struct coding_system):
420 * coding.c (detect_coding_utf_8, encode_coding_utf_8)
421 (detect_coding_utf_16, encode_coding_utf_16, detect_coding_emacs_mule)
422 (emacs_mule_char, decode_coding_emacs_mule)
423 (encode_coding_emacs_mule, detect_coding_iso_2022)
424 (decode_coding_iso_2022, encode_invocation_designation)
425 (encode_designation_at_bol, encode_coding_iso_2022)
426 (detect_coding_sjis, detect_coding_big5, decode_coding_sjis)
427 (decode_coding_big5, encode_coding_sjis, encode_coding_big5)
428 (detect_coding_ccl, encode_coding_ccl, decode_coding_raw_text)
429 (encode_coding_raw_text, detect_coding_charset)
430 (decode_coding_charset, encode_coding_charset, detect_eol)
431 (detect_coding, get_translation_table, produce_chars)
432 (consume_chars, reused_workbuf_in_use)
433 (make_conversion_work_buffer, code_conversion_save)
434 (decode_coding_object, encode_coding_object)
435 (detect_coding_system, char_encodable_p)
436 (Funencodable_char_position, code_convert_region)
437 (code_convert_string, code_convert_string_norecord)
438 (Fset_coding_system_priority):
439 * fileio.c (Finsert_file_contents):
440 Use bool for booleans.
441 * coding.h, lisp.h: Reflect above API changes.
442 * coding.c: Remove unnecessary static function decls.
443 (detect_coding): Use unsigned, not signed, to copy an unsigned field.
444 (decode_coding, encode_coding, decode_coding_gap): Return 'void',
445 not a boolean 'int', since callers never look at the return value.
446 (ALLOC_CONVERSION_WORK_AREA): Assume caller returns 'void', not 'int'.
447 * coding.h (decoding_buffer_size, encoding_buffer_size)
448 (emacs_mule_string_char): Remove unused extern decls.
449 (struct iso_2022_spec, struct coding_system):
450 Use 'unsigned int : 1' for boolean fields, since there's more than one.
451 (struct emacs_mule_spec): Remove unused field 'full_support'.
452 All initializations removed.
453 * cmds.c (internal_self_insert): Don't assume EMACS_INT fits in 'int'.
454
4552012-08-27 Dmitry Antipov <dmantipov@yandex.ru>
456
457 Fix spare memory change (Bug#12286).
458 * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE.
459 (valid_lisp_object_p): Likewise.
460
4612012-08-27 Martin Rudalics <rudalics@gmx.at>
462
463 * window.c (Fset_window_configuration): Record any window's old
464 buffer if it's replaced (see Bug#8789). If the new current
465 buffer doesn't appear in the selected window, go to its old
466 point (Bug#12208).
467
4682012-08-27 Dmitry Antipov <dmantipov@yandex.ru>
469
470 Special MEM_TYPE_SPARE to denote reserved memory.
471 * alloc.c (enum mem_type): New memory type.
472 (refill_memory_reserve): Use new type for spare memory.
473 This prevents live_cons_p and live_string_p from incorrect
474 detection of uninitialized objects from spare memory as live.
475
4762012-08-26 Paul Eggert <eggert@cs.ucla.edu>
477
478 Spelling fixes.
479 * Makefile.in (.PHONY): versioclean -> versionclean.
480
481 Remove unused external symbols.
482 * data.c (Qcons, Qfloat, Qmisc, Qstring, Qvector):
483 * window.c (Qwindow_valid_p, decode_valid_window):
484 Now static, not extern.
485 * data.c (Qinterval): Remove; unused.
486 (syms_of_data): Do not define 'interval'.
487 * lisp.h (Qinteger, Qstring, Qmisc, Qvector, Qfloat, Qcons):
488 * window.h (decode_valid_window):
489 Remove decls.
490
491 * character.c, charset.c, chartab.c: Use bool for booleans.
492 * character.c (lisp_string_width, string_count_byte8)
493 (string_escape_byte8):
494 * charset.c (charset_map_loaded, load_charset_map, read_hex):
495 (load_charset_map_from_file, map_charset_chars)
496 (Fdefine_charset_internal, define_charset_internal)
497 (Fdeclare_equiv_charset, find_charsets_in_text)
498 (Ffind_charset_region, char_charset, Fiso_charset):
499 * chartab.c (sub_char_table_ref, sub_char_table_ref_and_range)
500 (sub_char_table_set, sub_char_table_set_range)
501 (char_table_set_range, optimize_sub_char_table)
502 (map_sub_char_table):
503 Use bool for boolean.
504 * character.c (str_to_unibyte): Omit last boolean argument; it was
505 always 0. All callers changed.
506 * character.h, charset.h: Adjust to match previous changes.
507 * character.h (char_printable_p): Remove decl of nonexistent function.
508 * charset.h (struct charset): Members code_linear_p, iso_chars_96,
509 ascii_compatible_p, supplementary_p, compact_codes_p, unified_p
510 are all boolean, so make them single-bit bitfields.
511
512 * lisp.h (ASET): Remove attempt to detect side effects.
513 It was meant to be temporary and it often doesn't work,
514 because when IDX has side effects the behavior of IDX==IDX
515 is undefined. See Stefan Monnier in
516 <http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00762.html>.
517
5182012-08-26 Barry OReilly <gundaetiapo@gmail.com> (tiny change)
519
520 * lisp.h (functionp): New function (extracted from Ffunctionp).
521 (FUNCTIONP): Use it.
522 * eval.c (Ffunctionp): Use it.
523
5242012-08-25 Paul Eggert <eggert@cs.ucla.edu>
525
526 * xgselect.c (xg_select): Use auto storage for the GPollFD buffer
527 as that's faster and simpler than static storage. Don't bother
528 with the g_main_context_query overhead if g_main_context_pending
529 says no events are pending.
530 (gfds, gfds_size): Remove these static vars.
531 (xgselect_initialize): Remove; no longer needed.
532 All uses and decls removed.
533
534 * emacs.c (fatal_error_signal_hook): Remove.
535 All uses removed. This leftover from old code was always 0.
536
537 * casefiddle.c, casetab.c, category.c: Use bool for boolean.
538 * casefiddle.c (casify_object, casify_region):
539 * casetab.c (set_case_table):
540 * category.c, category.h (word_boundary_p):
541 * category.h (CHAR_HAS_CATEGORY):
542 Use bool for booleans, instead of int.
543
5442012-08-25 Eli Zaretskii <eliz@gnu.org>
545
546 * makefile.w32-in ($(BLD)/alloc.$(O)): Depend on $(GNU_LIB)/execinfo.h.
547
5482012-08-25 Paul Eggert <eggert@cs.ucla.edu>
549
550 On assertion failure, print backtrace if available.
551 * alloc.c [ENABLE_CHECKING]: Include <execinfo.h>.
552 (die) [ENABLE_CHECKING]: Print a backtrace if available.
553 * Makefile.in (LIB_EXECINFO): New macro.
554 (LIBES): Use it.
555
556 * bytecode.c, callint.c, callproc.c: Use bool for boolean.
557 * bytecode.c (exec_byte_code):
558 * callint.c (check_mark, Fcall_interactively):
559 * callproc.c (Fcall_process, add_env, child_setup, getenv_internal_1)
560 (getenv_internal, sync_process_alive, call_process_exited):
561 * lisp.h (USE_SAFE_ALLOCA):
562 Use bool for booleans, instead of int.
563 * lisp.h, process.h: Adjust prototypes to match above changes.
564 * callint.c (Fcall_interactively): Don't assume the mark's
565 offset fits in 'int'.
566
5672012-08-24 Paul Eggert <eggert@cs.ucla.edu>
568
569 * buffer.c, buffer.h: Use bool for boolean.
570 * buffer.c (reset_buffer_local_variables)
571 (buffer_lisp_local_variables, Fset_buffer_modified_p)
572 (Frestore_buffer_modified_p, Fset_buffer_multibyte):
573 (overlays_at, overlays_in, mouse_face_overlay_overlaps)
574 (overlay_touches_p, overlay_strings, Foverlay_put)
575 (report_overlay_modification, call_overlay_mod_hooks):
576 (mmap_enlarge, mmap_set_vars):
577 * buffer.h (buffer_has_overlays, uppercasep, lowercasep):
578 Use bool for booleans, instead of int.
579 * buffer.c (compact_buffer, mmap_free_1): Return void, not int,
580 since the 1-or-0 return value is always ignored anyway.
581 (mmap_initialized_p):
582 * buffer.h (struct buffer_text.inhibit_shrinking): Now bool, not int.
583 * buffer.h, lisp.h: Adjust prototypes to match above changes.
584
5852012-08-23 Paul Eggert <eggert@cs.ucla.edu>
586
587 * bidi.c: Use bool for boolean.
588 This is a bit more readable, and makes the text segment of bidi.o
589 0.4% smaller on my platform (GCC 4.7.1 x86-64, Fedora 15).
590 Presumably it's faster too.
591 (bidi_initialized, bidi_ignore_explicit_marks_for_paragraph_level):
592 Now bool.
593 (bidi_cache_find_level_change, bidi_cache_iterator_state)
594 (bidi_unshelve_cache, bidi_init_it, bidi_count_bytes)
595 (bidi_char_at_pos, bidi_fetch_char, bidi_paragraph_init)
596 (bidi_explicit_dir_char, bidi_level_of_next_char)
597 (bidi_find_other_level_edge, bidi_move_to_visually_next):
598 Use bool for booleans, instead of int.
599 * dispextern.h (bidi_init_it, bidi_paragraph_init)
600 (bidi_unshelve_cache): Adjust decls to match code.
601
6022012-08-23 Martin Rudalics <rudalics@gmx.at>
603
604 * keyboard.c (Fposn_at_x_y): Do not allow internal window as
605 argument.
606
6072012-08-23 Paul Eggert <eggert@cs.ucla.edu>
608
609 * atimer.c, atimer.h (turn_on_atimers): Use bool for boolean.
610 * atimer.h: Include <stdbool.h>.
611
6122012-08-22 Dan Nicolaescu <dann@gnu.org>
613
614 * frame.h (FRAME_W32_P, FRAME_MSDOS_P, FRAME_NS_P): Change to
615 compile time tests instead of run time tests on systems that do
616 not use them.
617 (FRAME_MAC_P): Remove leftover from deleted code.
618 * frame.c (syms_of_frame): Remove leftover from deleted code.
619
6202012-08-22 Jan Djärv <jan.h.d@swipnet.se>
621
622 * nsterm.m (insertText:): Don't clear modifiers if code is space.
623
6242012-08-22 Paul Eggert <eggert@cs.ucla.edu>
625
626 * fontset.c (FONTSET_ADD): Return void, not Lisp_Object.
627 Otherwise, the compiler complains about (A?B:C) where B is void
628 and C is Lisp_Object. This fixes an incompatibility with Sun C 5.12.
629 (fontset_add): Return void, for FONTSET_ADD.
630
6312012-08-21 Paul Eggert <eggert@cs.ucla.edu>
632
633 * alloc.c: Use bool for booleans.
634 (gc_in_progress, abort_on_gc)
635 (setjmp_tested_p) [!GC_SAVE_REGISTERS_ON_STACK && !GC_SETJMP_WORKS]:
636 (dont_register_blocks) [GC_MALLOC_CHECK]:
637 (suppress_checking) [ENABLE_CHECKING]: Now bool, not int.
638 (check_string_bytes, make_specified_string, memory_full)
639 (live_string_p, live_cons_p, live_symbol_p, live_float_p)
640 (live_misc_p, live_vector_p, live_buffer_p, mark_maybe_object)
641 (mark_stack, valid_pointer_p, make_pure_string)
642 (Fgarbage_collect, survives_gc_p, gc_sweep):
643 Use bool for booleans, instead of int.
644 (test_setjmp) [!GC_SAVE_REGISTERS_ON_STACK && !GC_SETJMP_WORKS]:
645 Remove unused local.
646 * alloc.c (PURE_POINTER_P):
647 * lisp.h (STRING_MULTIBYTE): Document that it returns a boolean.
648 * editfns.c (Fformat):
649 * fileio.c (Fexpand_file_name, Fsubstitute_in_file_name)
650 (Fdo_auto_save):
651 * fns.c (sweep_weak_table):
652 * lisp.h (suppress_checking, push_message, survives_gc_p)
653 (make_pure_string, gc_in_progress, abort_on_gc):
654 * lread.c (readchar, read1):
655 * print.c (Fprin1_to_string):
656 * xdisp.c (push_message):
657 Use bool for booleans affected directly or indirectly by
658 alloc.c's changes.
659
660 Make recently-introduced setters macros.
661 * fontset.c (set_fontset_id, set_fontset_name, set_fontset_ascii)
662 (set_fontset_base, set_fontset_frame, set_fontset_nofont_face)
663 (set_fontset_default, set_fontset_fallback): Rename from their
664 upper-case counterparts, and make them functions rather than macros.
665 This is more consistent with the other recently-introduced setters.
666 These don't need to be inline, since they're local.
667
6682012-08-21 Jan Djärv <jan.h.d@swipnet.se>
669
670 * nsterm.m (fd_handler:): Alloc and release a NSAutoreleasePool in
671 the loop (Bug#12247).
672
6732012-08-21 Paul Eggert <eggert@cs.ucla.edu>
674
675 * lisp.h (vcopy): Use memcpy rather than our own loop.
676 This fixes a performance regression introduced by the recent
677 addition of vcopy. This means 'vcopy' will need to be modified
678 for a copying collector, but that's OK. Also, tighten the
679 checking in the assertion.
680
6812012-08-21 Eli Zaretskii <eliz@gnu.org>
682
683 * w32uniscribe.c (uniscribe_shape): Fix producing gstring
684 components for RTL text (Bug#11860). Adjust X-OFFSET of each
685 non-base glyph for the width of the base character, according to
686 what x_draw_composite_glyph_string_foreground expects.
687 Generate WADJUST value according to composition_gstring_width's
688 expectations, to produce correct width of the composed character.
689 Reverse the sign of the DU offset produced by ScriptPlace.
690
6912012-08-21 Paul Eggert <eggert@cs.ucla.edu>
692
693 * dbusbind.c (xd_remove_watch): Do not assume C99 comments.
694
6952012-08-21 Dmitry Antipov <dmantipov@yandex.ru>
696
697 Avoid direct writes to contents member of struct Lisp_Vector.
698 * lisp.h (vcopy): New function to copy data into vector.
699 * dispnew.c (Fframe_or_buffer_changed_p): Use AREF and ASET.
700 * fns.c (Ffillarray): Use ASET.
701 * keyboard.c (timer_check_2): Use AREF and ASET.
702 (append_tool_bar_item, Frecent_keys): Use vcopy.
703 * lread.c (read_vector): Use ASET.
704 * msdos.c (Frecent_doskeys): Use vcopy.
705 * xface.c (Finternal_copy_lisp_face): Use vcopy.
706 (Finternal_merge_in_global_face): Use ASET and vcopy.
707 * xfont.c (xfont_list_pattern): Likewise.
708
7092012-08-21 Martin Rudalics <rudalics@gmx.at>
710
711 * window.c (Fwindow_point): For the selected window always return
712 the position of its buffer's point.
713 (Fset_window_point): For the selected window always go in its
714 buffer to the specified position.
715
7162012-08-21 Dmitry Antipov <dmantipov@yandex.ru>
717
718 Setter macros for fontsets.
719 * fontset.c (SET_FONTSET_ID, SET_FONTSET_NAME, SET_FONTSET_ASCII)
720 (SET_FONTSET_BASE, SET_FONTSET_FRAME, SET_FONTSET_NOFONT_FACE)
721 (SET_FONTSET_DEFAULT, SET_FONTSET_FALLBACK): New macros.
722 Adjust users.
723
7242012-08-20 Glenn Morris <rgm@gnu.org>
725
726 * Makefile.in (emacs$(EXEEXT), bootstrap-emacs$(EXEEXT)):
727 Don't assume that `ln -f' works.
728
7292012-08-20 Eli Zaretskii <eliz@gnu.org>
730
731 * .gdbinit: Use "set $dummy = ..." to avoid warnings from GDB 7.5
732 and later about non-assignments with no effect. See discussion at
733 http://sourceware.org/ml/gdb-patches/2012-08/msg00518.html for
734 details.
735
12012-08-20 Dmitry Antipov <dmantipov@yandex.ru> 7362012-08-20 Dmitry Antipov <dmantipov@yandex.ru>
2 737
3 Inline setter functions for Lisp_Objects slots of struct specbinding. 738 Inline setter functions for Lisp_Objects slots of struct specbinding.
@@ -42,6 +777,8 @@
42 Rely on <config.h> + <unistd.h> to declare 'environ', 777 Rely on <config.h> + <unistd.h> to declare 'environ',
43 as gnulib does this if the system doesn't. 778 as gnulib does this if the system doesn't.
44 * callproc.c, editfns.c, process.c (environ) [!USE_CRT_DLL]: 779 * callproc.c, editfns.c, process.c (environ) [!USE_CRT_DLL]:
780 Remove declaration. MS-Windows declares it on stdlib.h which is
781 included by conf_post.h.
45 * emacs.c (environ) [DOUG_LEA_MALLOC]: 782 * emacs.c (environ) [DOUG_LEA_MALLOC]:
46 * vm-limit.c (environ) [ORDINARY_LINK]: Remove decl. 783 * vm-limit.c (environ) [ORDINARY_LINK]: Remove decl.
47 * vm-limit.c: Include <unistd.h>, for 'environ'. 784 * vm-limit.c: Include <unistd.h>, for 'environ'.
diff --git a/src/Makefile.in b/src/Makefile.in
index 01034ca98d5..24c8b94b590 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -159,6 +159,8 @@ DBUS_LIBS = @DBUS_LIBS@
159## dbusbind.o if HAVE_DBUS, else empty. 159## dbusbind.o if HAVE_DBUS, else empty.
160DBUS_OBJ = @DBUS_OBJ@ 160DBUS_OBJ = @DBUS_OBJ@
161 161
162LIB_EXECINFO=@LIB_EXECINFO@
163
162SETTINGS_CFLAGS = @SETTINGS_CFLAGS@ 164SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
163SETTINGS_LIBS = @SETTINGS_LIBS@ 165SETTINGS_LIBS = @SETTINGS_LIBS@
164 166
@@ -209,8 +211,8 @@ LIBXMENU=@LIBXMENU@
209 211
210## xmenu.o if HAVE_X_WINDOWS, else empty. 212## xmenu.o if HAVE_X_WINDOWS, else empty.
211XMENU_OBJ=@XMENU_OBJ@ 213XMENU_OBJ=@XMENU_OBJ@
212## xterm.o xfns.o xselect.o xrdb.o fontset.o xsmfns.o fringe.o image.o 214## xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o xgselect.o if
213## xsettings.o xgselect.o if HAVE_X_WINDOWS, else empty. 215## HAVE_X_WINDOWS, else empty.
214XOBJ=@XOBJ@ 216XOBJ=@XOBJ@
215 217
216TOOLKIT_LIBW=@TOOLKIT_LIBW@ 218TOOLKIT_LIBW=@TOOLKIT_LIBW@
@@ -245,6 +247,9 @@ WIDGET_OBJ=@WIDGET_OBJ@
245## sheap.o if CYGWIN, otherwise empty. 247## sheap.o if CYGWIN, otherwise empty.
246CYGWIN_OBJ=@CYGWIN_OBJ@ 248CYGWIN_OBJ=@CYGWIN_OBJ@
247 249
250## fontset.o fringe.o image.o if we have any window system
251WINDOW_SYSTEM_OBJ=@WINDOW_SYSTEM_OBJ@
252
248## dosfns.o msdos.o w16select.o if MSDOS. 253## dosfns.o msdos.o w16select.o if MSDOS.
249MSDOS_OBJ = 254MSDOS_OBJ =
250## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS. 255## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS.
@@ -253,7 +258,6 @@ MSDOS_X_OBJ =
253ns_appdir=@ns_appdir@ 258ns_appdir=@ns_appdir@
254ns_appbindir=@ns_appbindir@ 259ns_appbindir=@ns_appbindir@
255ns_appsrc=@ns_appsrc@ 260ns_appsrc=@ns_appsrc@
256## fontset.o fringe.o image.o if HAVE_NS, else empty.
257NS_OBJ=@NS_OBJ@ 261NS_OBJ=@NS_OBJ@
258## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS. 262## nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o if HAVE_NS.
259NS_OBJC_OBJ=@NS_OBJC_OBJ@ 263NS_OBJC_OBJ=@NS_OBJC_OBJ@
@@ -338,7 +342,8 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
338 process.o gnutls.o callproc.o \ 342 process.o gnutls.o callproc.o \
339 region-cache.o sound.o atimer.o thread.o systhread.o \ 343 region-cache.o sound.o atimer.o thread.o systhread.o \
340 doprnt.o intervals.o textprop.o composite.o xml.o \ 344 doprnt.o intervals.o textprop.o composite.o xml.o \
341 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) 345 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
346 $(WINDOW_SYSTEM_OBJ)
342obj = $(base_obj) $(NS_OBJC_OBJ) 347obj = $(base_obj) $(NS_OBJC_OBJ)
343 348
344## Object files used on some machine or other. 349## Object files used on some machine or other.
@@ -383,6 +388,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
383## with GCC, we might need LIB_GCC again after them. 388## with GCC, we might need LIB_GCC again after them.
384LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ 389LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
385 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \ 390 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \
391 $(LIB_EXECINFO) \
386 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 392 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
387 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 393 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
388 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 394 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
@@ -402,11 +408,13 @@ $(leimdir)/leim-list.el: bootstrap-emacs$(EXEEXT)
402## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here. 408## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here.
403emacs$(EXEEXT): temacs$(EXEEXT) $(etc)/DOC $(lisp) $(leimdir)/leim-list.el 409emacs$(EXEEXT): temacs$(EXEEXT) $(etc)/DOC $(lisp) $(leimdir)/leim-list.el
404 if test "$(CANNOT_DUMP)" = "yes"; then \ 410 if test "$(CANNOT_DUMP)" = "yes"; then \
405 ln -f temacs$(EXEEXT) emacs$(EXEEXT); \ 411 rm -f emacs$(EXEEXT); \
412 ln temacs$(EXEEXT) emacs$(EXEEXT); \
406 else \ 413 else \
407 LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump || exit 1; \ 414 LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump || exit 1; \
408 test "X$(PAXCTL)" = X || $(PAXCTL) -zex emacs$(EXEEXT); \ 415 test "X$(PAXCTL)" = X || $(PAXCTL) -zex emacs$(EXEEXT); \
409 ln -f emacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \ 416 rm -f bootstrap-emacs$(EXEEXT); \
417 ln emacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \
410 fi 418 fi
411 419
412## We run make-docfile twice because the command line may get too long 420## We run make-docfile twice because the command line may get too long
@@ -440,7 +448,7 @@ GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m)
440 448
441gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES) 449gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
442 @rm -f gl-tmp 450 @rm -f gl-tmp
443 $(libsrc)/make-docfile -d $(srcdir) -g $(SOME_MACHINE_OBJECTS) $(obj) > gl-tmp 451 $(libsrc)/make-docfile -d $(srcdir) -g $(obj) > gl-tmp
444 $(srcdir)/../build-aux/move-if-change gl-tmp globals.h 452 $(srcdir)/../build-aux/move-if-change gl-tmp globals.h
445 echo timestamp > $@ 453 echo timestamp > $@
446 454
@@ -497,7 +505,7 @@ doc.o: buildobj.h
497@ns_frag@ 505@ns_frag@
498 506
499.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean 507.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
500.PHONY: versioclean extraclean frc 508.PHONY: versionclean extraclean frc
501 509
502mostlyclean: 510mostlyclean:
503 rm -f temacs$(EXEEXT) core *.core \#* *.o libXMenu11.a liblw.a 511 rm -f temacs$(EXEEXT) core *.core \#* *.o libXMenu11.a liblw.a
@@ -600,7 +608,8 @@ $(lispsource)/loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS)
600bootstrap-emacs$(EXEEXT): temacs$(EXEEXT) 608bootstrap-emacs$(EXEEXT): temacs$(EXEEXT)
601 cd ../lisp; $(MAKE) $(MFLAGS) update-subdirs 609 cd ../lisp; $(MAKE) $(MFLAGS) update-subdirs
602 if test "$(CANNOT_DUMP)" = "yes"; then \ 610 if test "$(CANNOT_DUMP)" = "yes"; then \
603 ln -f temacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \ 611 rm -f bootstrap-emacs$(EXEEXT); \
612 ln temacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \
604 else \ 613 else \
605 $(RUN_TEMACS) --batch --load loadup bootstrap || exit 1; \ 614 $(RUN_TEMACS) --batch --load loadup bootstrap || exit 1; \
606 test "X$(PAXCTL)" = X || $(PAXCTL) -zex emacs$(EXEEXT); \ 615 test "X$(PAXCTL)" = X || $(PAXCTL) -zex emacs$(EXEEXT); \
diff --git a/src/alloc.c b/src/alloc.c
index a8830684580..859961781e0 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -69,6 +69,9 @@ extern void *sbrk ();
69 69
70#include <fcntl.h> 70#include <fcntl.h>
71 71
72#ifdef USE_GTK
73# include "gtkutil.h"
74#endif
72#ifdef WINDOWSNT 75#ifdef WINDOWSNT
73#include "w32.h" 76#include "w32.h"
74#endif 77#endif
@@ -173,15 +176,15 @@ EMACS_INT gc_relative_threshold;
173 176
174EMACS_INT memory_full_cons_threshold; 177EMACS_INT memory_full_cons_threshold;
175 178
176/* Nonzero during GC. */ 179/* True during GC. */
177 180
178int gc_in_progress; 181bool gc_in_progress;
179 182
180/* Nonzero means abort if try to GC. 183/* True means abort if try to GC.
181 This is for code which is written on the assumption that 184 This is for code which is written on the assumption that
182 no GC will happen, so as to verify that assumption. */ 185 no GC will happen, so as to verify that assumption. */
183 186
184int abort_on_gc; 187bool abort_on_gc;
185 188
186/* Number of live and free conses etc. */ 189/* Number of live and free conses etc. */
187 190
@@ -223,7 +226,7 @@ static ptrdiff_t pure_size;
223 226
224static ptrdiff_t pure_bytes_used_before_overflow; 227static ptrdiff_t pure_bytes_used_before_overflow;
225 228
226/* Value is non-zero if P points into pure space. */ 229/* True if P points into pure space. */
227 230
228#define PURE_POINTER_P(P) \ 231#define PURE_POINTER_P(P) \
229 ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size) 232 ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size)
@@ -305,7 +308,9 @@ enum mem_type
305 and runtime slowdown. Minor but pointless. */ 308 and runtime slowdown. Minor but pointless. */
306 MEM_TYPE_VECTORLIKE, 309 MEM_TYPE_VECTORLIKE,
307 /* Special type to denote vector blocks. */ 310 /* Special type to denote vector blocks. */
308 MEM_TYPE_VECTOR_BLOCK 311 MEM_TYPE_VECTOR_BLOCK,
312 /* Special type to denote reserved memory. */
313 MEM_TYPE_SPARE
309}; 314};
310 315
311static void *lisp_malloc (size_t, enum mem_type); 316static void *lisp_malloc (size_t, enum mem_type);
@@ -387,13 +392,13 @@ static struct mem_node mem_z;
387 392
388static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t); 393static struct Lisp_Vector *allocate_vectorlike (ptrdiff_t);
389static void lisp_free (void *); 394static void lisp_free (void *);
390static int live_vector_p (struct mem_node *, void *); 395static bool live_vector_p (struct mem_node *, void *);
391static int live_buffer_p (struct mem_node *, void *); 396static bool live_buffer_p (struct mem_node *, void *);
392static int live_string_p (struct mem_node *, void *); 397static bool live_string_p (struct mem_node *, void *);
393static int live_cons_p (struct mem_node *, void *); 398static bool live_cons_p (struct mem_node *, void *);
394static int live_symbol_p (struct mem_node *, void *); 399static bool live_symbol_p (struct mem_node *, void *);
395static int live_float_p (struct mem_node *, void *); 400static bool live_float_p (struct mem_node *, void *);
396static int live_misc_p (struct mem_node *, void *); 401static bool live_misc_p (struct mem_node *, void *);
397static void mark_maybe_object (Lisp_Object); 402static void mark_maybe_object (Lisp_Object);
398static void mark_memory (void *, void *); 403static void mark_memory (void *, void *);
399#if GC_MARK_STACK || defined GC_MALLOC_CHECK 404#if GC_MARK_STACK || defined GC_MALLOC_CHECK
@@ -1232,7 +1237,7 @@ static void (*old_free_hook) (void*, const void*);
1232#endif 1237#endif
1233 1238
1234#ifdef GC_MALLOC_CHECK 1239#ifdef GC_MALLOC_CHECK
1235static int dont_register_blocks; 1240static bool dont_register_blocks;
1236#endif 1241#endif
1237 1242
1238static size_t bytes_used_when_reconsidered; 1243static size_t bytes_used_when_reconsidered;
@@ -1819,11 +1824,11 @@ check_sblock (struct sblock *b)
1819 1824
1820 1825
1821/* Check validity of Lisp strings' string_bytes member. ALL_P 1826/* Check validity of Lisp strings' string_bytes member. ALL_P
1822 non-zero means check all strings, otherwise check only most 1827 means check all strings, otherwise check only most
1823 recently allocated strings. Used for hunting a bug. */ 1828 recently allocated strings. Used for hunting a bug. */
1824 1829
1825static void 1830static void
1826check_string_bytes (int all_p) 1831check_string_bytes (bool all_p)
1827{ 1832{
1828 if (all_p) 1833 if (all_p)
1829 { 1834 {
@@ -2428,9 +2433,9 @@ make_string_from_bytes (const char *contents,
2428 2433
2429Lisp_Object 2434Lisp_Object
2430make_specified_string (const char *contents, 2435make_specified_string (const char *contents,
2431 ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) 2436 ptrdiff_t nchars, ptrdiff_t nbytes, bool multibyte)
2432{ 2437{
2433 register Lisp_Object val; 2438 Lisp_Object val;
2434 2439
2435 if (nchars < 0) 2440 if (nchars < 0)
2436 { 2441 {
@@ -3085,7 +3090,7 @@ sweep_vectors (void)
3085 3090
3086 for (block = vector_blocks; block; block = *bprev) 3091 for (block = vector_blocks; block; block = *bprev)
3087 { 3092 {
3088 int free_this_block = 0; 3093 bool free_this_block = 0;
3089 3094
3090 for (vector = (struct Lisp_Vector *) block->data; 3095 for (vector = (struct Lisp_Vector *) block->data;
3091 VECTOR_IN_BLOCK (vector, block); vector = next) 3096 VECTOR_IN_BLOCK (vector, block); vector = next)
@@ -3751,7 +3756,7 @@ void
3751memory_full (size_t nbytes) 3756memory_full (size_t nbytes)
3752{ 3757{
3753 /* Do not go into hysterics merely because a large request failed. */ 3758 /* Do not go into hysterics merely because a large request failed. */
3754 int enough_free_memory = 0; 3759 bool enough_free_memory = 0;
3755 if (SPARE_MEMORY < nbytes) 3760 if (SPARE_MEMORY < nbytes)
3756 { 3761 {
3757 void *p; 3762 void *p;
@@ -3814,22 +3819,22 @@ refill_memory_reserve (void)
3814 spare_memory[0] = malloc (SPARE_MEMORY); 3819 spare_memory[0] = malloc (SPARE_MEMORY);
3815 if (spare_memory[1] == 0) 3820 if (spare_memory[1] == 0)
3816 spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block), 3821 spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block),
3817 MEM_TYPE_CONS); 3822 MEM_TYPE_SPARE);
3818 if (spare_memory[2] == 0) 3823 if (spare_memory[2] == 0)
3819 spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block), 3824 spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block),
3820 MEM_TYPE_CONS); 3825 MEM_TYPE_SPARE);
3821 if (spare_memory[3] == 0) 3826 if (spare_memory[3] == 0)
3822 spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block), 3827 spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block),
3823 MEM_TYPE_CONS); 3828 MEM_TYPE_SPARE);
3824 if (spare_memory[4] == 0) 3829 if (spare_memory[4] == 0)
3825 spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block), 3830 spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block),
3826 MEM_TYPE_CONS); 3831 MEM_TYPE_SPARE);
3827 if (spare_memory[5] == 0) 3832 if (spare_memory[5] == 0)
3828 spare_memory[5] = lisp_malloc (sizeof (struct string_block), 3833 spare_memory[5] = lisp_malloc (sizeof (struct string_block),
3829 MEM_TYPE_STRING); 3834 MEM_TYPE_SPARE);
3830 if (spare_memory[6] == 0) 3835 if (spare_memory[6] == 0)
3831 spare_memory[6] = lisp_malloc (sizeof (struct string_block), 3836 spare_memory[6] = lisp_malloc (sizeof (struct string_block),
3832 MEM_TYPE_STRING); 3837 MEM_TYPE_SPARE);
3833 if (spare_memory[0] && spare_memory[1] && spare_memory[5]) 3838 if (spare_memory[0] && spare_memory[1] && spare_memory[5])
3834 Vmemory_full = Qnil; 3839 Vmemory_full = Qnil;
3835#endif 3840#endif
@@ -4244,7 +4249,7 @@ mem_delete_fixup (struct mem_node *x)
4244/* Value is non-zero if P is a pointer to a live Lisp string on 4249/* Value is non-zero if P is a pointer to a live Lisp string on
4245 the heap. M is a pointer to the mem_block for P. */ 4250 the heap. M is a pointer to the mem_block for P. */
4246 4251
4247static inline int 4252static inline bool
4248live_string_p (struct mem_node *m, void *p) 4253live_string_p (struct mem_node *m, void *p)
4249{ 4254{
4250 if (m->type == MEM_TYPE_STRING) 4255 if (m->type == MEM_TYPE_STRING)
@@ -4267,7 +4272,7 @@ live_string_p (struct mem_node *m, void *p)
4267/* Value is non-zero if P is a pointer to a live Lisp cons on 4272/* Value is non-zero if P is a pointer to a live Lisp cons on
4268 the heap. M is a pointer to the mem_block for P. */ 4273 the heap. M is a pointer to the mem_block for P. */
4269 4274
4270static inline int 4275static inline bool
4271live_cons_p (struct mem_node *m, void *p) 4276live_cons_p (struct mem_node *m, void *p)
4272{ 4277{
4273 if (m->type == MEM_TYPE_CONS) 4278 if (m->type == MEM_TYPE_CONS)
@@ -4293,7 +4298,7 @@ live_cons_p (struct mem_node *m, void *p)
4293/* Value is non-zero if P is a pointer to a live Lisp symbol on 4298/* Value is non-zero if P is a pointer to a live Lisp symbol on
4294 the heap. M is a pointer to the mem_block for P. */ 4299 the heap. M is a pointer to the mem_block for P. */
4295 4300
4296static inline int 4301static inline bool
4297live_symbol_p (struct mem_node *m, void *p) 4302live_symbol_p (struct mem_node *m, void *p)
4298{ 4303{
4299 if (m->type == MEM_TYPE_SYMBOL) 4304 if (m->type == MEM_TYPE_SYMBOL)
@@ -4319,7 +4324,7 @@ live_symbol_p (struct mem_node *m, void *p)
4319/* Value is non-zero if P is a pointer to a live Lisp float on 4324/* Value is non-zero if P is a pointer to a live Lisp float on
4320 the heap. M is a pointer to the mem_block for P. */ 4325 the heap. M is a pointer to the mem_block for P. */
4321 4326
4322static inline int 4327static inline bool
4323live_float_p (struct mem_node *m, void *p) 4328live_float_p (struct mem_node *m, void *p)
4324{ 4329{
4325 if (m->type == MEM_TYPE_FLOAT) 4330 if (m->type == MEM_TYPE_FLOAT)
@@ -4343,7 +4348,7 @@ live_float_p (struct mem_node *m, void *p)
4343/* Value is non-zero if P is a pointer to a live Lisp Misc on 4348/* Value is non-zero if P is a pointer to a live Lisp Misc on
4344 the heap. M is a pointer to the mem_block for P. */ 4349 the heap. M is a pointer to the mem_block for P. */
4345 4350
4346static inline int 4351static inline bool
4347live_misc_p (struct mem_node *m, void *p) 4352live_misc_p (struct mem_node *m, void *p)
4348{ 4353{
4349 if (m->type == MEM_TYPE_MISC) 4354 if (m->type == MEM_TYPE_MISC)
@@ -4369,7 +4374,7 @@ live_misc_p (struct mem_node *m, void *p)
4369/* Value is non-zero if P is a pointer to a live vector-like object. 4374/* Value is non-zero if P is a pointer to a live vector-like object.
4370 M is a pointer to the mem_block for P. */ 4375 M is a pointer to the mem_block for P. */
4371 4376
4372static inline int 4377static inline bool
4373live_vector_p (struct mem_node *m, void *p) 4378live_vector_p (struct mem_node *m, void *p)
4374{ 4379{
4375 if (m->type == MEM_TYPE_VECTOR_BLOCK) 4380 if (m->type == MEM_TYPE_VECTOR_BLOCK)
@@ -4405,7 +4410,7 @@ live_vector_p (struct mem_node *m, void *p)
4405/* Value is non-zero if P is a pointer to a live buffer. M is a 4410/* Value is non-zero if P is a pointer to a live buffer. M is a
4406 pointer to the mem_block for P. */ 4411 pointer to the mem_block for P. */
4407 4412
4408static inline int 4413static inline bool
4409live_buffer_p (struct mem_node *m, void *p) 4414live_buffer_p (struct mem_node *m, void *p)
4410{ 4415{
4411 /* P must point to the start of the block, and the buffer 4416 /* P must point to the start of the block, and the buffer
@@ -4485,7 +4490,7 @@ mark_maybe_object (Lisp_Object obj)
4485 4490
4486 if (m != MEM_NIL) 4491 if (m != MEM_NIL)
4487 { 4492 {
4488 int mark_p = 0; 4493 bool mark_p = 0;
4489 4494
4490 switch (XTYPE (obj)) 4495 switch (XTYPE (obj))
4491 { 4496 {
@@ -4559,6 +4564,7 @@ mark_maybe_pointer (void *p)
4559 switch (m->type) 4564 switch (m->type)
4560 { 4565 {
4561 case MEM_TYPE_NON_LISP: 4566 case MEM_TYPE_NON_LISP:
4567 case MEM_TYPE_SPARE:
4562 /* Nothing to do; not a pointer to Lisp memory. */ 4568 /* Nothing to do; not a pointer to Lisp memory. */
4563 break; 4569 break;
4564 4570
@@ -4705,7 +4711,8 @@ mark_memory (void *start, void *end)
4705 4711
4706#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS 4712#if !defined GC_SAVE_REGISTERS_ON_STACK && !defined GC_SETJMP_WORKS
4707 4713
4708static int setjmp_tested_p, longjmps_done; 4714static bool setjmp_tested_p;
4715static int longjmps_done;
4709 4716
4710#define SETJMP_WILL_LIKELY_WORK "\ 4717#define SETJMP_WILL_LIKELY_WORK "\
4711\n\ 4718\n\
@@ -4749,14 +4756,13 @@ test_setjmp (void)
4749 char buf[10]; 4756 char buf[10];
4750 register int x; 4757 register int x;
4751 jmp_buf jbuf; 4758 jmp_buf jbuf;
4752 int result = 0;
4753 4759
4754 /* Arrange for X to be put in a register. */ 4760 /* Arrange for X to be put in a register. */
4755 sprintf (buf, "1"); 4761 sprintf (buf, "1");
4756 x = strlen (buf); 4762 x = strlen (buf);
4757 x = 2 * x - 1; 4763 x = 2 * x - 1;
4758 4764
4759 setjmp (jbuf); 4765 _setjmp (jbuf);
4760 if (longjmps_done == 1) 4766 if (longjmps_done == 1)
4761 { 4767 {
4762 /* Came here after the longjmp at the end of the function. 4768 /* Came here after the longjmp at the end of the function.
@@ -4781,7 +4787,7 @@ test_setjmp (void)
4781 ++longjmps_done; 4787 ++longjmps_done;
4782 x = 2; 4788 x = 2;
4783 if (longjmps_done == 1) 4789 if (longjmps_done == 1)
4784 longjmp (jbuf, 1); 4790 _longjmp (jbuf, 1);
4785} 4791}
4786 4792
4787#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ 4793#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */
@@ -4908,7 +4914,7 @@ flush_stack_call_func (void (*func) (void *arg), void *arg)
4908 Lisp_Object o; 4914 Lisp_Object o;
4909 jmp_buf j; 4915 jmp_buf j;
4910 } j; 4916 } j;
4911 volatile int stack_grows_down_p = (char *) &j > (char *) stack_bottom; 4917 volatile bool stack_grows_down_p = (char *) &j > (char *) stack_bottom;
4912#endif 4918#endif
4913 /* This trick flushes the register windows so that all the state of 4919 /* This trick flushes the register windows so that all the state of
4914 the process is contained in the stack. */ 4920 the process is contained in the stack. */
@@ -4942,7 +4948,7 @@ flush_stack_call_func (void (*func) (void *arg), void *arg)
4942 } 4948 }
4943#endif /* GC_SETJMP_WORKS */ 4949#endif /* GC_SETJMP_WORKS */
4944 4950
4945 setjmp (j.j); 4951 _setjmp (j.j);
4946 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; 4952 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j;
4947#endif /* not GC_SAVE_REGISTERS_ON_STACK */ 4953#endif /* not GC_SAVE_REGISTERS_ON_STACK */
4948#endif /* not HAVE___BUILTIN_UNWIND_INIT */ 4954#endif /* not HAVE___BUILTIN_UNWIND_INIT */
@@ -4970,7 +4976,7 @@ valid_pointer_p (void *p)
4970 4976
4971 if (pipe (fd) == 0) 4977 if (pipe (fd) == 0)
4972 { 4978 {
4973 int valid = (emacs_write (fd[1], (char *) p, 16) == 16); 4979 bool valid = emacs_write (fd[1], (char *) p, 16) == 16;
4974 emacs_close (fd[1]); 4980 emacs_close (fd[1]);
4975 emacs_close (fd[0]); 4981 emacs_close (fd[0]);
4976 return valid; 4982 return valid;
@@ -5022,6 +5028,7 @@ valid_lisp_object_p (Lisp_Object obj)
5022 switch (m->type) 5028 switch (m->type)
5023 { 5029 {
5024 case MEM_TYPE_NON_LISP: 5030 case MEM_TYPE_NON_LISP:
5031 case MEM_TYPE_SPARE:
5025 return 0; 5032 return 0;
5026 5033
5027 case MEM_TYPE_BUFFER: 5034 case MEM_TYPE_BUFFER:
@@ -5191,7 +5198,7 @@ find_string_data_in_pure (const char *data, ptrdiff_t nbytes)
5191 5198
5192/* Return a string allocated in pure space. DATA is a buffer holding 5199/* Return a string allocated in pure space. DATA is a buffer holding
5193 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE 5200 NCHARS characters, and NBYTES bytes of string data. MULTIBYTE
5194 non-zero means make the result string multibyte. 5201 means make the result string multibyte.
5195 5202
5196 Must get an error if pure storage is full, since if it cannot hold 5203 Must get an error if pure storage is full, since if it cannot hold
5197 a large string it may be able to hold conses that point to that 5204 a large string it may be able to hold conses that point to that
@@ -5199,7 +5206,7 @@ find_string_data_in_pure (const char *data, ptrdiff_t nbytes)
5199 5206
5200Lisp_Object 5207Lisp_Object
5201make_pure_string (const char *data, 5208make_pure_string (const char *data,
5202 ptrdiff_t nchars, ptrdiff_t nbytes, int multibyte) 5209 ptrdiff_t nchars, ptrdiff_t nbytes, bool multibyte)
5203{ 5210{
5204 Lisp_Object string; 5211 Lisp_Object string;
5205 struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String); 5212 struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
@@ -5394,11 +5401,11 @@ returns nil, because real GC can't be done.
5394See Info node `(elisp)Garbage Collection'. */) 5401See Info node `(elisp)Garbage Collection'. */)
5395 (void) 5402 (void)
5396{ 5403{
5397 register struct specbinding *bind; 5404 struct specbinding *bind;
5398 register struct buffer *nextb; 5405 struct buffer *nextb;
5399 char stack_top_variable; 5406 char stack_top_variable;
5400 ptrdiff_t i; 5407 ptrdiff_t i;
5401 int message_p; 5408 bool message_p;
5402 ptrdiff_t count = SPECPDL_INDEX (); 5409 ptrdiff_t count = SPECPDL_INDEX ();
5403 EMACS_TIME start; 5410 EMACS_TIME start;
5404 Lisp_Object retval = Qnil; 5411 Lisp_Object retval = Qnil;
@@ -5473,13 +5480,9 @@ See Info node `(elisp)Garbage Collection'. */)
5473 mark_threads (); 5480 mark_threads ();
5474 mark_terminals (); 5481 mark_terminals ();
5475 mark_kboards (); 5482 mark_kboards ();
5476 mark_ttys ();
5477 5483
5478#ifdef USE_GTK 5484#ifdef USE_GTK
5479 { 5485 xg_mark_data ();
5480 extern void xg_mark_data (void);
5481 xg_mark_data ();
5482 }
5483#endif 5486#endif
5484 5487
5485#ifdef HAVE_WINDOW_SYSTEM 5488#ifdef HAVE_WINDOW_SYSTEM
@@ -6181,10 +6184,10 @@ mark_terminals (void)
6181/* Value is non-zero if OBJ will survive the current GC because it's 6184/* Value is non-zero if OBJ will survive the current GC because it's
6182 either marked or does not need to be marked to survive. */ 6185 either marked or does not need to be marked to survive. */
6183 6186
6184int 6187bool
6185survives_gc_p (Lisp_Object obj) 6188survives_gc_p (Lisp_Object obj)
6186{ 6189{
6187 int survives_p; 6190 bool survives_p;
6188 6191
6189 switch (XTYPE (obj)) 6192 switch (XTYPE (obj))
6190 { 6193 {
@@ -6429,7 +6432,7 @@ gc_sweep (void)
6429 /* Check if the symbol was created during loadup. In such a case 6432 /* Check if the symbol was created during loadup. In such a case
6430 it might be pointed to by pure bytecode which we don't trace, 6433 it might be pointed to by pure bytecode which we don't trace,
6431 so we conservatively assume that it is live. */ 6434 so we conservatively assume that it is live. */
6432 int pure_p = PURE_POINTER_P (XSTRING (sym->s.name)); 6435 bool pure_p = PURE_POINTER_P (XSTRING (sym->s.name));
6433 6436
6434 if (!sym->s.gcmarkbit && !pure_p) 6437 if (!sym->s.gcmarkbit && !pure_p)
6435 { 6438 {
@@ -6654,13 +6657,21 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6654} 6657}
6655 6658
6656#ifdef ENABLE_CHECKING 6659#ifdef ENABLE_CHECKING
6657int suppress_checking; 6660
6661# include <execinfo.h>
6662
6663bool suppress_checking;
6658 6664
6659void 6665void
6660die (const char *msg, const char *file, int line) 6666die (const char *msg, const char *file, int line)
6661{ 6667{
6668 enum { NPOINTERS_MAX = 500 };
6669 void *buffer[NPOINTERS_MAX];
6670 int npointers;
6662 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", 6671 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
6663 file, line, msg); 6672 file, line, msg);
6673 npointers = backtrace (buffer, NPOINTERS_MAX);
6674 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
6664 abort (); 6675 abort ();
6665} 6676}
6666#endif 6677#endif
diff --git a/src/atimer.c b/src/atimer.c
index d67e1375f9a..eb3136ae55d 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -408,7 +408,7 @@ do_pending_atimers (void)
408 some systems like HPUX (see process.c). */ 408 some systems like HPUX (see process.c). */
409 409
410void 410void
411turn_on_atimers (int on) 411turn_on_atimers (bool on)
412{ 412{
413 if (on) 413 if (on)
414 { 414 {
diff --git a/src/atimer.h b/src/atimer.h
index 4282bab49ba..6d441d71641 100644
--- a/src/atimer.h
+++ b/src/atimer.h
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#define EMACS_ATIMER_H 20#define EMACS_ATIMER_H
21 21
22#include "systime.h" /* for EMACS_TIME */ 22#include "systime.h" /* for EMACS_TIME */
23#include <stdbool.h>
23 24
24/* Forward declaration. */ 25/* Forward declaration. */
25 26
@@ -74,7 +75,7 @@ struct atimer *start_atimer (enum atimer_type, EMACS_TIME,
74void cancel_atimer (struct atimer *); 75void cancel_atimer (struct atimer *);
75void do_pending_atimers (void); 76void do_pending_atimers (void);
76void init_atimer (void); 77void init_atimer (void);
77void turn_on_atimers (int); 78void turn_on_atimers (bool);
78void stop_other_atimers (struct atimer *); 79void stop_other_atimers (struct atimer *);
79Lisp_Object unwind_stop_other_atimers (Lisp_Object); 80Lisp_Object unwind_stop_other_atimers (Lisp_Object);
80 81
diff --git a/src/bidi.c b/src/bidi.c
index 4df585d4f48..6b3ac53d318 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -63,7 +63,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#include "buffer.h" 63#include "buffer.h"
64#include "dispextern.h" 64#include "dispextern.h"
65 65
66static int bidi_initialized = 0; 66static bool bidi_initialized = 0;
67 67
68static Lisp_Object bidi_type_table, bidi_mirror_table; 68static Lisp_Object bidi_type_table, bidi_mirror_table;
69 69
@@ -82,10 +82,10 @@ typedef enum {
82/* UAX#9 says to search only for L, AL, or R types of characters, and 82/* UAX#9 says to search only for L, AL, or R types of characters, and
83 ignore RLE, RLO, LRE, and LRO, when determining the base paragraph 83 ignore RLE, RLO, LRE, and LRO, when determining the base paragraph
84 level. Yudit indeed ignores them. This variable is therefore set 84 level. Yudit indeed ignores them. This variable is therefore set
85 by default to ignore them, but setting it to zero will take them 85 by default to ignore them, but clearing it will take them into
86 into account. */ 86 account. */
87extern int bidi_ignore_explicit_marks_for_paragraph_level EXTERNALLY_VISIBLE; 87extern bool bidi_ignore_explicit_marks_for_paragraph_level EXTERNALLY_VISIBLE;
88int bidi_ignore_explicit_marks_for_paragraph_level = 1; 88bool bidi_ignore_explicit_marks_for_paragraph_level = 1;
89 89
90static Lisp_Object paragraph_start_re, paragraph_separate_re; 90static Lisp_Object paragraph_start_re, paragraph_separate_re;
91static Lisp_Object Qparagraph_start, Qparagraph_separate; 91static Lisp_Object Qparagraph_start, Qparagraph_separate;
@@ -438,7 +438,7 @@ bidi_cache_search (ptrdiff_t charpos, int level, int dir)
438 that is lower than LEVEL, and return its cache slot index. DIR is 438 that is lower than LEVEL, and return its cache slot index. DIR is
439 the direction to search, starting with the last used cache slot. 439 the direction to search, starting with the last used cache slot.
440 If DIR is zero, we search backwards from the last occupied cache 440 If DIR is zero, we search backwards from the last occupied cache
441 slot. BEFORE, if non-zero, means return the index of the slot that 441 slot. BEFORE means return the index of the slot that
442 is ``before'' the level change in the search direction. That is, 442 is ``before'' the level change in the search direction. That is,
443 given the cached levels like this: 443 given the cached levels like this:
444 444
@@ -448,9 +448,9 @@ bidi_cache_search (ptrdiff_t charpos, int level, int dir)
448 and assuming we are at the position cached at the slot marked with 448 and assuming we are at the position cached at the slot marked with
449 C, searching backwards (DIR = -1) for LEVEL = 2 will return the 449 C, searching backwards (DIR = -1) for LEVEL = 2 will return the
450 index of slot B or A, depending whether BEFORE is, respectively, 450 index of slot B or A, depending whether BEFORE is, respectively,
451 non-zero or zero. */ 451 true or false. */
452static ptrdiff_t 452static ptrdiff_t
453bidi_cache_find_level_change (int level, int dir, int before) 453bidi_cache_find_level_change (int level, int dir, bool before)
454{ 454{
455 if (bidi_cache_idx) 455 if (bidi_cache_idx)
456 { 456 {
@@ -512,7 +512,7 @@ bidi_cache_ensure_space (ptrdiff_t idx)
512} 512}
513 513
514static inline void 514static inline void
515bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved) 515bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
516{ 516{
517 ptrdiff_t idx; 517 ptrdiff_t idx;
518 518
@@ -690,11 +690,11 @@ bidi_shelve_cache (void)
690 690
691/* Restore the cache state from a copy stashed away by 691/* Restore the cache state from a copy stashed away by
692 bidi_shelve_cache, and free the buffer used to stash that copy. 692 bidi_shelve_cache, and free the buffer used to stash that copy.
693 JUST_FREE non-zero means free the buffer, but don't restore the 693 JUST_FREE means free the buffer, but don't restore the
694 cache; used when the corresponding iterator is discarded instead of 694 cache; used when the corresponding iterator is discarded instead of
695 being restored. */ 695 being restored. */
696void 696void
697bidi_unshelve_cache (void *databuf, int just_free) 697bidi_unshelve_cache (void *databuf, bool just_free)
698{ 698{
699 unsigned char *p = databuf; 699 unsigned char *p = databuf;
700 700
@@ -802,7 +802,7 @@ bidi_set_paragraph_end (struct bidi_it *bidi_it)
802 802
803/* Initialize the bidi iterator from buffer/string position CHARPOS. */ 803/* Initialize the bidi iterator from buffer/string position CHARPOS. */
804void 804void
805bidi_init_it (ptrdiff_t charpos, ptrdiff_t bytepos, int frame_window_p, 805bidi_init_it (ptrdiff_t charpos, ptrdiff_t bytepos, bool frame_window_p,
806 struct bidi_it *bidi_it) 806 struct bidi_it *bidi_it)
807{ 807{
808 if (! bidi_initialized) 808 if (! bidi_initialized)
@@ -872,11 +872,10 @@ bidi_line_init (struct bidi_it *bidi_it)
872 872
873/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END 873/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END
874 are zero-based character positions in S, BEGBYTE is byte position 874 are zero-based character positions in S, BEGBYTE is byte position
875 corresponding to BEG. UNIBYTE, if non-zero, means S is a unibyte 875 corresponding to BEG. UNIBYTE means S is a unibyte string. */
876 string. */
877static inline ptrdiff_t 876static inline ptrdiff_t
878bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg, 877bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
879 const ptrdiff_t begbyte, const ptrdiff_t end, int unibyte) 878 const ptrdiff_t begbyte, const ptrdiff_t end, bool unibyte)
880{ 879{
881 ptrdiff_t pos = beg; 880 ptrdiff_t pos = beg;
882 const unsigned char *p = s + begbyte, *start = p; 881 const unsigned char *p = s + begbyte, *start = p;
@@ -900,10 +899,10 @@ bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
900 899
901/* Fetch and returns the character at byte position BYTEPOS. If S is 900/* Fetch and returns the character at byte position BYTEPOS. If S is
902 non-NULL, fetch the character from string S; otherwise fetch the 901 non-NULL, fetch the character from string S; otherwise fetch the
903 character from the current buffer. UNIBYTE non-zero means S is a 902 character from the current buffer. UNIBYTE means S is a
904 unibyte string. */ 903 unibyte string. */
905static inline int 904static inline int
906bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, int unibyte) 905bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte)
907{ 906{
908 if (s) 907 if (s)
909 { 908 {
@@ -923,9 +922,9 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, int unibyte)
923 specifies the character position of the next display string, or -1 922 specifies the character position of the next display string, or -1
924 if not yet computed. When the next character is at or beyond that 923 if not yet computed. When the next character is at or beyond that
925 position, the function updates DISP_POS with the position of the 924 position, the function updates DISP_POS with the position of the
926 next display string. DISP_PROP non-zero means that there's really 925 next display string. *DISP_PROP non-zero means that there's really
927 a display string at DISP_POS, as opposed to when we searched till 926 a display string at DISP_POS, as opposed to when we searched till
928 DISP_POS without finding one. If DISP_PROP is 2, it means the 927 DISP_POS without finding one. If *DISP_PROP is 2, it means the
929 display spec is of the form `(space ...)', which is replaced with 928 display spec is of the form `(space ...)', which is replaced with
930 u+2029 to handle it as a paragraph separator. STRING->s is the C 929 u+2029 to handle it as a paragraph separator. STRING->s is the C
931 string to iterate, or NULL if iterating over a buffer or a Lisp 930 string to iterate, or NULL if iterating over a buffer or a Lisp
@@ -933,7 +932,7 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, int unibyte)
933static inline int 932static inline int
934bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos, 933bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos,
935 int *disp_prop, struct bidi_string_data *string, 934 int *disp_prop, struct bidi_string_data *string,
936 int frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars) 935 bool frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars)
937{ 936{
938 int ch; 937 int ch;
939 ptrdiff_t endpos 938 ptrdiff_t endpos
@@ -1134,7 +1133,7 @@ bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte)
1134 R2L, just use that. Otherwise, determine the paragraph direction 1133 R2L, just use that. Otherwise, determine the paragraph direction
1135 from the first strong directional character of the paragraph. 1134 from the first strong directional character of the paragraph.
1136 1135
1137 NO_DEFAULT_P non-zero means don't default to L2R if the paragraph 1136 NO_DEFAULT_P means don't default to L2R if the paragraph
1138 has no strong directional characters and both DIR and 1137 has no strong directional characters and both DIR and
1139 bidi_it->paragraph_dir are NEUTRAL_DIR. In that case, search back 1138 bidi_it->paragraph_dir are NEUTRAL_DIR. In that case, search back
1140 in the buffer until a paragraph is found with a strong character, 1139 in the buffer until a paragraph is found with a strong character,
@@ -1145,10 +1144,10 @@ bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte)
1145 direction as the preceding paragraph, even though Emacs generally 1144 direction as the preceding paragraph, even though Emacs generally
1146 views the separator as not belonging to any paragraph. */ 1145 views the separator as not belonging to any paragraph. */
1147void 1146void
1148bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p) 1147bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p)
1149{ 1148{
1150 ptrdiff_t bytepos = bidi_it->bytepos; 1149 ptrdiff_t bytepos = bidi_it->bytepos;
1151 int string_p = bidi_it->string.s != NULL || STRINGP (bidi_it->string.lstring); 1150 bool string_p = bidi_it->string.s || STRINGP (bidi_it->string.lstring);
1152 ptrdiff_t pstartbyte; 1151 ptrdiff_t pstartbyte;
1153 /* Note that begbyte is a byte position, while end is a character 1152 /* Note that begbyte is a byte position, while end is a character
1154 position. Yes, this is ugly, but we are trying to avoid costly 1153 position. Yes, this is ugly, but we are trying to avoid costly
@@ -1221,8 +1220,8 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1221 bidi_it->separator_limit = -1; 1220 bidi_it->separator_limit = -1;
1222 bidi_it->new_paragraph = 0; 1221 bidi_it->new_paragraph = 0;
1223 1222
1224 /* The following loop is run more than once only if NO_DEFAULT_P 1223 /* The following loop is run more than once only if NO_DEFAULT_P,
1225 is non-zero, and only if we are iterating on a buffer. */ 1224 and only if we are iterating on a buffer. */
1226 do { 1225 do {
1227 ptrdiff_t pos1; 1226 ptrdiff_t pos1;
1228 1227
@@ -1320,7 +1319,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, int no_default_p)
1320 The rest of this file constitutes the core of the UBA implementation. 1319 The rest of this file constitutes the core of the UBA implementation.
1321 ***********************************************************************/ 1320 ***********************************************************************/
1322 1321
1323static inline int 1322static inline bool
1324bidi_explicit_dir_char (int ch) 1323bidi_explicit_dir_char (int ch)
1325{ 1324{
1326 bidi_type_t ch_type; 1325 bidi_type_t ch_type;
@@ -1345,7 +1344,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
1345 int current_level; 1344 int current_level;
1346 int new_level; 1345 int new_level;
1347 bidi_dir_t override; 1346 bidi_dir_t override;
1348 int string_p = bidi_it->string.s != NULL || STRINGP (bidi_it->string.lstring); 1347 bool string_p = bidi_it->string.s || STRINGP (bidi_it->string.lstring);
1349 1348
1350 /* If reseat()'ed, don't advance, so as to start iteration from the 1349 /* If reseat()'ed, don't advance, so as to start iteration from the
1351 position where we were reseated. bidi_it->bytepos can be less 1350 position where we were reseated. bidi_it->bytepos can be less
@@ -2189,7 +2188,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2189 ptrdiff_t nc = bidi_it->nchars; 2188 ptrdiff_t nc = bidi_it->nchars;
2190 struct bidi_string_data bs = bidi_it->string; 2189 struct bidi_string_data bs = bidi_it->string;
2191 bidi_type_t chtype; 2190 bidi_type_t chtype;
2192 int fwp = bidi_it->frame_window_p; 2191 bool fwp = bidi_it->frame_window_p;
2193 int dpp = bidi_it->disp_prop; 2192 int dpp = bidi_it->disp_prop;
2194 2193
2195 if (bidi_it->nchars <= 0) 2194 if (bidi_it->nchars <= 0)
@@ -2268,8 +2267,8 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2268 return level; 2267 return level;
2269} 2268}
2270 2269
2271/* Move to the other edge of a level given by LEVEL. If END_FLAG is 2270/* Move to the other edge of a level given by LEVEL. If END_FLAG,
2272 non-zero, we are at the end of a level, and we need to prepare to 2271 we are at the end of a level, and we need to prepare to
2273 resume the scan of the lower level. 2272 resume the scan of the lower level.
2274 2273
2275 If this level's other edge is cached, we simply jump to it, filling 2274 If this level's other edge is cached, we simply jump to it, filling
@@ -2289,7 +2288,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
2289 function moves to point C, whereas the UAX#9 ``level 2 run'' ends 2288 function moves to point C, whereas the UAX#9 ``level 2 run'' ends
2290 at point B. */ 2289 at point B. */
2291static void 2290static void
2292bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, int end_flag) 2291bidi_find_other_level_edge (struct bidi_it *bidi_it, int level, bool end_flag)
2293{ 2292{
2294 int dir = end_flag ? -bidi_it->scan_dir : bidi_it->scan_dir; 2293 int dir = end_flag ? -bidi_it->scan_dir : bidi_it->scan_dir;
2295 ptrdiff_t idx; 2294 ptrdiff_t idx;
@@ -2363,7 +2362,7 @@ bidi_move_to_visually_next (struct bidi_it *bidi_it)
2363 scanning the text whenever we find a level change. */ 2362 scanning the text whenever we find a level change. */
2364 if (new_level != old_level) 2363 if (new_level != old_level)
2365 { 2364 {
2366 int ascending = new_level > old_level; 2365 bool ascending = new_level > old_level;
2367 int level_to_search = ascending ? old_level + 1 : old_level; 2366 int level_to_search = ascending ? old_level + 1 : old_level;
2368 int incr = ascending ? 1 : -1; 2367 int incr = ascending ? 1 : -1;
2369 int expected_next_level = old_level + incr; 2368 int expected_next_level = old_level + incr;
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);
diff --git a/src/buffer.h b/src/buffer.h
index de7ca7eb2e7..e603486418b 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -471,7 +471,7 @@ struct buffer_text
471 /* Usually 0. Temporarily set to 1 in decode_coding_gap to 471 /* Usually 0. Temporarily set to 1 in decode_coding_gap to
472 prevent Fgarbage_collect from shrinking the gap and losing 472 prevent Fgarbage_collect from shrinking the gap and losing
473 not-yet-decoded bytes. */ 473 not-yet-decoded bytes. */
474 int inhibit_shrinking; 474 bool inhibit_shrinking;
475 }; 475 };
476 476
477/* Most code should use this macro to access Lisp fields in struct buffer. */ 477/* Most code should use this macro to access Lisp fields in struct buffer. */
@@ -1002,23 +1002,46 @@ extern struct buffer buffer_local_symbols;
1002 1002
1003extern void delete_all_overlays (struct buffer *); 1003extern void delete_all_overlays (struct buffer *);
1004extern void reset_buffer (struct buffer *); 1004extern void reset_buffer (struct buffer *);
1005extern int compact_buffer (struct buffer *); 1005extern void compact_buffer (struct buffer *);
1006extern void evaporate_overlays (ptrdiff_t); 1006extern void evaporate_overlays (ptrdiff_t);
1007extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, 1007extern ptrdiff_t overlays_at (EMACS_INT, bool, Lisp_Object **,
1008 ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, 1008 ptrdiff_t *, ptrdiff_t *, ptrdiff_t *, bool);
1009 ptrdiff_t *prev_ptr, int change_req);
1010extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *); 1009extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *);
1011extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); 1010extern void recenter_overlay_lists (struct buffer *, ptrdiff_t);
1012extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); 1011extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **);
1013extern void validate_region (Lisp_Object *, Lisp_Object *); 1012extern void validate_region (Lisp_Object *, Lisp_Object *);
1014extern void set_buffer_internal (struct buffer *);
1015extern void set_buffer_internal_1 (struct buffer *); 1013extern void set_buffer_internal_1 (struct buffer *);
1016extern void set_buffer_temp (struct buffer *); 1014extern void set_buffer_temp (struct buffer *);
1017extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); 1015extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object);
1018extern void record_buffer (Lisp_Object); 1016extern void record_buffer (Lisp_Object);
1019extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int); 1017extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int);
1020extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); 1018extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t);
1021extern void mmap_set_vars (int); 1019extern void mmap_set_vars (bool);
1020
1021/* Set the current buffer to B.
1022
1023 We previously set windows_or_buffers_changed here to invalidate
1024 global unchanged information in beg_unchanged and end_unchanged.
1025 This is no longer necessary because we now compute unchanged
1026 information on a buffer-basis. Every action affecting other
1027 windows than the selected one requires a select_window at some
1028 time, and that increments windows_or_buffers_changed. */
1029
1030BUFFER_INLINE void
1031set_buffer_internal (struct buffer *b)
1032{
1033 if (current_buffer != b)
1034 set_buffer_internal_1 (b);
1035}
1036
1037/* Arrange to go back to the original buffer after the next
1038 call to unbind_to if the original buffer is still alive. */
1039
1040BUFFER_INLINE void
1041record_unwind_current_buffer (void)
1042{
1043 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
1044}
1022 1045
1023/* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. 1046/* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements.
1024 If NEXTP is non-NULL, return next overlay there. 1047 If NEXTP is non-NULL, return next overlay there.
@@ -1063,7 +1086,7 @@ set_buffer_intervals (struct buffer *b, INTERVAL i)
1063 1086
1064/* Non-zero if current buffer has overlays. */ 1087/* Non-zero if current buffer has overlays. */
1065 1088
1066BUFFER_INLINE int 1089BUFFER_INLINE bool
1067buffer_has_overlays (void) 1090buffer_has_overlays (void)
1068{ 1091{
1069 return current_buffer->overlays_before || current_buffer->overlays_after; 1092 return current_buffer->overlays_before || current_buffer->overlays_after;
@@ -1239,7 +1262,7 @@ downcase (int c)
1239} 1262}
1240 1263
1241/* 1 if C is upper case. */ 1264/* 1 if C is upper case. */
1242BUFFER_INLINE int uppercasep (int c) { return downcase (c) != c; } 1265BUFFER_INLINE bool uppercasep (int c) { return downcase (c) != c; }
1243 1266
1244/* Upcase a character C known to be not upper case. */ 1267/* Upcase a character C known to be not upper case. */
1245BUFFER_INLINE int 1268BUFFER_INLINE int
@@ -1251,8 +1274,11 @@ upcase1 (int c)
1251} 1274}
1252 1275
1253/* 1 if C is lower case. */ 1276/* 1 if C is lower case. */
1254BUFFER_INLINE int lowercasep (int c) 1277BUFFER_INLINE bool
1255{ return !uppercasep (c) && upcase1 (c) != c; } 1278lowercasep (int c)
1279{
1280 return !uppercasep (c) && upcase1 (c) != c;
1281}
1256 1282
1257/* Upcase a character C, or make no change if that cannot be done. */ 1283/* Upcase a character C, or make no change if that cannot be done. */
1258BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } 1284BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
diff --git a/src/bytecode.c b/src/bytecode.c
index d61e37d7886..be5b7ea6137 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -550,7 +550,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
550 if (INTEGERP (args_template)) 550 if (INTEGERP (args_template))
551 { 551 {
552 ptrdiff_t at = XINT (args_template); 552 ptrdiff_t at = XINT (args_template);
553 int rest = at & 128; 553 bool rest = (at & 128) != 0;
554 int mandatory = at & 127; 554 int mandatory = at & 127;
555 ptrdiff_t nonrest = at >> 8; 555 ptrdiff_t nonrest = at >> 8;
556 eassert (mandatory <= nonrest); 556 eassert (mandatory <= nonrest);
@@ -1048,7 +1048,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1048 1048
1049 CASE (Bsave_current_buffer): /* Obsolete since ??. */ 1049 CASE (Bsave_current_buffer): /* Obsolete since ??. */
1050 CASE (Bsave_current_buffer_1): 1050 CASE (Bsave_current_buffer_1):
1051 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 1051 record_unwind_current_buffer ();
1052 NEXT; 1052 NEXT;
1053 1053
1054 CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ 1054 CASE (Bsave_window_excursion): /* Obsolete since 24.1. */
diff --git a/src/callint.c b/src/callint.c
index 36a59e812f2..b11545ddea2 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -150,7 +150,7 @@ static const char *callint_argfuns[]
150 = {"", "point", "mark", "region-beginning", "region-end"}; 150 = {"", "point", "mark", "region-beginning", "region-end"};
151 151
152static void 152static void
153check_mark (int for_region) 153check_mark (bool for_region)
154{ 154{
155 Lisp_Object tem; 155 Lisp_Object tem;
156 tem = Fmarker_buffer (BVAR (current_buffer, mark)); 156 tem = Fmarker_buffer (BVAR (current_buffer, mark));
@@ -273,11 +273,11 @@ invoke it. If KEYS is omitted or nil, the return value of
273 signed char *varies; 273 signed char *varies;
274 274
275 ptrdiff_t i, nargs; 275 ptrdiff_t i, nargs;
276 int foo; 276 ptrdiff_t mark;
277 int arg_from_tty = 0; 277 bool arg_from_tty = 0;
278 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 278 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
279 ptrdiff_t key_count; 279 ptrdiff_t key_count;
280 int record_then_fail = 0; 280 bool record_then_fail = 0;
281 281
282 Lisp_Object save_this_command, save_last_command; 282 Lisp_Object save_this_command, save_last_command;
283 Lisp_Object save_this_original_command, save_real_this_command; 283 Lisp_Object save_this_original_command, save_real_this_command;
@@ -685,7 +685,7 @@ invoke it. If KEYS is omitted or nil, the return value of
685 goto have_prefix_arg; 685 goto have_prefix_arg;
686 case 'n': /* Read number from minibuffer. */ 686 case 'n': /* Read number from minibuffer. */
687 { 687 {
688 int first = 1; 688 bool first = 1;
689 do 689 do
690 { 690 {
691 Lisp_Object str; 691 Lisp_Object str;
@@ -726,11 +726,11 @@ invoke it. If KEYS is omitted or nil, the return value of
726 check_mark (1); 726 check_mark (1);
727 set_marker_both (point_marker, Qnil, PT, PT_BYTE); 727 set_marker_both (point_marker, Qnil, PT, PT_BYTE);
728 /* visargs[i+1] = Qnil; */ 728 /* visargs[i+1] = Qnil; */
729 foo = marker_position (BVAR (current_buffer, mark)); 729 mark = marker_position (BVAR (current_buffer, mark));
730 /* visargs[i] = Qnil; */ 730 /* visargs[i] = Qnil; */
731 args[i] = PT < foo ? point_marker : BVAR (current_buffer, mark); 731 args[i] = PT < mark ? point_marker : BVAR (current_buffer, mark);
732 varies[i] = 3; 732 varies[i] = 3;
733 args[++i] = PT > foo ? point_marker : BVAR (current_buffer, mark); 733 args[++i] = PT > mark ? point_marker : BVAR (current_buffer, mark);
734 varies[i] = 4; 734 varies[i] = 4;
735 break; 735 break;
736 736
diff --git a/src/callproc.c b/src/callproc.c
index 4bf1da04e1a..2e9a8950700 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -77,7 +77,7 @@ static Lisp_Object Vtemp_file_name_pattern;
77 77
78/* True if we are about to fork off a synchronous process or if we 78/* True if we are about to fork off a synchronous process or if we
79 are waiting for it. */ 79 are waiting for it. */
80int synch_process_alive; 80bool synch_process_alive;
81 81
82/* Nonzero => this is a string explaining death of synchronous subprocess. */ 82/* Nonzero => this is a string explaining death of synchronous subprocess. */
83const char *synch_process_death; 83const char *synch_process_death;
@@ -94,8 +94,8 @@ int synch_process_retcode;
94 On MSDOS, delete the temporary file on any kind of termination. 94 On MSDOS, delete the temporary file on any kind of termination.
95 On Unix, kill the process and any children on termination by signal. */ 95 On Unix, kill the process and any children on termination by signal. */
96 96
97/* Nonzero if this is termination due to exit. */ 97/* True if this is termination due to exit. */
98static int call_process_exited; 98static bool call_process_exited;
99 99
100static Lisp_Object 100static Lisp_Object
101call_process_kill (Lisp_Object fdpid) 101call_process_kill (Lisp_Object fdpid)
@@ -190,7 +190,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
190 (ptrdiff_t nargs, Lisp_Object *args) 190 (ptrdiff_t nargs, Lisp_Object *args)
191{ 191{
192 Lisp_Object infile, buffer, current_dir, path, cleanup_info_tail; 192 Lisp_Object infile, buffer, current_dir, path, cleanup_info_tail;
193 int display_p; 193 bool display_p;
194 int fd[2]; 194 int fd[2];
195 int filefd; 195 int filefd;
196#define CALLPROC_BUFFER_SIZE_MIN (16 * 1024) 196#define CALLPROC_BUFFER_SIZE_MIN (16 * 1024)
@@ -217,7 +217,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
217 struct coding_system argument_coding; /* coding-system of arguments */ 217 struct coding_system argument_coding; /* coding-system of arguments */
218 /* Set to the return value of Ffind_operation_coding_system. */ 218 /* Set to the return value of Ffind_operation_coding_system. */
219 Lisp_Object coding_systems; 219 Lisp_Object coding_systems;
220 int output_to_buffer = 1; 220 bool output_to_buffer = 1;
221 221
222 /* Qt denotes that Ffind_operation_coding_system is not yet called. */ 222 /* Qt denotes that Ffind_operation_coding_system is not yet called. */
223 coding_systems = Qt; 223 coding_systems = Qt;
@@ -241,7 +241,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
241 /* If arguments are supplied, we may have to encode them. */ 241 /* If arguments are supplied, we may have to encode them. */
242 if (nargs >= 5) 242 if (nargs >= 5)
243 { 243 {
244 int must_encode = 0; 244 bool must_encode = 0;
245 Lisp_Object coding_attrs; 245 Lisp_Object coding_attrs;
246 246
247 for (i = 4; i < nargs; i++) 247 for (i = 4; i < nargs; i++)
@@ -610,12 +610,12 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
610 Lisp_Object volatile buffer_volatile = buffer; 610 Lisp_Object volatile buffer_volatile = buffer;
611 Lisp_Object volatile coding_systems_volatile = coding_systems; 611 Lisp_Object volatile coding_systems_volatile = coding_systems;
612 Lisp_Object volatile current_dir_volatile = current_dir; 612 Lisp_Object volatile current_dir_volatile = current_dir;
613 int volatile display_p_volatile = display_p; 613 bool volatile display_p_volatile = display_p;
614 bool volatile output_to_buffer_volatile = output_to_buffer;
615 bool volatile sa_must_free_volatile = sa_must_free;
614 int volatile fd1_volatile = fd1; 616 int volatile fd1_volatile = fd1;
615 int volatile fd_error_volatile = fd_error; 617 int volatile fd_error_volatile = fd_error;
616 int volatile fd_output_volatile = fd_output; 618 int volatile fd_output_volatile = fd_output;
617 int volatile output_to_buffer_volatile = output_to_buffer;
618 int volatile sa_must_free_volatile = sa_must_free;
619 ptrdiff_t volatile sa_count_volatile = sa_count; 619 ptrdiff_t volatile sa_count_volatile = sa_count;
620 unsigned char const **volatile new_argv_volatile = new_argv; 620 unsigned char const **volatile new_argv_volatile = new_argv;
621 621
@@ -766,11 +766,11 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
766 766
767 if (output_to_buffer) 767 if (output_to_buffer)
768 { 768 {
769 register int nread; 769 int nread;
770 int first = 1; 770 bool first = 1;
771 EMACS_INT total_read = 0; 771 EMACS_INT total_read = 0;
772 int carryover = 0; 772 int carryover = 0;
773 int display_on_the_fly = display_p; 773 bool display_on_the_fly = display_p;
774 struct coding_system saved_coding; 774 struct coding_system saved_coding;
775 775
776 saved_coding = process_coding; 776 saved_coding = process_coding;
@@ -1086,7 +1086,7 @@ static char **
1086add_env (char **env, char **new_env, char *string) 1086add_env (char **env, char **new_env, char *string)
1087{ 1087{
1088 char **ep; 1088 char **ep;
1089 int ok = 1; 1089 bool ok = 1;
1090 if (string == NULL) 1090 if (string == NULL)
1091 return new_env; 1091 return new_env;
1092 1092
@@ -1126,8 +1126,7 @@ add_env (char **env, char **new_env, char *string)
1126 Therefore, the superior process must save and restore the value 1126 Therefore, the superior process must save and restore the value
1127 of environ around the vfork and the call to this function. 1127 of environ around the vfork and the call to this function.
1128 1128
1129 SET_PGRP is nonzero if we should put the subprocess into a separate 1129 If SET_PGRP, put the subprocess into a separate process group.
1130 process group.
1131 1130
1132 CURRENT_DIR is an elisp string giving the path of the current 1131 CURRENT_DIR is an elisp string giving the path of the current
1133 directory the subprocess should have. Since we can't really signal 1132 directory the subprocess should have. Since we can't really signal
@@ -1135,7 +1134,8 @@ add_env (char **env, char **new_env, char *string)
1135 executable directory by the parent. */ 1134 executable directory by the parent. */
1136 1135
1137int 1136int
1138child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, Lisp_Object current_dir) 1137child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1138 Lisp_Object current_dir)
1139{ 1139{
1140 char **env; 1140 char **env;
1141 char *pwd_var; 1141 char *pwd_var;
@@ -1394,7 +1394,7 @@ relocate_fd (int fd, int minfd)
1394} 1394}
1395#endif /* not WINDOWSNT */ 1395#endif /* not WINDOWSNT */
1396 1396
1397static int 1397static bool
1398getenv_internal_1 (const char *var, ptrdiff_t varlen, char **value, 1398getenv_internal_1 (const char *var, ptrdiff_t varlen, char **value,
1399 ptrdiff_t *valuelen, Lisp_Object env) 1399 ptrdiff_t *valuelen, Lisp_Object env)
1400{ 1400{
@@ -1429,7 +1429,7 @@ getenv_internal_1 (const char *var, ptrdiff_t varlen, char **value,
1429 return 0; 1429 return 0;
1430} 1430}
1431 1431
1432static int 1432static bool
1433getenv_internal (const char *var, ptrdiff_t varlen, char **value, 1433getenv_internal (const char *var, ptrdiff_t varlen, char **value,
1434 ptrdiff_t *valuelen, Lisp_Object frame) 1434 ptrdiff_t *valuelen, Lisp_Object frame)
1435{ 1435{
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 81e84252b72..1102054b153 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -35,8 +35,8 @@ Lisp_Object Qidentity;
35static Lisp_Object 35static Lisp_Object
36casify_object (enum case_action flag, Lisp_Object obj) 36casify_object (enum case_action flag, Lisp_Object obj)
37{ 37{
38 register int c, c1; 38 int c, c1;
39 register int inword = flag == CASE_DOWN; 39 bool inword = flag == CASE_DOWN;
40 40
41 /* If the case table is flagged as modified, rescan it. */ 41 /* If the case table is flagged as modified, rescan it. */
42 if (NILP (XCHAR_TABLE (BVAR (current_buffer, downcase_table))->extras[1])) 42 if (NILP (XCHAR_TABLE (BVAR (current_buffer, downcase_table))->extras[1]))
@@ -47,7 +47,8 @@ casify_object (enum case_action flag, Lisp_Object obj)
47 int flagbits = (CHAR_ALT | CHAR_SUPER | CHAR_HYPER 47 int flagbits = (CHAR_ALT | CHAR_SUPER | CHAR_HYPER
48 | CHAR_SHIFT | CHAR_CTL | CHAR_META); 48 | CHAR_SHIFT | CHAR_CTL | CHAR_META);
49 int flags = XINT (obj) & flagbits; 49 int flags = XINT (obj) & flagbits;
50 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 50 bool multibyte = ! NILP (BVAR (current_buffer,
51 enable_multibyte_characters));
51 52
52 /* If the character has higher bits set 53 /* If the character has higher bits set
53 above the flags, return it unchanged. 54 above the flags, return it unchanged.
@@ -189,9 +190,9 @@ The argument object is not altered--the value is a copy. */)
189static void 190static void
190casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) 191casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e)
191{ 192{
192 register int c; 193 int c;
193 register int inword = flag == CASE_DOWN; 194 bool inword = flag == CASE_DOWN;
194 register int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 195 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
195 ptrdiff_t start, end; 196 ptrdiff_t start, end;
196 ptrdiff_t start_byte; 197 ptrdiff_t start_byte;
197 198
diff --git a/src/casetab.c b/src/casetab.c
index a163d5204f8..3e22d0d0b77 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -79,7 +79,7 @@ This is the one used for new buffers. */)
79 return Vascii_downcase_table; 79 return Vascii_downcase_table;
80} 80}
81 81
82static Lisp_Object set_case_table (Lisp_Object table, int standard); 82static Lisp_Object set_case_table (Lisp_Object, bool);
83 83
84DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0, 84DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0,
85 doc: /* Select a new case table for the current buffer. 85 doc: /* Select a new case table for the current buffer.
@@ -113,7 +113,7 @@ See `set-case-table' for more info on case tables. */)
113} 113}
114 114
115static Lisp_Object 115static Lisp_Object
116set_case_table (Lisp_Object table, int standard) 116set_case_table (Lisp_Object table, bool standard)
117{ 117{
118 Lisp_Object up, canon, eqv; 118 Lisp_Object up, canon, eqv;
119 119
diff --git a/src/category.c b/src/category.c
index 1c9085fd558..80dc6938d8b 100644
--- a/src/category.c
+++ b/src/category.c
@@ -406,17 +406,17 @@ then delete CATEGORY from the category set instead of adding it. */)
406 return Qnil; 406 return Qnil;
407} 407}
408 408
409/* Return 1 if there is a word boundary between two word-constituent 409/* Return true if there is a word boundary between two word-constituent
410 characters C1 and C2 if they appear in this order, else return 0. 410 characters C1 and C2 if they appear in this order.
411 Use the macro WORD_BOUNDARY_P instead of calling this function 411 Use the macro WORD_BOUNDARY_P instead of calling this function
412 directly. */ 412 directly. */
413 413
414int 414bool
415word_boundary_p (int c1, int c2) 415word_boundary_p (int c1, int c2)
416{ 416{
417 Lisp_Object category_set1, category_set2; 417 Lisp_Object category_set1, category_set2;
418 Lisp_Object tail; 418 Lisp_Object tail;
419 int default_result; 419 bool default_result;
420 420
421 if (EQ (CHAR_TABLE_REF (Vchar_script_table, c1), 421 if (EQ (CHAR_TABLE_REF (Vchar_script_table, c1),
422 CHAR_TABLE_REF (Vchar_script_table, c2))) 422 CHAR_TABLE_REF (Vchar_script_table, c2)))
diff --git a/src/category.h b/src/category.h
index 9fb981ed383..17cd203db45 100644
--- a/src/category.h
+++ b/src/category.h
@@ -77,14 +77,14 @@ INLINE_HEADER_BEGIN
77/* Return the category set of character C in the current category table. */ 77/* Return the category set of character C in the current category table. */
78#define CATEGORY_SET(c) char_category_set (c) 78#define CATEGORY_SET(c) char_category_set (c)
79 79
80/* Return 1 if CATEGORY_SET contains CATEGORY, else return 0. 80/* Return true if CATEGORY_SET contains CATEGORY.
81 The faster version of `!NILP (Faref (category_set, category))'. */ 81 The faster version of `!NILP (Faref (category_set, category))'. */
82#define CATEGORY_MEMBER(category, category_set) \ 82#define CATEGORY_MEMBER(category, category_set) \
83 ((XCATEGORY_SET (category_set)->data[(category) / 8] \ 83 ((XCATEGORY_SET (category_set)->data[(category) / 8] \
84 >> ((category) % 8)) & 1) 84 >> ((category) % 8)) & 1)
85 85
86/* Return 1 if category set of CH contains CATEGORY, else return 0. */ 86/* Return true if category set of CH contains CATEGORY. */
87CATEGORY_INLINE int 87CATEGORY_INLINE bool
88CHAR_HAS_CATEGORY (int ch, int category) 88CHAR_HAS_CATEGORY (int ch, int category)
89{ 89{
90 Lisp_Object category_set = CATEGORY_SET (ch); 90 Lisp_Object category_set = CATEGORY_SET (ch);
@@ -108,14 +108,14 @@ CHAR_HAS_CATEGORY (int ch, int category)
108#define CATEGORY_TABLE_VERSION (table) \ 108#define CATEGORY_TABLE_VERSION (table) \
109 Fchar_table_extra_slot (table, make_number (1)) 109 Fchar_table_extra_slot (table, make_number (1))
110 110
111/* Return 1 if there is a word boundary between two word-constituent 111/* Return true if there is a word boundary between two
112 characters C1 and C2 if they appear in this order, else return 0. 112 word-constituent characters C1 and C2 if they appear in this order.
113 There is no word boundary between two word-constituent ASCII and 113 There is no word boundary between two word-constituent ASCII and
114 Latin-1 characters. */ 114 Latin-1 characters. */
115#define WORD_BOUNDARY_P(c1, c2) \ 115#define WORD_BOUNDARY_P(c1, c2) \
116 (!(SINGLE_BYTE_CHAR_P (c1) && SINGLE_BYTE_CHAR_P (c2)) \ 116 (!(SINGLE_BYTE_CHAR_P (c1) && SINGLE_BYTE_CHAR_P (c2)) \
117 && word_boundary_p (c1, c2)) 117 && word_boundary_p (c1, c2))
118 118
119extern int word_boundary_p (int, int); 119extern bool word_boundary_p (int, int);
120 120
121INLINE_HEADER_END 121INLINE_HEADER_END
diff --git a/src/ccl.h b/src/ccl.h
index 71139175be5..cc5daf11e1c 100644
--- a/src/ccl.h
+++ b/src/ccl.h
@@ -26,6 +26,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#ifndef EMACS_CCL_H 26#ifndef EMACS_CCL_H
27#define EMACS_CCL_H 27#define EMACS_CCL_H
28 28
29#include "character.h" /* For MAX_MULTIBYTE_LENGTH */
30
29/* Macros for exit status of CCL program. */ 31/* Macros for exit status of CCL program. */
30#define CCL_STAT_SUCCESS 0 /* Terminated successfully. */ 32#define CCL_STAT_SUCCESS 0 /* Terminated successfully. */
31#define CCL_STAT_SUSPEND_BY_SRC 1 /* Terminated by empty input. */ 33#define CCL_STAT_SUSPEND_BY_SRC 1 /* Terminated by empty input. */
diff --git a/src/character.c b/src/character.c
index b2acf36ec15..cfaaf8eeca9 100644
--- a/src/character.c
+++ b/src/character.c
@@ -427,7 +427,7 @@ lisp_string_width (Lisp_Object string, ptrdiff_t precision,
427 /* This set multibyte to 0 even if STRING is multibyte when it 427 /* This set multibyte to 0 even if STRING is multibyte when it
428 contains only ascii and eight-bit-graphic, but that's 428 contains only ascii and eight-bit-graphic, but that's
429 intentional. */ 429 intentional. */
430 int multibyte = len < SBYTES (string); 430 bool multibyte = len < SBYTES (string);
431 unsigned char *str = SDATA (string); 431 unsigned char *str = SDATA (string);
432 ptrdiff_t i = 0, i_byte = 0; 432 ptrdiff_t i = 0, i_byte = 0;
433 ptrdiff_t width = 0; 433 ptrdiff_t width = 0;
@@ -765,13 +765,10 @@ str_as_unibyte (unsigned char *str, ptrdiff_t bytes)
765 corresponding byte and store in DST. CHARS is the number of 765 corresponding byte and store in DST. CHARS is the number of
766 characters in SRC. The value is the number of bytes stored in DST. 766 characters in SRC. The value is the number of bytes stored in DST.
767 Usually, the value is the same as CHARS, but is less than it if SRC 767 Usually, the value is the same as CHARS, but is less than it if SRC
768 contains a non-ASCII, non-eight-bit character. If ACCEPT_LATIN_1 768 contains a non-ASCII, non-eight-bit character. */
769 is nonzero, a Latin-1 character is accepted and converted to a byte
770 of that character code.
771 Note: Currently the arg ACCEPT_LATIN_1 is not used. */
772 769
773ptrdiff_t 770ptrdiff_t
774str_to_unibyte (const unsigned char *src, unsigned char *dst, ptrdiff_t chars, int accept_latin_1) 771str_to_unibyte (const unsigned char *src, unsigned char *dst, ptrdiff_t chars)
775{ 772{
776 ptrdiff_t i; 773 ptrdiff_t i;
777 774
@@ -781,8 +778,7 @@ str_to_unibyte (const unsigned char *src, unsigned char *dst, ptrdiff_t chars, i
781 778
782 if (CHAR_BYTE8_P (c)) 779 if (CHAR_BYTE8_P (c))
783 c = CHAR_TO_BYTE8 (c); 780 c = CHAR_TO_BYTE8 (c);
784 else if (! ASCII_CHAR_P (c) 781 else if (! ASCII_CHAR_P (c))
785 && (! accept_latin_1 || c >= 0x100))
786 return i; 782 return i;
787 *dst++ = c; 783 *dst++ = c;
788 } 784 }
@@ -793,7 +789,7 @@ str_to_unibyte (const unsigned char *src, unsigned char *dst, ptrdiff_t chars, i
793static ptrdiff_t 789static ptrdiff_t
794string_count_byte8 (Lisp_Object string) 790string_count_byte8 (Lisp_Object string)
795{ 791{
796 int multibyte = STRING_MULTIBYTE (string); 792 bool multibyte = STRING_MULTIBYTE (string);
797 ptrdiff_t nbytes = SBYTES (string); 793 ptrdiff_t nbytes = SBYTES (string);
798 unsigned char *p = SDATA (string); 794 unsigned char *p = SDATA (string);
799 unsigned char *pend = p + nbytes; 795 unsigned char *pend = p + nbytes;
@@ -825,7 +821,7 @@ string_escape_byte8 (Lisp_Object string)
825{ 821{
826 ptrdiff_t nchars = SCHARS (string); 822 ptrdiff_t nchars = SCHARS (string);
827 ptrdiff_t nbytes = SBYTES (string); 823 ptrdiff_t nbytes = SBYTES (string);
828 int multibyte = STRING_MULTIBYTE (string); 824 bool multibyte = STRING_MULTIBYTE (string);
829 ptrdiff_t byte8_count; 825 ptrdiff_t byte8_count;
830 const unsigned char *src, *src_end; 826 const unsigned char *src, *src_end;
831 unsigned char *dst; 827 unsigned char *dst;
diff --git a/src/character.h b/src/character.h
index 332dfee373a..70d4e67a978 100644
--- a/src/character.h
+++ b/src/character.h
@@ -676,7 +676,6 @@ extern int string_char (const unsigned char *,
676 const unsigned char **, int *); 676 const unsigned char **, int *);
677 677
678extern int translate_char (Lisp_Object, int c); 678extern int translate_char (Lisp_Object, int c);
679extern int char_printable_p (int c);
680extern void parse_str_as_multibyte (const unsigned char *, 679extern void parse_str_as_multibyte (const unsigned char *,
681 ptrdiff_t, ptrdiff_t *, ptrdiff_t *); 680 ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
682extern ptrdiff_t count_size_as_multibyte (const unsigned char *, ptrdiff_t); 681extern ptrdiff_t count_size_as_multibyte (const unsigned char *, ptrdiff_t);
@@ -685,7 +684,7 @@ extern ptrdiff_t str_as_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t,
685extern ptrdiff_t str_to_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t); 684extern ptrdiff_t str_to_multibyte (unsigned char *, ptrdiff_t, ptrdiff_t);
686extern ptrdiff_t str_as_unibyte (unsigned char *, ptrdiff_t); 685extern ptrdiff_t str_as_unibyte (unsigned char *, ptrdiff_t);
687extern ptrdiff_t str_to_unibyte (const unsigned char *, unsigned char *, 686extern ptrdiff_t str_to_unibyte (const unsigned char *, unsigned char *,
688 ptrdiff_t, int); 687 ptrdiff_t);
689extern ptrdiff_t strwidth (const char *, ptrdiff_t); 688extern ptrdiff_t strwidth (const char *, ptrdiff_t);
690extern ptrdiff_t c_string_width (const unsigned char *, ptrdiff_t, int, 689extern ptrdiff_t c_string_width (const unsigned char *, ptrdiff_t, int,
691 ptrdiff_t *, ptrdiff_t *); 690 ptrdiff_t *, ptrdiff_t *);
diff --git a/src/charset.c b/src/charset.c
index 3e286fa947d..0673790e91c 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -215,7 +215,7 @@ static struct
215 215
216/* Set to 1 to warn that a charset map is loaded and thus a buffer 216/* Set to 1 to warn that a charset map is loaded and thus a buffer
217 text and a string data may be relocated. */ 217 text and a string data may be relocated. */
218int charset_map_loaded; 218bool charset_map_loaded;
219 219
220struct charset_map_entries 220struct charset_map_entries
221{ 221{
@@ -256,7 +256,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
256{ 256{
257 Lisp_Object vec IF_LINT (= Qnil), table IF_LINT (= Qnil); 257 Lisp_Object vec IF_LINT (= Qnil), table IF_LINT (= Qnil);
258 unsigned max_code = CHARSET_MAX_CODE (charset); 258 unsigned max_code = CHARSET_MAX_CODE (charset);
259 int ascii_compatible_p = charset->ascii_compatible_p; 259 bool ascii_compatible_p = charset->ascii_compatible_p;
260 int min_char, max_char, nonascii_min_char; 260 int min_char, max_char, nonascii_min_char;
261 int i; 261 int i;
262 unsigned char *fast_map = charset->fast_map; 262 unsigned char *fast_map = charset->fast_map;
@@ -423,7 +423,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
423 paying attention to comment character '#'. */ 423 paying attention to comment character '#'. */
424 424
425static inline unsigned 425static inline unsigned
426read_hex (FILE *fp, int *eof, int *overflow) 426read_hex (FILE *fp, bool *eof, bool *overflow)
427{ 427{
428 int c; 428 int c;
429 unsigned n; 429 unsigned n;
@@ -512,7 +512,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int co
512 { 512 {
513 unsigned from, to, c; 513 unsigned from, to, c;
514 int idx; 514 int idx;
515 int eof = 0, overflow = 0; 515 bool eof = 0, overflow = 0;
516 516
517 from = read_hex (fp, &eof, &overflow); 517 from = read_hex (fp, &eof, &overflow);
518 if (eof) 518 if (eof)
@@ -717,10 +717,8 @@ map_charset_chars (void (*c_function)(Lisp_Object, Lisp_Object), Lisp_Object fun
717 Lisp_Object arg, struct charset *charset, unsigned from, unsigned to) 717 Lisp_Object arg, struct charset *charset, unsigned from, unsigned to)
718{ 718{
719 Lisp_Object range; 719 Lisp_Object range;
720 int partial; 720 bool partial = (from > CHARSET_MIN_CODE (charset)
721 721 || to < CHARSET_MAX_CODE (charset));
722 partial = (from > CHARSET_MIN_CODE (charset)
723 || to < CHARSET_MAX_CODE (charset));
724 722
725 if (CHARSET_METHOD (charset) == CHARSET_METHOD_OFFSET) 723 if (CHARSET_METHOD (charset) == CHARSET_METHOD_OFFSET)
726 { 724 {
@@ -855,7 +853,7 @@ usage: (define-charset-internal ...) */)
855 struct charset charset; 853 struct charset charset;
856 int id; 854 int id;
857 int dimension; 855 int dimension;
858 int new_definition_p; 856 bool new_definition_p;
859 int nchars; 857 int nchars;
860 858
861 if (nargs != charset_arg_max) 859 if (nargs != charset_arg_max)
@@ -1250,7 +1248,7 @@ define_charset_internal (Lisp_Object name,
1250 const char *code_space_chars, 1248 const char *code_space_chars,
1251 unsigned min_code, unsigned max_code, 1249 unsigned min_code, unsigned max_code,
1252 int iso_final, int iso_revision, int emacs_mule_id, 1250 int iso_final, int iso_revision, int emacs_mule_id,
1253 int ascii_compatible, int supplementary, 1251 bool ascii_compatible, bool supplementary,
1254 int code_offset) 1252 int code_offset)
1255{ 1253{
1256 const unsigned char *code_space = (const unsigned char *) code_space_chars; 1254 const unsigned char *code_space = (const unsigned char *) code_space_chars;
@@ -1448,7 +1446,7 @@ if CHARSET is designated instead. */)
1448 (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset) 1446 (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset)
1449{ 1447{
1450 int id; 1448 int id;
1451 int chars_flag; 1449 bool chars_flag;
1452 1450
1453 CHECK_CHARSET_GET_ID (charset, id); 1451 CHECK_CHARSET_GET_ID (charset, id);
1454 check_iso_charset_parameter (dimension, chars, final_char); 1452 check_iso_charset_parameter (dimension, chars, final_char);
@@ -1499,7 +1497,9 @@ string_xstring_p (Lisp_Object string)
1499 It may lookup a translation table TABLE if supplied. */ 1497 It may lookup a translation table TABLE if supplied. */
1500 1498
1501static void 1499static void
1502find_charsets_in_text (const unsigned char *ptr, ptrdiff_t nchars, ptrdiff_t nbytes, Lisp_Object charsets, Lisp_Object table, int multibyte) 1500find_charsets_in_text (const unsigned char *ptr, ptrdiff_t nchars,
1501 ptrdiff_t nbytes, Lisp_Object charsets,
1502 Lisp_Object table, bool multibyte)
1503{ 1503{
1504 const unsigned char *pend = ptr + nbytes; 1504 const unsigned char *pend = ptr + nbytes;
1505 1505
@@ -1549,7 +1549,7 @@ only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
1549 ptrdiff_t from, from_byte, to, stop, stop_byte; 1549 ptrdiff_t from, from_byte, to, stop, stop_byte;
1550 int i; 1550 int i;
1551 Lisp_Object val; 1551 Lisp_Object val;
1552 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 1552 bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
1553 1553
1554 validate_region (&beg, &end); 1554 validate_region (&beg, &end);
1555 from = XFASTINT (beg); 1555 from = XFASTINT (beg);
@@ -1735,7 +1735,7 @@ decode_char (struct charset *charset, unsigned int code)
1735/* Variable used temporarily by the macro ENCODE_CHAR. */ 1735/* Variable used temporarily by the macro ENCODE_CHAR. */
1736Lisp_Object charset_work; 1736Lisp_Object charset_work;
1737 1737
1738/* Return a code-point of CHAR in CHARSET. If CHAR doesn't belong to 1738/* Return a code-point of C in CHARSET. If C doesn't belong to
1739 CHARSET, return CHARSET_INVALID_CODE (CHARSET). If STRICT is true, 1739 CHARSET, return CHARSET_INVALID_CODE (CHARSET). If STRICT is true,
1740 use CHARSET's strict_max_char instead of max_char. */ 1740 use CHARSET's strict_max_char instead of max_char. */
1741 1741
@@ -1978,7 +1978,7 @@ is specified. */)
1978struct charset * 1978struct charset *
1979char_charset (int c, Lisp_Object charset_list, unsigned int *code_return) 1979char_charset (int c, Lisp_Object charset_list, unsigned int *code_return)
1980{ 1980{
1981 int maybe_null = 0; 1981 bool maybe_null = 0;
1982 1982
1983 if (NILP (charset_list)) 1983 if (NILP (charset_list))
1984 charset_list = Vcharset_ordered_list; 1984 charset_list = Vcharset_ordered_list;
@@ -2106,7 +2106,7 @@ DIMENSION, CHARS, and FINAL-CHAR. */)
2106 (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char) 2106 (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char)
2107{ 2107{
2108 int id; 2108 int id;
2109 int chars_flag; 2109 bool chars_flag;
2110 2110
2111 check_iso_charset_parameter (dimension, chars, final_char); 2111 check_iso_charset_parameter (dimension, chars, final_char);
2112 chars_flag = XFASTINT (chars) == 96; 2112 chars_flag = XFASTINT (chars) == 96;
diff --git a/src/charset.h b/src/charset.h
index 4ef8ddc2c33..50d230489fe 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -173,12 +173,24 @@ struct charset
173 check if a code-point is in a valid range. */ 173 check if a code-point is in a valid range. */
174 unsigned char *code_space_mask; 174 unsigned char *code_space_mask;
175 175
176 /* 1 if there's no gap in code-points. */ 176 /* True if there's no gap in code-points. */
177 int code_linear_p; 177 unsigned code_linear_p : 1;
178 178
179 /* If the charset is treated as 94-chars in ISO-2022, the value is 0. 179 /* True if the charset is treated as 96 chars in ISO-2022
180 If the charset is treated as 96-chars in ISO-2022, the value is 1. */ 180 as opposed to 94 chars. */
181 int iso_chars_96; 181 unsigned iso_chars_96 : 1;
182
183 /* True if the charset is compatible with ASCII. */
184 unsigned ascii_compatible_p : 1;
185
186 /* True if the charset is supplementary. */
187 unsigned supplementary_p : 1;
188
189 /* True if all the code points are representable by Lisp_Int. */
190 unsigned compact_codes_p : 1;
191
192 /* True if the charset is unified with Unicode. */
193 unsigned unified_p : 1;
182 194
183 /* ISO final byte of the charset: 48..127. It may be -1 if the 195 /* ISO final byte of the charset: 48..127. It may be -1 if the
184 charset doesn't conform to ISO-2022. */ 196 charset doesn't conform to ISO-2022. */
@@ -192,15 +204,6 @@ struct charset
192 version. Otherwise, -1. */ 204 version. Otherwise, -1. */
193 int emacs_mule_id; 205 int emacs_mule_id;
194 206
195 /* Nonzero if the charset is compatible with ASCII. */
196 int ascii_compatible_p;
197
198 /* Nonzero if the charset is supplementary. */
199 int supplementary_p;
200
201 /* Nonzero if all the code points are representable by Lisp_Int. */
202 int compact_codes_p;
203
204 /* The method for encoding/decoding characters of the charset. */ 207 /* The method for encoding/decoding characters of the charset. */
205 enum charset_method method; 208 enum charset_method method;
206 209
@@ -239,8 +242,6 @@ struct charset
239 /* Offset value to calculate a character code from code-point, and 242 /* Offset value to calculate a character code from code-point, and
240 visa versa. */ 243 visa versa. */
241 int code_offset; 244 int code_offset;
242
243 int unified_p;
244}; 245};
245 246
246/* Hash table of charset symbols vs. the corresponding attribute 247/* Hash table of charset symbols vs. the corresponding attribute
@@ -456,7 +457,7 @@ extern Lisp_Object charset_work;
456 457
457/* Set to 1 when a charset map is loaded to warn that a buffer text 458/* Set to 1 when a charset map is loaded to warn that a buffer text
458 and a string data may be relocated. */ 459 and a string data may be relocated. */
459extern int charset_map_loaded; 460extern bool charset_map_loaded;
460 461
461 462
462/* Set CHARSET to the charset highest priority of C, CODE to the 463/* Set CHARSET to the charset highest priority of C, CODE to the
@@ -474,10 +475,10 @@ extern int charset_map_loaded;
474 macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR). */ 475 macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR). */
475extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL]; 476extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
476 477
477/* A charset of type iso2022 who has DIMENSION, CHARS, and FINAL 478/* A charset of type iso2022 who has DIMENSION, CHARS_96, and FINAL
478 (final character). */ 479 (final character). */
479#define ISO_CHARSET_TABLE(dimension, chars_96, final) \ 480#define ISO_CHARSET_TABLE(dimension, chars_96, final) \
480 iso_charset_table[(dimension) - 1][(chars_96)][(final)] 481 iso_charset_table[(dimension) - 1][chars_96][final]
481 482
482/* Nonzero if the charset who has FAST_MAP may contain C. */ 483/* Nonzero if the charset who has FAST_MAP may contain C. */
483#define CHARSET_FAST_MAP_REF(c, fast_map) \ 484#define CHARSET_FAST_MAP_REF(c, fast_map) \
@@ -495,7 +496,7 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
495 496
496 497
497 498
498/* 1 if CHARSET may contain the character C. */ 499/* True if CHARSET may contain the character C. */
499#define CHAR_CHARSET_P(c, charset) \ 500#define CHAR_CHARSET_P(c, charset) \
500 ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \ 501 ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \
501 || ((CHARSET_UNIFIED_P (charset) \ 502 || ((CHARSET_UNIFIED_P (charset) \
diff --git a/src/chartab.c b/src/chartab.c
index 711a49ed397..c14df0ebac6 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -200,7 +200,7 @@ copy_char_table (Lisp_Object table)
200} 200}
201 201
202static Lisp_Object 202static Lisp_Object
203sub_char_table_ref (Lisp_Object table, int c, int is_uniprop) 203sub_char_table_ref (Lisp_Object table, int c, bool is_uniprop)
204{ 204{
205 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 205 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
206 int depth = XINT (tbl->depth); 206 int depth = XINT (tbl->depth);
@@ -245,7 +245,7 @@ char_table_ref (Lisp_Object table, int c)
245 245
246static Lisp_Object 246static Lisp_Object
247sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to, 247sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to,
248 Lisp_Object defalt, int is_uniprop) 248 Lisp_Object defalt, bool is_uniprop)
249{ 249{
250 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 250 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
251 int depth = XINT (tbl->depth); 251 int depth = XINT (tbl->depth);
@@ -320,7 +320,7 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
320 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table); 320 struct Lisp_Char_Table *tbl = XCHAR_TABLE (table);
321 int chartab_idx = CHARTAB_IDX (c, 0, 0), idx; 321 int chartab_idx = CHARTAB_IDX (c, 0, 0), idx;
322 Lisp_Object val; 322 Lisp_Object val;
323 int is_uniprop = UNIPROP_TABLE_P (table); 323 bool is_uniprop = UNIPROP_TABLE_P (table);
324 324
325 val = tbl->contents[chartab_idx]; 325 val = tbl->contents[chartab_idx];
326 if (*from < 0) 326 if (*from < 0)
@@ -382,7 +382,7 @@ char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to)
382 382
383 383
384static void 384static void
385sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, int is_uniprop) 385sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, bool is_uniprop)
386{ 386{
387 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 387 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
388 int depth = XINT ((tbl)->depth); 388 int depth = XINT ((tbl)->depth);
@@ -438,7 +438,7 @@ char_table_set (Lisp_Object table, int c, Lisp_Object val)
438 438
439static void 439static void
440sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val, 440sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val,
441 int is_uniprop) 441 bool is_uniprop)
442{ 442{
443 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 443 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
444 int depth = XINT ((tbl)->depth); 444 int depth = XINT ((tbl)->depth);
@@ -484,7 +484,7 @@ char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val)
484 char_table_set (table, from, val); 484 char_table_set (table, from, val);
485 else 485 else
486 { 486 {
487 int is_uniprop = UNIPROP_TABLE_P (table); 487 bool is_uniprop = UNIPROP_TABLE_P (table);
488 int lim = CHARTAB_IDX (to, 0, 0); 488 int lim = CHARTAB_IDX (to, 0, 0);
489 int i, c; 489 int i, c;
490 490
@@ -683,7 +683,8 @@ optimize_sub_char_table (Lisp_Object table, Lisp_Object test)
683 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 683 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
684 int depth = XINT (tbl->depth); 684 int depth = XINT (tbl->depth);
685 Lisp_Object elt, this; 685 Lisp_Object elt, this;
686 int i, optimizable; 686 int i;
687 bool optimizable;
687 688
688 elt = XSUB_CHAR_TABLE (table)->contents[0]; 689 elt = XSUB_CHAR_TABLE (table)->contents[0];
689 if (SUB_CHAR_TABLE_P (elt)) 690 if (SUB_CHAR_TABLE_P (elt))
@@ -762,7 +763,7 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
762 int chars_in_block; 763 int chars_in_block;
763 int from = XINT (XCAR (range)), to = XINT (XCDR (range)); 764 int from = XINT (XCAR (range)), to = XINT (XCDR (range));
764 int i, c; 765 int i, c;
765 int is_uniprop = UNIPROP_TABLE_P (top); 766 bool is_uniprop = UNIPROP_TABLE_P (top);
766 uniprop_decoder_t decoder = UNIPROP_GET_DECODER (top); 767 uniprop_decoder_t decoder = UNIPROP_GET_DECODER (top);
767 768
768 if (SUB_CHAR_TABLE_P (table)) 769 if (SUB_CHAR_TABLE_P (table))
@@ -811,7 +812,7 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
811 this = XCHAR_TABLE (top)->defalt; 812 this = XCHAR_TABLE (top)->defalt;
812 if (!EQ (val, this)) 813 if (!EQ (val, this))
813 { 814 {
814 int different_value = 1; 815 bool different_value = 1;
815 816
816 if (NILP (val)) 817 if (NILP (val))
817 { 818 {
diff --git a/src/cmds.c b/src/cmds.c
index b416135ee9e..90d3cd6dced 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -47,10 +47,10 @@ DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
47 return make_number (PT + XINT (n)); 47 return make_number (PT + XINT (n));
48} 48}
49 49
50/* Add N to point; or subtract N if FORWARD is zero. N defaults to 1. 50/* Add N to point; or subtract N if FORWARD is false. N defaults to 1.
51 Validate the new location. Return nil. */ 51 Validate the new location. Return nil. */
52static Lisp_Object 52static Lisp_Object
53move_point (Lisp_Object n, int forward) 53move_point (Lisp_Object n, bool forward)
54{ 54{
55 /* This used to just set point to point + XINT (n), and then check 55 /* This used to just set point to point + XINT (n), and then check
56 to see if it was within boundaries. But now that SET_PT can 56 to see if it was within boundaries. But now that SET_PT can
@@ -277,7 +277,7 @@ After insertion, the value of `auto-fill-function' is called if the
277At the end, it runs `post-self-insert-hook'. */) 277At the end, it runs `post-self-insert-hook'. */)
278 (Lisp_Object n) 278 (Lisp_Object n)
279{ 279{
280 int remove_boundary = 1; 280 bool remove_boundary = 1;
281 CHECK_NATNUM (n); 281 CHECK_NATNUM (n);
282 282
283 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) 283 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command)))
@@ -438,7 +438,7 @@ internal_self_insert (int c, EMACS_INT n)
438 : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) 438 : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ())))
439 == Sword)) 439 == Sword))
440 { 440 {
441 int modiff = MODIFF; 441 EMACS_INT modiff = MODIFF;
442 Lisp_Object sym; 442 Lisp_Object sym;
443 443
444 sym = call0 (Qexpand_abbrev); 444 sym = call0 (Qexpand_abbrev);
diff --git a/src/coding.c b/src/coding.c
index 971686dc180..02e7b34695e 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -147,18 +147,18 @@ STRUCT CODING_SYSTEM
147 CODING conforms to the format of XXX, and update the members of 147 CODING conforms to the format of XXX, and update the members of
148 DETECT_INFO. 148 DETECT_INFO.
149 149
150 Return 1 if the byte sequence conforms to XXX, otherwise return 0. 150 Return true if the byte sequence conforms to XXX.
151 151
152 Below is the template of these functions. */ 152 Below is the template of these functions. */
153 153
154#if 0 154#if 0
155static int 155static bool
156detect_coding_XXX (struct coding_system *coding, 156detect_coding_XXX (struct coding_system *coding,
157 struct coding_detection_info *detect_info) 157 struct coding_detection_info *detect_info)
158{ 158{
159 const unsigned char *src = coding->source; 159 const unsigned char *src = coding->source;
160 const unsigned char *src_end = coding->source + coding->src_bytes; 160 const unsigned char *src_end = coding->source + coding->src_bytes;
161 int multibytep = coding->src_multibyte; 161 bool multibytep = coding->src_multibyte;
162 ptrdiff_t consumed_chars = 0; 162 ptrdiff_t consumed_chars = 0;
163 int found = 0; 163 int found = 0;
164 ...; 164 ...;
@@ -212,7 +212,7 @@ decode_coding_XXXX (struct coding_system *coding)
212 /* A buffer to produce decoded characters. */ 212 /* A buffer to produce decoded characters. */
213 int *charbuf = coding->charbuf + coding->charbuf_used; 213 int *charbuf = coding->charbuf + coding->charbuf_used;
214 int *charbuf_end = coding->charbuf + coding->charbuf_size; 214 int *charbuf_end = coding->charbuf + coding->charbuf_size;
215 int multibytep = coding->src_multibyte; 215 bool multibytep = coding->src_multibyte;
216 216
217 while (1) 217 while (1)
218 { 218 {
@@ -260,7 +260,7 @@ decode_coding_XXXX (struct coding_system *coding)
260static void 260static void
261encode_coding_XXX (struct coding_system *coding) 261encode_coding_XXX (struct coding_system *coding)
262{ 262{
263 int multibytep = coding->dst_multibyte; 263 bool multibytep = coding->dst_multibyte;
264 int *charbuf = coding->charbuf; 264 int *charbuf = coding->charbuf;
265 int *charbuf_end = charbuf->charbuf + coding->charbuf_used; 265 int *charbuf_end = charbuf->charbuf + coding->charbuf_used;
266 unsigned char *dst = coding->destination + coding->produced; 266 unsigned char *dst = coding->destination + coding->produced;
@@ -651,8 +651,8 @@ static struct coding_system coding_categories[coding_category_max];
651 651
652/* Safely get one byte from the source text pointed by SRC which ends 652/* Safely get one byte from the source text pointed by SRC which ends
653 at SRC_END, and set C to that byte. If there are not enough bytes 653 at SRC_END, and set C to that byte. If there are not enough bytes
654 in the source, it jumps to `no_more_source'. If multibytep is 654 in the source, it jumps to 'no_more_source'. If MULTIBYTEP,
655 nonzero, and a multibyte character is found at SRC, set C to the 655 and a multibyte character is found at SRC, set C to the
656 negative value of the character code. The caller should declare 656 negative value of the character code. The caller should declare
657 and set these variables appropriately in advance: 657 and set these variables appropriately in advance:
658 src, src_end, multibytep */ 658 src, src_end, multibytep */
@@ -685,7 +685,7 @@ static struct coding_system coding_categories[coding_category_max];
685/* Safely get two bytes from the source text pointed by SRC which ends 685/* Safely get two bytes from the source text pointed by SRC which ends
686 at SRC_END, and set C1 and C2 to those bytes while skipping the 686 at SRC_END, and set C1 and C2 to those bytes while skipping the
687 heading multibyte characters. If there are not enough bytes in the 687 heading multibyte characters. If there are not enough bytes in the
688 source, it jumps to `no_more_source'. If multibytep is nonzero and 688 source, it jumps to 'no_more_source'. If MULTIBYTEP and
689 a multibyte character is found for C2, set C2 to the negative value 689 a multibyte character is found for C2, set C2 to the negative value
690 of the character code. The caller should declare and set these 690 of the character code. The caller should declare and set these
691 variables appropriately in advance: 691 variables appropriately in advance:
@@ -746,8 +746,8 @@ static struct coding_system coding_categories[coding_category_max];
746 746
747 747
748/* Store a byte C in the place pointed by DST and increment DST to the 748/* Store a byte C in the place pointed by DST and increment DST to the
749 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is 749 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP,
750 nonzero, store in an appropriate multibyte from. The caller should 750 store in an appropriate multibyte form. The caller should
751 declare and set the variables `dst' and `multibytep' appropriately 751 declare and set the variables `dst' and `multibytep' appropriately
752 in advance. */ 752 in advance. */
753 753
@@ -806,83 +806,6 @@ static struct coding_system coding_categories[coding_category_max];
806 } while (0) 806 } while (0)
807 807
808 808
809/* Prototypes for static functions. */
810static void record_conversion_result (struct coding_system *coding,
811 enum coding_result_code result);
812static int detect_coding_utf_8 (struct coding_system *,
813 struct coding_detection_info *info);
814static void decode_coding_utf_8 (struct coding_system *);
815static int encode_coding_utf_8 (struct coding_system *);
816
817static int detect_coding_utf_16 (struct coding_system *,
818 struct coding_detection_info *info);
819static void decode_coding_utf_16 (struct coding_system *);
820static int encode_coding_utf_16 (struct coding_system *);
821
822static int detect_coding_iso_2022 (struct coding_system *,
823 struct coding_detection_info *info);
824static void decode_coding_iso_2022 (struct coding_system *);
825static int encode_coding_iso_2022 (struct coding_system *);
826
827static int detect_coding_emacs_mule (struct coding_system *,
828 struct coding_detection_info *info);
829static void decode_coding_emacs_mule (struct coding_system *);
830static int encode_coding_emacs_mule (struct coding_system *);
831
832static int detect_coding_sjis (struct coding_system *,
833 struct coding_detection_info *info);
834static void decode_coding_sjis (struct coding_system *);
835static int encode_coding_sjis (struct coding_system *);
836
837static int detect_coding_big5 (struct coding_system *,
838 struct coding_detection_info *info);
839static void decode_coding_big5 (struct coding_system *);
840static int encode_coding_big5 (struct coding_system *);
841
842static int detect_coding_ccl (struct coding_system *,
843 struct coding_detection_info *info);
844static void decode_coding_ccl (struct coding_system *);
845static int encode_coding_ccl (struct coding_system *);
846
847static void decode_coding_raw_text (struct coding_system *);
848static int encode_coding_raw_text (struct coding_system *);
849
850static void coding_set_source (struct coding_system *);
851static ptrdiff_t coding_change_source (struct coding_system *);
852static void coding_set_destination (struct coding_system *);
853static ptrdiff_t coding_change_destination (struct coding_system *);
854static void coding_alloc_by_realloc (struct coding_system *, ptrdiff_t);
855static void coding_alloc_by_making_gap (struct coding_system *,
856 ptrdiff_t, ptrdiff_t);
857static unsigned char *alloc_destination (struct coding_system *,
858 ptrdiff_t, unsigned char *);
859static void setup_iso_safe_charsets (Lisp_Object);
860static ptrdiff_t encode_designation_at_bol (struct coding_system *,
861 int *, int *, unsigned char *);
862static int detect_eol (const unsigned char *,
863 ptrdiff_t, enum coding_category);
864static Lisp_Object adjust_coding_eol_type (struct coding_system *, int);
865static void decode_eol (struct coding_system *);
866static Lisp_Object get_translation_table (Lisp_Object, int, int *);
867static Lisp_Object get_translation (Lisp_Object, int *, int *);
868static int produce_chars (struct coding_system *, Lisp_Object, int);
869static inline void produce_charset (struct coding_system *, int *,
870 ptrdiff_t);
871static void produce_annotation (struct coding_system *, ptrdiff_t);
872static int decode_coding (struct coding_system *);
873static inline int *handle_composition_annotation (ptrdiff_t, ptrdiff_t,
874 struct coding_system *,
875 int *, ptrdiff_t *);
876static inline int *handle_charset_annotation (ptrdiff_t, ptrdiff_t,
877 struct coding_system *,
878 int *, ptrdiff_t *);
879static void consume_chars (struct coding_system *, Lisp_Object, int);
880static int encode_coding (struct coding_system *);
881static Lisp_Object make_conversion_work_buffer (int);
882static Lisp_Object code_conversion_restore (Lisp_Object);
883static inline int char_encodable_p (int, Lisp_Object);
884static Lisp_Object make_subsidiaries (Lisp_Object);
885
886static void 809static void
887record_conversion_result (struct coding_system *coding, 810record_conversion_result (struct coding_system *coding,
888 enum coding_result_code result) 811 enum coding_result_code result)
@@ -1264,8 +1187,7 @@ alloc_destination (struct coding_system *coding, ptrdiff_t nbytes,
1264/*** 3. UTF-8 ***/ 1187/*** 3. UTF-8 ***/
1265 1188
1266/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1189/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1267 Check if a text is encoded in UTF-8. If it is, return 1, else 1190 Return true if a text is encoded in UTF-8. */
1268 return 0. */
1269 1191
1270#define UTF_8_1_OCTET_P(c) ((c) < 0x80) 1192#define UTF_8_1_OCTET_P(c) ((c) < 0x80)
1271#define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) 1193#define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80)
@@ -1278,16 +1200,16 @@ alloc_destination (struct coding_system *coding, ptrdiff_t nbytes,
1278#define UTF_8_BOM_2 0xBB 1200#define UTF_8_BOM_2 0xBB
1279#define UTF_8_BOM_3 0xBF 1201#define UTF_8_BOM_3 0xBF
1280 1202
1281static int 1203static bool
1282detect_coding_utf_8 (struct coding_system *coding, 1204detect_coding_utf_8 (struct coding_system *coding,
1283 struct coding_detection_info *detect_info) 1205 struct coding_detection_info *detect_info)
1284{ 1206{
1285 const unsigned char *src = coding->source, *src_base; 1207 const unsigned char *src = coding->source, *src_base;
1286 const unsigned char *src_end = coding->source + coding->src_bytes; 1208 const unsigned char *src_end = coding->source + coding->src_bytes;
1287 int multibytep = coding->src_multibyte; 1209 bool multibytep = coding->src_multibyte;
1288 ptrdiff_t consumed_chars = 0; 1210 ptrdiff_t consumed_chars = 0;
1289 int bom_found = 0; 1211 bool bom_found = 0;
1290 int found = 0; 1212 bool found = 0;
1291 1213
1292 detect_info->checked |= CATEGORY_MASK_UTF_8; 1214 detect_info->checked |= CATEGORY_MASK_UTF_8;
1293 /* A coding system of this category is always ASCII compatible. */ 1215 /* A coding system of this category is always ASCII compatible. */
@@ -1371,10 +1293,10 @@ decode_coding_utf_8 (struct coding_system *coding)
1371 int *charbuf = coding->charbuf + coding->charbuf_used; 1293 int *charbuf = coding->charbuf + coding->charbuf_used;
1372 int *charbuf_end = coding->charbuf + coding->charbuf_size; 1294 int *charbuf_end = coding->charbuf + coding->charbuf_size;
1373 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; 1295 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0;
1374 int multibytep = coding->src_multibyte; 1296 bool multibytep = coding->src_multibyte;
1375 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); 1297 enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
1376 int eol_dos = 1298 bool eol_dos
1377 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 1299 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1378 int byte_after_cr = -1; 1300 int byte_after_cr = -1;
1379 1301
1380 if (bom != utf_without_bom) 1302 if (bom != utf_without_bom)
@@ -1513,10 +1435,10 @@ decode_coding_utf_8 (struct coding_system *coding)
1513} 1435}
1514 1436
1515 1437
1516static int 1438static bool
1517encode_coding_utf_8 (struct coding_system *coding) 1439encode_coding_utf_8 (struct coding_system *coding)
1518{ 1440{
1519 int multibytep = coding->dst_multibyte; 1441 bool multibytep = coding->dst_multibyte;
1520 int *charbuf = coding->charbuf; 1442 int *charbuf = coding->charbuf;
1521 int *charbuf_end = charbuf + coding->charbuf_used; 1443 int *charbuf_end = charbuf + coding->charbuf_used;
1522 unsigned char *dst = coding->destination + coding->produced; 1444 unsigned char *dst = coding->destination + coding->produced;
@@ -1577,8 +1499,7 @@ encode_coding_utf_8 (struct coding_system *coding)
1577 1499
1578 1500
1579/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1501/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1580 Check if a text is encoded in one of UTF-16 based coding systems. 1502 Return true if a text is encoded in one of UTF-16 based coding systems. */
1581 If it is, return 1, else return 0. */
1582 1503
1583#define UTF_16_HIGH_SURROGATE_P(val) \ 1504#define UTF_16_HIGH_SURROGATE_P(val) \
1584 (((val) & 0xFC00) == 0xD800) 1505 (((val) & 0xFC00) == 0xD800)
@@ -1587,13 +1508,13 @@ encode_coding_utf_8 (struct coding_system *coding)
1587 (((val) & 0xFC00) == 0xDC00) 1508 (((val) & 0xFC00) == 0xDC00)
1588 1509
1589 1510
1590static int 1511static bool
1591detect_coding_utf_16 (struct coding_system *coding, 1512detect_coding_utf_16 (struct coding_system *coding,
1592 struct coding_detection_info *detect_info) 1513 struct coding_detection_info *detect_info)
1593{ 1514{
1594 const unsigned char *src = coding->source; 1515 const unsigned char *src = coding->source;
1595 const unsigned char *src_end = coding->source + coding->src_bytes; 1516 const unsigned char *src_end = coding->source + coding->src_bytes;
1596 int multibytep = coding->src_multibyte; 1517 bool multibytep = coding->src_multibyte;
1597 int c1, c2; 1518 int c1, c2;
1598 1519
1599 detect_info->checked |= CATEGORY_MASK_UTF_16; 1520 detect_info->checked |= CATEGORY_MASK_UTF_16;
@@ -1680,12 +1601,12 @@ decode_coding_utf_16 (struct coding_system *coding)
1680 /* We may produces at most 3 chars in one loop. */ 1601 /* We may produces at most 3 chars in one loop. */
1681 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; 1602 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2;
1682 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; 1603 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0;
1683 int multibytep = coding->src_multibyte; 1604 bool multibytep = coding->src_multibyte;
1684 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1605 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1685 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); 1606 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
1686 int surrogate = CODING_UTF_16_SURROGATE (coding); 1607 int surrogate = CODING_UTF_16_SURROGATE (coding);
1687 int eol_dos = 1608 bool eol_dos
1688 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 1609 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1689 int byte_after_cr1 = -1, byte_after_cr2 = -1; 1610 int byte_after_cr1 = -1, byte_after_cr2 = -1;
1690 1611
1691 if (bom == utf_with_bom) 1612 if (bom == utf_with_bom)
@@ -1795,17 +1716,17 @@ decode_coding_utf_16 (struct coding_system *coding)
1795 coding->charbuf_used = charbuf - coding->charbuf; 1716 coding->charbuf_used = charbuf - coding->charbuf;
1796} 1717}
1797 1718
1798static int 1719static bool
1799encode_coding_utf_16 (struct coding_system *coding) 1720encode_coding_utf_16 (struct coding_system *coding)
1800{ 1721{
1801 int multibytep = coding->dst_multibyte; 1722 bool multibytep = coding->dst_multibyte;
1802 int *charbuf = coding->charbuf; 1723 int *charbuf = coding->charbuf;
1803 int *charbuf_end = charbuf + coding->charbuf_used; 1724 int *charbuf_end = charbuf + coding->charbuf_used;
1804 unsigned char *dst = coding->destination + coding->produced; 1725 unsigned char *dst = coding->destination + coding->produced;
1805 unsigned char *dst_end = coding->destination + coding->dst_bytes; 1726 unsigned char *dst_end = coding->destination + coding->dst_bytes;
1806 int safe_room = 8; 1727 int safe_room = 8;
1807 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1728 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1808 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; 1729 bool big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
1809 ptrdiff_t produced_chars = 0; 1730 ptrdiff_t produced_chars = 0;
1810 int c; 1731 int c;
1811 1732
@@ -1930,16 +1851,15 @@ char emacs_mule_bytes[256];
1930 1851
1931 1852
1932/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1853/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1933 Check if a text is encoded in `emacs-mule'. If it is, return 1, 1854 Return true if a text is encoded in 'emacs-mule'. */
1934 else return 0. */
1935 1855
1936static int 1856static bool
1937detect_coding_emacs_mule (struct coding_system *coding, 1857detect_coding_emacs_mule (struct coding_system *coding,
1938 struct coding_detection_info *detect_info) 1858 struct coding_detection_info *detect_info)
1939{ 1859{
1940 const unsigned char *src = coding->source, *src_base; 1860 const unsigned char *src = coding->source, *src_base;
1941 const unsigned char *src_end = coding->source + coding->src_bytes; 1861 const unsigned char *src_end = coding->source + coding->src_bytes;
1942 int multibytep = coding->src_multibyte; 1862 bool multibytep = coding->src_multibyte;
1943 ptrdiff_t consumed_chars = 0; 1863 ptrdiff_t consumed_chars = 0;
1944 int c; 1864 int c;
1945 int found = 0; 1865 int found = 0;
@@ -2029,12 +1949,12 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
2029{ 1949{
2030 const unsigned char *src_end = coding->source + coding->src_bytes; 1950 const unsigned char *src_end = coding->source + coding->src_bytes;
2031 const unsigned char *src_base = src; 1951 const unsigned char *src_base = src;
2032 int multibytep = coding->src_multibyte; 1952 bool multibytep = coding->src_multibyte;
2033 int charset_ID; 1953 int charset_ID;
2034 unsigned code; 1954 unsigned code;
2035 int c; 1955 int c;
2036 int consumed_chars = 0; 1956 int consumed_chars = 0;
2037 int mseq_found = 0; 1957 bool mseq_found = 0;
2038 1958
2039 ONE_MORE_BYTE (c); 1959 ONE_MORE_BYTE (c);
2040 if (c < 0) 1960 if (c < 0)
@@ -2411,12 +2331,12 @@ decode_coding_emacs_mule (struct coding_system *coding)
2411 /* We can produce up to 2 characters in a loop. */ 2331 /* We can produce up to 2 characters in a loop. */
2412 - 1; 2332 - 1;
2413 ptrdiff_t consumed_chars = 0, consumed_chars_base; 2333 ptrdiff_t consumed_chars = 0, consumed_chars_base;
2414 int multibytep = coding->src_multibyte; 2334 bool multibytep = coding->src_multibyte;
2415 ptrdiff_t char_offset = coding->produced_char; 2335 ptrdiff_t char_offset = coding->produced_char;
2416 ptrdiff_t last_offset = char_offset; 2336 ptrdiff_t last_offset = char_offset;
2417 int last_id = charset_ascii; 2337 int last_id = charset_ascii;
2418 int eol_dos = 2338 bool eol_dos
2419 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 2339 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
2420 int byte_after_cr = -1; 2340 int byte_after_cr = -1;
2421 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; 2341 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
2422 2342
@@ -2657,10 +2577,10 @@ decode_coding_emacs_mule (struct coding_system *coding)
2657 } while (0); 2577 } while (0);
2658 2578
2659 2579
2660static int 2580static bool
2661encode_coding_emacs_mule (struct coding_system *coding) 2581encode_coding_emacs_mule (struct coding_system *coding)
2662{ 2582{
2663 int multibytep = coding->dst_multibyte; 2583 bool multibytep = coding->dst_multibyte;
2664 int *charbuf = coding->charbuf; 2584 int *charbuf = coding->charbuf;
2665 int *charbuf_end = charbuf + coding->charbuf_used; 2585 int *charbuf_end = charbuf + coding->charbuf_used;
2666 unsigned char *dst = coding->destination + coding->produced; 2586 unsigned char *dst = coding->destination + coding->produced;
@@ -2722,7 +2642,7 @@ encode_coding_emacs_mule (struct coding_system *coding)
2722 2642
2723 if (preferred_charset_id >= 0) 2643 if (preferred_charset_id >= 0)
2724 { 2644 {
2725 int result; 2645 bool result;
2726 2646
2727 charset = CHARSET_FROM_ID (preferred_charset_id); 2647 charset = CHARSET_FROM_ID (preferred_charset_id);
2728 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); 2648 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result);
@@ -3017,17 +2937,17 @@ setup_iso_safe_charsets (Lisp_Object attrs)
3017 2937
3018 2938
3019/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 2939/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
3020 Check if a text is encoded in one of ISO-2022 based coding systems. 2940 Return true if a text is encoded in one of ISO-2022 based coding
3021 If it is, return 1, else return 0. */ 2941 systems. */
3022 2942
3023static int 2943static bool
3024detect_coding_iso_2022 (struct coding_system *coding, 2944detect_coding_iso_2022 (struct coding_system *coding,
3025 struct coding_detection_info *detect_info) 2945 struct coding_detection_info *detect_info)
3026{ 2946{
3027 const unsigned char *src = coding->source, *src_base = src; 2947 const unsigned char *src = coding->source, *src_base = src;
3028 const unsigned char *src_end = coding->source + coding->src_bytes; 2948 const unsigned char *src_end = coding->source + coding->src_bytes;
3029 int multibytep = coding->src_multibyte; 2949 bool multibytep = coding->src_multibyte;
3030 int single_shifting = 0; 2950 bool single_shifting = 0;
3031 int id; 2951 int id;
3032 int c, c1; 2952 int c, c1;
3033 ptrdiff_t consumed_chars = 0; 2953 ptrdiff_t consumed_chars = 0;
@@ -3390,8 +3310,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
3390 3310
3391/* Finish the current composition as invalid. */ 3311/* Finish the current composition as invalid. */
3392 3312
3393static int finish_composition (int *, struct composition_status *);
3394
3395static int 3313static int
3396finish_composition (int *charbuf, struct composition_status *cmp_status) 3314finish_composition (int *charbuf, struct composition_status *cmp_status)
3397{ 3315{
@@ -3541,7 +3459,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3541 int *charbuf_end 3459 int *charbuf_end
3542 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); 3460 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
3543 ptrdiff_t consumed_chars = 0, consumed_chars_base; 3461 ptrdiff_t consumed_chars = 0, consumed_chars_base;
3544 int multibytep = coding->src_multibyte; 3462 bool multibytep = coding->src_multibyte;
3545 /* Charsets invoked to graphic plane 0 and 1 respectively. */ 3463 /* Charsets invoked to graphic plane 0 and 1 respectively. */
3546 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); 3464 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0);
3547 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); 3465 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1);
@@ -3553,8 +3471,8 @@ decode_coding_iso_2022 (struct coding_system *coding)
3553 ptrdiff_t char_offset = coding->produced_char; 3471 ptrdiff_t char_offset = coding->produced_char;
3554 ptrdiff_t last_offset = char_offset; 3472 ptrdiff_t last_offset = char_offset;
3555 int last_id = charset_ascii; 3473 int last_id = charset_ascii;
3556 int eol_dos = 3474 bool eol_dos
3557 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 3475 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
3558 int byte_after_cr = -1; 3476 int byte_after_cr = -1;
3559 int i; 3477 int i;
3560 3478
@@ -4282,7 +4200,7 @@ encode_invocation_designation (struct charset *charset,
4282 struct coding_system *coding, 4200 struct coding_system *coding,
4283 unsigned char *dst, ptrdiff_t *p_nchars) 4201 unsigned char *dst, ptrdiff_t *p_nchars)
4284{ 4202{
4285 int multibytep = coding->dst_multibyte; 4203 bool multibytep = coding->dst_multibyte;
4286 ptrdiff_t produced_chars = *p_nchars; 4204 ptrdiff_t produced_chars = *p_nchars;
4287 int reg; /* graphic register number */ 4205 int reg; /* graphic register number */
4288 int id = CHARSET_ID (charset); 4206 int id = CHARSET_ID (charset);
@@ -4380,7 +4298,7 @@ encode_designation_at_bol (struct coding_system *coding,
4380 int r[4]; 4298 int r[4];
4381 int c, found = 0, reg; 4299 int c, found = 0, reg;
4382 ptrdiff_t produced_chars = 0; 4300 ptrdiff_t produced_chars = 0;
4383 int multibytep = coding->dst_multibyte; 4301 bool multibytep = coding->dst_multibyte;
4384 Lisp_Object attrs; 4302 Lisp_Object attrs;
4385 Lisp_Object charset_list; 4303 Lisp_Object charset_list;
4386 4304
@@ -4422,21 +4340,21 @@ encode_designation_at_bol (struct coding_system *coding,
4422 4340
4423/* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ 4341/* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */
4424 4342
4425static int 4343static bool
4426encode_coding_iso_2022 (struct coding_system *coding) 4344encode_coding_iso_2022 (struct coding_system *coding)
4427{ 4345{
4428 int multibytep = coding->dst_multibyte; 4346 bool multibytep = coding->dst_multibyte;
4429 int *charbuf = coding->charbuf; 4347 int *charbuf = coding->charbuf;
4430 int *charbuf_end = charbuf + coding->charbuf_used; 4348 int *charbuf_end = charbuf + coding->charbuf_used;
4431 unsigned char *dst = coding->destination + coding->produced; 4349 unsigned char *dst = coding->destination + coding->produced;
4432 unsigned char *dst_end = coding->destination + coding->dst_bytes; 4350 unsigned char *dst_end = coding->destination + coding->dst_bytes;
4433 int safe_room = 16; 4351 int safe_room = 16;
4434 int bol_designation 4352 bool bol_designation
4435 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL 4353 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL
4436 && CODING_ISO_BOL (coding)); 4354 && CODING_ISO_BOL (coding));
4437 ptrdiff_t produced_chars = 0; 4355 ptrdiff_t produced_chars = 0;
4438 Lisp_Object attrs, eol_type, charset_list; 4356 Lisp_Object attrs, eol_type, charset_list;
4439 int ascii_compatible; 4357 bool ascii_compatible;
4440 int c; 4358 int c;
4441 int preferred_charset_id = -1; 4359 int preferred_charset_id = -1;
4442 4360
@@ -4523,8 +4441,9 @@ encode_coding_iso_2022 (struct coding_system *coding)
4523 CODING_ISO_DESIGNATION (coding, i) 4441 CODING_ISO_DESIGNATION (coding, i)
4524 = CODING_ISO_INITIAL (coding, i); 4442 = CODING_ISO_INITIAL (coding, i);
4525 } 4443 }
4526 bol_designation 4444 bol_designation = ((CODING_ISO_FLAGS (coding)
4527 = CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL; 4445 & CODING_ISO_FLAG_DESIGNATE_AT_BOL)
4446 != 0);
4528 } 4447 }
4529 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) 4448 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL)
4530 ENCODE_RESET_PLANE_AND_REGISTER (); 4449 ENCODE_RESET_PLANE_AND_REGISTER ();
@@ -4551,7 +4470,7 @@ encode_coding_iso_2022 (struct coding_system *coding)
4551 4470
4552 if (preferred_charset_id >= 0) 4471 if (preferred_charset_id >= 0)
4553 { 4472 {
4554 int result; 4473 bool result;
4555 4474
4556 charset = CHARSET_FROM_ID (preferred_charset_id); 4475 charset = CHARSET_FROM_ID (preferred_charset_id);
4557 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); 4476 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result);
@@ -4631,16 +4550,15 @@ encode_coding_iso_2022 (struct coding_system *coding)
4631 */ 4550 */
4632 4551
4633/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 4552/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
4634 Check if a text is encoded in SJIS. If it is, return 4553 Return true if a text is encoded in SJIS. */
4635 CATEGORY_MASK_SJIS, else return 0. */
4636 4554
4637static int 4555static bool
4638detect_coding_sjis (struct coding_system *coding, 4556detect_coding_sjis (struct coding_system *coding,
4639 struct coding_detection_info *detect_info) 4557 struct coding_detection_info *detect_info)
4640{ 4558{
4641 const unsigned char *src = coding->source, *src_base; 4559 const unsigned char *src = coding->source, *src_base;
4642 const unsigned char *src_end = coding->source + coding->src_bytes; 4560 const unsigned char *src_end = coding->source + coding->src_bytes;
4643 int multibytep = coding->src_multibyte; 4561 bool multibytep = coding->src_multibyte;
4644 ptrdiff_t consumed_chars = 0; 4562 ptrdiff_t consumed_chars = 0;
4645 int found = 0; 4563 int found = 0;
4646 int c; 4564 int c;
@@ -4688,16 +4606,15 @@ detect_coding_sjis (struct coding_system *coding,
4688} 4606}
4689 4607
4690/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 4608/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
4691 Check if a text is encoded in BIG5. If it is, return 4609 Return true if a text is encoded in BIG5. */
4692 CATEGORY_MASK_BIG5, else return 0. */
4693 4610
4694static int 4611static bool
4695detect_coding_big5 (struct coding_system *coding, 4612detect_coding_big5 (struct coding_system *coding,
4696 struct coding_detection_info *detect_info) 4613 struct coding_detection_info *detect_info)
4697{ 4614{
4698 const unsigned char *src = coding->source, *src_base; 4615 const unsigned char *src = coding->source, *src_base;
4699 const unsigned char *src_end = coding->source + coding->src_bytes; 4616 const unsigned char *src_end = coding->source + coding->src_bytes;
4700 int multibytep = coding->src_multibyte; 4617 bool multibytep = coding->src_multibyte;
4701 ptrdiff_t consumed_chars = 0; 4618 ptrdiff_t consumed_chars = 0;
4702 int found = 0; 4619 int found = 0;
4703 int c; 4620 int c;
@@ -4735,8 +4652,7 @@ detect_coding_big5 (struct coding_system *coding,
4735 return 1; 4652 return 1;
4736} 4653}
4737 4654
4738/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". 4655/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */
4739 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */
4740 4656
4741static void 4657static void
4742decode_coding_sjis (struct coding_system *coding) 4658decode_coding_sjis (struct coding_system *coding)
@@ -4750,15 +4666,15 @@ decode_coding_sjis (struct coding_system *coding)
4750 int *charbuf_end 4666 int *charbuf_end
4751 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 4667 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
4752 ptrdiff_t consumed_chars = 0, consumed_chars_base; 4668 ptrdiff_t consumed_chars = 0, consumed_chars_base;
4753 int multibytep = coding->src_multibyte; 4669 bool multibytep = coding->src_multibyte;
4754 struct charset *charset_roman, *charset_kanji, *charset_kana; 4670 struct charset *charset_roman, *charset_kanji, *charset_kana;
4755 struct charset *charset_kanji2; 4671 struct charset *charset_kanji2;
4756 Lisp_Object attrs, charset_list, val; 4672 Lisp_Object attrs, charset_list, val;
4757 ptrdiff_t char_offset = coding->produced_char; 4673 ptrdiff_t char_offset = coding->produced_char;
4758 ptrdiff_t last_offset = char_offset; 4674 ptrdiff_t last_offset = char_offset;
4759 int last_id = charset_ascii; 4675 int last_id = charset_ascii;
4760 int eol_dos = 4676 bool eol_dos
4761 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 4677 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
4762 int byte_after_cr = -1; 4678 int byte_after_cr = -1;
4763 4679
4764 CODING_GET_INFO (coding, attrs, charset_list); 4680 CODING_GET_INFO (coding, attrs, charset_list);
@@ -4868,14 +4784,14 @@ decode_coding_big5 (struct coding_system *coding)
4868 int *charbuf_end 4784 int *charbuf_end
4869 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 4785 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
4870 ptrdiff_t consumed_chars = 0, consumed_chars_base; 4786 ptrdiff_t consumed_chars = 0, consumed_chars_base;
4871 int multibytep = coding->src_multibyte; 4787 bool multibytep = coding->src_multibyte;
4872 struct charset *charset_roman, *charset_big5; 4788 struct charset *charset_roman, *charset_big5;
4873 Lisp_Object attrs, charset_list, val; 4789 Lisp_Object attrs, charset_list, val;
4874 ptrdiff_t char_offset = coding->produced_char; 4790 ptrdiff_t char_offset = coding->produced_char;
4875 ptrdiff_t last_offset = char_offset; 4791 ptrdiff_t last_offset = char_offset;
4876 int last_id = charset_ascii; 4792 int last_id = charset_ascii;
4877 int eol_dos = 4793 bool eol_dos
4878 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 4794 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
4879 int byte_after_cr = -1; 4795 int byte_after_cr = -1;
4880 4796
4881 CODING_GET_INFO (coding, attrs, charset_list); 4797 CODING_GET_INFO (coding, attrs, charset_list);
@@ -4957,13 +4873,12 @@ decode_coding_big5 (struct coding_system *coding)
4957 `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We 4873 `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We
4958 are sure that all these charsets are registered as official charset 4874 are sure that all these charsets are registered as official charset
4959 (i.e. do not have extended leading-codes). Characters of other 4875 (i.e. do not have extended leading-codes). Characters of other
4960 charsets are produced without any encoding. If SJIS_P is 1, encode 4876 charsets are produced without any encoding. */
4961 SJIS text, else encode BIG5 text. */
4962 4877
4963static int 4878static bool
4964encode_coding_sjis (struct coding_system *coding) 4879encode_coding_sjis (struct coding_system *coding)
4965{ 4880{
4966 int multibytep = coding->dst_multibyte; 4881 bool multibytep = coding->dst_multibyte;
4967 int *charbuf = coding->charbuf; 4882 int *charbuf = coding->charbuf;
4968 int *charbuf_end = charbuf + coding->charbuf_used; 4883 int *charbuf_end = charbuf + coding->charbuf_used;
4969 unsigned char *dst = coding->destination + coding->produced; 4884 unsigned char *dst = coding->destination + coding->produced;
@@ -4971,7 +4886,7 @@ encode_coding_sjis (struct coding_system *coding)
4971 int safe_room = 4; 4886 int safe_room = 4;
4972 ptrdiff_t produced_chars = 0; 4887 ptrdiff_t produced_chars = 0;
4973 Lisp_Object attrs, charset_list, val; 4888 Lisp_Object attrs, charset_list, val;
4974 int ascii_compatible; 4889 bool ascii_compatible;
4975 struct charset *charset_kanji, *charset_kana; 4890 struct charset *charset_kanji, *charset_kana;
4976 struct charset *charset_kanji2; 4891 struct charset *charset_kanji2;
4977 int c; 4892 int c;
@@ -5054,10 +4969,10 @@ encode_coding_sjis (struct coding_system *coding)
5054 return 0; 4969 return 0;
5055} 4970}
5056 4971
5057static int 4972static bool
5058encode_coding_big5 (struct coding_system *coding) 4973encode_coding_big5 (struct coding_system *coding)
5059{ 4974{
5060 int multibytep = coding->dst_multibyte; 4975 bool multibytep = coding->dst_multibyte;
5061 int *charbuf = coding->charbuf; 4976 int *charbuf = coding->charbuf;
5062 int *charbuf_end = charbuf + coding->charbuf_used; 4977 int *charbuf_end = charbuf + coding->charbuf_used;
5063 unsigned char *dst = coding->destination + coding->produced; 4978 unsigned char *dst = coding->destination + coding->produced;
@@ -5065,7 +4980,7 @@ encode_coding_big5 (struct coding_system *coding)
5065 int safe_room = 4; 4980 int safe_room = 4;
5066 ptrdiff_t produced_chars = 0; 4981 ptrdiff_t produced_chars = 0;
5067 Lisp_Object attrs, charset_list, val; 4982 Lisp_Object attrs, charset_list, val;
5068 int ascii_compatible; 4983 bool ascii_compatible;
5069 struct charset *charset_big5; 4984 struct charset *charset_big5;
5070 int c; 4985 int c;
5071 4986
@@ -5130,17 +5045,16 @@ encode_coding_big5 (struct coding_system *coding)
5130/*** 10. CCL handlers ***/ 5045/*** 10. CCL handlers ***/
5131 5046
5132/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 5047/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
5133 Check if a text is encoded in a coding system of which 5048 Return true if a text is encoded in a coding system of which
5134 encoder/decoder are written in CCL program. If it is, return 5049 encoder/decoder are written in CCL program. */
5135 CATEGORY_MASK_CCL, else return 0. */
5136 5050
5137static int 5051static bool
5138detect_coding_ccl (struct coding_system *coding, 5052detect_coding_ccl (struct coding_system *coding,
5139 struct coding_detection_info *detect_info) 5053 struct coding_detection_info *detect_info)
5140{ 5054{
5141 const unsigned char *src = coding->source, *src_base; 5055 const unsigned char *src = coding->source, *src_base;
5142 const unsigned char *src_end = coding->source + coding->src_bytes; 5056 const unsigned char *src_end = coding->source + coding->src_bytes;
5143 int multibytep = coding->src_multibyte; 5057 bool multibytep = coding->src_multibyte;
5144 ptrdiff_t consumed_chars = 0; 5058 ptrdiff_t consumed_chars = 0;
5145 int found = 0; 5059 int found = 0;
5146 unsigned char *valids; 5060 unsigned char *valids;
@@ -5182,7 +5096,7 @@ decode_coding_ccl (struct coding_system *coding)
5182 int *charbuf = coding->charbuf + coding->charbuf_used; 5096 int *charbuf = coding->charbuf + coding->charbuf_used;
5183 int *charbuf_end = coding->charbuf + coding->charbuf_size; 5097 int *charbuf_end = coding->charbuf + coding->charbuf_size;
5184 ptrdiff_t consumed_chars = 0; 5098 ptrdiff_t consumed_chars = 0;
5185 int multibytep = coding->src_multibyte; 5099 bool multibytep = coding->src_multibyte;
5186 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5100 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5187 int source_charbuf[1024]; 5101 int source_charbuf[1024];
5188 int source_byteidx[1025]; 5102 int source_byteidx[1025];
@@ -5243,11 +5157,11 @@ decode_coding_ccl (struct coding_system *coding)
5243 coding->charbuf_used = charbuf - coding->charbuf; 5157 coding->charbuf_used = charbuf - coding->charbuf;
5244} 5158}
5245 5159
5246static int 5160static bool
5247encode_coding_ccl (struct coding_system *coding) 5161encode_coding_ccl (struct coding_system *coding)
5248{ 5162{
5249 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5163 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5250 int multibytep = coding->dst_multibyte; 5164 bool multibytep = coding->dst_multibyte;
5251 int *charbuf = coding->charbuf; 5165 int *charbuf = coding->charbuf;
5252 int *charbuf_end = charbuf + coding->charbuf_used; 5166 int *charbuf_end = charbuf + coding->charbuf_used;
5253 unsigned char *dst = coding->destination + coding->produced; 5167 unsigned char *dst = coding->destination + coding->produced;
@@ -5308,7 +5222,6 @@ encode_coding_ccl (struct coding_system *coding)
5308 return 0; 5222 return 0;
5309} 5223}
5310 5224
5311
5312 5225
5313/*** 10, 11. no-conversion handlers ***/ 5226/*** 10, 11. no-conversion handlers ***/
5314 5227
@@ -5317,8 +5230,8 @@ encode_coding_ccl (struct coding_system *coding)
5317static void 5230static void
5318decode_coding_raw_text (struct coding_system *coding) 5231decode_coding_raw_text (struct coding_system *coding)
5319{ 5232{
5320 int eol_dos = 5233 bool eol_dos
5321 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5234 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
5322 5235
5323 coding->chars_at_source = 1; 5236 coding->chars_at_source = 1;
5324 coding->consumed_char = coding->src_chars; 5237 coding->consumed_char = coding->src_chars;
@@ -5333,10 +5246,10 @@ decode_coding_raw_text (struct coding_system *coding)
5333 record_conversion_result (coding, CODING_RESULT_SUCCESS); 5246 record_conversion_result (coding, CODING_RESULT_SUCCESS);
5334} 5247}
5335 5248
5336static int 5249static bool
5337encode_coding_raw_text (struct coding_system *coding) 5250encode_coding_raw_text (struct coding_system *coding)
5338{ 5251{
5339 int multibytep = coding->dst_multibyte; 5252 bool multibytep = coding->dst_multibyte;
5340 int *charbuf = coding->charbuf; 5253 int *charbuf = coding->charbuf;
5341 int *charbuf_end = coding->charbuf + coding->charbuf_used; 5254 int *charbuf_end = coding->charbuf + coding->charbuf_used;
5342 unsigned char *dst = coding->destination + coding->produced; 5255 unsigned char *dst = coding->destination + coding->produced;
@@ -5414,21 +5327,20 @@ encode_coding_raw_text (struct coding_system *coding)
5414} 5327}
5415 5328
5416/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 5329/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
5417 Check if a text is encoded in a charset-based coding system. If it 5330 Return true if a text is encoded in a charset-based coding system. */
5418 is, return 1, else return 0. */
5419 5331
5420static int 5332static bool
5421detect_coding_charset (struct coding_system *coding, 5333detect_coding_charset (struct coding_system *coding,
5422 struct coding_detection_info *detect_info) 5334 struct coding_detection_info *detect_info)
5423{ 5335{
5424 const unsigned char *src = coding->source, *src_base; 5336 const unsigned char *src = coding->source, *src_base;
5425 const unsigned char *src_end = coding->source + coding->src_bytes; 5337 const unsigned char *src_end = coding->source + coding->src_bytes;
5426 int multibytep = coding->src_multibyte; 5338 bool multibytep = coding->src_multibyte;
5427 ptrdiff_t consumed_chars = 0; 5339 ptrdiff_t consumed_chars = 0;
5428 Lisp_Object attrs, valids, name; 5340 Lisp_Object attrs, valids, name;
5429 int found = 0; 5341 int found = 0;
5430 ptrdiff_t head_ascii = coding->head_ascii; 5342 ptrdiff_t head_ascii = coding->head_ascii;
5431 int check_latin_extra = 0; 5343 bool check_latin_extra = 0;
5432 5344
5433 detect_info->checked |= CATEGORY_MASK_CHARSET; 5345 detect_info->checked |= CATEGORY_MASK_CHARSET;
5434 5346
@@ -5532,14 +5444,14 @@ decode_coding_charset (struct coding_system *coding)
5532 int *charbuf_end 5444 int *charbuf_end
5533 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 5445 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
5534 ptrdiff_t consumed_chars = 0, consumed_chars_base; 5446 ptrdiff_t consumed_chars = 0, consumed_chars_base;
5535 int multibytep = coding->src_multibyte; 5447 bool multibytep = coding->src_multibyte;
5536 Lisp_Object attrs = CODING_ID_ATTRS (coding->id); 5448 Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
5537 Lisp_Object valids; 5449 Lisp_Object valids;
5538 ptrdiff_t char_offset = coding->produced_char; 5450 ptrdiff_t char_offset = coding->produced_char;
5539 ptrdiff_t last_offset = char_offset; 5451 ptrdiff_t last_offset = char_offset;
5540 int last_id = charset_ascii; 5452 int last_id = charset_ascii;
5541 int eol_dos = 5453 bool eol_dos
5542 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5454 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
5543 int byte_after_cr = -1; 5455 int byte_after_cr = -1;
5544 5456
5545 valids = AREF (attrs, coding_attr_charset_valids); 5457 valids = AREF (attrs, coding_attr_charset_valids);
@@ -5648,10 +5560,10 @@ decode_coding_charset (struct coding_system *coding)
5648 coding->charbuf_used = charbuf - coding->charbuf; 5560 coding->charbuf_used = charbuf - coding->charbuf;
5649} 5561}
5650 5562
5651static int 5563static bool
5652encode_coding_charset (struct coding_system *coding) 5564encode_coding_charset (struct coding_system *coding)
5653{ 5565{
5654 int multibytep = coding->dst_multibyte; 5566 bool multibytep = coding->dst_multibyte;
5655 int *charbuf = coding->charbuf; 5567 int *charbuf = coding->charbuf;
5656 int *charbuf_end = charbuf + coding->charbuf_used; 5568 int *charbuf_end = charbuf + coding->charbuf_used;
5657 unsigned char *dst = coding->destination + coding->produced; 5569 unsigned char *dst = coding->destination + coding->produced;
@@ -5659,7 +5571,7 @@ encode_coding_charset (struct coding_system *coding)
5659 int safe_room = MAX_MULTIBYTE_LENGTH; 5571 int safe_room = MAX_MULTIBYTE_LENGTH;
5660 ptrdiff_t produced_chars = 0; 5572 ptrdiff_t produced_chars = 0;
5661 Lisp_Object attrs, charset_list; 5573 Lisp_Object attrs, charset_list;
5662 int ascii_compatible; 5574 bool ascii_compatible;
5663 int c; 5575 int c;
5664 5576
5665 CODING_GET_INFO (coding, attrs, charset_list); 5577 CODING_GET_INFO (coding, attrs, charset_list);
@@ -5865,7 +5777,6 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
5865 coding->encoder = encode_coding_emacs_mule; 5777 coding->encoder = encode_coding_emacs_mule;
5866 coding->common_flags 5778 coding->common_flags
5867 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); 5779 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK);
5868 coding->spec.emacs_mule.full_support = 1;
5869 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) 5780 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full))
5870 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) 5781 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list))
5871 { 5782 {
@@ -5883,7 +5794,6 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
5883 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); 5794 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0);
5884 coding->max_charset_id = max_charset_id; 5795 coding->max_charset_id = max_charset_id;
5885 coding->safe_charsets = SDATA (safe_charsets); 5796 coding->safe_charsets = SDATA (safe_charsets);
5886 coding->spec.emacs_mule.full_support = 1;
5887 } 5797 }
5888 coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO; 5798 coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO;
5889 coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO; 5799 coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO;
@@ -6216,11 +6126,9 @@ detect_eol (const unsigned char *source, ptrdiff_t src_bytes,
6216 6126
6217 if ((1 << category) & CATEGORY_MASK_UTF_16) 6127 if ((1 << category) & CATEGORY_MASK_UTF_16)
6218 { 6128 {
6219 int msb, lsb; 6129 bool msb = category == (coding_category_utf_16_le
6220 6130 | coding_category_utf_16_le_nosig);
6221 msb = category == (coding_category_utf_16_le 6131 bool lsb = !msb;
6222 | coding_category_utf_16_le_nosig);
6223 lsb = 1 - msb;
6224 6132
6225 while (src + 1 < src_end) 6133 while (src + 1 < src_end)
6226 { 6134 {
@@ -6335,7 +6243,7 @@ static void
6335detect_coding (struct coding_system *coding) 6243detect_coding (struct coding_system *coding)
6336{ 6244{
6337 const unsigned char *src, *src_end; 6245 const unsigned char *src, *src_end;
6338 int saved_mode = coding->mode; 6246 unsigned int saved_mode = coding->mode;
6339 6247
6340 coding->consumed = coding->consumed_char = 0; 6248 coding->consumed = coding->consumed_char = 0;
6341 coding->produced = coding->produced_char = 0; 6249 coding->produced = coding->produced_char = 0;
@@ -6350,7 +6258,7 @@ detect_coding (struct coding_system *coding)
6350 { 6258 {
6351 int c, i; 6259 int c, i;
6352 struct coding_detection_info detect_info; 6260 struct coding_detection_info detect_info;
6353 int null_byte_found = 0, eight_bit_found = 0; 6261 bool null_byte_found = 0, eight_bit_found = 0;
6354 6262
6355 detect_info.checked = detect_info.found = detect_info.rejected = 0; 6263 detect_info.checked = detect_info.found = detect_info.rejected = 0;
6356 for (src = coding->source; src < src_end; src++) 6264 for (src = coding->source; src < src_end; src++)
@@ -6609,11 +6517,11 @@ decode_eol (struct coding_system *coding)
6609 6517
6610 6518
6611/* Return a translation table (or list of them) from coding system 6519/* Return a translation table (or list of them) from coding system
6612 attribute vector ATTRS for encoding (ENCODEP is nonzero) or 6520 attribute vector ATTRS for encoding (if ENCODEP) or decoding (if
6613 decoding (ENCODEP is zero). */ 6521 not ENCODEP). */
6614 6522
6615static Lisp_Object 6523static Lisp_Object
6616get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) 6524get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup)
6617{ 6525{
6618 Lisp_Object standard, translation_table; 6526 Lisp_Object standard, translation_table;
6619 Lisp_Object val; 6527 Lisp_Object val;
@@ -6743,7 +6651,7 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end)
6743 6651
6744static int 6652static int
6745produce_chars (struct coding_system *coding, Lisp_Object translation_table, 6653produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6746 int last_block) 6654 bool last_block)
6747{ 6655{
6748 unsigned char *dst = coding->destination + coding->produced; 6656 unsigned char *dst = coding->destination + coding->produced;
6749 unsigned char *dst_end = coding->destination + coding->dst_bytes; 6657 unsigned char *dst_end = coding->destination + coding->dst_bytes;
@@ -6846,7 +6754,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6846 { 6754 {
6847 if (coding->src_multibyte) 6755 if (coding->src_multibyte)
6848 { 6756 {
6849 int multibytep = 1; 6757 bool multibytep = 1;
6850 ptrdiff_t consumed_chars = 0; 6758 ptrdiff_t consumed_chars = 0;
6851 6759
6852 while (1) 6760 while (1)
@@ -6882,7 +6790,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6882 else 6790 else
6883 while (src < src_end) 6791 while (src < src_end)
6884 { 6792 {
6885 int multibytep = 1; 6793 bool multibytep = 1;
6886 int c = *src++; 6794 int c = *src++;
6887 6795
6888 if (dst >= dst_end - 1) 6796 if (dst >= dst_end - 1)
@@ -7018,7 +6926,7 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
7018 if (! coding->charbuf) \ 6926 if (! coding->charbuf) \
7019 { \ 6927 { \
7020 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ 6928 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \
7021 return coding->result; \ 6929 return; \
7022 } \ 6930 } \
7023 coding->charbuf_size = size; \ 6931 coding->charbuf_size = size; \
7024 } while (0) 6932 } while (0)
@@ -7079,7 +6987,7 @@ produce_annotation (struct coding_system *coding, ptrdiff_t pos)
7079 CODING->dst_object. 6987 CODING->dst_object.
7080*/ 6988*/
7081 6989
7082static int 6990static void
7083decode_coding (struct coding_system *coding) 6991decode_coding (struct coding_system *coding)
7084{ 6992{
7085 Lisp_Object attrs; 6993 Lisp_Object attrs;
@@ -7098,8 +7006,7 @@ decode_coding (struct coding_system *coding)
7098 undo_list = Qt; 7006 undo_list = Qt;
7099 if (BUFFERP (coding->dst_object)) 7007 if (BUFFERP (coding->dst_object))
7100 { 7008 {
7101 if (current_buffer != XBUFFER (coding->dst_object)) 7009 set_buffer_internal (XBUFFER (coding->dst_object));
7102 set_buffer_internal (XBUFFER (coding->dst_object));
7103 if (GPT != PT) 7010 if (GPT != PT)
7104 move_gap_both (PT, PT_BYTE); 7011 move_gap_both (PT, PT_BYTE);
7105 7012
@@ -7212,7 +7119,6 @@ decode_coding (struct coding_system *coding)
7212 bset_undo_list (current_buffer, undo_list); 7119 bset_undo_list (current_buffer, undo_list);
7213 record_insert (coding->dst_pos, coding->produced_char); 7120 record_insert (coding->dst_pos, coding->produced_char);
7214 } 7121 }
7215 return coding->result;
7216} 7122}
7217 7123
7218 7124
@@ -7341,7 +7247,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7341 const unsigned char *src_end = coding->source + coding->src_bytes; 7247 const unsigned char *src_end = coding->source + coding->src_bytes;
7342 ptrdiff_t pos = coding->src_pos + coding->consumed_char; 7248 ptrdiff_t pos = coding->src_pos + coding->consumed_char;
7343 ptrdiff_t end_pos = coding->src_pos + coding->src_chars; 7249 ptrdiff_t end_pos = coding->src_pos + coding->src_chars;
7344 int multibytep = coding->src_multibyte; 7250 bool multibytep = coding->src_multibyte;
7345 Lisp_Object eol_type; 7251 Lisp_Object eol_type;
7346 int c; 7252 int c;
7347 ptrdiff_t stop, stop_composition, stop_charset; 7253 ptrdiff_t stop, stop_composition, stop_charset;
@@ -7488,7 +7394,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7488 If CODING->dst_object is nil, the encoded data is placed at the 7394 If CODING->dst_object is nil, the encoded data is placed at the
7489 memory area specified by CODING->destination. */ 7395 memory area specified by CODING->destination. */
7490 7396
7491static int 7397static void
7492encode_coding (struct coding_system *coding) 7398encode_coding (struct coding_system *coding)
7493{ 7399{
7494 Lisp_Object attrs; 7400 Lisp_Object attrs;
@@ -7530,8 +7436,6 @@ encode_coding (struct coding_system *coding)
7530 7436
7531 if (BUFFERP (coding->dst_object) && coding->produced_char > 0) 7437 if (BUFFERP (coding->dst_object) && coding->produced_char > 0)
7532 insert_from_gap (coding->produced_char, coding->produced); 7438 insert_from_gap (coding->produced_char, coding->produced);
7533
7534 return (coding->result);
7535} 7439}
7536 7440
7537 7441
@@ -7545,26 +7449,27 @@ static Lisp_Object Vcode_conversion_workbuf_name;
7545 versions of Vcode_conversion_workbuf_name. */ 7449 versions of Vcode_conversion_workbuf_name. */
7546static Lisp_Object Vcode_conversion_reused_workbuf; 7450static Lisp_Object Vcode_conversion_reused_workbuf;
7547 7451
7548/* 1 iff Vcode_conversion_reused_workbuf is already in use. */ 7452/* True iff Vcode_conversion_reused_workbuf is already in use. */
7549static int reused_workbuf_in_use; 7453static bool reused_workbuf_in_use;
7550 7454
7551 7455
7552/* Return a working buffer of code conversion. MULTIBYTE specifies the 7456/* Return a working buffer of code conversion. MULTIBYTE specifies the
7553 multibyteness of returning buffer. */ 7457 multibyteness of returning buffer. */
7554 7458
7555static Lisp_Object 7459static Lisp_Object
7556make_conversion_work_buffer (int multibyte) 7460make_conversion_work_buffer (bool multibyte)
7557{ 7461{
7558 Lisp_Object name, workbuf; 7462 Lisp_Object name, workbuf;
7559 struct buffer *current; 7463 struct buffer *current;
7560 7464
7561 if (reused_workbuf_in_use++) 7465 if (reused_workbuf_in_use)
7562 { 7466 {
7563 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); 7467 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
7564 workbuf = Fget_buffer_create (name); 7468 workbuf = Fget_buffer_create (name);
7565 } 7469 }
7566 else 7470 else
7567 { 7471 {
7472 reused_workbuf_in_use = 1;
7568 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) 7473 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf)))
7569 Vcode_conversion_reused_workbuf 7474 Vcode_conversion_reused_workbuf
7570 = Fget_buffer_create (Vcode_conversion_workbuf_name); 7475 = Fget_buffer_create (Vcode_conversion_workbuf_name);
@@ -7606,7 +7511,7 @@ code_conversion_restore (Lisp_Object arg)
7606} 7511}
7607 7512
7608Lisp_Object 7513Lisp_Object
7609code_conversion_save (int with_work_buf, int multibyte) 7514code_conversion_save (bool with_work_buf, bool multibyte)
7610{ 7515{
7611 Lisp_Object workbuf = Qnil; 7516 Lisp_Object workbuf = Qnil;
7612 7517
@@ -7617,7 +7522,7 @@ code_conversion_save (int with_work_buf, int multibyte)
7617 return workbuf; 7522 return workbuf;
7618} 7523}
7619 7524
7620int 7525void
7621decode_coding_gap (struct coding_system *coding, 7526decode_coding_gap (struct coding_system *coding,
7622 ptrdiff_t chars, ptrdiff_t bytes) 7527 ptrdiff_t chars, ptrdiff_t bytes)
7623{ 7528{
@@ -7660,7 +7565,6 @@ decode_coding_gap (struct coding_system *coding,
7660 } 7565 }
7661 7566
7662 unbind_to (count, Qnil); 7567 unbind_to (count, Qnil);
7663 return coding->result;
7664} 7568}
7665 7569
7666 7570
@@ -7706,8 +7610,8 @@ decode_coding_object (struct coding_system *coding,
7706 ptrdiff_t chars = to - from; 7610 ptrdiff_t chars = to - from;
7707 ptrdiff_t bytes = to_byte - from_byte; 7611 ptrdiff_t bytes = to_byte - from_byte;
7708 Lisp_Object attrs; 7612 Lisp_Object attrs;
7709 int saved_pt = -1, saved_pt_byte IF_LINT (= 0); 7613 ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
7710 int need_marker_adjustment = 0; 7614 bool need_marker_adjustment = 0;
7711 Lisp_Object old_deactivate_mark; 7615 Lisp_Object old_deactivate_mark;
7712 7616
7713 old_deactivate_mark = Vdeactivate_mark; 7617 old_deactivate_mark = Vdeactivate_mark;
@@ -7894,9 +7798,9 @@ encode_coding_object (struct coding_system *coding,
7894 ptrdiff_t chars = to - from; 7798 ptrdiff_t chars = to - from;
7895 ptrdiff_t bytes = to_byte - from_byte; 7799 ptrdiff_t bytes = to_byte - from_byte;
7896 Lisp_Object attrs; 7800 Lisp_Object attrs;
7897 int saved_pt = -1, saved_pt_byte IF_LINT (= 0); 7801 ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
7898 int need_marker_adjustment = 0; 7802 bool need_marker_adjustment = 0;
7899 int kill_src_buffer = 0; 7803 bool kill_src_buffer = 0;
7900 Lisp_Object old_deactivate_mark; 7804 Lisp_Object old_deactivate_mark;
7901 7805
7902 old_deactivate_mark = Vdeactivate_mark; 7806 old_deactivate_mark = Vdeactivate_mark;
@@ -8172,10 +8076,10 @@ function `define-coding-system'. */)
8172 8076
8173 8077
8174/* Detect how the bytes at SRC of length SRC_BYTES are encoded. If 8078/* Detect how the bytes at SRC of length SRC_BYTES are encoded. If
8175 HIGHEST is nonzero, return the coding system of the highest 8079 HIGHEST, return the coding system of the highest
8176 priority among the detected coding systems. Otherwise return a 8080 priority among the detected coding systems. Otherwise return a
8177 list of detected coding systems sorted by their priorities. If 8081 list of detected coding systems sorted by their priorities. If
8178 MULTIBYTEP is nonzero, it is assumed that the bytes are in correct 8082 MULTIBYTEP, it is assumed that the bytes are in correct
8179 multibyte form but contains only ASCII and eight-bit chars. 8083 multibyte form but contains only ASCII and eight-bit chars.
8180 Otherwise, the bytes are raw bytes. 8084 Otherwise, the bytes are raw bytes.
8181 8085
@@ -8190,7 +8094,7 @@ function `define-coding-system'. */)
8190Lisp_Object 8094Lisp_Object
8191detect_coding_system (const unsigned char *src, 8095detect_coding_system (const unsigned char *src,
8192 ptrdiff_t src_chars, ptrdiff_t src_bytes, 8096 ptrdiff_t src_chars, ptrdiff_t src_bytes,
8193 int highest, int multibytep, 8097 bool highest, bool multibytep,
8194 Lisp_Object coding_system) 8098 Lisp_Object coding_system)
8195{ 8099{
8196 const unsigned char *src_end = src + src_bytes; 8100 const unsigned char *src_end = src + src_bytes;
@@ -8200,7 +8104,7 @@ detect_coding_system (const unsigned char *src,
8200 ptrdiff_t id; 8104 ptrdiff_t id;
8201 struct coding_detection_info detect_info; 8105 struct coding_detection_info detect_info;
8202 enum coding_category base_category; 8106 enum coding_category base_category;
8203 int null_byte_found = 0, eight_bit_found = 0; 8107 bool null_byte_found = 0, eight_bit_found = 0;
8204 8108
8205 if (NILP (coding_system)) 8109 if (NILP (coding_system))
8206 coding_system = Qundecided; 8110 coding_system = Qundecided;
@@ -8556,7 +8460,7 @@ highest priority. */)
8556} 8460}
8557 8461
8558 8462
8559static inline int 8463static inline bool
8560char_encodable_p (int c, Lisp_Object attrs) 8464char_encodable_p (int c, Lisp_Object attrs)
8561{ 8465{
8562 Lisp_Object tail; 8466 Lisp_Object tail;
@@ -8728,7 +8632,7 @@ to the string. */)
8728 Lisp_Object positions; 8632 Lisp_Object positions;
8729 ptrdiff_t from, to; 8633 ptrdiff_t from, to;
8730 const unsigned char *p, *stop, *pend; 8634 const unsigned char *p, *stop, *pend;
8731 int ascii_compatible; 8635 bool ascii_compatible;
8732 8636
8733 setup_coding_system (Fcheck_coding_system (coding_system), &coding); 8637 setup_coding_system (Fcheck_coding_system (coding_system), &coding);
8734 attrs = CODING_ID_ATTRS (coding.id); 8638 attrs = CODING_ID_ATTRS (coding.id);
@@ -8952,7 +8856,7 @@ is nil. */)
8952static Lisp_Object 8856static Lisp_Object
8953code_convert_region (Lisp_Object start, Lisp_Object end, 8857code_convert_region (Lisp_Object start, Lisp_Object end,
8954 Lisp_Object coding_system, Lisp_Object dst_object, 8858 Lisp_Object coding_system, Lisp_Object dst_object,
8955 int encodep, int norecord) 8859 bool encodep, bool norecord)
8956{ 8860{
8957 struct coding_system coding; 8861 struct coding_system coding;
8958 ptrdiff_t from, from_byte, to, to_byte; 8862 ptrdiff_t from, from_byte, to, to_byte;
@@ -9040,7 +8944,8 @@ not fully specified.) */)
9040 8944
9041Lisp_Object 8945Lisp_Object
9042code_convert_string (Lisp_Object string, Lisp_Object coding_system, 8946code_convert_string (Lisp_Object string, Lisp_Object coding_system,
9043 Lisp_Object dst_object, int encodep, int nocopy, int norecord) 8947 Lisp_Object dst_object, bool encodep, bool nocopy,
8948 bool norecord)
9044{ 8949{
9045 struct coding_system coding; 8950 struct coding_system coding;
9046 ptrdiff_t chars, bytes; 8951 ptrdiff_t chars, bytes;
@@ -9088,7 +8993,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
9088 8993
9089Lisp_Object 8994Lisp_Object
9090code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, 8995code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
9091 int encodep) 8996 bool encodep)
9092{ 8997{
9093 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); 8998 return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
9094} 8999}
@@ -9489,7 +9394,7 @@ usage: (set-coding-system-priority &rest coding-systems) */)
9489 (ptrdiff_t nargs, Lisp_Object *args) 9394 (ptrdiff_t nargs, Lisp_Object *args)
9490{ 9395{
9491 ptrdiff_t i, j; 9396 ptrdiff_t i, j;
9492 int changed[coding_category_max]; 9397 bool changed[coding_category_max];
9493 enum coding_category priorities[coding_category_max]; 9398 enum coding_category priorities[coding_category_max];
9494 9399
9495 memset (changed, 0, sizeof changed); 9400 memset (changed, 0, sizeof changed);
diff --git a/src/coding.h b/src/coding.h
index 2987f19607b..c45d2ef86e2 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -321,7 +321,7 @@ struct composition_status
321{ 321{
322 enum composition_state state; 322 enum composition_state state;
323 enum composition_method method; 323 enum composition_method method;
324 int old_form; /* 0:pre-21 form, 1:post-21 form */ 324 bool old_form; /* true if pre-21 form */
325 int length; /* number of elements produced in charbuf */ 325 int length; /* number of elements produced in charbuf */
326 int nchars; /* number of characters composed */ 326 int nchars; /* number of characters composed */
327 int ncomps; /* number of composition components */ 327 int ncomps; /* number of composition components */
@@ -350,18 +350,18 @@ struct iso_2022_spec
350 there was an invalid designation previously. */ 350 there was an invalid designation previously. */
351 int current_designation[4]; 351 int current_designation[4];
352 352
353 /* Set to 1 temporarily only when graphic register 2 or 3 is invoked
354 by single-shift while encoding. */
355 int single_shifting;
356
357 /* Set to 1 temporarily only when processing at beginning of line. */
358 int bol;
359
360 /* If positive, we are now scanning CTEXT extended segment. */ 353 /* If positive, we are now scanning CTEXT extended segment. */
361 int ctext_extended_segment_len; 354 int ctext_extended_segment_len;
362 355
363 /* If nonzero, we are now scanning embedded UTF-8 sequence. */ 356 /* True temporarily only when graphic register 2 or 3 is invoked by
364 int embedded_utf_8; 357 single-shift while encoding. */
358 unsigned single_shifting : 1;
359
360 /* True temporarily only when processing at beginning of line. */
361 unsigned bol : 1;
362
363 /* If true, we are now scanning embedded UTF-8 sequence. */
364 unsigned embedded_utf_8 : 1;
365 365
366 /* The current composition. */ 366 /* The current composition. */
367 struct composition_status cmp_status; 367 struct composition_status cmp_status;
@@ -369,7 +369,6 @@ struct iso_2022_spec
369 369
370struct emacs_mule_spec 370struct emacs_mule_spec
371{ 371{
372 int full_support;
373 struct composition_status cmp_status; 372 struct composition_status cmp_status;
374}; 373};
375 374
@@ -470,10 +469,6 @@ struct coding_system
470 Lisp_Object dst_object; 469 Lisp_Object dst_object;
471 unsigned char *destination; 470 unsigned char *destination;
472 471
473 /* Set to 1 if the source of conversion is not in the member
474 `charbuf', but at `src_object'. */
475 int chars_at_source;
476
477 /* If an element is non-negative, it is a character code. 472 /* If an element is non-negative, it is a character code.
478 473
479 If it is in the range -128..-1, it is a 8-bit character code 474 If it is in the range -128..-1, it is a 8-bit character code
@@ -489,18 +484,21 @@ struct coding_system
489 int *charbuf; 484 int *charbuf;
490 int charbuf_size, charbuf_used; 485 int charbuf_size, charbuf_used;
491 486
487 /* True if the source of conversion is not in the member
488 `charbuf', but at `src_object'. */
489 unsigned chars_at_source : 1;
490
492 /* Set to 1 if charbuf contains an annotation. */ 491 /* Set to 1 if charbuf contains an annotation. */
493 int annotated; 492 unsigned annotated : 1;
494 493
495 unsigned char carryover[64]; 494 unsigned char carryover[64];
496 int carryover_bytes; 495 int carryover_bytes;
497 496
498 int default_char; 497 int default_char;
499 498
500 int (*detector) (struct coding_system *, 499 bool (*detector) (struct coding_system *, struct coding_detection_info *);
501 struct coding_detection_info *);
502 void (*decoder) (struct coding_system *); 500 void (*decoder) (struct coding_system *);
503 int (*encoder) (struct coding_system *); 501 bool (*encoder) (struct coding_system *);
504}; 502};
505 503
506/* Meanings of bits in the member `common_flags' of the structure 504/* Meanings of bits in the member `common_flags' of the structure
@@ -688,22 +686,20 @@ struct coding_system
688#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) 686#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
689 687
690/* Extern declarations. */ 688/* Extern declarations. */
691extern Lisp_Object code_conversion_save (int, int); 689extern Lisp_Object code_conversion_save (bool, bool);
692extern int decoding_buffer_size (struct coding_system *, int);
693extern int encoding_buffer_size (struct coding_system *, int);
694extern void setup_coding_system (Lisp_Object, struct coding_system *); 690extern void setup_coding_system (Lisp_Object, struct coding_system *);
695extern Lisp_Object coding_charset_list (struct coding_system *); 691extern Lisp_Object coding_charset_list (struct coding_system *);
696extern Lisp_Object coding_system_charset_list (Lisp_Object); 692extern Lisp_Object coding_system_charset_list (Lisp_Object);
697extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, 693extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object,
698 Lisp_Object, int, int, int); 694 Lisp_Object, bool, bool, bool);
699extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, 695extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object,
700 int); 696 bool);
701extern Lisp_Object raw_text_coding_system (Lisp_Object); 697extern Lisp_Object raw_text_coding_system (Lisp_Object);
702extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); 698extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object);
703extern Lisp_Object complement_process_encoding_system (Lisp_Object); 699extern Lisp_Object complement_process_encoding_system (Lisp_Object);
704 700
705extern int decode_coding_gap (struct coding_system *, 701extern void decode_coding_gap (struct coding_system *,
706 ptrdiff_t, ptrdiff_t); 702 ptrdiff_t, ptrdiff_t);
707extern void decode_coding_object (struct coding_system *, 703extern void decode_coding_object (struct coding_system *,
708 Lisp_Object, ptrdiff_t, ptrdiff_t, 704 Lisp_Object, ptrdiff_t, ptrdiff_t,
709 ptrdiff_t, ptrdiff_t, Lisp_Object); 705 ptrdiff_t, ptrdiff_t, Lisp_Object);
@@ -778,6 +774,5 @@ extern struct coding_system safe_terminal_coding;
778extern Lisp_Object Qcoding_system_error; 774extern Lisp_Object Qcoding_system_error;
779 775
780extern char emacs_mule_bytes[256]; 776extern char emacs_mule_bytes[256];
781extern int emacs_mule_string_char (unsigned char *);
782 777
783#endif /* EMACS_CODING_H */ 778#endif /* EMACS_CODING_H */
diff --git a/src/composite.c b/src/composite.c
index 4e90e9bb914..eddabb66d33 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -428,7 +428,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
428 428
429 This doesn't check the validity of composition. */ 429 This doesn't check the validity of composition. */
430 430
431int 431bool
432find_composition (ptrdiff_t pos, ptrdiff_t limit, 432find_composition (ptrdiff_t pos, ptrdiff_t limit,
433 ptrdiff_t *start, ptrdiff_t *end, 433 ptrdiff_t *start, ptrdiff_t *end,
434 Lisp_Object *prop, Lisp_Object object) 434 Lisp_Object *prop, Lisp_Object object)
@@ -709,7 +709,7 @@ static Lisp_Object fill_gstring_header (Lisp_Object, Lisp_Object,
709 Lisp_Object, Lisp_Object, 709 Lisp_Object, Lisp_Object,
710 Lisp_Object); 710 Lisp_Object);
711 711
712int 712bool
713composition_gstring_p (Lisp_Object gstring) 713composition_gstring_p (Lisp_Object gstring)
714{ 714{
715 Lisp_Object header; 715 Lisp_Object header;
@@ -1212,11 +1212,13 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
1212 string. In that case, FACE must not be NULL. 1212 string. In that case, FACE must not be NULL.
1213 1213
1214 If the character is composed, setup members of CMP_IT (id, nglyphs, 1214 If the character is composed, setup members of CMP_IT (id, nglyphs,
1215 from, to, reversed_p), and return 1. Otherwise, update 1215 from, to, reversed_p), and return true. Otherwise, update
1216 CMP_IT->stop_pos, and return 0. */ 1216 CMP_IT->stop_pos, and return false. */
1217 1217
1218int 1218bool
1219composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, struct face *face, Lisp_Object string) 1219composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos,
1220 ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w,
1221 struct face *face, Lisp_Object string)
1220{ 1222{
1221 if (endpos < 0) 1223 if (endpos < 0)
1222 endpos = NILP (string) ? BEGV : 0; 1224 endpos = NILP (string) ? BEGV : 0;
@@ -1482,10 +1484,10 @@ struct position_record
1482/* This is like find_composition, but find an automatic composition 1484/* This is like find_composition, but find an automatic composition
1483 instead. It is assured that POS is not within a static 1485 instead. It is assured that POS is not within a static
1484 composition. If found, set *GSTRING to the glyph-string 1486 composition. If found, set *GSTRING to the glyph-string
1485 representing the composition, and return 1. Otherwise, *GSTRING to 1487 representing the composition, and return true. Otherwise, *GSTRING to
1486 Qnil, and return 0. */ 1488 Qnil, and return false. */
1487 1489
1488static int 1490static bool
1489find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, 1491find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
1490 ptrdiff_t *start, ptrdiff_t *end, 1492 ptrdiff_t *start, ptrdiff_t *end,
1491 Lisp_Object *gstring, Lisp_Object string) 1493 Lisp_Object *gstring, Lisp_Object string)
@@ -1498,7 +1500,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
1498 int c; 1500 int c;
1499 Lisp_Object window; 1501 Lisp_Object window;
1500 struct window *w; 1502 struct window *w;
1501 int need_adjustment = 0; 1503 bool need_adjustment = 0;
1502 1504
1503 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); 1505 window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
1504 if (NILP (window)) 1506 if (NILP (window))
diff --git a/src/composite.h b/src/composite.h
index 6a7e0a5e2c7..68f5b27ee42 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -223,8 +223,8 @@ extern Lisp_Object Qcomposition;
223extern Lisp_Object composition_hash_table; 223extern Lisp_Object composition_hash_table;
224extern ptrdiff_t get_composition_id (ptrdiff_t, ptrdiff_t, ptrdiff_t, 224extern ptrdiff_t get_composition_id (ptrdiff_t, ptrdiff_t, ptrdiff_t,
225 Lisp_Object, Lisp_Object); 225 Lisp_Object, Lisp_Object);
226extern int find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *, 226extern bool find_composition (ptrdiff_t, ptrdiff_t, ptrdiff_t *, ptrdiff_t *,
227 Lisp_Object *, Lisp_Object); 227 Lisp_Object *, Lisp_Object);
228extern void update_compositions (ptrdiff_t, ptrdiff_t, int); 228extern void update_compositions (ptrdiff_t, ptrdiff_t, int);
229extern void make_composition_value_copy (Lisp_Object); 229extern void make_composition_value_copy (Lisp_Object);
230extern void compose_region (int, int, Lisp_Object, Lisp_Object, 230extern void compose_region (int, int, Lisp_Object, Lisp_Object,
@@ -310,17 +310,16 @@ struct font_metrics;
310 310
311extern Lisp_Object composition_gstring_put_cache (Lisp_Object, ptrdiff_t); 311extern Lisp_Object composition_gstring_put_cache (Lisp_Object, ptrdiff_t);
312extern Lisp_Object composition_gstring_from_id (ptrdiff_t); 312extern Lisp_Object composition_gstring_from_id (ptrdiff_t);
313extern int composition_gstring_p (Lisp_Object); 313extern bool composition_gstring_p (Lisp_Object);
314extern int composition_gstring_width (Lisp_Object, ptrdiff_t, ptrdiff_t, 314extern int composition_gstring_width (Lisp_Object, ptrdiff_t, ptrdiff_t,
315 struct font_metrics *); 315 struct font_metrics *);
316 316
317extern void composition_compute_stop_pos (struct composition_it *, 317extern void composition_compute_stop_pos (struct composition_it *,
318 ptrdiff_t, ptrdiff_t, ptrdiff_t, 318 ptrdiff_t, ptrdiff_t, ptrdiff_t,
319 Lisp_Object); 319 Lisp_Object);
320extern int composition_reseat_it (struct composition_it *, 320extern bool composition_reseat_it (struct composition_it *, ptrdiff_t,
321 ptrdiff_t, ptrdiff_t, ptrdiff_t, 321 ptrdiff_t, ptrdiff_t, struct window *,
322 struct window *, struct face *, 322 struct face *, Lisp_Object);
323 Lisp_Object);
324extern int composition_update_it (struct composition_it *, 323extern int composition_update_it (struct composition_it *,
325 ptrdiff_t, ptrdiff_t, Lisp_Object); 324 ptrdiff_t, ptrdiff_t, Lisp_Object);
326 325
diff --git a/src/conf_post.h b/src/conf_post.h
index ead7298e98d..f90ef90fb83 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -178,6 +178,9 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
178#endif 178#endif
179 179
180#include <string.h> 180#include <string.h>
181/* If you think about removing the line below, note that the
182 MS-Windows build relies on it for declaration of 'environ' needed
183 by a few source files. */
181#include <stdlib.h> 184#include <stdlib.h>
182 185
183#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ 186#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */
diff --git a/src/data.c b/src/data.c
index ac6c7af9d3c..a93cd169bf5 100644
--- a/src/data.c
+++ b/src/data.c
@@ -83,8 +83,8 @@ Lisp_Object Qoverflow_error, Qunderflow_error;
83Lisp_Object Qfloatp; 83Lisp_Object Qfloatp;
84Lisp_Object Qnumberp, Qnumber_or_marker_p; 84Lisp_Object Qnumberp, Qnumber_or_marker_p;
85 85
86Lisp_Object Qinteger, Qinterval, Qfloat, Qvector; 86Lisp_Object Qinteger, Qsymbol;
87Lisp_Object Qsymbol, Qstring, Qcons, Qmisc; 87static Lisp_Object Qcons, Qfloat, Qmisc, Qstring, Qvector;
88Lisp_Object Qwindow; 88Lisp_Object Qwindow;
89static Lisp_Object Qoverlay, Qwindow_configuration; 89static Lisp_Object Qoverlay, Qwindow_configuration;
90static Lisp_Object Qprocess, Qmarker; 90static Lisp_Object Qprocess, Qmarker;
@@ -1117,10 +1117,10 @@ DEFUN ("set", Fset, Sset, 2, 2, 0,
1117 return newval; 1117 return newval;
1118} 1118}
1119 1119
1120/* Return 1 if SYMBOL currently has a let-binding 1120/* Return true if SYMBOL currently has a let-binding
1121 which was made in the buffer that is now current. */ 1121 which was made in the buffer that is now current. */
1122 1122
1123static int 1123static bool
1124let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) 1124let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol)
1125{ 1125{
1126 struct specbinding *p; 1126 struct specbinding *p;
@@ -1139,7 +1139,7 @@ let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol)
1139 return 0; 1139 return 0;
1140} 1140}
1141 1141
1142static int 1142static bool
1143let_shadows_global_binding_p (Lisp_Object symbol) 1143let_shadows_global_binding_p (Lisp_Object symbol)
1144{ 1144{
1145 struct specbinding *p; 1145 struct specbinding *p;
@@ -1155,14 +1155,15 @@ let_shadows_global_binding_p (Lisp_Object symbol)
1155 If buffer/frame-locality is an issue, WHERE specifies which context to use. 1155 If buffer/frame-locality is an issue, WHERE specifies which context to use.
1156 (nil stands for the current buffer/frame). 1156 (nil stands for the current buffer/frame).
1157 1157
1158 If BINDFLAG is zero, then if this symbol is supposed to become 1158 If BINDFLAG is false, then if this symbol is supposed to become
1159 local in every buffer where it is set, then we make it local. 1159 local in every buffer where it is set, then we make it local.
1160 If BINDFLAG is nonzero, we don't do that. */ 1160 If BINDFLAG is true, we don't do that. */
1161 1161
1162void 1162void
1163set_internal (register Lisp_Object symbol, register Lisp_Object newval, register Lisp_Object where, int bindflag) 1163set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1164 bool bindflag)
1164{ 1165{
1165 int voide = EQ (newval, Qunbound); 1166 bool voide = EQ (newval, Qunbound);
1166 struct Lisp_Symbol *sym; 1167 struct Lisp_Symbol *sym;
1167 Lisp_Object tem1; 1168 Lisp_Object tem1;
1168 1169
@@ -1501,7 +1502,8 @@ union Lisp_Val_Fwd
1501 }; 1502 };
1502 1503
1503static struct Lisp_Buffer_Local_Value * 1504static struct Lisp_Buffer_Local_Value *
1504make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) 1505make_blv (struct Lisp_Symbol *sym, bool forwarded,
1506 union Lisp_Val_Fwd valcontents)
1505{ 1507{
1506 struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv); 1508 struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv);
1507 Lisp_Object symbol; 1509 Lisp_Object symbol;
@@ -1545,7 +1547,7 @@ The function `default-value' gets the default value and `set-default' sets it.
1545 struct Lisp_Symbol *sym; 1547 struct Lisp_Symbol *sym;
1546 struct Lisp_Buffer_Local_Value *blv = NULL; 1548 struct Lisp_Buffer_Local_Value *blv = NULL;
1547 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); 1549 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO});
1548 int forwarded IF_LINT (= 0); 1550 bool forwarded IF_LINT (= 0);
1549 1551
1550 CHECK_SYMBOL (variable); 1552 CHECK_SYMBOL (variable);
1551 sym = XSYMBOL (variable); 1553 sym = XSYMBOL (variable);
@@ -1617,10 +1619,10 @@ See also `make-variable-buffer-local'.
1617 1619
1618Do not use `make-local-variable' to make a hook variable buffer-local. 1620Do not use `make-local-variable' to make a hook variable buffer-local.
1619Instead, use `add-hook' and specify t for the LOCAL argument. */) 1621Instead, use `add-hook' and specify t for the LOCAL argument. */)
1620 (register Lisp_Object variable) 1622 (Lisp_Object variable)
1621{ 1623{
1622 register Lisp_Object tem; 1624 Lisp_Object tem;
1623 int forwarded IF_LINT (= 0); 1625 bool forwarded IF_LINT (= 0);
1624 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); 1626 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO});
1625 struct Lisp_Symbol *sym; 1627 struct Lisp_Symbol *sym;
1626 struct Lisp_Buffer_Local_Value *blv = NULL; 1628 struct Lisp_Buffer_Local_Value *blv = NULL;
@@ -1804,9 +1806,9 @@ is to set the VARIABLE frame parameter of that frame. See
1804Note that since Emacs 23.1, variables cannot be both buffer-local and 1806Note that since Emacs 23.1, variables cannot be both buffer-local and
1805frame-local any more (buffer-local bindings used to take precedence over 1807frame-local any more (buffer-local bindings used to take precedence over
1806frame-local bindings). */) 1808frame-local bindings). */)
1807 (register Lisp_Object variable) 1809 (Lisp_Object variable)
1808{ 1810{
1809 int forwarded; 1811 bool forwarded;
1810 union Lisp_Val_Fwd valcontents; 1812 union Lisp_Val_Fwd valcontents;
1811 struct Lisp_Symbol *sym; 1813 struct Lisp_Symbol *sym;
1812 struct Lisp_Buffer_Local_Value *blv = NULL; 1814 struct Lisp_Buffer_Local_Value *blv = NULL;
@@ -2262,7 +2264,7 @@ static Lisp_Object
2262arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) 2264arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
2263{ 2265{
2264 double f1 = 0, f2 = 0; 2266 double f1 = 0, f2 = 0;
2265 int floatp = 0; 2267 bool floatp = 0;
2266 2268
2267 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1); 2269 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1);
2268 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2); 2270 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2);
@@ -2379,7 +2381,7 @@ DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0,
2379uintmax_t 2381uintmax_t
2380cons_to_unsigned (Lisp_Object c, uintmax_t max) 2382cons_to_unsigned (Lisp_Object c, uintmax_t max)
2381{ 2383{
2382 int valid = 0; 2384 bool valid = 0;
2383 uintmax_t val IF_LINT (= 0); 2385 uintmax_t val IF_LINT (= 0);
2384 if (INTEGERP (c)) 2386 if (INTEGERP (c))
2385 { 2387 {
@@ -2432,7 +2434,7 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
2432intmax_t 2434intmax_t
2433cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max) 2435cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max)
2434{ 2436{
2435 int valid = 0; 2437 bool valid = 0;
2436 intmax_t val IF_LINT (= 0); 2438 intmax_t val IF_LINT (= 0);
2437 if (INTEGERP (c)) 2439 if (INTEGERP (c))
2438 { 2440 {
@@ -2550,14 +2552,11 @@ static Lisp_Object float_arith_driver (double, ptrdiff_t, enum arithop,
2550static Lisp_Object 2552static Lisp_Object
2551arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) 2553arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args)
2552{ 2554{
2553 register Lisp_Object val; 2555 Lisp_Object val;
2554 ptrdiff_t argnum; 2556 ptrdiff_t argnum, ok_args;
2555 register EMACS_INT accum = 0; 2557 EMACS_INT accum = 0;
2556 register EMACS_INT next; 2558 EMACS_INT next, ok_accum;
2557 2559 bool overflow = 0;
2558 int overflow = 0;
2559 ptrdiff_t ok_args;
2560 EMACS_INT ok_accum;
2561 2560
2562 switch (code) 2561 switch (code)
2563 { 2562 {
@@ -3130,8 +3129,6 @@ syms_of_data (void)
3130 DEFSYM (Qthread, "thread"); 3129 DEFSYM (Qthread, "thread");
3131 DEFSYM (Qmutex, "mutex"); 3130 DEFSYM (Qmutex, "mutex");
3132 DEFSYM (Qcondition_variable, "condition-variable"); 3131 DEFSYM (Qcondition_variable, "condition-variable");
3133 /* Used by Fgarbage_collect. */
3134 DEFSYM (Qinterval, "interval");
3135 DEFSYM (Qmisc, "misc"); 3132 DEFSYM (Qmisc, "misc");
3136 3133
3137 DEFSYM (Qdefun, "defun"); 3134 DEFSYM (Qdefun, "defun");
diff --git a/src/dbusbind.c b/src/dbusbind.c
index c1b1310454c..901820648cb 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -70,7 +70,7 @@ static Lisp_Object QCdbus_registered_signal;
70static Lisp_Object xd_registered_buses; 70static Lisp_Object xd_registered_buses;
71 71
72/* Whether we are reading a D-Bus event. */ 72/* Whether we are reading a D-Bus event. */
73static int xd_in_read_queued_messages = 0; 73static bool xd_in_read_queued_messages = 0;
74 74
75 75
76/* We use "xd_" and "XD_" as prefix for all internal symbols, because 76/* We use "xd_" and "XD_" as prefix for all internal symbols, because
@@ -997,8 +997,7 @@ xd_find_watch_fd (DBusWatch *watch)
997} 997}
998 998
999/* Prototype. */ 999/* Prototype. */
1000static void 1000static void xd_read_queued_messages (int fd, void *data);
1001xd_read_queued_messages (int fd, void *data, int for_read);
1002 1001
1003/* Start monitoring WATCH for possible I/O. */ 1002/* Start monitoring WATCH for possible I/O. */
1004static dbus_bool_t 1003static dbus_bool_t
@@ -1039,11 +1038,13 @@ xd_remove_watch (DBusWatch *watch, void *data)
1039 return; 1038 return;
1040 1039
1041 /* Unset session environment. */ 1040 /* Unset session environment. */
1041#if 0
1042 if (XSYMBOL (QCdbus_session_bus) == data) 1042 if (XSYMBOL (QCdbus_session_bus) == data)
1043 { 1043 {
1044 // XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); 1044 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
1045 // unsetenv ("DBUS_SESSION_BUS_ADDRESS"); 1045 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
1046 } 1046 }
1047#endif
1047 1048
1048 if (flags & DBUS_WATCH_WRITABLE) 1049 if (flags & DBUS_WATCH_WRITABLE)
1049 delete_write_fd (fd); 1050 delete_write_fd (fd);
@@ -1684,7 +1685,7 @@ xd_read_message (Lisp_Object bus)
1684 1685
1685/* Callback called when something is ready to read or write. */ 1686/* Callback called when something is ready to read or write. */
1686static void 1687static void
1687xd_read_queued_messages (int fd, void *data, int for_read) 1688xd_read_queued_messages (int fd, void *data)
1688{ 1689{
1689 Lisp_Object busp = xd_registered_buses; 1690 Lisp_Object busp = xd_registered_buses;
1690 Lisp_Object bus = Qnil; 1691 Lisp_Object bus = Qnil;
diff --git a/src/dired.c b/src/dired.c
index 771230717e3..fa293258107 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -109,18 +109,20 @@ directory_files_internal_unwind (Lisp_Object dh)
109} 109}
110 110
111/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes. 111/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes.
112 When ATTRS is zero, return a list of directory filenames; when 112 If not ATTRS, return a list of directory filenames;
113 non-zero, return a list of directory filenames and their attributes. 113 if ATTRS, return a list of directory filenames and their attributes.
114 In the latter case, ID_FORMAT is passed to Ffile_attributes. */ 114 In the latter case, ID_FORMAT is passed to Ffile_attributes. */
115 115
116Lisp_Object 116Lisp_Object
117directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object match, Lisp_Object nosort, int attrs, Lisp_Object id_format) 117directory_files_internal (Lisp_Object directory, Lisp_Object full,
118 Lisp_Object match, Lisp_Object nosort, bool attrs,
119 Lisp_Object id_format)
118{ 120{
119 DIR *d; 121 DIR *d;
120 ptrdiff_t directory_nbytes; 122 ptrdiff_t directory_nbytes;
121 Lisp_Object list, dirfilename, encoded_directory; 123 Lisp_Object list, dirfilename, encoded_directory;
122 struct re_pattern_buffer *bufp = NULL; 124 struct re_pattern_buffer *bufp = NULL;
123 int needsep = 0; 125 bool needsep = 0;
124 ptrdiff_t count = SPECPDL_INDEX (); 126 ptrdiff_t count = SPECPDL_INDEX ();
125 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 127 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
126 DIRENTRY *dp; 128 DIRENTRY *dp;
@@ -227,7 +229,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m
227 if (DIRENTRY_NONEMPTY (dp)) 229 if (DIRENTRY_NONEMPTY (dp))
228 { 230 {
229 ptrdiff_t len; 231 ptrdiff_t len;
230 int wanted = 0; 232 bool wanted = 0;
231 Lisp_Object name, finalname; 233 Lisp_Object name, finalname;
232 struct gcpro gcpro1, gcpro2; 234 struct gcpro gcpro1, gcpro2;
233 235
@@ -381,9 +383,8 @@ which see. */)
381} 383}
382 384
383 385
384static Lisp_Object file_name_completion 386static Lisp_Object file_name_completion (Lisp_Object, Lisp_Object, bool,
385 (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, 387 Lisp_Object);
386 Lisp_Object predicate);
387 388
388DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion, 389DEFUN ("file-name-completion", Ffile_name_completion, Sfile_name_completion,
389 2, 3, 0, 390 2, 3, 0,
@@ -415,7 +416,7 @@ determined by the variable `completion-ignored-extensions', which see. */)
415 if (!NILP (handler)) 416 if (!NILP (handler))
416 return call4 (handler, Qfile_name_completion, file, directory, predicate); 417 return call4 (handler, Qfile_name_completion, file, directory, predicate);
417 418
418 return file_name_completion (file, directory, 0, 0, predicate); 419 return file_name_completion (file, directory, 0, predicate);
419} 420}
420 421
421DEFUN ("file-name-all-completions", Ffile_name_all_completions, 422DEFUN ("file-name-all-completions", Ffile_name_all_completions,
@@ -439,14 +440,15 @@ These are all file names in directory DIRECTORY which begin with FILE. */)
439 if (!NILP (handler)) 440 if (!NILP (handler))
440 return call3 (handler, Qfile_name_all_completions, file, directory); 441 return call3 (handler, Qfile_name_all_completions, file, directory);
441 442
442 return file_name_completion (file, directory, 1, 0, Qnil); 443 return file_name_completion (file, directory, 1, Qnil);
443} 444}
444 445
445static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr); 446static int file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_addr);
446static Lisp_Object Qdefault_directory; 447static Lisp_Object Qdefault_directory;
447 448
448static Lisp_Object 449static Lisp_Object
449file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int ver_flag, Lisp_Object predicate) 450file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
451 Lisp_Object predicate)
450{ 452{
451 DIR *d; 453 DIR *d;
452 ptrdiff_t bestmatchsize = 0; 454 ptrdiff_t bestmatchsize = 0;
@@ -458,11 +460,11 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
458 Lisp_Object encoded_file; 460 Lisp_Object encoded_file;
459 Lisp_Object encoded_dir; 461 Lisp_Object encoded_dir;
460 struct stat st; 462 struct stat st;
461 int directoryp; 463 bool directoryp;
462 /* If includeall is zero, exclude files in completion-ignored-extensions as 464 /* If not INCLUDEALL, exclude files in completion-ignored-extensions as
463 well as "." and "..". Until shown otherwise, assume we can't exclude 465 well as "." and "..". Until shown otherwise, assume we can't exclude
464 anything. */ 466 anything. */
465 int includeall = 1; 467 bool includeall = 1;
466 ptrdiff_t count = SPECPDL_INDEX (); 468 ptrdiff_t count = SPECPDL_INDEX ();
467 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 469 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
468 470
@@ -500,7 +502,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
500 { 502 {
501 DIRENTRY *dp; 503 DIRENTRY *dp;
502 ptrdiff_t len; 504 ptrdiff_t len;
503 int canexclude = 0; 505 bool canexclude = 0;
504 506
505 errno = 0; 507 errno = 0;
506 dp = readdir (d); 508 dp = readdir (d);
@@ -528,7 +530,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
528 if (file_name_completion_stat (encoded_dir, dp, &st) < 0) 530 if (file_name_completion_stat (encoded_dir, dp, &st) < 0)
529 continue; 531 continue;
530 532
531 directoryp = S_ISDIR (st.st_mode); 533 directoryp = S_ISDIR (st.st_mode) != 0;
532 tem = Qnil; 534 tem = Qnil;
533 /* If all_flag is set, always include all. 535 /* If all_flag is set, always include all.
534 It would not actually be helpful to the user to ignore any possible 536 It would not actually be helpful to the user to ignore any possible
@@ -716,7 +718,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
716 /* This tests that the current file is an exact match 718 /* This tests that the current file is an exact match
717 but BESTMATCH is not (it is too long). */ 719 but BESTMATCH is not (it is too long). */
718 if ((matchsize == SCHARS (name) 720 if ((matchsize == SCHARS (name)
719 && matchsize + !!directoryp < SCHARS (bestmatch)) 721 && matchsize + directoryp < SCHARS (bestmatch))
720 || 722 ||
721 /* If there is no exact match ignoring case, 723 /* If there is no exact match ignoring case,
722 prefer a match that does not change the case 724 prefer a match that does not change the case
@@ -728,7 +730,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
728 either both or neither are exact. */ 730 either both or neither are exact. */
729 (((matchsize == SCHARS (name)) 731 (((matchsize == SCHARS (name))
730 == 732 ==
731 (matchsize + !!directoryp == SCHARS (bestmatch))) 733 (matchsize + directoryp == SCHARS (bestmatch)))
732 && (cmp = Fcompare_strings (name, zero, 734 && (cmp = Fcompare_strings (name, zero,
733 make_number (SCHARS (file)), 735 make_number (SCHARS (file)),
734 file, zero, 736 file, zero,
diff --git a/src/dispextern.h b/src/dispextern.h
index a25aac96df9..73f3350713f 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -671,7 +671,7 @@ struct glyph_matrix
671 671
672 /* Values of BEGV and ZV as of last redisplay. Set in 672 /* Values of BEGV and ZV as of last redisplay. Set in
673 mark_window_display_accurate_1. */ 673 mark_window_display_accurate_1. */
674 int begv, zv; 674 ptrdiff_t begv, zv;
675}; 675};
676 676
677 677
@@ -1126,11 +1126,11 @@ struct glyph_row *matrix_row (struct glyph_matrix *, int);
1126 ((ROW)->phys_height - (ROW)->phys_ascent \ 1126 ((ROW)->phys_height - (ROW)->phys_ascent \
1127 > (ROW)->height - (ROW)->ascent) 1127 > (ROW)->height - (ROW)->ascent)
1128 1128
1129/* Non-zero means that fonts have been loaded since the last glyph 1129/* True means that fonts have been loaded since the last glyph
1130 matrix adjustments. The function redisplay_internal adjusts glyph 1130 matrix adjustments. The function redisplay_internal adjusts glyph
1131 matrices when this flag is non-zero. */ 1131 matrices when this flag is true. */
1132 1132
1133extern int fonts_changed_p; 1133extern bool fonts_changed_p;
1134 1134
1135/* A glyph for a space. */ 1135/* A glyph for a space. */
1136 1136
@@ -1149,7 +1149,7 @@ extern int updated_area;
1149/* Non-zero means last display completed. Zero means it was 1149/* Non-zero means last display completed. Zero means it was
1150 preempted. */ 1150 preempted. */
1151 1151
1152extern int display_completed; 1152extern bool display_completed;
1153 1153
1154 1154
1155 1155
@@ -1415,7 +1415,7 @@ struct glyph_string
1415 && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \ 1415 && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \
1416 && WINDOW_TOTAL_LINES (W) > 1) 1416 && WINDOW_TOTAL_LINES (W) > 1)
1417 1417
1418/* Value is non-zero if window W wants a header line. */ 1418/* Value is true if window W wants a header line. */
1419 1419
1420#define WINDOW_WANTS_HEADER_LINE_P(W) \ 1420#define WINDOW_WANTS_HEADER_LINE_P(W) \
1421 (!MINI_WINDOW_P ((W)) \ 1421 (!MINI_WINDOW_P ((W)) \
@@ -1856,7 +1856,6 @@ struct bidi_it {
1856 int resolved_level; /* final resolved level of this character */ 1856 int resolved_level; /* final resolved level of this character */
1857 int invalid_levels; /* how many PDFs to ignore */ 1857 int invalid_levels; /* how many PDFs to ignore */
1858 int invalid_rl_levels; /* how many PDFs from RLE/RLO to ignore */ 1858 int invalid_rl_levels; /* how many PDFs from RLE/RLO to ignore */
1859 int prev_was_pdf; /* if non-zero, previous char was PDF */
1860 struct bidi_saved_info prev; /* info about previous character */ 1859 struct bidi_saved_info prev; /* info about previous character */
1861 struct bidi_saved_info last_strong; /* last-seen strong directional char */ 1860 struct bidi_saved_info last_strong; /* last-seen strong directional char */
1862 struct bidi_saved_info next_for_neutral; /* surrounding characters for... */ 1861 struct bidi_saved_info next_for_neutral; /* surrounding characters for... */
@@ -1879,6 +1878,7 @@ struct bidi_it {
1879 struct bidi_string_data string; /* string to reorder */ 1878 struct bidi_string_data string; /* string to reorder */
1880 bidi_dir_t paragraph_dir; /* current paragraph direction */ 1879 bidi_dir_t paragraph_dir; /* current paragraph direction */
1881 ptrdiff_t separator_limit; /* where paragraph separator should end */ 1880 ptrdiff_t separator_limit; /* where paragraph separator should end */
1881 unsigned prev_was_pdf : 1; /* if non-zero, previous char was PDF */
1882 unsigned first_elt : 1; /* if non-zero, examine current char first */ 1882 unsigned first_elt : 1; /* if non-zero, examine current char first */
1883 unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */ 1883 unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */
1884 unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */ 1884 unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */
@@ -2085,10 +2085,10 @@ struct composition_it
2085 ptrdiff_t lookback; 2085 ptrdiff_t lookback;
2086 /* If non-negative, number of glyphs of the glyph-string. */ 2086 /* If non-negative, number of glyphs of the glyph-string. */
2087 int nglyphs; 2087 int nglyphs;
2088 /* Nonzero iff the composition is created while buffer is scanned in 2088 /* True iff the composition is created while buffer is scanned in
2089 reverse order, and thus the grapheme clusters must be rendered 2089 reverse order, and thus the grapheme clusters must be rendered
2090 from the last to the first. */ 2090 from the last to the first. */
2091 int reversed_p; 2091 bool reversed_p;
2092 2092
2093 /** The following members contain information about the current 2093 /** The following members contain information about the current
2094 grapheme cluster. */ 2094 grapheme cluster. */
@@ -3002,14 +3002,14 @@ enum tool_bar_item_image
3002 3002
3003/* Defined in bidi.c */ 3003/* Defined in bidi.c */
3004 3004
3005extern void bidi_init_it (ptrdiff_t, ptrdiff_t, int, struct bidi_it *); 3005extern void bidi_init_it (ptrdiff_t, ptrdiff_t, bool, struct bidi_it *);
3006extern void bidi_move_to_visually_next (struct bidi_it *); 3006extern void bidi_move_to_visually_next (struct bidi_it *);
3007extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, int); 3007extern void bidi_paragraph_init (bidi_dir_t, struct bidi_it *, bool);
3008extern int bidi_mirror_char (int); 3008extern int bidi_mirror_char (int);
3009extern void bidi_push_it (struct bidi_it *); 3009extern void bidi_push_it (struct bidi_it *);
3010extern void bidi_pop_it (struct bidi_it *); 3010extern void bidi_pop_it (struct bidi_it *);
3011extern void *bidi_shelve_cache (void); 3011extern void *bidi_shelve_cache (void);
3012extern void bidi_unshelve_cache (void *, int); 3012extern void bidi_unshelve_cache (void *, bool);
3013 3013
3014/* Defined in xdisp.c */ 3014/* Defined in xdisp.c */
3015 3015
@@ -3055,7 +3055,7 @@ void move_it_in_display_line (struct it *it,
3055int in_display_vector_p (struct it *); 3055int in_display_vector_p (struct it *);
3056int frame_mode_line_height (struct frame *); 3056int frame_mode_line_height (struct frame *);
3057extern Lisp_Object Qtool_bar; 3057extern Lisp_Object Qtool_bar;
3058extern int redisplaying_p; 3058extern bool redisplaying_p;
3059extern int help_echo_showing_p; 3059extern int help_echo_showing_p;
3060extern int current_mode_line_height, current_header_line_height; 3060extern int current_mode_line_height, current_header_line_height;
3061extern Lisp_Object help_echo_string, help_echo_window; 3061extern Lisp_Object help_echo_string, help_echo_window;
@@ -3251,9 +3251,12 @@ void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
3251 3251
3252extern Lisp_Object tip_frame; 3252extern Lisp_Object tip_frame;
3253extern Window tip_window; 3253extern Window tip_window;
3254extern frame_parm_handler x_frame_parm_handlers[];
3255
3254extern void start_hourglass (void); 3256extern void start_hourglass (void);
3255extern void cancel_hourglass (void); 3257extern void cancel_hourglass (void);
3256extern int hourglass_shown_p; 3258extern int hourglass_shown_p;
3259
3257struct atimer; /* Defined in atimer.h. */ 3260struct atimer; /* Defined in atimer.h. */
3258/* If non-null, an asynchronous timer that, when it expires, displays 3261/* If non-null, an asynchronous timer that, when it expires, displays
3259 an hourglass cursor on all frames. */ 3262 an hourglass cursor on all frames. */
@@ -3304,7 +3307,7 @@ extern Lisp_Object marginal_area_string (struct window *, enum window_part,
3304extern void redraw_frame (struct frame *); 3307extern void redraw_frame (struct frame *);
3305extern void cancel_line (int, struct frame *); 3308extern void cancel_line (int, struct frame *);
3306extern void init_desired_glyphs (struct frame *); 3309extern void init_desired_glyphs (struct frame *);
3307extern int update_frame (struct frame *, int, int); 3310extern bool update_frame (struct frame *, bool, bool);
3308extern void bitch_at_user (void); 3311extern void bitch_at_user (void);
3309void adjust_glyphs (struct frame *); 3312void adjust_glyphs (struct frame *);
3310void free_glyphs (struct frame *); 3313void free_glyphs (struct frame *);
@@ -3320,13 +3323,13 @@ void rotate_matrix (struct glyph_matrix *, int, int, int);
3320void increment_matrix_positions (struct glyph_matrix *, 3323void increment_matrix_positions (struct glyph_matrix *,
3321 int, int, ptrdiff_t, ptrdiff_t); 3324 int, int, ptrdiff_t, ptrdiff_t);
3322void blank_row (struct window *, struct glyph_row *, int); 3325void blank_row (struct window *, struct glyph_row *, int);
3323void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int); 3326void clear_glyph_matrix_rows (struct glyph_matrix *, int, int);
3324void clear_glyph_row (struct glyph_row *); 3327void clear_glyph_row (struct glyph_row *);
3325void prepare_desired_row (struct glyph_row *); 3328void prepare_desired_row (struct glyph_row *);
3326void set_window_update_flags (struct window *, int); 3329void set_window_update_flags (struct window *, bool);
3327void update_single_window (struct window *, int); 3330void update_single_window (struct window *, bool);
3328void do_pending_window_change (int); 3331void do_pending_window_change (bool);
3329void change_frame_size (struct frame *, int, int, int, int, int); 3332void change_frame_size (struct frame *, int, int, bool, bool, bool);
3330void init_display (void); 3333void init_display (void);
3331void syms_of_display (void); 3334void syms_of_display (void);
3332extern Lisp_Object Qredisplay_dont_pause; 3335extern Lisp_Object Qredisplay_dont_pause;
diff --git a/src/dispnew.c b/src/dispnew.c
index 8db4f93dc70..cac4c2da4c4 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -47,17 +47,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47 47
48#include "syssignal.h" 48#include "syssignal.h"
49 49
50#ifdef HAVE_X_WINDOWS 50#ifdef HAVE_WINDOW_SYSTEM
51#include "xterm.h" 51#include TERM_HEADER
52#endif /* HAVE_X_WINDOWS */ 52#endif /* HAVE_WINDOW_SYSTEM */
53
54#ifdef HAVE_NTGUI
55#include "w32term.h"
56#endif /* HAVE_NTGUI */
57
58#ifdef HAVE_NS
59#include "nsterm.h"
60#endif
61 53
62/* Include systime.h after xterm.h to avoid double inclusion of time.h. */ 54/* Include systime.h after xterm.h to avoid double inclusion of time.h. */
63 55
@@ -88,7 +80,7 @@ static void update_frame_line (struct frame *, int);
88static int required_matrix_height (struct window *); 80static int required_matrix_height (struct window *);
89static int required_matrix_width (struct window *); 81static int required_matrix_width (struct window *);
90static void adjust_frame_glyphs (struct frame *); 82static void adjust_frame_glyphs (struct frame *);
91static void change_frame_size_1 (struct frame *, int, int, int, int, int); 83static void change_frame_size_1 (struct frame *, int, int, bool, bool, bool);
92static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t); 84static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t);
93static void fill_up_frame_row_with_spaces (struct glyph_row *, int); 85static void fill_up_frame_row_with_spaces (struct glyph_row *, int);
94static void build_frame_matrix_from_window_tree (struct glyph_matrix *, 86static void build_frame_matrix_from_window_tree (struct glyph_matrix *,
@@ -98,20 +90,20 @@ static void build_frame_matrix_from_leaf_window (struct glyph_matrix *,
98static void adjust_frame_message_buffer (struct frame *); 90static void adjust_frame_message_buffer (struct frame *);
99static void adjust_decode_mode_spec_buffer (struct frame *); 91static void adjust_decode_mode_spec_buffer (struct frame *);
100static void fill_up_glyph_row_with_spaces (struct glyph_row *); 92static void fill_up_glyph_row_with_spaces (struct glyph_row *);
101static void clear_window_matrices (struct window *, int); 93static void clear_window_matrices (struct window *, bool);
102static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int); 94static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int);
103static int scrolling_window (struct window *, int); 95static int scrolling_window (struct window *, bool);
104static int update_window_line (struct window *, int, int *); 96static bool update_window_line (struct window *, int, bool *);
105static void mirror_make_current (struct window *, int); 97static void mirror_make_current (struct window *, int);
106#ifdef GLYPH_DEBUG 98#ifdef GLYPH_DEBUG
107static void check_matrix_pointers (struct glyph_matrix *, 99static void check_matrix_pointers (struct glyph_matrix *,
108 struct glyph_matrix *); 100 struct glyph_matrix *);
109#endif 101#endif
110static void mirror_line_dance (struct window *, int, int, int *, char *); 102static void mirror_line_dance (struct window *, int, int, int *, char *);
111static int update_window_tree (struct window *, int); 103static bool update_window_tree (struct window *, bool);
112static int update_window (struct window *, int); 104static bool update_window (struct window *, bool);
113static int update_frame_1 (struct frame *, int, int); 105static bool update_frame_1 (struct frame *, bool, bool);
114static int scrolling (struct frame *); 106static bool scrolling (struct frame *);
115static void set_window_cursor_after_update (struct window *); 107static void set_window_cursor_after_update (struct window *);
116static void adjust_frame_glyphs_for_window_redisplay (struct frame *); 108static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
117static void adjust_frame_glyphs_for_frame_redisplay (struct frame *); 109static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
@@ -122,14 +114,14 @@ static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
122static EMACS_TIME preemption_period; 114static EMACS_TIME preemption_period;
123static EMACS_TIME preemption_next_check; 115static EMACS_TIME preemption_next_check;
124 116
125/* Nonzero upon entry to redisplay means do not assume anything about 117/* True upon entry to redisplay means do not assume anything about
126 current contents of actual terminal frame; clear and redraw it. */ 118 current contents of actual terminal frame; clear and redraw it. */
127 119
128int frame_garbaged; 120bool frame_garbaged;
129 121
130/* Nonzero means last display completed. Zero means it was preempted. */ 122/* True means last display completed. False means it was preempted. */
131 123
132int display_completed; 124bool display_completed;
133 125
134Lisp_Object Qdisplay_table, Qredisplay_dont_pause; 126Lisp_Object Qdisplay_table, Qredisplay_dont_pause;
135 127
@@ -146,13 +138,13 @@ Lisp_Object selected_frame;
146 138
147struct frame *last_nonminibuf_frame; 139struct frame *last_nonminibuf_frame;
148 140
149/* 1 means SIGWINCH happened when not safe. */ 141/* True means SIGWINCH happened when not safe. */
150 142
151static int delayed_size_change; 143static bool delayed_size_change;
152 144
153/* 1 means glyph initialization has been completed at startup. */ 145/* 1 means glyph initialization has been completed at startup. */
154 146
155static int glyphs_initialized_initially_p; 147static bool glyphs_initialized_initially_p;
156 148
157/* Updated window if != 0. Set by update_window. */ 149/* Updated window if != 0. Set by update_window. */
158 150
@@ -178,15 +170,15 @@ static int glyph_pool_count;
178 170
179static struct frame *frame_matrix_frame; 171static struct frame *frame_matrix_frame;
180 172
181/* Non-zero means that fonts have been loaded since the last glyph 173/* True means that fonts have been loaded since the last glyph
182 matrix adjustments. Redisplay must stop, and glyph matrices must 174 matrix adjustments. Redisplay must stop, and glyph matrices must
183 be adjusted when this flag becomes non-zero during display. The 175 be adjusted when this flag becomes true during display. The
184 reason fonts can be loaded so late is that fonts of fontsets are 176 reason fonts can be loaded so late is that fonts of fontsets are
185 loaded on demand. Another reason is that a line contains many 177 loaded on demand. Another reason is that a line contains many
186 characters displayed by zero width or very narrow glyphs of 178 characters displayed by zero width or very narrow glyphs of
187 variable-width fonts. */ 179 variable-width fonts. */
188 180
189int fonts_changed_p; 181bool fonts_changed_p;
190 182
191/* Convert vpos and hpos from frame to window and vice versa. 183/* Convert vpos and hpos from frame to window and vice versa.
192 This may only be used for terminal frames. */ 184 This may only be used for terminal frames. */
@@ -222,16 +214,14 @@ static int history_idx;
222 history. */ 214 history. */
223 215
224static uprintmax_t history_tick; 216static uprintmax_t history_tick;
225
226static void add_frame_display_history (struct frame *, int);
227 217
228/* Add to the redisplay history how window W has been displayed. 218/* Add to the redisplay history how window W has been displayed.
229 MSG is a trace containing the information how W's glyph matrix 219 MSG is a trace containing the information how W's glyph matrix
230 has been constructed. PAUSED_P non-zero means that the update 220 has been constructed. PAUSED_P means that the update
231 has been interrupted for pending input. */ 221 has been interrupted for pending input. */
232 222
233static void 223static void
234add_window_display_history (struct window *w, const char *msg, int paused_p) 224add_window_display_history (struct window *w, const char *msg, bool paused_p)
235{ 225{
236 char *buf; 226 char *buf;
237 227
@@ -254,11 +244,11 @@ add_window_display_history (struct window *w, const char *msg, int paused_p)
254 244
255 245
256/* Add to the redisplay history that frame F has been displayed. 246/* Add to the redisplay history that frame F has been displayed.
257 PAUSED_P non-zero means that the update has been interrupted for 247 PAUSED_P means that the update has been interrupted for
258 pending input. */ 248 pending input. */
259 249
260static void 250static void
261add_frame_display_history (struct frame *f, int paused_p) 251add_frame_display_history (struct frame *f, bool paused_p)
262{ 252{
263 char *buf; 253 char *buf;
264 254
@@ -395,10 +385,10 @@ margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin
395 return n; 385 return n;
396} 386}
397 387
398/* Return non-zero if ROW's hash value is correct, zero if not. 388/* Return true if ROW's hash value is correct.
399 Optimized away if ENABLE_CHECKING is not defined. */ 389 Optimized away if ENABLE_CHECKING is not defined. */
400 390
401static int 391static bool
402verify_row_hash (struct glyph_row *row) 392verify_row_hash (struct glyph_row *row)
403{ 393{
404 return row->hash == row_hash (row); 394 return row->hash == row_hash (row);
@@ -431,9 +421,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
431{ 421{
432 int i; 422 int i;
433 int new_rows; 423 int new_rows;
434 int marginal_areas_changed_p = 0; 424 bool marginal_areas_changed_p = 0;
435 int header_line_changed_p = 0; 425 bool header_line_changed_p = 0;
436 int header_line_p = 0; 426 bool header_line_p = 0;
437 int left = -1, right = -1; 427 int left = -1, right = -1;
438 int window_width = -1, window_height = -1; 428 int window_width = -1, window_height = -1;
439 429
@@ -736,30 +726,28 @@ increment_matrix_positions (struct glyph_matrix *matrix, int start, int end,
736} 726}
737 727
738 728
739/* Enable a range of rows in glyph matrix MATRIX. START and END are 729/* Clear the enable_p flags in a range of rows in glyph matrix MATRIX.
740 the row indices of the first and last + 1 row to enable. If 730 START and END are the row indices of the first and last + 1 row to clear. */
741 ENABLED_P is non-zero, enabled_p flags in rows will be set to 1. */
742 731
743void 732void
744enable_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end, int enabled_p) 733clear_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end)
745{ 734{
746 eassert (start <= end); 735 eassert (start <= end);
747 eassert (start >= 0 && start < matrix->nrows); 736 eassert (start >= 0 && start < matrix->nrows);
748 eassert (end >= 0 && end <= matrix->nrows); 737 eassert (end >= 0 && end <= matrix->nrows);
749 738
750 for (; start < end; ++start) 739 for (; start < end; ++start)
751 matrix->rows[start].enabled_p = enabled_p != 0; 740 matrix->rows[start].enabled_p = 0;
752} 741}
753 742
754 743
755/* Clear MATRIX. 744/* Clear MATRIX.
756 745
757 This empties all rows in MATRIX by setting the enabled_p flag for 746 Empty all rows in MATRIX by clearing their enabled_p flags.
758 all rows of the matrix to zero. The function prepare_desired_row 747 The function prepare_desired_row will eventually really clear a row
759 will eventually really clear a row when it sees one with a zero 748 when it sees one with a false enabled_p flag.
760 enabled_p flag.
761 749
762 Resets update hints to defaults value. The only update hint 750 Reset update hints to default values. The only update hint
763 currently present is the flag MATRIX->no_scrolling_p. */ 751 currently present is the flag MATRIX->no_scrolling_p. */
764 752
765void 753void
@@ -767,7 +755,7 @@ clear_glyph_matrix (struct glyph_matrix *matrix)
767{ 755{
768 if (matrix) 756 if (matrix)
769 { 757 {
770 enable_glyph_matrix_rows (matrix, 0, matrix->nrows, 0); 758 clear_glyph_matrix_rows (matrix, 0, matrix->nrows);
771 matrix->no_scrolling_p = 0; 759 matrix->no_scrolling_p = 0;
772 } 760 }
773} 761}
@@ -853,11 +841,11 @@ clear_desired_matrices (register struct frame *f)
853} 841}
854 842
855 843
856/* Clear matrices in window tree rooted in W. If DESIRED_P is 844/* Clear matrices in window tree rooted in W. If DESIRED_P,
857 non-zero clear desired matrices, otherwise clear current matrices. */ 845 clear desired matrices, otherwise clear current matrices. */
858 846
859static void 847static void
860clear_window_matrices (struct window *w, int desired_p) 848clear_window_matrices (struct window *w, bool desired_p)
861{ 849{
862 while (w) 850 while (w)
863 { 851 {
@@ -1109,12 +1097,12 @@ assign_row (struct glyph_row *to, struct glyph_row *from)
1109/* Test whether the glyph memory of the glyph row WINDOW_ROW, which is 1097/* Test whether the glyph memory of the glyph row WINDOW_ROW, which is
1110 a row in a window matrix, is a slice of the glyph memory of the 1098 a row in a window matrix, is a slice of the glyph memory of the
1111 glyph row FRAME_ROW which is a row in a frame glyph matrix. Value 1099 glyph row FRAME_ROW which is a row in a frame glyph matrix. Value
1112 is non-zero if the glyph memory of WINDOW_ROW is part of the glyph 1100 is true if the glyph memory of WINDOW_ROW is part of the glyph
1113 memory of FRAME_ROW. */ 1101 memory of FRAME_ROW. */
1114 1102
1115#ifdef GLYPH_DEBUG 1103#ifdef GLYPH_DEBUG
1116 1104
1117static int 1105static bool
1118glyph_row_slice_p (struct glyph_row *window_row, struct glyph_row *frame_row) 1106glyph_row_slice_p (struct glyph_row *window_row, struct glyph_row *frame_row)
1119{ 1107{
1120 struct glyph *window_glyph_start = window_row->glyphs[0]; 1108 struct glyph *window_glyph_start = window_row->glyphs[0];
@@ -1161,7 +1149,7 @@ prepare_desired_row (struct glyph_row *row)
1161{ 1149{
1162 if (!row->enabled_p) 1150 if (!row->enabled_p)
1163 { 1151 {
1164 int rp = row->reversed_p; 1152 bool rp = row->reversed_p;
1165 1153
1166 clear_glyph_row (row); 1154 clear_glyph_row (row);
1167 row->enabled_p = 1; 1155 row->enabled_p = 1;
@@ -1260,12 +1248,11 @@ line_draw_cost (struct glyph_matrix *matrix, int vpos)
1260} 1248}
1261 1249
1262 1250
1263/* Test two glyph rows A and B for equality. Value is non-zero if A 1251/* Return true if the glyph rows A and B have equal contents.
1264 and B have equal contents. MOUSE_FACE_P non-zero means compare the 1252 MOUSE_FACE_P means compare the mouse_face_p flags of A and B, too. */
1265 mouse_face_p flags of A and B, too. */
1266 1253
1267static inline int 1254static inline bool
1268row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) 1255row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p)
1269{ 1256{
1270 eassert (verify_row_hash (a)); 1257 eassert (verify_row_hash (a));
1271 eassert (verify_row_hash (b)); 1258 eassert (verify_row_hash (b));
@@ -1380,14 +1367,14 @@ free_glyph_pool (struct glyph_pool *pool)
1380 is changed from a large value to a smaller one. But, if someone 1367 is changed from a large value to a smaller one. But, if someone
1381 does it once, we can expect that he will do it again. 1368 does it once, we can expect that he will do it again.
1382 1369
1383 Value is non-zero if the pool changed in a way which makes 1370 Return true if the pool changed in a way which makes
1384 re-adjusting window glyph matrices necessary. */ 1371 re-adjusting window glyph matrices necessary. */
1385 1372
1386static int 1373static bool
1387realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) 1374realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim)
1388{ 1375{
1389 ptrdiff_t needed; 1376 ptrdiff_t needed;
1390 int changed_p; 1377 bool changed_p;
1391 1378
1392 changed_p = (pool->glyphs == 0 1379 changed_p = (pool->glyphs == 0
1393 || matrix_dim.height != pool->nrows 1380 || matrix_dim.height != pool->nrows
@@ -1561,7 +1548,7 @@ check_matrix_invariants (struct window *w)
1561 1548
1562 X and Y are column/row within the frame glyph matrix where 1549 X and Y are column/row within the frame glyph matrix where
1563 sub-matrices for the window tree rooted at WINDOW must be 1550 sub-matrices for the window tree rooted at WINDOW must be
1564 allocated. DIM_ONLY_P non-zero means that the caller of this 1551 allocated. DIM_ONLY_P means that the caller of this
1565 function is only interested in the result matrix dimension, and 1552 function is only interested in the result matrix dimension, and
1566 matrix adjustments should not be performed. 1553 matrix adjustments should not be performed.
1567 1554
@@ -1638,7 +1625,7 @@ check_matrix_invariants (struct window *w)
1638 1625
1639static struct dim 1626static struct dim
1640allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y, 1627allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1641 int dim_only_p, int *window_change_flags) 1628 bool dim_only_p, int *window_change_flags)
1642{ 1629{
1643 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); 1630 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
1644 int x0 = x, y0 = y; 1631 int x0 = x, y0 = y;
@@ -1646,7 +1633,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1646 struct dim total; 1633 struct dim total;
1647 struct dim dim; 1634 struct dim dim;
1648 struct window *w; 1635 struct window *w;
1649 int in_horz_combination_p; 1636 bool in_horz_combination_p;
1650 1637
1651 /* What combination is WINDOW part of? Compute this once since the 1638 /* What combination is WINDOW part of? Compute this once since the
1652 result is the same for all windows in the `next' chain. The 1639 result is the same for all windows in the `next' chain. The
@@ -1704,7 +1691,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1704 /* Actually change matrices, if allowed. Do not consider 1691 /* Actually change matrices, if allowed. Do not consider
1705 CHANGED_LEAF_MATRIX computed above here because the pool 1692 CHANGED_LEAF_MATRIX computed above here because the pool
1706 may have been changed which we don't now here. We trust 1693 may have been changed which we don't now here. We trust
1707 that we only will be called with DIM_ONLY_P != 0 when 1694 that we only will be called with DIM_ONLY_P when
1708 necessary. */ 1695 necessary. */
1709 if (!dim_only_p) 1696 if (!dim_only_p)
1710 { 1697 {
@@ -1919,9 +1906,9 @@ adjust_frame_glyphs (struct frame *f)
1919 f->glyphs_initialized_p = 1; 1906 f->glyphs_initialized_p = 1;
1920} 1907}
1921 1908
1922/* Return 1 if any window in the tree has nonzero window margins. See 1909/* Return true if any window in the tree has nonzero window margins. See
1923 the hack at the end of adjust_frame_glyphs_for_frame_redisplay. */ 1910 the hack at the end of adjust_frame_glyphs_for_frame_redisplay. */
1924static int 1911static bool
1925showing_window_margins_p (struct window *w) 1912showing_window_margins_p (struct window *w)
1926{ 1913{
1927 while (w) 1914 while (w)
@@ -2052,7 +2039,7 @@ static void
2052adjust_frame_glyphs_for_frame_redisplay (struct frame *f) 2039adjust_frame_glyphs_for_frame_redisplay (struct frame *f)
2053{ 2040{
2054 struct dim matrix_dim; 2041 struct dim matrix_dim;
2055 int pool_changed_p; 2042 bool pool_changed_p;
2056 int window_change_flags; 2043 int window_change_flags;
2057 int top_window_y; 2044 int top_window_y;
2058 2045
@@ -2468,7 +2455,7 @@ build_frame_matrix_from_window_tree (struct glyph_matrix *matrix, struct window
2468 desired frame matrix built. W is a leaf window whose desired or 2455 desired frame matrix built. W is a leaf window whose desired or
2469 current matrix is to be added to FRAME_MATRIX. W's flag 2456 current matrix is to be added to FRAME_MATRIX. W's flag
2470 must_be_updated_p determines which matrix it contributes to 2457 must_be_updated_p determines which matrix it contributes to
2471 FRAME_MATRIX. If must_be_updated_p is non-zero, W's desired matrix 2458 FRAME_MATRIX. If W->must_be_updated_p, W's desired matrix
2472 is added to FRAME_MATRIX, otherwise W's current matrix is added. 2459 is added to FRAME_MATRIX, otherwise W's current matrix is added.
2473 Adding a desired matrix means setting up used counters and such in 2460 Adding a desired matrix means setting up used counters and such in
2474 frame rows, while adding a current window matrix to FRAME_MATRIX 2461 frame rows, while adding a current window matrix to FRAME_MATRIX
@@ -2519,7 +2506,7 @@ build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct w
2519 { 2506 {
2520 struct glyph_row *frame_row = frame_matrix->rows + frame_y; 2507 struct glyph_row *frame_row = frame_matrix->rows + frame_y;
2521 struct glyph_row *window_row = window_matrix->rows + window_y; 2508 struct glyph_row *window_row = window_matrix->rows + window_y;
2522 int current_row_p = window_matrix == w->current_matrix; 2509 bool current_row_p = window_matrix == w->current_matrix;
2523 2510
2524 /* Fill up the frame row with spaces up to the left margin of the 2511 /* Fill up the frame row with spaces up to the left margin of the
2525 window row. */ 2512 window row. */
@@ -2692,7 +2679,7 @@ make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_
2692{ 2679{
2693 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row); 2680 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row);
2694 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row); 2681 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row);
2695 int mouse_face_p = current_row->mouse_face_p; 2682 bool mouse_face_p = current_row->mouse_face_p;
2696 2683
2697 /* Do current_row = desired_row. This exchanges glyph pointers 2684 /* Do current_row = desired_row. This exchanges glyph pointers
2698 between both rows, and does a structure assignment otherwise. */ 2685 between both rows, and does a structure assignment otherwise. */
@@ -2789,7 +2776,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
2789 /* Assign new rows, maybe clear lines. */ 2776 /* Assign new rows, maybe clear lines. */
2790 for (i = 0; i < nlines; ++i) 2777 for (i = 0; i < nlines; ++i)
2791 { 2778 {
2792 int enabled_before_p = new_rows[i].enabled_p; 2779 bool enabled_before_p = new_rows[i].enabled_p;
2793 2780
2794 eassert (i + unchanged_at_top < matrix->nrows); 2781 eassert (i + unchanged_at_top < matrix->nrows);
2795 eassert (unchanged_at_top + copy_from[i] < matrix->nrows); 2782 eassert (unchanged_at_top + copy_from[i] < matrix->nrows);
@@ -2897,7 +2884,8 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
2897 /* W is a leaf window, and we are working on its current 2884 /* W is a leaf window, and we are working on its current
2898 matrix m. */ 2885 matrix m. */
2899 struct glyph_matrix *m = w->current_matrix; 2886 struct glyph_matrix *m = w->current_matrix;
2900 int i, sync_p = 0; 2887 int i;
2888 bool sync_p = 0;
2901 struct glyph_row *old_rows; 2889 struct glyph_row *old_rows;
2902 2890
2903 /* Make a copy of the original rows of matrix m. */ 2891 /* Make a copy of the original rows of matrix m. */
@@ -2919,22 +2907,19 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
2919 int window_from = frame_from - m->matrix_y; 2907 int window_from = frame_from - m->matrix_y;
2920 2908
2921 /* Is assigned line inside window? */ 2909 /* Is assigned line inside window? */
2922 int from_inside_window_p 2910 bool from_inside_window_p
2923 = window_from >= 0 && window_from < m->matrix_h; 2911 = window_from >= 0 && window_from < m->matrix_h;
2924 2912
2925 /* Is assigned to line inside window? */ 2913 /* Is assigned to line inside window? */
2926 int to_inside_window_p 2914 bool to_inside_window_p
2927 = window_to >= 0 && window_to < m->matrix_h; 2915 = window_to >= 0 && window_to < m->matrix_h;
2928 2916
2929 if (from_inside_window_p && to_inside_window_p) 2917 if (from_inside_window_p && to_inside_window_p)
2930 { 2918 {
2931 /* Enabled setting before assignment. */
2932 int enabled_before_p;
2933
2934 /* Do the assignment. The enabled_p flag is saved 2919 /* Do the assignment. The enabled_p flag is saved
2935 over the assignment because the old redisplay did 2920 over the assignment because the old redisplay did
2936 that. */ 2921 that. */
2937 enabled_before_p = m->rows[window_to].enabled_p; 2922 bool enabled_before_p = m->rows[window_to].enabled_p;
2938 m->rows[window_to] = old_rows[window_from]; 2923 m->rows[window_to] = old_rows[window_from];
2939 m->rows[window_to].enabled_p = enabled_before_p; 2924 m->rows[window_to].enabled_p = enabled_before_p;
2940 2925
@@ -3155,17 +3140,16 @@ DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
3155 3140
3156/* Update frame F based on the data in desired matrices. 3141/* Update frame F based on the data in desired matrices.
3157 3142
3158 If FORCE_P is non-zero, don't let redisplay be stopped by detecting 3143 If FORCE_P, don't let redisplay be stopped by detecting pending input.
3159 pending input. If INHIBIT_HAIRY_ID_P is non-zero, don't try 3144 If INHIBIT_HAIRY_ID_P, don't try scrolling.
3160 scrolling.
3161 3145
3162 Value is non-zero if redisplay was stopped due to pending input. */ 3146 Value is true if redisplay was stopped due to pending input. */
3163 3147
3164int 3148bool
3165update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p) 3149update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
3166{ 3150{
3167 /* 1 means display has been paused because of pending input. */ 3151 /* True means display has been paused because of pending input. */
3168 int paused_p; 3152 bool paused_p;
3169 struct window *root_window = XWINDOW (f->root_window); 3153 struct window *root_window = XWINDOW (f->root_window);
3170 3154
3171 if (redisplay_dont_pause) 3155 if (redisplay_dont_pause)
@@ -3283,13 +3267,13 @@ update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p)
3283 Window-based updates 3267 Window-based updates
3284 ************************************************************************/ 3268 ************************************************************************/
3285 3269
3286/* Perform updates in window tree rooted at W. FORCE_P non-zero means 3270/* Perform updates in window tree rooted at W.
3287 don't stop updating when input is pending. */ 3271 If FORCE_P, don't stop updating if input is pending. */
3288 3272
3289static int 3273static bool
3290update_window_tree (struct window *w, int force_p) 3274update_window_tree (struct window *w, bool force_p)
3291{ 3275{
3292 int paused_p = 0; 3276 bool paused_p = 0;
3293 3277
3294 while (w && !paused_p) 3278 while (w && !paused_p)
3295 { 3279 {
@@ -3307,11 +3291,11 @@ update_window_tree (struct window *w, int force_p)
3307} 3291}
3308 3292
3309 3293
3310/* Update window W if its flag must_be_updated_p is non-zero. If 3294/* Update window W if its flag must_be_updated_p is set.
3311 FORCE_P is non-zero, don't stop updating if input is pending. */ 3295 If FORCE_P, don't stop updating if input is pending. */
3312 3296
3313void 3297void
3314update_single_window (struct window *w, int force_p) 3298update_single_window (struct window *w, bool force_p)
3315{ 3299{
3316 if (w->must_be_updated_p) 3300 if (w->must_be_updated_p)
3317 { 3301 {
@@ -3460,7 +3444,7 @@ redraw_overlapping_rows (struct window *w, int yb)
3460static void 3444static void
3461check_current_matrix_flags (struct window *w) 3445check_current_matrix_flags (struct window *w)
3462{ 3446{
3463 int last_seen_p = 0; 3447 bool last_seen_p = 0;
3464 int i, yb = window_text_bottom_y (w); 3448 int i, yb = window_text_bottom_y (w);
3465 3449
3466 for (i = 0; i < w->current_matrix->nrows - 1; ++i) 3450 for (i = 0; i < w->current_matrix->nrows - 1; ++i)
@@ -3476,14 +3460,14 @@ check_current_matrix_flags (struct window *w)
3476#endif /* GLYPH_DEBUG */ 3460#endif /* GLYPH_DEBUG */
3477 3461
3478 3462
3479/* Update display of window W. FORCE_P non-zero means that we should 3463/* Update display of window W.
3480 not stop when detecting pending input. */ 3464 If FORCE_P, don't stop updating when input is pending. */
3481 3465
3482static int 3466static bool
3483update_window (struct window *w, int force_p) 3467update_window (struct window *w, bool force_p)
3484{ 3468{
3485 struct glyph_matrix *desired_matrix = w->desired_matrix; 3469 struct glyph_matrix *desired_matrix = w->desired_matrix;
3486 int paused_p; 3470 bool paused_p;
3487#if !PERIODIC_PREEMPTION_CHECKING 3471#if !PERIODIC_PREEMPTION_CHECKING
3488 int preempt_count = baud_rate / 2400 + 1; 3472 int preempt_count = baud_rate / 2400 + 1;
3489#endif 3473#endif
@@ -3506,7 +3490,8 @@ update_window (struct window *w, int force_p)
3506 struct glyph_row *row, *end; 3490 struct glyph_row *row, *end;
3507 struct glyph_row *mode_line_row; 3491 struct glyph_row *mode_line_row;
3508 struct glyph_row *header_line_row; 3492 struct glyph_row *header_line_row;
3509 int yb, changed_p = 0, mouse_face_overwritten_p = 0; 3493 int yb;
3494 bool changed_p = 0, mouse_face_overwritten_p = 0;
3510#if ! PERIODIC_PREEMPTION_CHECKING 3495#if ! PERIODIC_PREEMPTION_CHECKING
3511 int n_updated = 0; 3496 int n_updated = 0;
3512#endif 3497#endif
@@ -3693,15 +3678,15 @@ update_marginal_area (struct window *w, int area, int vpos)
3693 3678
3694 3679
3695/* Update the display of the text area of row VPOS in window W. 3680/* Update the display of the text area of row VPOS in window W.
3696 Value is non-zero if display has changed. */ 3681 Value is true if display has changed. */
3697 3682
3698static int 3683static bool
3699update_text_area (struct window *w, int vpos) 3684update_text_area (struct window *w, int vpos)
3700{ 3685{
3701 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); 3686 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
3702 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); 3687 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
3703 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 3688 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
3704 int changed_p = 0; 3689 bool changed_p = 0;
3705 3690
3706 /* Let functions in xterm.c know what area subsequent X positions 3691 /* Let functions in xterm.c know what area subsequent X positions
3707 will be relative to. */ 3692 will be relative to. */
@@ -3751,9 +3736,9 @@ update_text_area (struct window *w, int vpos)
3751 int stop, i, x; 3736 int stop, i, x;
3752 struct glyph *current_glyph = current_row->glyphs[TEXT_AREA]; 3737 struct glyph *current_glyph = current_row->glyphs[TEXT_AREA];
3753 struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA]; 3738 struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA];
3754 int overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p; 3739 bool overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p;
3755 int desired_stop_pos = desired_row->used[TEXT_AREA]; 3740 int desired_stop_pos = desired_row->used[TEXT_AREA];
3756 int abort_skipping = 0; 3741 bool abort_skipping = 0;
3757 3742
3758 /* If the desired row extends its face to the text area end, and 3743 /* If the desired row extends its face to the text area end, and
3759 unless the current row also does so at the same position, 3744 unless the current row also does so at the same position,
@@ -3773,7 +3758,7 @@ update_text_area (struct window *w, int vpos)
3773 in common. */ 3758 in common. */
3774 while (i < stop) 3759 while (i < stop)
3775 { 3760 {
3776 int can_skip_p = !abort_skipping; 3761 bool can_skip_p = !abort_skipping;
3777 3762
3778 /* Skip over glyphs that both rows have in common. These 3763 /* Skip over glyphs that both rows have in common. These
3779 don't have to be written. We can't skip if the last 3764 don't have to be written. We can't skip if the last
@@ -3847,7 +3832,7 @@ update_text_area (struct window *w, int vpos)
3847 int start_x = x, start_hpos = i; 3832 int start_x = x, start_hpos = i;
3848 struct glyph *start = desired_glyph; 3833 struct glyph *start = desired_glyph;
3849 int current_x = x; 3834 int current_x = x;
3850 int skip_first_p = !can_skip_p; 3835 bool skip_first_p = !can_skip_p;
3851 3836
3852 /* Find the next glyph that's equal again. */ 3837 /* Find the next glyph that's equal again. */
3853 while (i < stop 3838 while (i < stop
@@ -3938,16 +3923,15 @@ update_text_area (struct window *w, int vpos)
3938} 3923}
3939 3924
3940 3925
3941/* Update row VPOS in window W. Value is non-zero if display has been 3926/* Update row VPOS in window W. Value is true if display has been changed. */
3942 changed. */
3943 3927
3944static int 3928static bool
3945update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p) 3929update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3946{ 3930{
3947 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); 3931 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
3948 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); 3932 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
3949 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 3933 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
3950 int changed_p = 0; 3934 bool changed_p = 0;
3951 3935
3952 /* Set the row being updated. This is important to let xterm.c 3936 /* Set the row being updated. This is important to let xterm.c
3953 know what line height values are in effect. */ 3937 know what line height values are in effect. */
@@ -4095,7 +4079,7 @@ set_window_cursor_after_update (struct window *w)
4095 tree rooted at W. */ 4079 tree rooted at W. */
4096 4080
4097void 4081void
4098set_window_update_flags (struct window *w, int on_p) 4082set_window_update_flags (struct window *w, bool on_p)
4099{ 4083{
4100 while (w) 4084 while (w)
4101 { 4085 {
@@ -4198,7 +4182,7 @@ add_row_entry (struct glyph_row *row)
4198 4182
4199 4183
4200/* Try to reuse part of the current display of W by scrolling lines. 4184/* Try to reuse part of the current display of W by scrolling lines.
4201 HEADER_LINE_P non-zero means W has a header line. 4185 HEADER_LINE_P means W has a header line.
4202 4186
4203 The algorithm is taken from Communications of the ACM, Apr78 "A 4187 The algorithm is taken from Communications of the ACM, Apr78 "A
4204 Technique for Isolating Differences Between Files." It should take 4188 Technique for Isolating Differences Between Files." It should take
@@ -4224,7 +4208,7 @@ add_row_entry (struct glyph_row *row)
4224 1 if we did scroll. */ 4208 1 if we did scroll. */
4225 4209
4226static int 4210static int
4227scrolling_window (struct window *w, int header_line_p) 4211scrolling_window (struct window *w, bool header_line_p)
4228{ 4212{
4229 struct glyph_matrix *desired_matrix = w->desired_matrix; 4213 struct glyph_matrix *desired_matrix = w->desired_matrix;
4230 struct glyph_matrix *current_matrix = w->current_matrix; 4214 struct glyph_matrix *current_matrix = w->current_matrix;
@@ -4237,7 +4221,7 @@ scrolling_window (struct window *w, int header_line_p)
4237 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 4221 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
4238 4222
4239 /* Skip over rows equal at the start. */ 4223 /* Skip over rows equal at the start. */
4240 for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i) 4224 for (i = header_line_p; i < current_matrix->nrows - 1; ++i)
4241 { 4225 {
4242 struct glyph_row *d = MATRIX_ROW (desired_matrix, i); 4226 struct glyph_row *d = MATRIX_ROW (desired_matrix, i);
4243 struct glyph_row *c = MATRIX_ROW (current_matrix, i); 4227 struct glyph_row *c = MATRIX_ROW (current_matrix, i);
@@ -4496,7 +4480,7 @@ scrolling_window (struct window *w, int header_line_p)
4496 for (j = nruns - 1; j > i; --j) 4480 for (j = nruns - 1; j > i; --j)
4497 { 4481 {
4498 struct run *p = runs[j]; 4482 struct run *p = runs[j];
4499 int truncated_p = 0; 4483 bool truncated_p = 0;
4500 4484
4501 if (p->nrows > 0 4485 if (p->nrows > 0
4502 && p->desired_y < r->desired_y + r->height 4486 && p->desired_y < r->desired_y + r->height
@@ -4559,7 +4543,7 @@ scrolling_window (struct window *w, int header_line_p)
4559 for (j = 0; j < r->nrows; ++j) 4543 for (j = 0; j < r->nrows; ++j)
4560 { 4544 {
4561 struct glyph_row *from, *to; 4545 struct glyph_row *from, *to;
4562 int to_overlapped_p; 4546 bool to_overlapped_p;
4563 4547
4564 to = MATRIX_ROW (current_matrix, r->desired_vpos + j); 4548 to = MATRIX_ROW (current_matrix, r->desired_vpos + j);
4565 from = MATRIX_ROW (desired_matrix, r->desired_vpos + j); 4549 from = MATRIX_ROW (desired_matrix, r->desired_vpos + j);
@@ -4594,20 +4578,19 @@ scrolling_window (struct window *w, int header_line_p)
4594 4578
4595/* Update the desired frame matrix of frame F. 4579/* Update the desired frame matrix of frame F.
4596 4580
4597 FORCE_P non-zero means that the update should not be stopped by 4581 FORCE_P means that the update should not be stopped by pending input.
4598 pending input. INHIBIT_HAIRY_ID_P non-zero means that scrolling 4582 INHIBIT_HAIRY_ID_P means that scrolling should not be tried.
4599 should not be tried.
4600 4583
4601 Value is non-zero if update was stopped due to pending input. */ 4584 Value is true if update was stopped due to pending input. */
4602 4585
4603static int 4586static bool
4604update_frame_1 (struct frame *f, int force_p, int inhibit_id_p) 4587update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
4605{ 4588{
4606 /* Frame matrices to work on. */ 4589 /* Frame matrices to work on. */
4607 struct glyph_matrix *current_matrix = f->current_matrix; 4590 struct glyph_matrix *current_matrix = f->current_matrix;
4608 struct glyph_matrix *desired_matrix = f->desired_matrix; 4591 struct glyph_matrix *desired_matrix = f->desired_matrix;
4609 int i; 4592 int i;
4610 int pause_p; 4593 bool pause_p;
4611 int preempt_count = baud_rate / 2400 + 1; 4594 int preempt_count = baud_rate / 2400 + 1;
4612 4595
4613 eassert (current_matrix && desired_matrix); 4596 eassert (current_matrix && desired_matrix);
@@ -4699,7 +4682,8 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
4699 } 4682 }
4700 } 4683 }
4701 4684
4702 pause_p = (i < FRAME_LINES (f) - 1) ? i : 0; 4685 lint_assume (0 <= FRAME_LINES (f));
4686 pause_p = 0 < i && i < FRAME_LINES (f) - 1;
4703 4687
4704 /* Now just clean up termcap drivers and set cursor, etc. */ 4688 /* Now just clean up termcap drivers and set cursor, etc. */
4705 if (!pause_p) 4689 if (!pause_p)
@@ -4809,7 +4793,7 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
4809 4793
4810/* Do line insertions/deletions on frame F for frame-based redisplay. */ 4794/* Do line insertions/deletions on frame F for frame-based redisplay. */
4811 4795
4812static int 4796static bool
4813scrolling (struct frame *frame) 4797scrolling (struct frame *frame)
4814{ 4798{
4815 int unchanged_at_top, unchanged_at_bottom; 4799 int unchanged_at_top, unchanged_at_bottom;
@@ -4952,10 +4936,10 @@ update_frame_line (struct frame *f, int vpos)
4952 struct glyph_matrix *desired_matrix = f->desired_matrix; 4936 struct glyph_matrix *desired_matrix = f->desired_matrix;
4953 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos); 4937 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos);
4954 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos); 4938 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos);
4955 int must_write_whole_line_p; 4939 bool must_write_whole_line_p;
4956 int write_spaces_p = FRAME_MUST_WRITE_SPACES (f); 4940 bool write_spaces_p = FRAME_MUST_WRITE_SPACES (f);
4957 int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background 4941 bool colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
4958 != FACE_TTY_DEFAULT_BG_COLOR); 4942 != FACE_TTY_DEFAULT_BG_COLOR);
4959 4943
4960 if (colored_spaces_p) 4944 if (colored_spaces_p)
4961 write_spaces_p = 1; 4945 write_spaces_p = 1;
@@ -5289,7 +5273,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5289 /* start_display takes into account the header-line row, but IT's 5273 /* start_display takes into account the header-line row, but IT's
5290 vpos still counts from the glyph row that includes the window's 5274 vpos still counts from the glyph row that includes the window's
5291 start position. Adjust for a possible header-line row. */ 5275 start position. Adjust for a possible header-line row. */
5292 it.vpos += WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0; 5276 it.vpos += WINDOW_WANTS_HEADER_LINE_P (w);
5293 5277
5294 x0 = *x; 5278 x0 = *x;
5295 5279
@@ -5613,12 +5597,12 @@ window_change_signal (int signalnum) /* If we don't have an argument, */
5613#endif /* SIGWINCH */ 5597#endif /* SIGWINCH */
5614 5598
5615 5599
5616/* Do any change in frame size that was requested by a signal. SAFE 5600/* Do any change in frame size that was requested by a signal.
5617 non-zero means this function is called from a place where it is 5601 SAFE means this function is called from a place where it is
5618 safe to change frame sizes while a redisplay is in progress. */ 5602 safe to change frame sizes while a redisplay is in progress. */
5619 5603
5620void 5604void
5621do_pending_window_change (int safe) 5605do_pending_window_change (bool safe)
5622{ 5606{
5623 /* If window_change_signal should have run before, run it now. */ 5607 /* If window_change_signal should have run before, run it now. */
5624 if (redisplaying_p && !safe) 5608 if (redisplaying_p && !safe)
@@ -5645,16 +5629,17 @@ do_pending_window_change (int safe)
5645/* Change the frame height and/or width. Values may be given as zero to 5629/* Change the frame height and/or width. Values may be given as zero to
5646 indicate no change is to take place. 5630 indicate no change is to take place.
5647 5631
5648 If DELAY is non-zero, then assume we're being called from a signal 5632 If DELAY, assume we're being called from a signal handler, and
5649 handler, and queue the change for later - perhaps the next 5633 queue the change for later - perhaps the next redisplay.
5650 redisplay. Since this tries to resize windows, we can't call it 5634 Since this tries to resize windows, we can't call it
5651 from a signal handler. 5635 from a signal handler.
5652 5636
5653 SAFE non-zero means this function is called from a place where it's 5637 SAFE means this function is called from a place where it's
5654 safe to change frame sizes while a redisplay is in progress. */ 5638 safe to change frame sizes while a redisplay is in progress. */
5655 5639
5656void 5640void
5657change_frame_size (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) 5641change_frame_size (struct frame *f, int newheight, int newwidth,
5642 bool pretend, bool delay, bool safe)
5658{ 5643{
5659 Lisp_Object tail, frame; 5644 Lisp_Object tail, frame;
5660 5645
@@ -5673,7 +5658,8 @@ change_frame_size (register struct frame *f, int newheight, int newwidth, int pr
5673} 5658}
5674 5659
5675static void 5660static void
5676change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) 5661change_frame_size_1 (struct frame *f, int newheight, int newwidth,
5662 bool pretend, bool delay, bool safe)
5677{ 5663{
5678 int new_frame_total_cols; 5664 int new_frame_total_cols;
5679 ptrdiff_t count = SPECPDL_INDEX (); 5665 ptrdiff_t count = SPECPDL_INDEX ();
@@ -5769,7 +5755,7 @@ change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int
5769 5755
5770 UNBLOCK_INPUT; 5756 UNBLOCK_INPUT;
5771 5757
5772 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 5758 record_unwind_current_buffer ();
5773 5759
5774 run_window_configuration_change_hook (f); 5760 run_window_configuration_change_hook (f);
5775 5761
@@ -5929,13 +5915,13 @@ additional wait period, in milliseconds; this is for backwards compatibility.
5929 5915
5930 TIMEOUT is number of seconds to wait (float or integer), 5916 TIMEOUT is number of seconds to wait (float or integer),
5931 or t to wait forever. 5917 or t to wait forever.
5932 READING is 1 if reading input. 5918 READING is true if reading input.
5933 If DO_DISPLAY is >0 display process output while waiting. 5919 If DO_DISPLAY is >0 display process output while waiting.
5934 If DO_DISPLAY is >1 perform an initial redisplay before waiting. 5920 If DO_DISPLAY is >1 perform an initial redisplay before waiting.
5935*/ 5921*/
5936 5922
5937Lisp_Object 5923Lisp_Object
5938sit_for (Lisp_Object timeout, int reading, int do_display) 5924sit_for (Lisp_Object timeout, bool reading, int do_display)
5939{ 5925{
5940 intmax_t sec; 5926 intmax_t sec;
5941 int nsec; 5927 int nsec;
@@ -6044,8 +6030,7 @@ pass nil for VARIABLE. */)
6044 (Lisp_Object variable) 6030 (Lisp_Object variable)
6045{ 6031{
6046 Lisp_Object state, tail, frame, buf; 6032 Lisp_Object state, tail, frame, buf;
6047 Lisp_Object *vecp, *end; 6033 ptrdiff_t n, idx;
6048 ptrdiff_t n;
6049 6034
6050 if (! NILP (variable)) 6035 if (! NILP (variable))
6051 { 6036 {
@@ -6057,18 +6042,16 @@ pass nil for VARIABLE. */)
6057 else 6042 else
6058 state = frame_and_buffer_state; 6043 state = frame_and_buffer_state;
6059 6044
6060 vecp = XVECTOR (state)->contents; 6045 idx = 0;
6061 end = vecp + ASIZE (state);
6062
6063 FOR_EACH_FRAME (tail, frame) 6046 FOR_EACH_FRAME (tail, frame)
6064 { 6047 {
6065 if (vecp == end) 6048 if (idx == ASIZE (state))
6066 goto changed; 6049 goto changed;
6067 if (!EQ (*vecp++, frame)) 6050 if (!EQ (AREF (state, idx++), frame))
6068 goto changed; 6051 goto changed;
6069 if (vecp == end) 6052 if (idx == ASIZE (state))
6070 goto changed; 6053 goto changed;
6071 if (!EQ (*vecp++, XFRAME (frame)->name)) 6054 if (!EQ (AREF (state, idx++), XFRAME (frame)->name))
6072 goto changed; 6055 goto changed;
6073 } 6056 }
6074 /* Check that the buffer info matches. */ 6057 /* Check that the buffer info matches. */
@@ -6078,23 +6061,23 @@ pass nil for VARIABLE. */)
6078 /* Ignore buffers that aren't included in buffer lists. */ 6061 /* Ignore buffers that aren't included in buffer lists. */
6079 if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ') 6062 if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ')
6080 continue; 6063 continue;
6081 if (vecp == end) 6064 if (idx == ASIZE (state))
6082 goto changed; 6065 goto changed;
6083 if (!EQ (*vecp++, buf)) 6066 if (!EQ (AREF (state, idx++), buf))
6084 goto changed; 6067 goto changed;
6085 if (vecp == end) 6068 if (idx == ASIZE (state))
6086 goto changed; 6069 goto changed;
6087 if (!EQ (*vecp++, BVAR (XBUFFER (buf), read_only))) 6070 if (!EQ (AREF (state, idx++), BVAR (XBUFFER (buf), read_only)))
6088 goto changed; 6071 goto changed;
6089 if (vecp == end) 6072 if (idx == ASIZE (state))
6090 goto changed; 6073 goto changed;
6091 if (!EQ (*vecp++, Fbuffer_modified_p (buf))) 6074 if (!EQ (AREF (state, idx++), Fbuffer_modified_p (buf)))
6092 goto changed; 6075 goto changed;
6093 } 6076 }
6094 if (vecp == end) 6077 if (idx == ASIZE (state))
6095 goto changed; 6078 goto changed;
6096 /* Detect deletion of a buffer at the end of the list. */ 6079 /* Detect deletion of a buffer at the end of the list. */
6097 if (EQ (*vecp, Qlambda)) 6080 if (EQ (AREF (state, idx), Qlambda))
6098 return Qnil; 6081 return Qnil;
6099 6082
6100 /* Come here if we decide the data has changed. */ 6083 /* Come here if we decide the data has changed. */
@@ -6121,11 +6104,13 @@ pass nil for VARIABLE. */)
6121 } 6104 }
6122 6105
6123 /* Record the new data in the (possibly reallocated) vector. */ 6106 /* Record the new data in the (possibly reallocated) vector. */
6124 vecp = XVECTOR (state)->contents; 6107 idx = 0;
6125 FOR_EACH_FRAME (tail, frame) 6108 FOR_EACH_FRAME (tail, frame)
6126 { 6109 {
6127 *vecp++ = frame; 6110 ASET (state, idx, frame);
6128 *vecp++ = XFRAME (frame)->name; 6111 idx++;
6112 ASET (state, idx, XFRAME (frame)->name);
6113 idx++;
6129 } 6114 }
6130 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail)) 6115 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
6131 { 6116 {
@@ -6133,19 +6118,23 @@ pass nil for VARIABLE. */)
6133 /* Ignore buffers that aren't included in buffer lists. */ 6118 /* Ignore buffers that aren't included in buffer lists. */
6134 if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ') 6119 if (SREF (BVAR (XBUFFER (buf), name), 0) == ' ')
6135 continue; 6120 continue;
6136 *vecp++ = buf; 6121 ASET (state, idx, buf);
6137 *vecp++ = BVAR (XBUFFER (buf), read_only); 6122 idx++;
6138 *vecp++ = Fbuffer_modified_p (buf); 6123 ASET (state, idx, BVAR (XBUFFER (buf), read_only));
6124 idx++;
6125 ASET (state, idx, Fbuffer_modified_p (buf));
6126 idx++;
6139 } 6127 }
6140 /* Fill up the vector with lambdas (always at least one). */ 6128 /* Fill up the vector with lambdas (always at least one). */
6141 *vecp++ = Qlambda; 6129 ASET (state, idx, Qlambda);
6142 while (vecp - XVECTOR (state)->contents 6130 idx++;
6143 < ASIZE (state)) 6131 while (idx < ASIZE (state))
6144 *vecp++ = Qlambda; 6132 {
6133 ASET (state, idx, Qlambda);
6134 idx++;
6135 }
6145 /* Make sure we didn't overflow the vector. */ 6136 /* Make sure we didn't overflow the vector. */
6146 if (vecp - XVECTOR (state)->contents 6137 eassert (idx <= ASIZE (state));
6147 > ASIZE (state))
6148 abort ();
6149 return Qt; 6138 return Qt;
6150} 6139}
6151 6140
diff --git a/src/doc.c b/src/doc.c
index ed311d918d7..02a5b4b8143 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -37,7 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37 37
38Lisp_Object Qfunction_documentation; 38Lisp_Object Qfunction_documentation;
39 39
40extern Lisp_Object Qclosure;
41/* Buffer used for reading from documentation file. */ 40/* Buffer used for reading from documentation file. */
42static char *get_doc_string_buffer; 41static char *get_doc_string_buffer;
43static ptrdiff_t get_doc_string_buffer_size; 42static ptrdiff_t get_doc_string_buffer_size;
@@ -48,7 +47,7 @@ static unsigned char *read_bytecode_pointer;
48 If UNREADFLAG is 1, we unread a byte. */ 47 If UNREADFLAG is 1, we unread a byte. */
49 48
50int 49int
51read_bytecode_char (int unreadflag) 50read_bytecode_char (bool unreadflag)
52{ 51{
53 if (unreadflag) 52 if (unreadflag)
54 { 53 {
@@ -70,20 +69,18 @@ read_bytecode_char (int unreadflag)
70 (e.g. because the file has been modified and the location is stale), 69 (e.g. because the file has been modified and the location is stale),
71 return nil. 70 return nil.
72 71
73 If UNIBYTE is nonzero, always make a unibyte string. 72 If UNIBYTE, always make a unibyte string.
74 73
75 If DEFINITION is nonzero, assume this is for reading 74 If DEFINITION, assume this is for reading
76 a dynamic function definition; convert the bytestring 75 a dynamic function definition; convert the bytestring
77 and the constants vector with appropriate byte handling, 76 and the constants vector with appropriate byte handling,
78 and return a cons cell. */ 77 and return a cons cell. */
79 78
80Lisp_Object 79Lisp_Object
81get_doc_string (Lisp_Object filepos, int unibyte, int definition) 80get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
82{ 81{
83 char *from, *to; 82 char *from, *to, *name, *p, *p1;
84 register int fd; 83 int fd;
85 register char *name;
86 register char *p, *p1;
87 ptrdiff_t minsize; 84 ptrdiff_t minsize;
88 int offset; 85 int offset;
89 EMACS_INT position; 86 EMACS_INT position;
@@ -302,7 +299,7 @@ read_doc_string (Lisp_Object filepos)
302 return get_doc_string (filepos, 0, 1); 299 return get_doc_string (filepos, 0, 1);
303} 300}
304 301
305static int 302static bool
306reread_doc_file (Lisp_Object file) 303reread_doc_file (Lisp_Object file)
307{ 304{
308#if 0 305#if 0
@@ -335,7 +332,7 @@ string is passed through `substitute-command-keys'. */)
335 Lisp_Object fun; 332 Lisp_Object fun;
336 Lisp_Object funcar; 333 Lisp_Object funcar;
337 Lisp_Object doc; 334 Lisp_Object doc;
338 int try_reload = 1; 335 bool try_reload = 1;
339 336
340 documentation: 337 documentation:
341 338
@@ -467,7 +464,7 @@ This differs from `get' in that it can refer to strings stored in the
467aren't strings. */) 464aren't strings. */)
468 (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw) 465 (Lisp_Object symbol, Lisp_Object prop, Lisp_Object raw)
469{ 466{
470 int try_reload = 1; 467 bool try_reload = 1;
471 Lisp_Object tem; 468 Lisp_Object tem;
472 469
473 documentation_property: 470 documentation_property:
@@ -562,12 +559,11 @@ the same file name is found in the `doc-directory'. */)
562{ 559{
563 int fd; 560 int fd;
564 char buf[1024 + 1]; 561 char buf[1024 + 1];
565 register int filled; 562 int filled;
566 register EMACS_INT pos; 563 EMACS_INT pos;
567 register char *p;
568 Lisp_Object sym; 564 Lisp_Object sym;
569 char *name; 565 char *p, *name;
570 int skip_file = 0; 566 bool skip_file = 0;
571 567
572 CHECK_STRING (filename); 568 CHECK_STRING (filename);
573 569
@@ -722,9 +718,9 @@ Otherwise, return a new string, without any text properties. */)
722 (Lisp_Object string) 718 (Lisp_Object string)
723{ 719{
724 char *buf; 720 char *buf;
725 int changed = 0; 721 bool changed = 0;
726 register unsigned char *strp; 722 unsigned char *strp;
727 register char *bufp; 723 char *bufp;
728 ptrdiff_t idx; 724 ptrdiff_t idx;
729 ptrdiff_t bsize; 725 ptrdiff_t bsize;
730 Lisp_Object tem; 726 Lisp_Object tem;
@@ -733,7 +729,7 @@ Otherwise, return a new string, without any text properties. */)
733 ptrdiff_t length, length_byte; 729 ptrdiff_t length, length_byte;
734 Lisp_Object name; 730 Lisp_Object name;
735 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 731 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
736 int multibyte; 732 bool multibyte;
737 ptrdiff_t nchars; 733 ptrdiff_t nchars;
738 734
739 if (NILP (string)) 735 if (NILP (string))
@@ -787,7 +783,7 @@ Otherwise, return a new string, without any text properties. */)
787 else if (strp[0] == '\\' && strp[1] == '[') 783 else if (strp[0] == '\\' && strp[1] == '[')
788 { 784 {
789 ptrdiff_t start_idx; 785 ptrdiff_t start_idx;
790 int follow_remap = 1; 786 bool follow_remap = 1;
791 787
792 changed = 1; 788 changed = 1;
793 strp += 2; /* skip \[ */ 789 strp += 2; /* skip \[ */
diff --git a/src/editfns.c b/src/editfns.c
index fa57edead28..a14e043c1bf 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -65,7 +65,7 @@ extern Lisp_Object w32_get_internal_run_time (void);
65#endif 65#endif
66 66
67static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME, 67static Lisp_Object format_time_string (char const *, ptrdiff_t, EMACS_TIME,
68 int, struct tm *); 68 bool, struct tm *);
69static int tm_diff (struct tm *, struct tm *); 69static int tm_diff (struct tm *, struct tm *);
70static void update_buffer_properties (ptrdiff_t, ptrdiff_t); 70static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
71 71
@@ -246,11 +246,11 @@ The return value is POSITION. */)
246 246
247 247
248/* Return the start or end position of the region. 248/* Return the start or end position of the region.
249 BEGINNINGP non-zero means return the start. 249 BEGINNINGP means return the start.
250 If there is no region active, signal an error. */ 250 If there is no region active, signal an error. */
251 251
252static Lisp_Object 252static Lisp_Object
253region_limit (int beginningp) 253region_limit (bool beginningp)
254{ 254{
255 Lisp_Object m; 255 Lisp_Object m;
256 256
@@ -264,7 +264,7 @@ region_limit (int beginningp)
264 error ("The mark is not set now, so there is no region"); 264 error ("The mark is not set now, so there is no region");
265 265
266 /* Clip to the current narrowing (bug#11770). */ 266 /* Clip to the current narrowing (bug#11770). */
267 return make_number ((PT < XFASTINT (m)) == (beginningp != 0) 267 return make_number ((PT < XFASTINT (m)) == beginningp
268 ? PT 268 ? PT
269 : clip_to_bounds (BEGV, XFASTINT (m), ZV)); 269 : clip_to_bounds (BEGV, XFASTINT (m), ZV));
270} 270}
@@ -435,12 +435,12 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o
435 BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned 435 BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned
436 results; they do not effect boundary behavior. 436 results; they do not effect boundary behavior.
437 437
438 If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first 438 If MERGE_AT_BOUNDARY is non-nil, then if POS is at the very first
439 position of a field, then the beginning of the previous field is 439 position of a field, then the beginning of the previous field is
440 returned instead of the beginning of POS's field (since the end of a 440 returned instead of the beginning of POS's field (since the end of a
441 field is actually also the beginning of the next input field, this 441 field is actually also the beginning of the next input field, this
442 behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY 442 behavior is sometimes useful). Additionally in the MERGE_AT_BOUNDARY
443 true case, if two fields are separated by a field with the special 443 non-nil case, if two fields are separated by a field with the special
444 value `boundary', and POS lies within it, then the two separated 444 value `boundary', and POS lies within it, then the two separated
445 fields are considered to be adjacent, and POS between them, when 445 fields are considered to be adjacent, and POS between them, when
446 finding the beginning and ending of the "merged" field. 446 finding the beginning and ending of the "merged" field.
@@ -455,10 +455,10 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
455{ 455{
456 /* Fields right before and after the point. */ 456 /* Fields right before and after the point. */
457 Lisp_Object before_field, after_field; 457 Lisp_Object before_field, after_field;
458 /* 1 if POS counts as the start of a field. */ 458 /* True if POS counts as the start of a field. */
459 int at_field_start = 0; 459 bool at_field_start = 0;
460 /* 1 if POS counts as the end of a field. */ 460 /* True if POS counts as the end of a field. */
461 int at_field_end = 0; 461 bool at_field_end = 0;
462 462
463 if (NILP (pos)) 463 if (NILP (pos))
464 XSETFASTINT (pos, PT); 464 XSETFASTINT (pos, PT);
@@ -502,19 +502,19 @@ find_field (Lisp_Object pos, Lisp_Object merge_at_boundary,
502 502
503 xxxx.yyyy 503 xxxx.yyyy
504 504
505 In this situation, if merge_at_boundary is true, we consider the 505 In this situation, if merge_at_boundary is non-nil, consider the
506 `x' and `y' fields as forming one big merged field, and so the end 506 `x' and `y' fields as forming one big merged field, and so the end
507 of the field is the end of `y'. 507 of the field is the end of `y'.
508 508
509 However, if `x' and `y' are separated by a special `boundary' field 509 However, if `x' and `y' are separated by a special `boundary' field
510 (a field with a `field' char-property of 'boundary), then we ignore 510 (a field with a `field' char-property of 'boundary), then ignore
511 this special field when merging adjacent fields. Here's the same 511 this special field when merging adjacent fields. Here's the same
512 situation, but with a `boundary' field between the `x' and `y' fields: 512 situation, but with a `boundary' field between the `x' and `y' fields:
513 513
514 xxx.BBBByyyy 514 xxx.BBBByyyy
515 515
516 Here, if point is at the end of `x', the beginning of `y', or 516 Here, if point is at the end of `x', the beginning of `y', or
517 anywhere in-between (within the `boundary' field), we merge all 517 anywhere in-between (within the `boundary' field), merge all
518 three fields and consider the beginning as being the beginning of 518 three fields and consider the beginning as being the beginning of
519 the `x' field, and the end as being the end of the `y' field. */ 519 the `x' field, and the end as being the end of the `y' field. */
520 520
@@ -658,7 +658,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
658{ 658{
659 /* If non-zero, then the original point, before re-positioning. */ 659 /* If non-zero, then the original point, before re-positioning. */
660 ptrdiff_t orig_point = 0; 660 ptrdiff_t orig_point = 0;
661 int fwd; 661 bool fwd;
662 Lisp_Object prev_old, prev_new; 662 Lisp_Object prev_old, prev_new;
663 663
664 if (NILP (new_pos)) 664 if (NILP (new_pos))
@@ -816,8 +816,8 @@ This function does not move point. */)
816Lisp_Object 816Lisp_Object
817save_excursion_save (void) 817save_excursion_save (void)
818{ 818{
819 int visible = (XBUFFER (XWINDOW (selected_window)->buffer) 819 bool visible = (XBUFFER (XWINDOW (selected_window)->buffer)
820 == current_buffer); 820 == current_buffer);
821 821
822 return Fcons (Fpoint_marker (), 822 return Fcons (Fpoint_marker (),
823 Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil), 823 Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil),
@@ -831,7 +831,7 @@ save_excursion_restore (Lisp_Object info)
831{ 831{
832 Lisp_Object tem, tem1, omark, nmark; 832 Lisp_Object tem, tem1, omark, nmark;
833 struct gcpro gcpro1, gcpro2, gcpro3; 833 struct gcpro gcpro1, gcpro2, gcpro3;
834 int visible_p; 834 bool visible_p;
835 835
836 tem = Fmarker_buffer (XCAR (info)); 836 tem = Fmarker_buffer (XCAR (info));
837 /* If buffer being returned to is now deleted, avoid error */ 837 /* If buffer being returned to is now deleted, avoid error */
@@ -946,13 +946,10 @@ BODY is executed just like `progn'.
946usage: (save-current-buffer &rest BODY) */) 946usage: (save-current-buffer &rest BODY) */)
947 (Lisp_Object args) 947 (Lisp_Object args)
948{ 948{
949 Lisp_Object val;
950 ptrdiff_t count = SPECPDL_INDEX (); 949 ptrdiff_t count = SPECPDL_INDEX ();
951 950
952 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 951 record_unwind_current_buffer ();
953 952 return unbind_to (count, Fprogn (args));
954 val = Fprogn (args);
955 return unbind_to (count, val);
956} 953}
957 954
958DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0, 955DEFUN ("buffer-size", Fbufsize, Sbufsize, 0, 1, 0,
@@ -1470,8 +1467,8 @@ make_lisp_time (EMACS_TIME t)
1470 1467
1471/* Decode a Lisp list SPECIFIED_TIME that represents a time. 1468/* Decode a Lisp list SPECIFIED_TIME that represents a time.
1472 Set *PHIGH, *PLOW, *PUSEC, *PPSEC to its parts; do not check their values. 1469 Set *PHIGH, *PLOW, *PUSEC, *PPSEC to its parts; do not check their values.
1473 Return nonzero if successful. */ 1470 Return true if successful. */
1474static int 1471static bool
1475disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh, 1472disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh,
1476 Lisp_Object *plow, Lisp_Object *pusec, 1473 Lisp_Object *plow, Lisp_Object *pusec,
1477 Lisp_Object *ppsec) 1474 Lisp_Object *ppsec)
@@ -1514,8 +1511,8 @@ disassemble_lisp_time (Lisp_Object specified_time, Lisp_Object *phigh,
1514 If *DRESULT is not null, store into *DRESULT the number of 1511 If *DRESULT is not null, store into *DRESULT the number of
1515 seconds since the start of the POSIX Epoch. 1512 seconds since the start of the POSIX Epoch.
1516 1513
1517 Return nonzero if successful. */ 1514 Return true if successful. */
1518int 1515bool
1519decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec, 1516decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec,
1520 Lisp_Object psec, 1517 Lisp_Object psec,
1521 EMACS_TIME *result, double *dresult) 1518 EMACS_TIME *result, double *dresult)
@@ -1635,7 +1632,7 @@ or (if you need time as a string) `format-time-string'. */)
1635 1632
1636/* Write information into buffer S of size MAXSIZE, according to the 1633/* Write information into buffer S of size MAXSIZE, according to the
1637 FORMAT of length FORMAT_LEN, using time information taken from *TP. 1634 FORMAT of length FORMAT_LEN, using time information taken from *TP.
1638 Default to Universal Time if UT is nonzero, local time otherwise. 1635 Default to Universal Time if UT, local time otherwise.
1639 Use NS as the number of nanoseconds in the %N directive. 1636 Use NS as the number of nanoseconds in the %N directive.
1640 Return the number of bytes written, not including the terminating 1637 Return the number of bytes written, not including the terminating
1641 '\0'. If S is NULL, nothing will be written anywhere; so to 1638 '\0'. If S is NULL, nothing will be written anywhere; so to
@@ -1646,7 +1643,7 @@ or (if you need time as a string) `format-time-string'. */)
1646 bytes in FORMAT and it does not support nanoseconds. */ 1643 bytes in FORMAT and it does not support nanoseconds. */
1647static size_t 1644static size_t
1648emacs_nmemftime (char *s, size_t maxsize, const char *format, 1645emacs_nmemftime (char *s, size_t maxsize, const char *format,
1649 size_t format_len, const struct tm *tp, int ut, int ns) 1646 size_t format_len, const struct tm *tp, bool ut, int ns)
1650{ 1647{
1651 size_t total = 0; 1648 size_t total = 0;
1652 1649
@@ -1751,7 +1748,7 @@ usage: (format-time-string FORMAT-STRING &optional TIME UNIVERSAL) */)
1751 1748
1752static Lisp_Object 1749static Lisp_Object
1753format_time_string (char const *format, ptrdiff_t formatlen, 1750format_time_string (char const *format, ptrdiff_t formatlen,
1754 EMACS_TIME t, int ut, struct tm *tmp) 1751 EMACS_TIME t, bool ut, struct tm *tmp)
1755{ 1752{
1756 char buffer[4000]; 1753 char buffer[4000];
1757 char *buf = buffer; 1754 char *buf = buffer;
@@ -2231,11 +2228,11 @@ general_insert_function (void (*insert_func)
2231 (const char *, ptrdiff_t), 2228 (const char *, ptrdiff_t),
2232 void (*insert_from_string_func) 2229 void (*insert_from_string_func)
2233 (Lisp_Object, ptrdiff_t, ptrdiff_t, 2230 (Lisp_Object, ptrdiff_t, ptrdiff_t,
2234 ptrdiff_t, ptrdiff_t, int), 2231 ptrdiff_t, ptrdiff_t, bool),
2235 int inherit, ptrdiff_t nargs, Lisp_Object *args) 2232 bool inherit, ptrdiff_t nargs, Lisp_Object *args)
2236{ 2233{
2237 ptrdiff_t argnum; 2234 ptrdiff_t argnum;
2238 register Lisp_Object val; 2235 Lisp_Object val;
2239 2236
2240 for (argnum = 0; argnum < nargs; argnum++) 2237 for (argnum = 0; argnum < nargs; argnum++)
2241 { 2238 {
@@ -2458,7 +2455,7 @@ from adjoining text, if those properties are sticky. */)
2458/* Return a Lisp_String containing the text of the current buffer from 2455/* Return a Lisp_String containing the text of the current buffer from
2459 START to END. If text properties are in use and the current buffer 2456 START to END. If text properties are in use and the current buffer
2460 has properties in the range specified, the resulting string will also 2457 has properties in the range specified, the resulting string will also
2461 have them, if PROPS is nonzero. 2458 have them, if PROPS is true.
2462 2459
2463 We don't want to use plain old make_string here, because it calls 2460 We don't want to use plain old make_string here, because it calls
2464 make_uninit_string, which can cause the buffer arena to be 2461 make_uninit_string, which can cause the buffer arena to be
@@ -2469,7 +2466,7 @@ from adjoining text, if those properties are sticky. */)
2469 buffer substrings. */ 2466 buffer substrings. */
2470 2467
2471Lisp_Object 2468Lisp_Object
2472make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props) 2469make_buffer_string (ptrdiff_t start, ptrdiff_t end, bool props)
2473{ 2470{
2474 ptrdiff_t start_byte = CHAR_TO_BYTE (start); 2471 ptrdiff_t start_byte = CHAR_TO_BYTE (start);
2475 ptrdiff_t end_byte = CHAR_TO_BYTE (end); 2472 ptrdiff_t end_byte = CHAR_TO_BYTE (end);
@@ -2482,7 +2479,7 @@ make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props)
2482 2479
2483 If text properties are in use and the current buffer 2480 If text properties are in use and the current buffer
2484 has properties in the range specified, the resulting string will also 2481 has properties in the range specified, the resulting string will also
2485 have them, if PROPS is nonzero. 2482 have them, if PROPS is true.
2486 2483
2487 We don't want to use plain old make_string here, because it calls 2484 We don't want to use plain old make_string here, because it calls
2488 make_uninit_string, which can cause the buffer arena to be 2485 make_uninit_string, which can cause the buffer arena to be
@@ -2494,7 +2491,7 @@ make_buffer_string (ptrdiff_t start, ptrdiff_t end, int props)
2494 2491
2495Lisp_Object 2492Lisp_Object
2496make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte, 2493make_buffer_string_both (ptrdiff_t start, ptrdiff_t start_byte,
2497 ptrdiff_t end, ptrdiff_t end_byte, int props) 2494 ptrdiff_t end, ptrdiff_t end_byte, bool props)
2498{ 2495{
2499 Lisp_Object result, tem, tem1; 2496 Lisp_Object result, tem, tem1;
2500 2497
@@ -2845,7 +2842,8 @@ Both characters must have the same length of multi-byte form. */)
2845#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) 2842#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
2846 int maybe_byte_combining = COMBINING_NO; 2843 int maybe_byte_combining = COMBINING_NO;
2847 ptrdiff_t last_changed = 0; 2844 ptrdiff_t last_changed = 0;
2848 int multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 2845 bool multibyte_p
2846 = !NILP (BVAR (current_buffer, enable_multibyte_characters));
2849 int fromc, toc; 2847 int fromc, toc;
2850 2848
2851 restart: 2849 restart:
@@ -3081,8 +3079,8 @@ It returns the number of characters changed. */)
3081 int cnt; /* Number of changes made. */ 3079 int cnt; /* Number of changes made. */
3082 ptrdiff_t size; /* Size of translate table. */ 3080 ptrdiff_t size; /* Size of translate table. */
3083 ptrdiff_t pos, pos_byte, end_pos; 3081 ptrdiff_t pos, pos_byte, end_pos;
3084 int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 3082 bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
3085 int string_multibyte IF_LINT (= 0); 3083 bool string_multibyte IF_LINT (= 0);
3086 3084
3087 validate_region (&start, &end); 3085 validate_region (&start, &end);
3088 if (CHAR_TABLE_P (table)) 3086 if (CHAR_TABLE_P (table))
@@ -3642,20 +3640,20 @@ usage: (format STRING &rest OBJECTS) */)
3642 ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1; 3640 ptrdiff_t max_bufsize = STRING_BYTES_BOUND + 1;
3643 char *p; 3641 char *p;
3644 Lisp_Object buf_save_value IF_LINT (= {0}); 3642 Lisp_Object buf_save_value IF_LINT (= {0});
3645 register char *format, *end, *format_start; 3643 char *format, *end, *format_start;
3646 ptrdiff_t formatlen, nchars; 3644 ptrdiff_t formatlen, nchars;
3647 /* Nonzero if the format is multibyte. */ 3645 /* True if the format is multibyte. */
3648 int multibyte_format = 0; 3646 bool multibyte_format = 0;
3649 /* Nonzero if the output should be a multibyte string, 3647 /* True if the output should be a multibyte string,
3650 which is true if any of the inputs is one. */ 3648 which is true if any of the inputs is one. */
3651 int multibyte = 0; 3649 bool multibyte = 0;
3652 /* When we make a multibyte string, we must pay attention to the 3650 /* When we make a multibyte string, we must pay attention to the
3653 byte combining problem, i.e., a byte may be combined with a 3651 byte combining problem, i.e., a byte may be combined with a
3654 multibyte character of the previous string. This flag tells if we 3652 multibyte character of the previous string. This flag tells if we
3655 must consider such a situation or not. */ 3653 must consider such a situation or not. */
3656 int maybe_combine_byte; 3654 bool maybe_combine_byte;
3657 Lisp_Object val; 3655 Lisp_Object val;
3658 int arg_intervals = 0; 3656 bool arg_intervals = 0;
3659 USE_SAFE_ALLOCA; 3657 USE_SAFE_ALLOCA;
3660 3658
3661 /* discarded[I] is 1 if byte I of the format 3659 /* discarded[I] is 1 if byte I of the format
@@ -3671,8 +3669,8 @@ usage: (format STRING &rest OBJECTS) */)
3671 struct info 3669 struct info
3672 { 3670 {
3673 ptrdiff_t start, end; 3671 ptrdiff_t start, end;
3674 int converted_to_string; 3672 unsigned converted_to_string : 1;
3675 int intervals; 3673 unsigned intervals : 1;
3676 } *info = 0; 3674 } *info = 0;
3677 3675
3678 /* It should not be necessary to GCPRO ARGS, because 3676 /* It should not be necessary to GCPRO ARGS, because
@@ -3749,13 +3747,13 @@ usage: (format STRING &rest OBJECTS) */)
3749 digits to print after the '.' for floats, or the max. 3747 digits to print after the '.' for floats, or the max.
3750 number of chars to print from a string. */ 3748 number of chars to print from a string. */
3751 3749
3752 int minus_flag = 0; 3750 bool minus_flag = 0;
3753 int plus_flag = 0; 3751 bool plus_flag = 0;
3754 int space_flag = 0; 3752 bool space_flag = 0;
3755 int sharp_flag = 0; 3753 bool sharp_flag = 0;
3756 int zero_flag = 0; 3754 bool zero_flag = 0;
3757 ptrdiff_t field_width; 3755 ptrdiff_t field_width;
3758 int precision_given; 3756 bool precision_given;
3759 uintmax_t precision = UINTMAX_MAX; 3757 uintmax_t precision = UINTMAX_MAX;
3760 char *num_end; 3758 char *num_end;
3761 char conversion; 3759 char conversion;
@@ -4135,7 +4133,7 @@ usage: (format STRING &rest OBJECTS) */)
4135 char *src = sprintf_buf; 4133 char *src = sprintf_buf;
4136 char src0 = src[0]; 4134 char src0 = src[0];
4137 int exponent_bytes = 0; 4135 int exponent_bytes = 0;
4138 int signedp = src0 == '-' || src0 == '+' || src0 == ' '; 4136 bool signedp = src0 == '-' || src0 == '+' || src0 == ' ';
4139 int significand_bytes; 4137 int significand_bytes;
4140 if (zero_flag 4138 if (zero_flag
4141 && ((src[signedp] >= '0' && src[signedp] <= '9') 4139 && ((src[signedp] >= '0' && src[signedp] <= '9')
diff --git a/src/emacs.c b/src/emacs.c
index a039e89d48f..3c814a36043 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -31,6 +31,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 31
32#include "lisp.h" 32#include "lisp.h"
33 33
34#ifdef HAVE_WINDOW_SYSTEM
35#include TERM_HEADER
36#endif /* HAVE_WINDOW_SYSTEM */
37
34#ifdef WINDOWSNT 38#ifdef WINDOWSNT
35#include <fcntl.h> 39#include <fcntl.h>
36#include <windows.h> /* just for w32.h */ 40#include <windows.h> /* just for w32.h */
@@ -62,20 +66,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62#include "gnutls.h" 66#include "gnutls.h"
63#endif 67#endif
64 68
65#ifdef HAVE_NS
66#include "nsterm.h"
67#endif
68
69#if (defined PROFILING \ 69#if (defined PROFILING \
70 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)) 70 && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
71# include <sys/gmon.h> 71# include <sys/gmon.h>
72extern void moncontrol (int mode); 72extern void moncontrol (int mode);
73#endif 73#endif
74 74
75#ifdef HAVE_X_WINDOWS
76#include "xterm.h"
77#endif
78
79#ifdef HAVE_SETLOCALE 75#ifdef HAVE_SETLOCALE
80#include <locale.h> 76#include <locale.h>
81#endif 77#endif
@@ -99,10 +95,10 @@ static const char emacs_copyright[] = "Copyright (C) 2012 Free Software Foundati
99/* Empty lisp strings. To avoid having to build any others. */ 95/* Empty lisp strings. To avoid having to build any others. */
100Lisp_Object empty_unibyte_string, empty_multibyte_string; 96Lisp_Object empty_unibyte_string, empty_multibyte_string;
101 97
102/* Set nonzero after Emacs has started up the first time. 98/* Set after Emacs has started up the first time.
103 Prevents reinitialization of the Lisp world and keymaps 99 Prevents reinitialization of the Lisp world and keymaps
104 on subsequent starts. */ 100 on subsequent starts. */
105int initialized; 101bool initialized;
106 102
107#ifdef DARWIN_OS 103#ifdef DARWIN_OS
108extern void unexec_init_emacs_zone (void); 104extern void unexec_init_emacs_zone (void);
@@ -116,9 +112,9 @@ static void *malloc_state_ptr;
116extern void *malloc_get_state (void); 112extern void *malloc_get_state (void);
117/* From glibc, a routine that overwrites the malloc internal state. */ 113/* From glibc, a routine that overwrites the malloc internal state. */
118extern int malloc_set_state (void*); 114extern int malloc_set_state (void*);
119/* Non-zero if the MALLOC_CHECK_ environment variable was set while 115/* True if the MALLOC_CHECK_ environment variable was set while
120 dumping. Used to work around a bug in glibc's malloc. */ 116 dumping. Used to work around a bug in glibc's malloc. */
121static int malloc_using_checking; 117static bool malloc_using_checking;
122#endif 118#endif
123 119
124Lisp_Object Qfile_name_handler_alist; 120Lisp_Object Qfile_name_handler_alist;
@@ -127,17 +123,17 @@ Lisp_Object Qrisky_local_variable;
127 123
128Lisp_Object Qkill_emacs; 124Lisp_Object Qkill_emacs;
129 125
130/* If non-zero, Emacs should not attempt to use a window-specific code, 126/* If true, Emacs should not attempt to use a window-specific code,
131 but instead should use the virtual terminal under which it was started. */ 127 but instead should use the virtual terminal under which it was started. */
132int inhibit_window_system; 128bool inhibit_window_system;
133 129
134/* If non-zero, a filter or a sentinel is running. Tested to save the match 130/* If true, a filter or a sentinel is running. Tested to save the match
135 data on the first attempt to change it inside asynchronous code. */ 131 data on the first attempt to change it inside asynchronous code. */
136int running_asynch_code; 132bool running_asynch_code;
137 133
138#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 134#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
139/* If non-zero, -d was specified, meaning we're using some window system. */ 135/* If true, -d was specified, meaning we're using some window system. */
140int display_arg; 136bool display_arg;
141#endif 137#endif
142 138
143#if defined (DOUG_LEA_MALLOC) || defined (GNU_LINUX) 139#if defined (DOUG_LEA_MALLOC) || defined (GNU_LINUX)
@@ -150,11 +146,11 @@ static void *my_heap_start;
150static uprintmax_t heap_bss_diff; 146static uprintmax_t heap_bss_diff;
151#endif 147#endif
152 148
153/* Nonzero means running Emacs without interactive terminal. */ 149/* True means running Emacs without interactive terminal. */
154int noninteractive; 150bool noninteractive;
155 151
156/* Nonzero means remove site-lisp directories from load-path. */ 152/* True means remove site-lisp directories from load-path. */
157int no_site_lisp; 153bool no_site_lisp;
158 154
159/* Name for the server started by the daemon.*/ 155/* Name for the server started by the daemon.*/
160static char *daemon_name; 156static char *daemon_name;
@@ -272,13 +268,8 @@ section of the Emacs manual or the file BUGS.\n"
272/* Signal code for the fatal signal that was received. */ 268/* Signal code for the fatal signal that was received. */
273static int fatal_error_code; 269static int fatal_error_code;
274 270
275/* Nonzero if handling a fatal error already. */ 271/* True if handling a fatal error already. */
276int fatal_error_in_progress; 272bool fatal_error_in_progress;
277
278/* If non-null, call this function from fatal_error_signal before
279 committing suicide. */
280
281static void (*fatal_error_signal_hook) (void);
282 273
283#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 274#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
284/* When compiled with GTK and running under Gnome, 275/* When compiled with GTK and running under Gnome,
@@ -316,7 +307,7 @@ fatal_error_signal (int sig)
316 if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT) 307 if (sig == SIGTERM || sig == SIGHUP || sig == SIGINT)
317 Fkill_emacs (make_number (sig)); 308 Fkill_emacs (make_number (sig));
318 309
319 shut_down_emacs (sig, 0, Qnil); 310 shut_down_emacs (sig, Qnil);
320 } 311 }
321 312
322 /* Signal the same code; this time it will really be fatal. 313 /* Signal the same code; this time it will really be fatal.
@@ -327,9 +318,6 @@ fatal_error_signal (int sig)
327 sigunblock (sigmask (fatal_error_code)); 318 sigunblock (sigmask (fatal_error_code));
328#endif 319#endif
329 320
330 if (fatal_error_signal_hook)
331 fatal_error_signal_hook ();
332
333 kill (getpid (), fatal_error_code); 321 kill (getpid (), fatal_error_code);
334} 322}
335 323
@@ -576,7 +564,7 @@ DEFINE_DUMMY_FUNCTION (__main)
576 Too bad we can't just use getopt for all of this, but we don't have 564 Too bad we can't just use getopt for all of this, but we don't have
577 enough information to do it right. */ 565 enough information to do it right. */
578 566
579static int 567static bool
580argmatch (char **argv, int argc, const char *sstr, const char *lstr, 568argmatch (char **argv, int argc, const char *sstr, const char *lstr,
581 int minlen, char **valptr, int *skipptr) 569 int minlen, char **valptr, int *skipptr)
582{ 570{
@@ -680,12 +668,12 @@ int
680main (int argc, char **argv) 668main (int argc, char **argv)
681{ 669{
682 char stack_bottom_variable; 670 char stack_bottom_variable;
683 int do_initial_setlocale; 671 bool do_initial_setlocale;
684 int skip_args = 0; 672 int skip_args = 0;
685#ifdef HAVE_SETRLIMIT 673#ifdef HAVE_SETRLIMIT
686 struct rlimit rlim; 674 struct rlimit rlim;
687#endif 675#endif
688 int no_loadup = 0; 676 bool no_loadup = 0;
689 char *junk = 0; 677 char *junk = 0;
690 char *dname_arg = 0; 678 char *dname_arg = 0;
691#ifdef NS_IMPL_COCOA 679#ifdef NS_IMPL_COCOA
@@ -1280,6 +1268,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1280 init_data (); 1268 init_data ();
1281 init_atimer (); 1269 init_atimer ();
1282 running_asynch_code = 0; 1270 running_asynch_code = 0;
1271 init_random ();
1283 1272
1284 no_loadup 1273 no_loadup
1285 = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); 1274 = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
@@ -1959,7 +1948,7 @@ all of which are called before Emacs is actually killed. */)
1959 x_clipboard_manager_save_all (); 1948 x_clipboard_manager_save_all ();
1960#endif 1949#endif
1961 1950
1962 shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil); 1951 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil);
1963 1952
1964#ifdef HAVE_NS 1953#ifdef HAVE_NS
1965 ns_release_autorelease_pool (ns_pool); 1954 ns_release_autorelease_pool (ns_pool);
@@ -1995,7 +1984,7 @@ all of which are called before Emacs is actually killed. */)
1995 and Fkill_emacs. */ 1984 and Fkill_emacs. */
1996 1985
1997void 1986void
1998shut_down_emacs (int sig, int no_x, Lisp_Object stuff) 1987shut_down_emacs (int sig, Lisp_Object stuff)
1999{ 1988{
2000 /* Prevent running of hooks from now on. */ 1989 /* Prevent running of hooks from now on. */
2001 Vrun_hooks = Qnil; 1990 Vrun_hooks = Qnil;
@@ -2030,17 +2019,6 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
2030 unlock_all_files (); 2019 unlock_all_files ();
2031#endif 2020#endif
2032 2021
2033#if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
2034#ifdef HAVE_X_WINDOWS
2035 /* It's not safe to call intern here. Maybe we are crashing. */
2036 if (!noninteractive && SYMBOLP (Vinitial_window_system)
2037 && SCHARS (SYMBOL_NAME (Vinitial_window_system)) == 1
2038 && SREF (SYMBOL_NAME (Vinitial_window_system), 0) == 'x'
2039 && ! no_x)
2040 Fx_close_current_connection ();
2041#endif /* HAVE_X_WINDOWS */
2042#endif
2043
2044#ifdef SIGIO 2022#ifdef SIGIO
2045 /* There is a tendency for a SIGIO signal to arrive within exit, 2023 /* There is a tendency for a SIGIO signal to arrive within exit,
2046 and cause a SIGHUP because the input descriptor is already closed. */ 2024 and cause a SIGHUP because the input descriptor is already closed. */
@@ -2232,7 +2210,7 @@ decode_env_path (const char *evarname, const char *defalt)
2232 const char *path, *p; 2210 const char *path, *p;
2233 Lisp_Object lpath, element, tem; 2211 Lisp_Object lpath, element, tem;
2234#ifdef WINDOWSNT 2212#ifdef WINDOWSNT
2235 int defaulted = 0; 2213 bool defaulted = 0;
2236 const char *emacs_dir = egetenv ("emacs_dir"); 2214 const char *emacs_dir = egetenv ("emacs_dir");
2237 static const char *emacs_dir_env = "%emacs_dir%/"; 2215 static const char *emacs_dir_env = "%emacs_dir%/";
2238 const size_t emacs_dir_len = strlen (emacs_dir_env); 2216 const size_t emacs_dir_len = strlen (emacs_dir_env);
@@ -2328,7 +2306,7 @@ from the parent process and its tty file descriptors. */)
2328 (void) 2306 (void)
2329{ 2307{
2330 int nfd; 2308 int nfd;
2331 int err = 0; 2309 bool err = 0;
2332 2310
2333 if (!IS_DAEMON) 2311 if (!IS_DAEMON)
2334 error ("This function can only be called if emacs is run as a daemon"); 2312 error ("This function can only be called if emacs is run as a daemon");
diff --git a/src/eval.c b/src/eval.c
index c7a35fc91af..ecdbe960a8a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -131,7 +131,7 @@ int handling_signal;
131Lisp_Object inhibit_lisp_code; 131Lisp_Object inhibit_lisp_code;
132 132
133static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *); 133static Lisp_Object funcall_lambda (Lisp_Object, ptrdiff_t, Lisp_Object *);
134static int interactive_p (int); 134static bool interactive_p (void);
135static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); 135static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
136 136
137/* Functions to set Lisp_Object slots of struct specbinding. */ 137/* Functions to set Lisp_Object slots of struct specbinding. */
@@ -213,7 +213,7 @@ restore_stack_limits (Lisp_Object data)
213static Lisp_Object 213static Lisp_Object
214call_debugger (Lisp_Object arg) 214call_debugger (Lisp_Object arg)
215{ 215{
216 int debug_while_redisplaying; 216 bool debug_while_redisplaying;
217 ptrdiff_t count = SPECPDL_INDEX (); 217 ptrdiff_t count = SPECPDL_INDEX ();
218 Lisp_Object val; 218 Lisp_Object val;
219 EMACS_INT old_max = max_specpdl_size; 219 EMACS_INT old_max = max_specpdl_size;
@@ -544,7 +544,7 @@ spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
544use `called-interactively-p'. */) 544use `called-interactively-p'. */)
545 (void) 545 (void)
546{ 546{
547 return interactive_p (1) ? Qt : Qnil; 547 return interactive_p () ? Qt : Qnil;
548} 548}
549 549
550 550
@@ -563,26 +563,23 @@ thinking of using it for any other purpose, it is quite likely that
563you're making a mistake. Think: what do you want to do when the 563you're making a mistake. Think: what do you want to do when the
564command is called from a keyboard macro? 564command is called from a keyboard macro?
565 565
566This function is meant for implementing advice and other 566Instead of using this function, it is sometimes cleaner to give your
567function-modifying features. Instead of using this, it is sometimes 567function an extra optional argument whose `interactive' spec specifies
568cleaner to give your function an extra optional argument whose 568non-nil unconditionally (\"p\" is a good way to do this), or via
569`interactive' spec specifies non-nil unconditionally (\"p\" is a good 569\(not (or executing-kbd-macro noninteractive)). */)
570way to do this), or via (not (or executing-kbd-macro noninteractive)). */)
571 (Lisp_Object kind) 570 (Lisp_Object kind)
572{ 571{
573 return ((INTERACTIVE || !EQ (kind, intern ("interactive"))) 572 return (((INTERACTIVE || !EQ (kind, intern ("interactive")))
574 && interactive_p (1)) ? Qt : Qnil; 573 && interactive_p ())
574 ? Qt : Qnil);
575} 575}
576 576
577 577
578/* Return 1 if function in which this appears was called using 578/* Return true if function in which this appears was called using
579 call-interactively. 579 call-interactively and is not a built-in. */
580 580
581 EXCLUDE_SUBRS_P non-zero means always return 0 if the function 581static bool
582 called is a built-in. */ 582interactive_p (void)
583
584static int
585interactive_p (int exclude_subrs_p)
586{ 583{
587 struct backtrace *btp; 584 struct backtrace *btp;
588 Lisp_Object fun; 585 Lisp_Object fun;
@@ -611,9 +608,9 @@ interactive_p (int exclude_subrs_p)
611 /* `btp' now points at the frame of the innermost function that isn't 608 /* `btp' now points at the frame of the innermost function that isn't
612 a special form, ignoring frames for Finteractive_p and/or 609 a special form, ignoring frames for Finteractive_p and/or
613 Fbytecode at the top. If this frame is for a built-in function 610 Fbytecode at the top. If this frame is for a built-in function
614 (such as load or eval-region) return nil. */ 611 (such as load or eval-region) return false. */
615 fun = Findirect_function (*btp->function, Qnil); 612 fun = Findirect_function (*btp->function, Qnil);
616 if (exclude_subrs_p && SUBRP (fun)) 613 if (SUBRP (fun))
617 return 0; 614 return 0;
618 615
619 /* `btp' points to the frame of a Lisp function that called interactive-p. 616 /* `btp' points to the frame of a Lisp function that called interactive-p.
@@ -1121,7 +1118,7 @@ internal_catch (Lisp_Object tag, Lisp_Object (*func) (Lisp_Object), Lisp_Object
1121static _Noreturn void 1118static _Noreturn void
1122unwind_to_catch (struct catchtag *catch, Lisp_Object value) 1119unwind_to_catch (struct catchtag *catch, Lisp_Object value)
1123{ 1120{
1124 int last_time; 1121 bool last_time;
1125 1122
1126 /* Save the value in the tag. */ 1123 /* Save the value in the tag. */
1127 catch->val = value; 1124 catch->val = value;
@@ -1470,8 +1467,8 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
1470 1467
1471 1468
1472static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object); 1469static Lisp_Object find_handler_clause (Lisp_Object, Lisp_Object);
1473static int maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, 1470static bool maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig,
1474 Lisp_Object data); 1471 Lisp_Object data);
1475 1472
1476void 1473void
1477process_quit_flag (void) 1474process_quit_flag (void)
@@ -1576,7 +1573,7 @@ See also the function `condition-case'. */)
1576 if requested". */ 1573 if requested". */
1577 || EQ (h->handler, Qerror))) 1574 || EQ (h->handler, Qerror)))
1578 { 1575 {
1579 int debugger_called 1576 bool debugger_called
1580 = maybe_call_debugger (conditions, error_symbol, data); 1577 = maybe_call_debugger (conditions, error_symbol, data);
1581 /* We can't return values to code which signaled an error, but we 1578 /* We can't return values to code which signaled an error, but we
1582 can continue code which has signaled a quit. */ 1579 can continue code which has signaled a quit. */
@@ -1670,10 +1667,10 @@ signal_error (const char *s, Lisp_Object arg)
1670} 1667}
1671 1668
1672 1669
1673/* Return nonzero if LIST is a non-nil atom or 1670/* Return true if LIST is a non-nil atom or
1674 a list containing one of CONDITIONS. */ 1671 a list containing one of CONDITIONS. */
1675 1672
1676static int 1673static bool
1677wants_debugger (Lisp_Object list, Lisp_Object conditions) 1674wants_debugger (Lisp_Object list, Lisp_Object conditions)
1678{ 1675{
1679 if (NILP (list)) 1676 if (NILP (list))
@@ -1693,15 +1690,15 @@ wants_debugger (Lisp_Object list, Lisp_Object conditions)
1693 return 0; 1690 return 0;
1694} 1691}
1695 1692
1696/* Return 1 if an error with condition-symbols CONDITIONS, 1693/* Return true if an error with condition-symbols CONDITIONS,
1697 and described by SIGNAL-DATA, should skip the debugger 1694 and described by SIGNAL-DATA, should skip the debugger
1698 according to debugger-ignored-errors. */ 1695 according to debugger-ignored-errors. */
1699 1696
1700static int 1697static bool
1701skip_debugger (Lisp_Object conditions, Lisp_Object data) 1698skip_debugger (Lisp_Object conditions, Lisp_Object data)
1702{ 1699{
1703 Lisp_Object tail; 1700 Lisp_Object tail;
1704 int first_string = 1; 1701 bool first_string = 1;
1705 Lisp_Object error_message; 1702 Lisp_Object error_message;
1706 1703
1707 error_message = Qnil; 1704 error_message = Qnil;
@@ -1736,7 +1733,7 @@ skip_debugger (Lisp_Object conditions, Lisp_Object data)
1736 = SIG is the error symbol, and DATA is the rest of the data. 1733 = SIG is the error symbol, and DATA is the rest of the data.
1737 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA). 1734 = SIG is nil, and DATA is (SYMBOL . REST-OF-DATA).
1738 This is for memory-full errors only. */ 1735 This is for memory-full errors only. */
1739static int 1736static bool
1740maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data) 1737maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
1741{ 1738{
1742 Lisp_Object combined_data; 1739 Lisp_Object combined_data;
@@ -2252,7 +2249,6 @@ eval_sub (Lisp_Object form)
2252 if (EQ (funcar, Qmacro)) 2249 if (EQ (funcar, Qmacro))
2253 { 2250 {
2254 ptrdiff_t count = SPECPDL_INDEX (); 2251 ptrdiff_t count = SPECPDL_INDEX ();
2255 extern Lisp_Object Qlexical_binding;
2256 Lisp_Object exp; 2252 Lisp_Object exp;
2257 /* Bind lexical-binding during expansion of the macro, so the 2253 /* Bind lexical-binding during expansion of the macro, so the
2258 macro can know reliably if the code it outputs will be 2254 macro can know reliably if the code it outputs will be
@@ -2741,33 +2737,9 @@ DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0,
2741 doc: /* Non-nil if OBJECT is a function. */) 2737 doc: /* Non-nil if OBJECT is a function. */)
2742 (Lisp_Object object) 2738 (Lisp_Object object)
2743{ 2739{
2744 if (SYMBOLP (object) && !NILP (Ffboundp (object))) 2740 if (FUNCTIONP (object))
2745 {
2746 object = Findirect_function (object, Qt);
2747
2748 if (CONSP (object) && EQ (XCAR (object), Qautoload))
2749 {
2750 /* Autoloaded symbols are functions, except if they load
2751 macros or keymaps. */
2752 int i;
2753 for (i = 0; i < 4 && CONSP (object); i++)
2754 object = XCDR (object);
2755
2756 return (CONSP (object) && !NILP (XCAR (object))) ? Qnil : Qt;
2757 }
2758 }
2759
2760 if (SUBRP (object))
2761 return (XSUBR (object)->max_args != UNEVALLED) ? Qt : Qnil;
2762 else if (COMPILEDP (object))
2763 return Qt; 2741 return Qt;
2764 else if (CONSP (object)) 2742 return Qnil;
2765 {
2766 Lisp_Object car = XCAR (object);
2767 return (EQ (car, Qlambda) || EQ (car, Qclosure)) ? Qt : Qnil;
2768 }
2769 else
2770 return Qnil;
2771} 2743}
2772 2744
2773DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, 2745DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
@@ -2984,7 +2956,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2984 Lisp_Object val, syms_left, next, lexenv; 2956 Lisp_Object val, syms_left, next, lexenv;
2985 ptrdiff_t count = SPECPDL_INDEX (); 2957 ptrdiff_t count = SPECPDL_INDEX ();
2986 ptrdiff_t i; 2958 ptrdiff_t i;
2987 int optional, rest; 2959 bool optional, rest;
2988 2960
2989 if (CONSP (fun)) 2961 if (CONSP (fun))
2990 { 2962 {
@@ -3470,13 +3442,13 @@ Output stream used is value of `standard-output'. */)
3470 write_string ("(", -1); 3442 write_string ("(", -1);
3471 if (backlist->nargs == MANY) 3443 if (backlist->nargs == MANY)
3472 { /* FIXME: Can this happen? */ 3444 { /* FIXME: Can this happen? */
3473 int i; 3445 bool later_arg = 0;
3474 for (tail = *backlist->args, i = 0; 3446 for (tail = *backlist->args; !NILP (tail); tail = Fcdr (tail))
3475 !NILP (tail);
3476 tail = Fcdr (tail), i = 1)
3477 { 3447 {
3478 if (i) write_string (" ", -1); 3448 if (later_arg)
3449 write_string (" ", -1);
3479 Fprin1 (Fcar (tail), Qnil); 3450 Fprin1 (Fcar (tail), Qnil);
3451 later_arg = 1;
3480 } 3452 }
3481 } 3453 }
3482 else 3454 else
diff --git a/src/fileio.c b/src/fileio.c
index 2f4a2ad2314..7466914af1c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -766,7 +766,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
766#endif /* DOS_NT */ 766#endif /* DOS_NT */
767 ptrdiff_t length; 767 ptrdiff_t length;
768 Lisp_Object handler, result, handled_name; 768 Lisp_Object handler, result, handled_name;
769 int multibyte; 769 bool multibyte;
770 Lisp_Object hdir; 770 Lisp_Object hdir;
771 771
772 CHECK_STRING (name); 772 CHECK_STRING (name);
@@ -1566,7 +1566,7 @@ those `/' is discarded. */)
1566 char *target = NULL; 1566 char *target = NULL;
1567 int total = 0; 1567 int total = 0;
1568 int substituted = 0; 1568 int substituted = 0;
1569 int multibyte; 1569 bool multibyte;
1570 char *xnm; 1570 char *xnm;
1571 Lisp_Object handler; 1571 Lisp_Object handler;
1572 1572
@@ -3142,8 +3142,7 @@ decide_coding_unwind (Lisp_Object unwind_data)
3142 undo_list = XCAR (unwind_data); 3142 undo_list = XCAR (unwind_data);
3143 buffer = XCDR (unwind_data); 3143 buffer = XCDR (unwind_data);
3144 3144
3145 if (current_buffer != XBUFFER (buffer)) 3145 set_buffer_internal (XBUFFER (buffer));
3146 set_buffer_internal (XBUFFER (buffer));
3147 adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE); 3146 adjust_markers_for_delete (BEG, BEG_BYTE, Z, Z_BYTE);
3148 adjust_overlays_for_delete (BEG, Z - BEG); 3147 adjust_overlays_for_delete (BEG, Z - BEG);
3149 set_buffer_intervals (current_buffer, NULL); 3148 set_buffer_intervals (current_buffer, NULL);
@@ -3481,7 +3480,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
3481 Lisp_Object workbuf; 3480 Lisp_Object workbuf;
3482 struct buffer *buf; 3481 struct buffer *buf;
3483 3482
3484 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 3483 record_unwind_current_buffer ();
3485 3484
3486 workbuf = Fget_buffer_create (build_string (" *code-converting-work*")); 3485 workbuf = Fget_buffer_create (build_string (" *code-converting-work*"));
3487 buf = XBUFFER (workbuf); 3486 buf = XBUFFER (workbuf);
@@ -3760,7 +3759,8 @@ variable `last-coding-system-used' to the coding system actually used. */)
3760 ptrdiff_t temp; 3759 ptrdiff_t temp;
3761 ptrdiff_t this = 0; 3760 ptrdiff_t this = 0;
3762 ptrdiff_t this_count = SPECPDL_INDEX (); 3761 ptrdiff_t this_count = SPECPDL_INDEX ();
3763 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 3762 bool multibyte
3763 = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
3764 Lisp_Object conversion_buffer; 3764 Lisp_Object conversion_buffer;
3765 struct gcpro gcpro1; 3765 struct gcpro gcpro1;
3766 3766
@@ -5306,7 +5306,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5306 FILE *stream = NULL; 5306 FILE *stream = NULL;
5307 ptrdiff_t count = SPECPDL_INDEX (); 5307 ptrdiff_t count = SPECPDL_INDEX ();
5308 int orig_minibuffer_auto_raise = minibuffer_auto_raise; 5308 int orig_minibuffer_auto_raise = minibuffer_auto_raise;
5309 int old_message_p = 0; 5309 bool old_message_p = 0;
5310 struct gcpro gcpro1, gcpro2; 5310 struct gcpro gcpro1, gcpro2;
5311 5311
5312 if (max_specpdl_size < specpdl_size + 40) 5312 if (max_specpdl_size < specpdl_size + 40)
diff --git a/src/firstfile.c b/src/firstfile.c
index 84511cfe0ad..444fb71b55d 100644
--- a/src/firstfile.c
+++ b/src/firstfile.c
@@ -27,7 +27,6 @@ static char _my_begbss[1];
27char * my_begbss_static = _my_begbss; 27char * my_begbss_static = _my_begbss;
28 28
29/* Add a dummy reference to ensure emacs.obj is linked in. */ 29/* Add a dummy reference to ensure emacs.obj is linked in. */
30extern int initialized; 30extern int main (int, char **);
31static int * dummy = &initialized; 31static int (*dummy) (int, char **) = main;
32#endif 32#endif
33
diff --git a/src/fns.c b/src/fns.c
index 79f8e233fb5..4d82e4e6e1d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -52,10 +52,6 @@ static Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper;
52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512; 52static Lisp_Object Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512;
53 53
54static int internal_equal (Lisp_Object , Lisp_Object, int, int); 54static int internal_equal (Lisp_Object , Lisp_Object, int, int);
55
56#ifndef HAVE_UNISTD_H
57extern long time ();
58#endif
59 55
60DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, 56DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
61 doc: /* Return the argument unchanged. */) 57 doc: /* Return the argument unchanged. */)
@@ -74,32 +70,16 @@ Other values of LIMIT are ignored. */)
74 (Lisp_Object limit) 70 (Lisp_Object limit)
75{ 71{
76 EMACS_INT val; 72 EMACS_INT val;
77 Lisp_Object lispy_val;
78 73
79 if (EQ (limit, Qt)) 74 if (EQ (limit, Qt))
80 { 75 init_random ();
81 EMACS_TIME t = current_emacs_time (); 76 else if (STRINGP (limit))
82 seed_random (getpid () ^ EMACS_SECS (t) ^ EMACS_NSECS (t)); 77 seed_random (SSDATA (limit), SBYTES (limit));
83 }
84 78
79 val = get_random ();
85 if (NATNUMP (limit) && XFASTINT (limit) != 0) 80 if (NATNUMP (limit) && XFASTINT (limit) != 0)
86 { 81 val %= XFASTINT (limit);
87 /* Try to take our random number from the higher bits of VAL, 82 return make_number (val);
88 not the lower, since (says Gentzel) the low bits of `random'
89 are less random than the higher ones. We do this by using the
90 quotient rather than the remainder. At the high end of the RNG
91 it's possible to get a quotient larger than n; discarding
92 these values eliminates the bias that would otherwise appear
93 when using a large n. */
94 EMACS_INT denominator = (INTMASK + 1) / XFASTINT (limit);
95 do
96 val = get_random () / denominator;
97 while (val >= XFASTINT (limit));
98 }
99 else
100 val = get_random ();
101 XSETINT (lispy_val, val);
102 return lispy_val;
103} 83}
104 84
105/* Heuristic on how many iterations of a tight loop can be safely done 85/* Heuristic on how many iterations of a tight loop can be safely done
@@ -1100,7 +1080,7 @@ an error is signaled. */)
1100 { 1080 {
1101 ptrdiff_t chars = SCHARS (string); 1081 ptrdiff_t chars = SCHARS (string);
1102 unsigned char *str = xmalloc (chars); 1082 unsigned char *str = xmalloc (chars);
1103 ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0); 1083 ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars);
1104 1084
1105 if (converted < chars) 1085 if (converted < chars)
1106 error ("Can't convert the %"pD"dth character to unibyte", converted); 1086 error ("Can't convert the %"pD"dth character to unibyte", converted);
@@ -2139,12 +2119,8 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2139 register ptrdiff_t size, idx; 2119 register ptrdiff_t size, idx;
2140 2120
2141 if (VECTORP (array)) 2121 if (VECTORP (array))
2142 { 2122 for (idx = 0, size = ASIZE (array); idx < size; idx++)
2143 register Lisp_Object *p = XVECTOR (array)->contents; 2123 ASET (array, idx, item);
2144 size = ASIZE (array);
2145 for (idx = 0; idx < size; idx++)
2146 p[idx] = item;
2147 }
2148 else if (CHAR_TABLE_P (array)) 2124 else if (CHAR_TABLE_P (array))
2149 { 2125 {
2150 int i; 2126 int i;
@@ -3971,8 +3947,8 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
3971 for (idx = HASH_INDEX (h, bucket); !NILP (idx); idx = next) 3947 for (idx = HASH_INDEX (h, bucket); !NILP (idx); idx = next)
3972 { 3948 {
3973 ptrdiff_t i = XFASTINT (idx); 3949 ptrdiff_t i = XFASTINT (idx);
3974 int key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i)); 3950 bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
3975 int value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i)); 3951 bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
3976 int remove_p; 3952 int remove_p;
3977 3953
3978 if (EQ (h->weak, Qkey)) 3954 if (EQ (h->weak, Qkey))
@@ -4660,13 +4636,12 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4660 { 4636 {
4661 struct buffer *prev = current_buffer; 4637 struct buffer *prev = current_buffer;
4662 4638
4663 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 4639 record_unwind_current_buffer ();
4664 4640
4665 CHECK_BUFFER (object); 4641 CHECK_BUFFER (object);
4666 4642
4667 bp = XBUFFER (object); 4643 bp = XBUFFER (object);
4668 if (bp != current_buffer) 4644 set_buffer_internal (bp);
4669 set_buffer_internal (bp);
4670 4645
4671 if (NILP (start)) 4646 if (NILP (start))
4672 b = BEGV; 4647 b = BEGV;
@@ -4753,8 +4728,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4753 } 4728 }
4754 4729
4755 object = make_buffer_string (b, e, 0); 4730 object = make_buffer_string (b, e, 0);
4756 if (prev != current_buffer) 4731 set_buffer_internal (prev);
4757 set_buffer_internal (prev);
4758 /* Discard the unwind protect for recovering the current 4732 /* Discard the unwind protect for recovering the current
4759 buffer. */ 4733 buffer. */
4760 specpdl_ptr--; 4734 specpdl_ptr--;
diff --git a/src/font.c b/src/font.c
index 5b9e4f1cfcf..cf9964f08f3 100644
--- a/src/font.c
+++ b/src/font.c
@@ -38,17 +38,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#include "fontset.h" 38#include "fontset.h"
39#include "font.h" 39#include "font.h"
40 40
41#ifdef HAVE_X_WINDOWS 41#ifdef HAVE_WINDOW_SYSTEM
42#include "xterm.h" 42#include TERM_HEADER
43#endif /* HAVE_X_WINDOWS */ 43#endif /* HAVE_WINDOW_SYSTEM */
44
45#ifdef HAVE_NTGUI
46#include "w32term.h"
47#endif /* HAVE_NTGUI */
48
49#ifdef HAVE_NS
50#include "nsterm.h"
51#endif /* HAVE_NS */
52 44
53Lisp_Object Qopentype; 45Lisp_Object Qopentype;
54 46
diff --git a/src/font.h b/src/font.h
index 6e9387f7632..3b90bc2ab8a 100644
--- a/src/font.h
+++ b/src/font.h
@@ -817,6 +817,7 @@ extern struct font_driver xfont_driver;
817extern void syms_of_xfont (void); 817extern void syms_of_xfont (void);
818extern void syms_of_ftxfont (void); 818extern void syms_of_ftxfont (void);
819#ifdef HAVE_XFT 819#ifdef HAVE_XFT
820extern Lisp_Object Qxft;
820extern struct font_driver xftfont_driver; 821extern struct font_driver xftfont_driver;
821extern void syms_of_xftfont (void); 822extern void syms_of_xftfont (void);
822#elif defined HAVE_FREETYPE 823#elif defined HAVE_FREETYPE
diff --git a/src/fontset.c b/src/fontset.c
index c39d68a8ecf..01e38fe45e5 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -185,8 +185,7 @@ void (*check_window_system_func) (void);
185 185
186 186
187/* Prototype declarations for static functions. */ 187/* Prototype declarations for static functions. */
188static Lisp_Object fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, 188static void fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
189 Lisp_Object);
190static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *, 189static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *,
191 int, int); 190 int, int);
192static void reorder_font_vector (Lisp_Object, struct font *); 191static void reorder_font_vector (Lisp_Object, struct font *);
@@ -213,27 +212,71 @@ fontset_id_valid_p (int id)
213/* Return the fontset with ID. No check of ID's validness. */ 212/* Return the fontset with ID. No check of ID's validness. */
214#define FONTSET_FROM_ID(id) AREF (Vfontset_table, id) 213#define FONTSET_FROM_ID(id) AREF (Vfontset_table, id)
215 214
216/* Macros to access special values of FONTSET. */ 215/* Access special values of FONTSET. */
217#define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0]
218 216
219/* Macros to access special values of (base) FONTSET. */ 217#define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0]
220#define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1] 218static void
221#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4] 219set_fontset_id (Lisp_Object fontset, Lisp_Object id)
222/* #define FONTSET_SPEC(fontset) XCHAR_TABLE (fontset)->extras[5] */ 220{
221 set_char_table_extras (fontset, 0, id);
222}
223
224/* Access special values of (base) FONTSET. */
225
226#define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1]
227static void
228set_fontset_name (Lisp_Object fontset, Lisp_Object name)
229{
230 set_char_table_extras (fontset, 1, name);
231}
232
233#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4]
234static void
235set_fontset_ascii (Lisp_Object fontset, Lisp_Object ascii)
236{
237 set_char_table_extras (fontset, 4, ascii);
238}
239
240/* Access special values of (realized) FONTSET. */
241
242#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2]
243static void
244set_fontset_base (Lisp_Object fontset, Lisp_Object base)
245{
246 set_char_table_extras (fontset, 2, base);
247}
248
249#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3]
250static void
251set_fontset_frame (Lisp_Object fontset, Lisp_Object frame)
252{
253 set_char_table_extras (fontset, 3, frame);
254}
223 255
224/* Macros to access special values of (realized) FONTSET. */ 256#define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5]
225#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2] 257static void
226#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] 258set_fontset_nofont_face (Lisp_Object fontset, Lisp_Object face)
227/* #define FONTSET_OBJLIST(fontset) XCHAR_TABLE (fontset)->extras[4] */ 259{
228#define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] 260 set_char_table_extras (fontset, 5, face);
229/* #define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] */ 261}
230#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7] 262
263#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7]
264static void
265set_fontset_default (Lisp_Object fontset, Lisp_Object def)
266{
267 set_char_table_extras (fontset, 7, def);
268}
231 269
232/* For both base and realized fontset. */ 270/* For both base and realized fontset. */
233#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
234 271
235#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) 272#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
273static void
274set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback)
275{
276 set_char_table_extras (fontset, 8, fallback);
277}
236 278
279#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset)))
237 280
238/* Macros for FONT-DEF and RFONT-DEF of fontset. */ 281/* Macros for FONT-DEF and RFONT-DEF of fontset. */
239#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \ 282#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \
@@ -265,7 +308,7 @@ fontset_id_valid_p (int id)
265#define RFONT_DEF_NEW(rfont_def, font_def) \ 308#define RFONT_DEF_NEW(rfont_def, font_def) \
266 do { \ 309 do { \
267 (rfont_def) = Fmake_vector (make_number (4), Qnil); \ 310 (rfont_def) = Fmake_vector (make_number (4), Qnil); \
268 ASET ((rfont_def), 1, (font_def)); \ 311 ASET ((rfont_def), 1, (font_def)); \
269 RFONT_DEF_SET_SCORE ((rfont_def), 0); \ 312 RFONT_DEF_SET_SCORE ((rfont_def), 0); \
270 } while (0) 313 } while (0)
271 314
@@ -307,15 +350,17 @@ fontset_ref (Lisp_Object fontset, int c)
307 replace with ELT, if ADD is `prepend', prepend ELT, otherwise, 350 replace with ELT, if ADD is `prepend', prepend ELT, otherwise,
308 append ELT. */ 351 append ELT. */
309 352
310#define FONTSET_ADD(fontset, range, elt, add) \ 353#define FONTSET_ADD(fontset, range, elt, add) \
311 (NILP (add) \ 354 (NILP (add) \
312 ? (NILP (range) \ 355 ? (NILP (range) \
313 ? (FONTSET_FALLBACK (fontset) = Fmake_vector (make_number (1), (elt))) \ 356 ? (set_fontset_fallback \
314 : Fset_char_table_range ((fontset), (range), \ 357 (fontset, Fmake_vector (make_number (1), (elt)))) \
315 Fmake_vector (make_number (1), (elt)))) \ 358 : ((void) \
359 Fset_char_table_range (fontset, range, \
360 Fmake_vector (make_number (1), elt)))) \
316 : fontset_add ((fontset), (range), (elt), (add))) 361 : fontset_add ((fontset), (range), (elt), (add)))
317 362
318static Lisp_Object 363static void
319fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add) 364fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add)
320{ 365{
321 Lisp_Object args[2]; 366 Lisp_Object args[2];
@@ -341,10 +386,9 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Objec
341 else 386 else
342 { 387 {
343 args[idx] = FONTSET_FALLBACK (fontset); 388 args[idx] = FONTSET_FALLBACK (fontset);
344 FONTSET_FALLBACK (fontset) 389 set_fontset_fallback
345 = NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args); 390 (fontset, NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args));
346 } 391 }
347 return Qnil;
348} 392}
349 393
350static int 394static int
@@ -485,7 +529,7 @@ fontset_get_font_group (Lisp_Object fontset, int c)
485 if (c >= 0) 529 if (c >= 0)
486 char_table_set_range (fontset, from, to, font_group); 530 char_table_set_range (fontset, from, to, font_group);
487 else 531 else
488 FONTSET_FALLBACK (fontset) = font_group; 532 set_fontset_fallback (fontset, font_group);
489 return font_group; 533 return font_group;
490} 534}
491 535
@@ -720,8 +764,9 @@ fontset_font (Lisp_Object fontset, int c, struct face *face, int id)
720 if (! EQ (base_fontset, Vdefault_fontset)) 764 if (! EQ (base_fontset, Vdefault_fontset))
721 { 765 {
722 if (NILP (FONTSET_DEFAULT (fontset))) 766 if (NILP (FONTSET_DEFAULT (fontset)))
723 FONTSET_DEFAULT (fontset) 767 set_fontset_default
724 = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset); 768 (fontset,
769 make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset));
725 FONT_DEFERRED_LOG ("default fontset: font for", make_number (c), Qnil); 770 FONT_DEFERRED_LOG ("default fontset: font for", make_number (c), Qnil);
726 default_rfont_def 771 default_rfont_def
727 = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0); 772 = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0);
@@ -781,16 +826,14 @@ make_fontset (Lisp_Object frame, Lisp_Object name, Lisp_Object base)
781 826
782 fontset = Fmake_char_table (Qfontset, Qnil); 827 fontset = Fmake_char_table (Qfontset, Qnil);
783 828
784 FONTSET_ID (fontset) = make_number (id); 829 set_fontset_id (fontset, make_number (id));
785 if (NILP (base)) 830 if (NILP (base))
786 { 831 set_fontset_name (fontset, name);
787 FONTSET_NAME (fontset) = name;
788 }
789 else 832 else
790 { 833 {
791 FONTSET_NAME (fontset) = Qnil; 834 set_fontset_name (fontset, Qnil);
792 FONTSET_FRAME (fontset) = frame; 835 set_fontset_frame (fontset, frame);
793 FONTSET_BASE (fontset) = base; 836 set_fontset_base (fontset, base);
794 } 837 }
795 838
796 ASET (Vfontset_table, id, fontset); 839 ASET (Vfontset_table, id, fontset);
@@ -958,7 +1001,7 @@ face_for_char (FRAME_PTR f, struct face *face, int c, int pos, Lisp_Object objec
958 else 1001 else
959 { 1002 {
960 face_id = face_for_font (f, Qnil, face); 1003 face_id = face_for_font (f, Qnil, face);
961 FONTSET_NOFONT_FACE (fontset) = make_number (face_id); 1004 set_fontset_nofont_face (fontset, make_number (face_id));
962 } 1005 }
963 } 1006 }
964 eassert (face_id >= 0); 1007 eassert (face_id >= 0);
@@ -1580,7 +1623,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1580 Lisp_Object tail, fr, alist; 1623 Lisp_Object tail, fr, alist;
1581 int fontset_id = XINT (FONTSET_ID (fontset)); 1624 int fontset_id = XINT (FONTSET_ID (fontset));
1582 1625
1583 FONTSET_ASCII (fontset) = fontname; 1626 set_fontset_ascii (fontset, fontname);
1584 name = FONTSET_NAME (fontset); 1627 name = FONTSET_NAME (fontset);
1585 FOR_EACH_FRAME (tail, fr) 1628 FOR_EACH_FRAME (tail, fr)
1586 { 1629 {
@@ -1658,7 +1701,7 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
1658 len = font_unparse_xlfd (font_spec, 0, xlfd, 256); 1701 len = font_unparse_xlfd (font_spec, 0, xlfd, 256);
1659 if (len < 0) 1702 if (len < 0)
1660 error ("Invalid fontset name (perhaps too long): %s", SDATA (name)); 1703 error ("Invalid fontset name (perhaps too long): %s", SDATA (name));
1661 FONTSET_ASCII (fontset) = make_unibyte_string (xlfd, len); 1704 set_fontset_ascii (fontset, make_unibyte_string (xlfd, len));
1662 } 1705 }
1663 else 1706 else
1664 { 1707 {
@@ -1744,7 +1787,7 @@ fontset_from_font (Lisp_Object font_object)
1744 Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil); 1787 Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil);
1745 } 1788 }
1746 1789
1747 FONTSET_ASCII (fontset) = font_name; 1790 set_fontset_ascii (fontset, font_name);
1748 1791
1749 return XINT (FONTSET_ID (fontset)); 1792 return XINT (FONTSET_ID (fontset));
1750} 1793}
@@ -2161,9 +2204,10 @@ syms_of_fontset (void)
2161 2204
2162 Vdefault_fontset = Fmake_char_table (Qfontset, Qnil); 2205 Vdefault_fontset = Fmake_char_table (Qfontset, Qnil);
2163 staticpro (&Vdefault_fontset); 2206 staticpro (&Vdefault_fontset);
2164 FONTSET_ID (Vdefault_fontset) = make_number (0); 2207 set_fontset_id (Vdefault_fontset, make_number (0));
2165 FONTSET_NAME (Vdefault_fontset) 2208 set_fontset_name
2166 = build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"); 2209 (Vdefault_fontset,
2210 build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"));
2167 ASET (Vfontset_table, 0, Vdefault_fontset); 2211 ASET (Vfontset_table, 0, Vdefault_fontset);
2168 next_fontset_id = 1; 2212 next_fontset_id = 1;
2169 2213
diff --git a/src/frame.c b/src/frame.c
index a00f44a1e5a..968cb4905a2 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -30,15 +30,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30 30
31#include "lisp.h" 31#include "lisp.h"
32#include "character.h" 32#include "character.h"
33#ifdef HAVE_X_WINDOWS 33
34#include "xterm.h" 34#ifdef HAVE_WINDOW_SYSTEM
35#endif 35#include TERM_HEADER
36#ifdef WINDOWSNT 36#endif /* HAVE_WINDOW_SYSTEM */
37#include "w32term.h" 37
38#endif
39#ifdef HAVE_NS
40#include "nsterm.h"
41#endif
42#include "buffer.h" 38#include "buffer.h"
43/* These help us bind and responding to switch-frame events. */ 39/* These help us bind and responding to switch-frame events. */
44#include "commands.h" 40#include "commands.h"
@@ -58,11 +54,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58#include "dosfns.h" 54#include "dosfns.h"
59#endif 55#endif
60 56
61
62#ifdef HAVE_WINDOW_SYSTEM
63
64#endif
65
66#ifdef HAVE_NS 57#ifdef HAVE_NS
67Lisp_Object Qns_parse_geometry; 58Lisp_Object Qns_parse_geometry;
68#endif 59#endif
@@ -4247,7 +4238,6 @@ syms_of_frame (void)
4247 DEFSYM (Qx, "x"); 4238 DEFSYM (Qx, "x");
4248 DEFSYM (Qw32, "w32"); 4239 DEFSYM (Qw32, "w32");
4249 DEFSYM (Qpc, "pc"); 4240 DEFSYM (Qpc, "pc");
4250 DEFSYM (Qmac, "mac");
4251 DEFSYM (Qns, "ns"); 4241 DEFSYM (Qns, "ns");
4252 DEFSYM (Qvisible, "visible"); 4242 DEFSYM (Qvisible, "visible");
4253 DEFSYM (Qbuffer_predicate, "buffer-predicate"); 4243 DEFSYM (Qbuffer_predicate, "buffer-predicate");
diff --git a/src/frame.h b/src/frame.h
index 92fbda42c70..1fe3ebd9182 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -34,7 +34,7 @@ INLINE_HEADER_BEGIN
34/* Miscellanea. */ 34/* Miscellanea. */
35 35
36/* Nonzero means there is at least one garbaged frame. */ 36/* Nonzero means there is at least one garbaged frame. */
37extern int frame_garbaged; 37extern bool frame_garbaged;
38 38
39 39
40/* The structure representing a frame. */ 40/* The structure representing a frame. */
@@ -361,7 +361,7 @@ struct frame
361#endif 361#endif
362 362
363 /* Nonzero if last attempt at redisplay on this frame was preempted. */ 363 /* Nonzero if last attempt at redisplay on this frame was preempted. */
364 unsigned char display_preempted : 1; 364 unsigned display_preempted : 1;
365 365
366 /* visible is nonzero if the frame is currently displayed; we check 366 /* visible is nonzero if the frame is currently displayed; we check
367 it to see if we should bother updating the frame's contents. 367 it to see if we should bother updating the frame's contents.
@@ -391,8 +391,8 @@ struct frame
391 391
392 These two are mutually exclusive. They might both be zero, if the 392 These two are mutually exclusive. They might both be zero, if the
393 frame has been made invisible without an icon. */ 393 frame has been made invisible without an icon. */
394 unsigned char visible : 2; 394 unsigned visible : 2;
395 unsigned char iconified : 1; 395 unsigned iconified : 1;
396 396
397 /* Let's not use bitfields for volatile variables. */ 397 /* Let's not use bitfields for volatile variables. */
398 398
@@ -406,40 +406,40 @@ struct frame
406 406
407 /* True if frame actually has a minibuffer window on it. 407 /* True if frame actually has a minibuffer window on it.
408 0 if using a minibuffer window that isn't on this frame. */ 408 0 if using a minibuffer window that isn't on this frame. */
409 unsigned char has_minibuffer : 1; 409 unsigned has_minibuffer : 1;
410 410
411 /* 0 means, if this frame has just one window, 411 /* 0 means, if this frame has just one window,
412 show no modeline for that window. */ 412 show no modeline for that window. */
413 unsigned char wants_modeline : 1; 413 unsigned wants_modeline : 1;
414 414
415 /* Non-zero if the hardware device this frame is displaying on can 415 /* Non-zero if the hardware device this frame is displaying on can
416 support scroll bars. */ 416 support scroll bars. */
417 char can_have_scroll_bars; 417 char can_have_scroll_bars;
418 418
419 /* Non-0 means raise this frame to the top of the heap when selected. */ 419 /* Non-0 means raise this frame to the top of the heap when selected. */
420 unsigned char auto_raise : 1; 420 unsigned auto_raise : 1;
421 421
422 /* Non-0 means lower this frame to the bottom of the stack when left. */ 422 /* Non-0 means lower this frame to the bottom of the stack when left. */
423 unsigned char auto_lower : 1; 423 unsigned auto_lower : 1;
424 424
425 /* True if frame's root window can't be split. */ 425 /* True if frame's root window can't be split. */
426 unsigned char no_split : 1; 426 unsigned no_split : 1;
427 427
428 /* If this is set, then Emacs won't change the frame name to indicate 428 /* If this is set, then Emacs won't change the frame name to indicate
429 the current buffer, etcetera. If the user explicitly sets the frame 429 the current buffer, etcetera. If the user explicitly sets the frame
430 name, this gets set. If the user sets the name to Qnil, this is 430 name, this gets set. If the user sets the name to Qnil, this is
431 cleared. */ 431 cleared. */
432 unsigned char explicit_name : 1; 432 unsigned explicit_name : 1;
433 433
434 /* Nonzero if size of some window on this frame has changed. */ 434 /* Nonzero if size of some window on this frame has changed. */
435 unsigned char window_sizes_changed : 1; 435 unsigned window_sizes_changed : 1;
436 436
437 /* Nonzero if the mouse has moved on this display device 437 /* Nonzero if the mouse has moved on this display device
438 since the last time we checked. */ 438 since the last time we checked. */
439 unsigned char mouse_moved :1; 439 unsigned mouse_moved :1;
440 440
441 /* Nonzero means that the pointer is invisible. */ 441 /* Nonzero means that the pointer is invisible. */
442 unsigned char pointer_invisible :1; 442 unsigned pointer_invisible :1;
443 443
444 /* If can_have_scroll_bars is non-zero, this is non-zero if we should 444 /* If can_have_scroll_bars is non-zero, this is non-zero if we should
445 actually display them on this frame. */ 445 actually display them on this frame. */
@@ -621,11 +621,21 @@ typedef struct frame *FRAME_PTR;
621#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial) 621#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
622#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap) 622#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
623#define FRAME_X_P(f) ((f)->output_method == output_x_window) 623#define FRAME_X_P(f) ((f)->output_method == output_x_window)
624#ifndef WINDOWSNT
625#define FRAME_W32_P(f) (0)
626#else
624#define FRAME_W32_P(f) ((f)->output_method == output_w32) 627#define FRAME_W32_P(f) ((f)->output_method == output_w32)
628#endif
629#ifndef MSDOS
630#define FRAME_MSDOS_P(f) (0)
631#else
625#define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw) 632#define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
626#define FRAME_MAC_P(f) ((f)->output_method == output_mac) 633#endif
634#ifndef HAVE_NS
635#define FRAME_NS_P(f) (0)
636#else
627#define FRAME_NS_P(f) ((f)->output_method == output_ns) 637#define FRAME_NS_P(f) ((f)->output_method == output_ns)
628 638#endif
629/* FRAME_WINDOW_P tests whether the frame is a window, and is 639/* FRAME_WINDOW_P tests whether the frame is a window, and is
630 defined to be the predicate for the window system being used. */ 640 defined to be the predicate for the window system being used. */
631 641
@@ -1196,6 +1206,7 @@ extern Lisp_Object Qrun_hook_with_args;
1196extern void x_set_scroll_bar_default_width (struct frame *); 1206extern void x_set_scroll_bar_default_width (struct frame *);
1197extern void x_set_offset (struct frame *, int, int, int); 1207extern void x_set_offset (struct frame *, int, int, int);
1198extern void x_wm_set_icon_position (struct frame *, int, int); 1208extern void x_wm_set_icon_position (struct frame *, int, int);
1209extern void x_wm_set_size_hint (FRAME_PTR f, long flags, int user_position);
1199 1210
1200extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int); 1211extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1201 1212
@@ -1241,10 +1252,40 @@ extern Lisp_Object display_x_get_resource (Display_Info *,
1241 Lisp_Object component, 1252 Lisp_Object component,
1242 Lisp_Object subclass); 1253 Lisp_Object subclass);
1243 1254
1255extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
1256extern void x_set_window_size (struct frame *f, int change_grav,
1257 int cols, int rows);
1258extern void x_sync (struct frame *);
1259extern Lisp_Object x_get_focus_frame (struct frame *);
1260extern void x_set_mouse_position (struct frame *f, int h, int v);
1261extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
1262extern void x_make_frame_visible (struct frame *f);
1263extern void x_make_frame_invisible (struct frame *f);
1264extern void x_iconify_frame (struct frame *f);
1265extern int x_char_width (struct frame *f);
1266extern int x_char_height (struct frame *f);
1267extern int x_pixel_width (struct frame *f);
1268extern int x_pixel_height (struct frame *f);
1269extern void x_set_frame_alpha (struct frame *f);
1270extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1271extern void x_set_tool_bar_lines (struct frame *f,
1272 Lisp_Object value,
1273 Lisp_Object oldval);
1274extern void x_activate_menubar (struct frame *);
1275extern void x_real_positions (struct frame *, int *, int *);
1276extern int x_bitmap_icon (struct frame *, Lisp_Object);
1277extern void x_set_menu_bar_lines (struct frame *,
1278 Lisp_Object,
1279 Lisp_Object);
1280extern void free_frame_menubar (struct frame *);
1281extern void x_free_frame_resources (struct frame *);
1282
1244#if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT 1283#if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT
1245extern char *x_get_resource_string (const char *, const char *); 1284extern char *x_get_resource_string (const char *, const char *);
1246#endif 1285#endif
1247 1286
1287extern void x_query_colors (struct frame *f, XColor *, int);
1288
1248/* In xmenu.c */ 1289/* In xmenu.c */
1249extern void set_frame_menubar (FRAME_PTR, int, int); 1290extern void set_frame_menubar (FRAME_PTR, int, int);
1250 1291
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 2941605d448..f0d2c022f0c 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1348,13 +1348,14 @@ x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position)
1348 size_hints.height_inc = FRAME_LINE_HEIGHT (f); 1348 size_hints.height_inc = FRAME_LINE_HEIGHT (f);
1349 1349
1350 hint_flags |= GDK_HINT_BASE_SIZE; 1350 hint_flags |= GDK_HINT_BASE_SIZE;
1351 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0) + FRAME_TOOLBAR_WIDTH (f); 1351 /* Use one row/col here so base_height/width does not become zero.
1352 /* Use one row here so base_height does not become zero.
1353 Gtk+ and/or Unity on Ubuntu 12.04 can't handle it. */ 1352 Gtk+ and/or Unity on Ubuntu 12.04 can't handle it. */
1353 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 1) + FRAME_TOOLBAR_WIDTH (f);
1354 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1) 1354 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1)
1355 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); 1355 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
1356 1356
1357 check_frame_size (f, &min_rows, &min_cols); 1357 check_frame_size (f, &min_rows, &min_cols);
1358 if (min_cols > 0) --min_cols; /* We used one col in base_width = ... 1); */
1358 if (min_rows > 0) --min_rows; /* We used one row in base_height = ... 1); */ 1359 if (min_rows > 0) --min_rows; /* We used one row in base_height = ... 1); */
1359 1360
1360 size_hints.base_width = base_width; 1361 size_hints.base_width = base_width;
@@ -2018,11 +2019,6 @@ xg_get_file_name (FRAME_PTR f,
2018 2019
2019#if USE_NEW_GTK_FONT_CHOOSER 2020#if USE_NEW_GTK_FONT_CHOOSER
2020 2021
2021extern Lisp_Object Qxft, Qnormal;
2022extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold;
2023extern Lisp_Object Qbold, Qextra_bold, Qultra_bold;
2024extern Lisp_Object Qoblique, Qitalic;
2025
2026#define XG_WEIGHT_TO_SYMBOL(w) \ 2022#define XG_WEIGHT_TO_SYMBOL(w) \
2027 (w <= PANGO_WEIGHT_THIN ? Qextra_light \ 2023 (w <= PANGO_WEIGHT_THIN ? Qextra_light \
2028 : w <= PANGO_WEIGHT_ULTRALIGHT ? Qlight \ 2024 : w <= PANGO_WEIGHT_ULTRALIGHT ? Qlight \
@@ -2042,6 +2038,7 @@ extern Lisp_Object Qoblique, Qitalic;
2042 2038
2043 2039
2044static char *x_last_font_name; 2040static char *x_last_font_name;
2041extern Lisp_Object Qxft;
2045 2042
2046/* Pop up a GTK font selector and return the name of the font the user 2043/* Pop up a GTK font selector and return the name of the font the user
2047 selects, as a C string. The returned font name follows GTK's own 2044 selects, as a C string. The returned font name follows GTK's own
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 462e879d3e7..926478dd728 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -25,6 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#include <gtk/gtk.h> 26#include <gtk/gtk.h>
27#include "frame.h" 27#include "frame.h"
28#include "xterm.h"
28 29
29/* Minimum and maximum values used for GTK scroll bars */ 30/* Minimum and maximum values used for GTK scroll bars */
30 31
@@ -149,9 +150,6 @@ extern GdkCursor * xg_create_default_cursor (Display *dpy);
149 150
150extern int xg_create_frame_widgets (FRAME_PTR f); 151extern int xg_create_frame_widgets (FRAME_PTR f);
151extern void xg_free_frame_widgets (FRAME_PTR f); 152extern void xg_free_frame_widgets (FRAME_PTR f);
152extern void x_wm_set_size_hint (FRAME_PTR f,
153 long flags,
154 int user_position);
155extern void xg_set_background_color (FRAME_PTR f, unsigned long bg); 153extern void xg_set_background_color (FRAME_PTR f, unsigned long bg);
156extern int xg_check_special_colors (struct frame *f, 154extern int xg_check_special_colors (struct frame *f,
157 const char *color_name, 155 const char *color_name,
diff --git a/src/image.c b/src/image.c
index f2778165ece..3e021677e09 100644
--- a/src/image.c
+++ b/src/image.c
@@ -50,11 +50,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#include "termhooks.h" 50#include "termhooks.h"
51#include "font.h" 51#include "font.h"
52 52
53#ifdef HAVE_X_WINDOWS 53#ifdef HAVE_SYS_STAT_H
54#include "xterm.h"
55#include <sys/types.h>
56#include <sys/stat.h> 54#include <sys/stat.h>
55#endif /* HAVE_SYS_STAT_H */
56
57#ifdef HAVE_SYS_TYPES_H
58#include <sys/types.h>
59#endif /* HAVE_SYS_TYPES_H */
60
61#ifdef HAVE_WINDOW_SYSTEM
62#include TERM_HEADER
63#endif /* HAVE_WINDOW_SYSTEM */
57 64
65#ifdef HAVE_X_WINDOWS
58#define COLOR_TABLE_SUPPORT 1 66#define COLOR_TABLE_SUPPORT 1
59 67
60typedef struct x_bitmap_record Bitmap_Record; 68typedef struct x_bitmap_record Bitmap_Record;
@@ -67,11 +75,8 @@ typedef struct x_bitmap_record Bitmap_Record;
67#define PIX_MASK_DRAW 1 75#define PIX_MASK_DRAW 1
68#endif /* HAVE_X_WINDOWS */ 76#endif /* HAVE_X_WINDOWS */
69 77
70
71#ifdef HAVE_NTGUI 78#ifdef HAVE_NTGUI
72#include "w32.h" 79#include "w32.h"
73#include "w32term.h"
74
75/* W32_TODO : Color tables on W32. */ 80/* W32_TODO : Color tables on W32. */
76#undef COLOR_TABLE_SUPPORT 81#undef COLOR_TABLE_SUPPORT
77 82
@@ -84,15 +89,9 @@ typedef struct w32_bitmap_record Bitmap_Record;
84#define PIX_MASK_RETAIN 0 89#define PIX_MASK_RETAIN 0
85#define PIX_MASK_DRAW 1 90#define PIX_MASK_DRAW 1
86 91
87#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
88#define x_defined_color w32_defined_color 92#define x_defined_color w32_defined_color
89#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits) 93#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
90 94
91/* Functions from w32term.c that depend on XColor (so can't go in w32term.h
92 without modifying lots of files). */
93extern void x_query_colors (struct frame *f, XColor *colors, int ncolors);
94extern void x_query_color (struct frame *f, XColor *color);
95
96/* Version of libpng that we were compiled with, or -1 if no PNG 95/* Version of libpng that we were compiled with, or -1 if no PNG
97 support was compiled in. This is tested by w32-win.el to correctly 96 support was compiled in. This is tested by w32-win.el to correctly
98 set up the alist used to search for PNG libraries. */ 97 set up the alist used to search for PNG libraries. */
@@ -100,10 +99,6 @@ Lisp_Object Qlibpng_version;
100#endif /* HAVE_NTGUI */ 99#endif /* HAVE_NTGUI */
101 100
102#ifdef HAVE_NS 101#ifdef HAVE_NS
103#include "nsterm.h"
104#include <sys/types.h>
105#include <sys/stat.h>
106
107#undef COLOR_TABLE_SUPPORT 102#undef COLOR_TABLE_SUPPORT
108 103
109typedef struct ns_bitmap_record Bitmap_Record; 104typedef struct ns_bitmap_record Bitmap_Record;
@@ -117,10 +112,8 @@ typedef struct ns_bitmap_record Bitmap_Record;
117#define PIX_MASK_RETAIN 0 112#define PIX_MASK_RETAIN 0
118#define PIX_MASK_DRAW 1 113#define PIX_MASK_DRAW 1
119 114
120#define FRAME_X_VISUAL FRAME_NS_DISPLAY_INFO (f)->visual
121#define x_defined_color(f, name, color_def, alloc) \ 115#define x_defined_color(f, name, color_def, alloc) \
122 ns_defined_color (f, name, color_def, alloc, 0) 116 ns_defined_color (f, name, color_def, alloc, 0)
123#define FRAME_X_SCREEN(f) 0
124#define DefaultDepthOfScreen(screen) x_display_list->n_planes 117#define DefaultDepthOfScreen(screen) x_display_list->n_planes
125#endif /* HAVE_NS */ 118#endif /* HAVE_NS */
126 119
@@ -5524,13 +5517,13 @@ init_png_functions (Lisp_Object libraries)
5524 5517
5525 5518
5526#if (PNG_LIBPNG_VER < 10500) 5519#if (PNG_LIBPNG_VER < 10500)
5527#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) 5520#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1))
5528#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) 5521#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
5529#else 5522#else
5530/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ 5523/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */
5531#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1)) 5524#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1))
5532#define PNG_JMPBUF(ptr) \ 5525#define PNG_JMPBUF(ptr) \
5533 (*fn_png_set_longjmp_fn ((ptr), longjmp, sizeof (jmp_buf))) 5526 (*fn_png_set_longjmp_fn ((ptr), _longjmp, sizeof (jmp_buf)))
5534#endif 5527#endif
5535 5528
5536/* Error and warning handlers installed when the PNG library 5529/* Error and warning handlers installed when the PNG library
@@ -5703,7 +5696,7 @@ png_load (struct frame *f, struct image *img)
5703 5696
5704 /* Set error jump-back. We come back here when the PNG library 5697 /* Set error jump-back. We come back here when the PNG library
5705 detects an error. */ 5698 detects an error. */
5706 if (setjmp (PNG_JMPBUF (png_ptr))) 5699 if (_setjmp (PNG_JMPBUF (png_ptr)))
5707 { 5700 {
5708 error: 5701 error:
5709 if (png_ptr) 5702 if (png_ptr)
@@ -6121,7 +6114,7 @@ static _Noreturn void
6121my_error_exit (j_common_ptr cinfo) 6114my_error_exit (j_common_ptr cinfo)
6122{ 6115{
6123 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; 6116 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
6124 longjmp (mgr->setjmp_buffer, 1); 6117 _longjmp (mgr->setjmp_buffer, 1);
6125} 6118}
6126 6119
6127 6120
@@ -6372,7 +6365,7 @@ jpeg_load (struct frame *f, struct image *img)
6372 cinfo.err = fn_jpeg_std_error (&mgr.pub); 6365 cinfo.err = fn_jpeg_std_error (&mgr.pub);
6373 mgr.pub.error_exit = my_error_exit; 6366 mgr.pub.error_exit = my_error_exit;
6374 6367
6375 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 6368 if ((rc = _setjmp (mgr.setjmp_buffer)) != 0)
6376 { 6369 {
6377 if (rc == 1) 6370 if (rc == 1)
6378 { 6371 {
@@ -6418,12 +6411,12 @@ jpeg_load (struct frame *f, struct image *img)
6418 if (!check_image_size (f, width, height)) 6411 if (!check_image_size (f, width, height))
6419 { 6412 {
6420 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6413 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
6421 longjmp (mgr.setjmp_buffer, 2); 6414 _longjmp (mgr.setjmp_buffer, 2);
6422 } 6415 }
6423 6416
6424 /* Create X image and pixmap. */ 6417 /* Create X image and pixmap. */
6425 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 6418 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6426 longjmp (mgr.setjmp_buffer, 2); 6419 _longjmp (mgr.setjmp_buffer, 2);
6427 6420
6428 /* Allocate colors. When color quantization is used, 6421 /* Allocate colors. When color quantization is used,
6429 cinfo.actual_number_of_colors has been set with the number of 6422 cinfo.actual_number_of_colors has been set with the number of
diff --git a/src/insdel.c b/src/insdel.c
index 1dceb67bffa..da258c19a1e 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -31,19 +31,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include "blockinput.h" 31#include "blockinput.h"
32#include "region-cache.h" 32#include "region-cache.h"
33 33
34static void insert_from_string_1 (Lisp_Object string, 34static void insert_from_string_1 (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t,
35 ptrdiff_t pos, ptrdiff_t pos_byte, 35 ptrdiff_t, bool, bool);
36 ptrdiff_t nchars, ptrdiff_t nbytes, 36static void insert_from_buffer_1 (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
37 int inherit, int before_markers); 37static void gap_left (ptrdiff_t, ptrdiff_t, bool);
38static void insert_from_buffer_1 (struct buffer *buf, 38static void gap_right (ptrdiff_t, ptrdiff_t);
39 ptrdiff_t from, ptrdiff_t nchars,
40 int inherit);
41static void gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap);
42static void gap_right (ptrdiff_t charpos, ptrdiff_t bytepos);
43 39
44/* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT) 40/* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT)
45 describing changes which happened while combine_after_change_calls 41 describing changes which happened while combine_after_change_calls
46 was nonzero. We use this to decide how to call them 42 was non-nil. We use this to decide how to call them
47 once the deferral ends. 43 once the deferral ends.
48 44
49 In each element. 45 In each element.
@@ -67,8 +63,8 @@ static void signal_before_change (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
67static void 63static void
68check_markers (void) 64check_markers (void)
69{ 65{
70 register struct Lisp_Marker *tail; 66 struct Lisp_Marker *tail;
71 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 67 bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
72 68
73 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) 69 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
74 { 70 {
@@ -113,13 +109,13 @@ move_gap_both (ptrdiff_t charpos, ptrdiff_t bytepos)
113/* Move the gap to a position less than the current GPT. 109/* Move the gap to a position less than the current GPT.
114 BYTEPOS describes the new position as a byte position, 110 BYTEPOS describes the new position as a byte position,
115 and CHARPOS is the corresponding char position. 111 and CHARPOS is the corresponding char position.
116 If NEWGAP is nonzero, then don't update beg_unchanged and end_unchanged. */ 112 If NEWGAP, then don't update beg_unchanged and end_unchanged. */
117 113
118static void 114static void
119gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap) 115gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, bool newgap)
120{ 116{
121 register unsigned char *to, *from; 117 unsigned char *to, *from;
122 register ptrdiff_t i; 118 ptrdiff_t i;
123 ptrdiff_t new_s1; 119 ptrdiff_t new_s1;
124 120
125 if (!newgap) 121 if (!newgap)
@@ -287,10 +283,10 @@ adjust_markers_for_delete (ptrdiff_t from, ptrdiff_t from_byte,
287 283
288static void 284static void
289adjust_markers_for_insert (ptrdiff_t from, ptrdiff_t from_byte, 285adjust_markers_for_insert (ptrdiff_t from, ptrdiff_t from_byte,
290 ptrdiff_t to, ptrdiff_t to_byte, int before_markers) 286 ptrdiff_t to, ptrdiff_t to_byte, bool before_markers)
291{ 287{
292 struct Lisp_Marker *m; 288 struct Lisp_Marker *m;
293 int adjusted = 0; 289 bool adjusted = 0;
294 ptrdiff_t nchars = to - from; 290 ptrdiff_t nchars = to - from;
295 ptrdiff_t nbytes = to_byte - from_byte; 291 ptrdiff_t nbytes = to_byte - from_byte;
296 292
@@ -515,7 +511,7 @@ make_gap (ptrdiff_t nbytes_added)
515 511
516ptrdiff_t 512ptrdiff_t
517copy_text (const unsigned char *from_addr, unsigned char *to_addr, 513copy_text (const unsigned char *from_addr, unsigned char *to_addr,
518 ptrdiff_t nbytes, int from_multibyte, int to_multibyte) 514 ptrdiff_t nbytes, bool from_multibyte, bool to_multibyte)
519{ 515{
520 if (from_multibyte == to_multibyte) 516 if (from_multibyte == to_multibyte)
521 { 517 {
@@ -664,7 +660,7 @@ insert_before_markers_and_inherit (const char *string,
664 660
665void 661void
666insert_1 (const char *string, ptrdiff_t nbytes, 662insert_1 (const char *string, ptrdiff_t nbytes,
667 int inherit, int prepare, int before_markers) 663 bool inherit, bool prepare, bool before_markers)
668{ 664{
669 insert_1_both (string, chars_in_text ((unsigned char *) string, nbytes), 665 insert_1_both (string, chars_in_text ((unsigned char *) string, nbytes),
670 nbytes, inherit, prepare, before_markers); 666 nbytes, inherit, prepare, before_markers);
@@ -790,7 +786,7 @@ count_combining_after (const unsigned char *string,
790void 786void
791insert_1_both (const char *string, 787insert_1_both (const char *string,
792 ptrdiff_t nchars, ptrdiff_t nbytes, 788 ptrdiff_t nchars, ptrdiff_t nbytes,
793 int inherit, int prepare, int before_markers) 789 bool inherit, bool prepare, bool before_markers)
794{ 790{
795 if (nchars == 0) 791 if (nchars == 0)
796 return; 792 return;
@@ -867,7 +863,7 @@ insert_1_both (const char *string,
867 863
868void 864void
869insert_from_string (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, 865insert_from_string (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
870 ptrdiff_t length, ptrdiff_t length_byte, int inherit) 866 ptrdiff_t length, ptrdiff_t length_byte, bool inherit)
871{ 867{
872 ptrdiff_t opoint = PT; 868 ptrdiff_t opoint = PT;
873 869
@@ -887,7 +883,7 @@ void
887insert_from_string_before_markers (Lisp_Object string, 883insert_from_string_before_markers (Lisp_Object string,
888 ptrdiff_t pos, ptrdiff_t pos_byte, 884 ptrdiff_t pos, ptrdiff_t pos_byte,
889 ptrdiff_t length, ptrdiff_t length_byte, 885 ptrdiff_t length, ptrdiff_t length_byte,
890 int inherit) 886 bool inherit)
891{ 887{
892 ptrdiff_t opoint = PT; 888 ptrdiff_t opoint = PT;
893 889
@@ -905,7 +901,7 @@ insert_from_string_before_markers (Lisp_Object string,
905static void 901static void
906insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, 902insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
907 ptrdiff_t nchars, ptrdiff_t nbytes, 903 ptrdiff_t nchars, ptrdiff_t nbytes,
908 int inherit, int before_markers) 904 bool inherit, bool before_markers)
909{ 905{
910 struct gcpro gcpro1; 906 struct gcpro gcpro1;
911 ptrdiff_t outgoing_nbytes = nbytes; 907 ptrdiff_t outgoing_nbytes = nbytes;
@@ -1039,7 +1035,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
1039 1035
1040void 1036void
1041insert_from_buffer (struct buffer *buf, 1037insert_from_buffer (struct buffer *buf,
1042 ptrdiff_t charpos, ptrdiff_t nchars, int inherit) 1038 ptrdiff_t charpos, ptrdiff_t nchars, bool inherit)
1043{ 1039{
1044 ptrdiff_t opoint = PT; 1040 ptrdiff_t opoint = PT;
1045 1041
@@ -1050,7 +1046,7 @@ insert_from_buffer (struct buffer *buf,
1050 1046
1051static void 1047static void
1052insert_from_buffer_1 (struct buffer *buf, 1048insert_from_buffer_1 (struct buffer *buf,
1053 ptrdiff_t from, ptrdiff_t nchars, int inherit) 1049 ptrdiff_t from, ptrdiff_t nchars, bool inherit)
1054{ 1050{
1055 ptrdiff_t chunk, chunk_expanded; 1051 ptrdiff_t chunk, chunk_expanded;
1056 ptrdiff_t from_byte = buf_charpos_to_bytepos (buf, from); 1052 ptrdiff_t from_byte = buf_charpos_to_bytepos (buf, from);
@@ -1265,7 +1261,7 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte,
1265} 1261}
1266 1262
1267/* Replace the text from character positions FROM to TO with NEW, 1263/* Replace the text from character positions FROM to TO with NEW,
1268 If PREPARE is nonzero, call prepare_to_modify_buffer. 1264 If PREPARE, call prepare_to_modify_buffer.
1269 If INHERIT, the newly inserted text should inherit text properties 1265 If INHERIT, the newly inserted text should inherit text properties
1270 from the surrounding non-deleted text. */ 1266 from the surrounding non-deleted text. */
1271 1267
@@ -1278,7 +1274,7 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte,
1278 1274
1279void 1275void
1280replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, 1276replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1281 int prepare, int inherit, int markers) 1277 bool prepare, bool inherit, bool markers)
1282{ 1278{
1283 ptrdiff_t inschars = SCHARS (new); 1279 ptrdiff_t inschars = SCHARS (new);
1284 ptrdiff_t insbytes = SBYTES (new); 1280 ptrdiff_t insbytes = SBYTES (new);
@@ -1443,7 +1439,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
1443 1439
1444 Note that this does not yet handle markers quite right. 1440 Note that this does not yet handle markers quite right.
1445 1441
1446 If MARKERS is nonzero, relocate markers. 1442 If MARKERS, relocate markers.
1447 1443
1448 Unlike most functions at this level, never call 1444 Unlike most functions at this level, never call
1449 prepare_to_modify_buffer and never call signal_after_change. */ 1445 prepare_to_modify_buffer and never call signal_after_change. */
@@ -1452,7 +1448,7 @@ void
1452replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte, 1448replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1453 ptrdiff_t to, ptrdiff_t to_byte, 1449 ptrdiff_t to, ptrdiff_t to_byte,
1454 const char *ins, ptrdiff_t inschars, ptrdiff_t insbytes, 1450 const char *ins, ptrdiff_t inschars, ptrdiff_t insbytes,
1455 int markers) 1451 bool markers)
1456{ 1452{
1457 ptrdiff_t nbytes_del, nchars_del; 1453 ptrdiff_t nbytes_del, nchars_del;
1458 1454
@@ -1563,7 +1559,7 @@ del_range (ptrdiff_t from, ptrdiff_t to)
1563 RET_STRING says to return the deleted text. */ 1559 RET_STRING says to return the deleted text. */
1564 1560
1565Lisp_Object 1561Lisp_Object
1566del_range_1 (ptrdiff_t from, ptrdiff_t to, int prepare, int ret_string) 1562del_range_1 (ptrdiff_t from, ptrdiff_t to, bool prepare, bool ret_string)
1567{ 1563{
1568 ptrdiff_t from_byte, to_byte; 1564 ptrdiff_t from_byte, to_byte;
1569 Lisp_Object deletion; 1565 Lisp_Object deletion;
@@ -1599,7 +1595,7 @@ del_range_1 (ptrdiff_t from, ptrdiff_t to, int prepare, int ret_string)
1599/* Like del_range_1 but args are byte positions, not char positions. */ 1595/* Like del_range_1 but args are byte positions, not char positions. */
1600 1596
1601void 1597void
1602del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, int prepare) 1598del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, bool prepare)
1603{ 1599{
1604 ptrdiff_t from, to; 1600 ptrdiff_t from, to;
1605 1601
@@ -1643,7 +1639,7 @@ del_range_byte (ptrdiff_t from_byte, ptrdiff_t to_byte, int prepare)
1643 1639
1644void 1640void
1645del_range_both (ptrdiff_t from, ptrdiff_t from_byte, 1641del_range_both (ptrdiff_t from, ptrdiff_t from_byte,
1646 ptrdiff_t to, ptrdiff_t to_byte, int prepare) 1642 ptrdiff_t to, ptrdiff_t to_byte, bool prepare)
1647{ 1643{
1648 /* Make args be valid */ 1644 /* Make args be valid */
1649 if (from_byte < BEGV_BYTE) 1645 if (from_byte < BEGV_BYTE)
@@ -1685,13 +1681,13 @@ del_range_both (ptrdiff_t from, ptrdiff_t from_byte,
1685/* Delete a range of text, specified both as character positions 1681/* Delete a range of text, specified both as character positions
1686 and byte positions. FROM and TO are character positions, 1682 and byte positions. FROM and TO are character positions,
1687 while FROM_BYTE and TO_BYTE are byte positions. 1683 while FROM_BYTE and TO_BYTE are byte positions.
1688 If RET_STRING is true, the deleted area is returned as a string. */ 1684 If RET_STRING, the deleted area is returned as a string. */
1689 1685
1690Lisp_Object 1686Lisp_Object
1691del_range_2 (ptrdiff_t from, ptrdiff_t from_byte, 1687del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1692 ptrdiff_t to, ptrdiff_t to_byte, int ret_string) 1688 ptrdiff_t to, ptrdiff_t to_byte, bool ret_string)
1693{ 1689{
1694 register ptrdiff_t nbytes_del, nchars_del; 1690 ptrdiff_t nbytes_del, nchars_del;
1695 Lisp_Object deletion; 1691 Lisp_Object deletion;
1696 1692
1697 check_markers (); 1693 check_markers ();
@@ -1770,17 +1766,16 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
1770 and warns the next redisplay that it should pay attention to that 1766 and warns the next redisplay that it should pay attention to that
1771 area. 1767 area.
1772 1768
1773 If PRESERVE_CHARS_MODIFF is non-zero, do not update CHARS_MODIFF. 1769 If PRESERVE_CHARS_MODIFF, do not update CHARS_MODIFF.
1774 Otherwise set CHARS_MODIFF to the new value of MODIFF. */ 1770 Otherwise set CHARS_MODIFF to the new value of MODIFF. */
1775 1771
1776void 1772void
1777modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end, 1773modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end,
1778 int preserve_chars_modiff) 1774 bool preserve_chars_modiff)
1779{ 1775{
1780 struct buffer *old_buffer = current_buffer; 1776 struct buffer *old_buffer = current_buffer;
1781 1777
1782 if (buffer != old_buffer) 1778 set_buffer_internal (buffer);
1783 set_buffer_internal (buffer);
1784 1779
1785 prepare_to_modify_buffer (start, end, NULL); 1780 prepare_to_modify_buffer (start, end, NULL);
1786 1781
@@ -1794,8 +1789,7 @@ modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end,
1794 1789
1795 bset_point_before_scroll (buffer, Qnil); 1790 bset_point_before_scroll (buffer, Qnil);
1796 1791
1797 if (buffer != old_buffer) 1792 set_buffer_internal (old_buffer);
1798 set_buffer_internal (old_buffer);
1799} 1793}
1800 1794
1801/* Check that it is okay to modify the buffer between START and END, 1795/* Check that it is okay to modify the buffer between START and END,
@@ -2119,7 +2113,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
2119 return Qnil; 2113 return Qnil;
2120 } 2114 }
2121 2115
2122 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 2116 record_unwind_current_buffer ();
2123 2117
2124 Fset_buffer (combine_after_change_buffer); 2118 Fset_buffer (combine_after_change_buffer);
2125 2119
diff --git a/src/intervals.c b/src/intervals.c
index 0a85e20e5d9..49d61b2f9b0 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -178,14 +178,13 @@ merge_properties (register INTERVAL source, register INTERVAL target)
178 } 178 }
179} 179}
180 180
181/* Return 1 if the two intervals have the same properties, 181/* Return true if the two intervals have the same properties. */
182 0 otherwise. */
183 182
184int 183bool
185intervals_equal (INTERVAL i0, INTERVAL i1) 184intervals_equal (INTERVAL i0, INTERVAL i1)
186{ 185{
187 register Lisp_Object i0_cdr, i0_sym; 186 Lisp_Object i0_cdr, i0_sym;
188 register Lisp_Object i1_cdr, i1_val; 187 Lisp_Object i1_cdr, i1_val;
189 188
190 if (DEFAULT_INTERVAL_P (i0) && DEFAULT_INTERVAL_P (i1)) 189 if (DEFAULT_INTERVAL_P (i0) && DEFAULT_INTERVAL_P (i1))
191 return 1; 190 return 1;
@@ -469,10 +468,10 @@ balance_an_interval (INTERVAL i)
469 Lisp Object. */ 468 Lisp Object. */
470 469
471static inline INTERVAL 470static inline INTERVAL
472balance_possible_root_interval (register INTERVAL interval) 471balance_possible_root_interval (INTERVAL interval)
473{ 472{
474 Lisp_Object parent; 473 Lisp_Object parent;
475 int have_parent = 0; 474 bool have_parent = 0;
476 475
477 if (!INTERVAL_HAS_OBJECT (interval) && !INTERVAL_HAS_PARENT (interval)) 476 if (!INTERVAL_HAS_OBJECT (interval) && !INTERVAL_HAS_PARENT (interval))
478 return interval; 477 return interval;
@@ -845,9 +844,9 @@ static INTERVAL
845adjust_intervals_for_insertion (INTERVAL tree, 844adjust_intervals_for_insertion (INTERVAL tree,
846 ptrdiff_t position, ptrdiff_t length) 845 ptrdiff_t position, ptrdiff_t length)
847{ 846{
848 register INTERVAL i; 847 INTERVAL i;
849 register INTERVAL temp; 848 INTERVAL temp;
850 int eobp = 0; 849 bool eobp = 0;
851 Lisp_Object parent; 850 Lisp_Object parent;
852 ptrdiff_t offset; 851 ptrdiff_t offset;
853 852
@@ -1068,11 +1067,10 @@ FR 8 9 A B
1068static Lisp_Object 1067static Lisp_Object
1069merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright) 1068merge_properties_sticky (Lisp_Object pleft, Lisp_Object pright)
1070{ 1069{
1071 register Lisp_Object props, front, rear; 1070 Lisp_Object props, front, rear;
1072 Lisp_Object lfront, lrear, rfront, rrear; 1071 Lisp_Object lfront, lrear, rfront, rrear;
1073 register Lisp_Object tail1, tail2, sym, lval, rval, cat; 1072 Lisp_Object tail1, tail2, sym, lval, rval, cat;
1074 int use_left, use_right; 1073 bool use_left, use_right, lpresent;
1075 int lpresent;
1076 1074
1077 props = Qnil; 1075 props = Qnil;
1078 front = Qnil; 1076 front = Qnil;
@@ -1610,7 +1608,7 @@ reproduce_tree_obj (INTERVAL source, Lisp_Object parent)
1610void 1608void
1611graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position, 1609graft_intervals_into_buffer (INTERVAL source, ptrdiff_t position,
1612 ptrdiff_t length, struct buffer *buffer, 1610 ptrdiff_t length, struct buffer *buffer,
1613 int inherit) 1611 bool inherit)
1614{ 1612{
1615 INTERVAL tree = buffer_intervals (buffer); 1613 INTERVAL tree = buffer_intervals (buffer);
1616 INTERVAL under, over, this; 1614 INTERVAL under, over, this;
@@ -1753,9 +1751,9 @@ textget (Lisp_Object plist, register Lisp_Object prop)
1753} 1751}
1754 1752
1755Lisp_Object 1753Lisp_Object
1756lookup_char_property (Lisp_Object plist, register Lisp_Object prop, int textprop) 1754lookup_char_property (Lisp_Object plist, Lisp_Object prop, bool textprop)
1757{ 1755{
1758 register Lisp_Object tail, fallback = Qnil; 1756 Lisp_Object tail, fallback = Qnil;
1759 1757
1760 for (tail = plist; CONSP (tail); tail = Fcdr (XCDR (tail))) 1758 for (tail = plist; CONSP (tail); tail = Fcdr (XCDR (tail)))
1761 { 1759 {
@@ -1826,8 +1824,8 @@ set_point (ptrdiff_t charpos)
1826/* If there's an invisible character at position POS + TEST_OFFS in the 1824/* If there's an invisible character at position POS + TEST_OFFS in the
1827 current buffer, and the invisible property has a `stickiness' such that 1825 current buffer, and the invisible property has a `stickiness' such that
1828 inserting a character at position POS would inherit the property it, 1826 inserting a character at position POS would inherit the property it,
1829 return POS + ADJ, otherwise return POS. If TEST_INTANG is non-zero, 1827 return POS + ADJ, otherwise return POS. If TEST_INTANG, intangibility
1830 then intangibility is required as well as invisibility. 1828 is required as well as invisibility.
1831 1829
1832 TEST_OFFS should be either 0 or -1, and ADJ should be either 1 or -1. 1830 TEST_OFFS should be either 0 or -1, and ADJ should be either 1 or -1.
1833 1831
@@ -1836,7 +1834,7 @@ set_point (ptrdiff_t charpos)
1836 1834
1837static ptrdiff_t 1835static ptrdiff_t
1838adjust_for_invis_intang (ptrdiff_t pos, ptrdiff_t test_offs, ptrdiff_t adj, 1836adjust_for_invis_intang (ptrdiff_t pos, ptrdiff_t test_offs, ptrdiff_t adj,
1839 int test_intang) 1837 bool test_intang)
1840{ 1838{
1841 Lisp_Object invis_propval, invis_overlay; 1839 Lisp_Object invis_propval, invis_overlay;
1842 Lisp_Object test_pos; 1840 Lisp_Object test_pos;
@@ -1883,8 +1881,8 @@ set_point_both (ptrdiff_t charpos, ptrdiff_t bytepos)
1883 initial position is the same as the destination, in the rare 1881 initial position is the same as the destination, in the rare
1884 instances where this is important, e.g. in line-move-finish 1882 instances where this is important, e.g. in line-move-finish
1885 (simple.el). */ 1883 (simple.el). */
1886 int backwards = (charpos < old_position ? 1 : 0); 1884 bool backwards = charpos < old_position;
1887 int have_overlays; 1885 bool have_overlays;
1888 ptrdiff_t original_position; 1886 ptrdiff_t original_position;
1889 1887
1890 bset_point_before_scroll (current_buffer, Qnil); 1888 bset_point_before_scroll (current_buffer, Qnil);
@@ -2154,12 +2152,12 @@ move_if_not_intangible (ptrdiff_t position)
2154 2152
2155/* If text at position POS has property PROP, set *VAL to the property 2153/* If text at position POS has property PROP, set *VAL to the property
2156 value, *START and *END to the beginning and end of a region that 2154 value, *START and *END to the beginning and end of a region that
2157 has the same property, and return 1. Otherwise return 0. 2155 has the same property, and return true. Otherwise return false.
2158 2156
2159 OBJECT is the string or buffer to look for the property in; 2157 OBJECT is the string or buffer to look for the property in;
2160 nil means the current buffer. */ 2158 nil means the current buffer. */
2161 2159
2162int 2160bool
2163get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val, 2161get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val,
2164 ptrdiff_t *start, ptrdiff_t *end, Lisp_Object object) 2162 ptrdiff_t *start, ptrdiff_t *end, Lisp_Object object)
2165{ 2163{
@@ -2306,10 +2304,10 @@ copy_intervals_to_string (Lisp_Object string, struct buffer *buffer,
2306 set_string_intervals (string, interval_copy); 2304 set_string_intervals (string, interval_copy);
2307} 2305}
2308 2306
2309/* Return 1 if strings S1 and S2 have identical properties; 0 otherwise. 2307/* Return true if strings S1 and S2 have identical properties.
2310 Assume they have identical characters. */ 2308 Assume they have identical characters. */
2311 2309
2312int 2310bool
2313compare_string_intervals (Lisp_Object s1, Lisp_Object s2) 2311compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
2314{ 2312{
2315 INTERVAL i1, i2; 2313 INTERVAL i1, i2;
@@ -2348,7 +2346,7 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2)
2348 START_BYTE ... END_BYTE in bytes. */ 2346 START_BYTE ... END_BYTE in bytes. */
2349 2347
2350static void 2348static void
2351set_intervals_multibyte_1 (INTERVAL i, int multi_flag, 2349set_intervals_multibyte_1 (INTERVAL i, bool multi_flag,
2352 ptrdiff_t start, ptrdiff_t start_byte, 2350 ptrdiff_t start, ptrdiff_t start_byte,
2353 ptrdiff_t end, ptrdiff_t end_byte) 2351 ptrdiff_t end, ptrdiff_t end_byte)
2354{ 2352{
@@ -2456,11 +2454,11 @@ set_intervals_multibyte_1 (INTERVAL i, int multi_flag,
2456} 2454}
2457 2455
2458/* Update the intervals of the current buffer 2456/* Update the intervals of the current buffer
2459 to fit the contents as multibyte (if MULTI_FLAG is 1) 2457 to fit the contents as multibyte (if MULTI_FLAG)
2460 or to fit them as non-multibyte (if MULTI_FLAG is 0). */ 2458 or to fit them as non-multibyte (if not MULTI_FLAG). */
2461 2459
2462void 2460void
2463set_intervals_multibyte (int multi_flag) 2461set_intervals_multibyte (bool multi_flag)
2464{ 2462{
2465 INTERVAL i = buffer_intervals (current_buffer); 2463 INTERVAL i = buffer_intervals (current_buffer);
2466 2464
diff --git a/src/intervals.h b/src/intervals.h
index 01e72d7c9db..2b30101d0fa 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -227,7 +227,7 @@ extern INTERVAL make_interval (void);
227 227
228extern INTERVAL create_root_interval (Lisp_Object); 228extern INTERVAL create_root_interval (Lisp_Object);
229extern void copy_properties (INTERVAL, INTERVAL); 229extern void copy_properties (INTERVAL, INTERVAL);
230extern int intervals_equal (INTERVAL, INTERVAL); 230extern bool intervals_equal (INTERVAL, INTERVAL);
231extern void traverse_intervals (INTERVAL, ptrdiff_t, 231extern void traverse_intervals (INTERVAL, ptrdiff_t,
232 void (*) (INTERVAL, Lisp_Object), 232 void (*) (INTERVAL, Lisp_Object),
233 Lisp_Object); 233 Lisp_Object);
@@ -242,22 +242,22 @@ extern INTERVAL previous_interval (INTERVAL);
242extern INTERVAL merge_interval_left (INTERVAL); 242extern INTERVAL merge_interval_left (INTERVAL);
243extern void offset_intervals (struct buffer *, ptrdiff_t, ptrdiff_t); 243extern void offset_intervals (struct buffer *, ptrdiff_t, ptrdiff_t);
244extern void graft_intervals_into_buffer (INTERVAL, ptrdiff_t, ptrdiff_t, 244extern void graft_intervals_into_buffer (INTERVAL, ptrdiff_t, ptrdiff_t,
245 struct buffer *, int); 245 struct buffer *, bool);
246extern void verify_interval_modification (struct buffer *, 246extern void verify_interval_modification (struct buffer *,
247 ptrdiff_t, ptrdiff_t); 247 ptrdiff_t, ptrdiff_t);
248extern INTERVAL balance_intervals (INTERVAL); 248extern INTERVAL balance_intervals (INTERVAL);
249extern void copy_intervals_to_string (Lisp_Object, struct buffer *, 249extern void copy_intervals_to_string (Lisp_Object, struct buffer *,
250 ptrdiff_t, ptrdiff_t); 250 ptrdiff_t, ptrdiff_t);
251extern INTERVAL copy_intervals (INTERVAL, ptrdiff_t, ptrdiff_t); 251extern INTERVAL copy_intervals (INTERVAL, ptrdiff_t, ptrdiff_t);
252extern int compare_string_intervals (Lisp_Object, Lisp_Object); 252extern bool compare_string_intervals (Lisp_Object, Lisp_Object);
253extern Lisp_Object textget (Lisp_Object, Lisp_Object); 253extern Lisp_Object textget (Lisp_Object, Lisp_Object);
254extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, int); 254extern Lisp_Object lookup_char_property (Lisp_Object, Lisp_Object, bool);
255extern void move_if_not_intangible (ptrdiff_t); 255extern void move_if_not_intangible (ptrdiff_t);
256extern int get_property_and_range (ptrdiff_t, Lisp_Object, Lisp_Object *, 256extern bool get_property_and_range (ptrdiff_t, Lisp_Object, Lisp_Object *,
257 ptrdiff_t *, ptrdiff_t *, Lisp_Object); 257 ptrdiff_t *, ptrdiff_t *, Lisp_Object);
258extern Lisp_Object get_local_map (ptrdiff_t, struct buffer *, Lisp_Object); 258extern Lisp_Object get_local_map (ptrdiff_t, struct buffer *, Lisp_Object);
259extern INTERVAL update_interval (INTERVAL, ptrdiff_t); 259extern INTERVAL update_interval (INTERVAL, ptrdiff_t);
260extern void set_intervals_multibyte (int); 260extern void set_intervals_multibyte (bool);
261extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *, 261extern INTERVAL validate_interval_range (Lisp_Object, Lisp_Object *,
262 Lisp_Object *, int); 262 Lisp_Object *, int);
263extern INTERVAL interval_of (ptrdiff_t, Lisp_Object); 263extern INTERVAL interval_of (ptrdiff_t, Lisp_Object);
diff --git a/src/keyboard.c b/src/keyboard.c
index 868d0c8d2c1..464c3ae0d66 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -63,20 +63,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
63#include <unistd.h> 63#include <unistd.h>
64#include <fcntl.h> 64#include <fcntl.h>
65 65
66/* This is to get the definitions of the XK_ symbols. */ 66#ifdef HAVE_WINDOW_SYSTEM
67#ifdef HAVE_X_WINDOWS 67#include TERM_HEADER
68#include "xterm.h" 68#endif /* HAVE_WINDOW_SYSTEM */
69#endif
70
71#ifdef HAVE_NTGUI
72#include "w32term.h"
73#endif /* HAVE_NTGUI */
74
75#ifdef HAVE_NS
76#include "nsterm.h"
77#endif
78 69
79/* Variables for blockinput.h: */ 70/* Variables for blockinput.h: */
80 71
81/* Non-zero if interrupt input is blocked right now. */ 72/* Non-zero if interrupt input is blocked right now. */
82volatile int interrupt_input_blocked; 73volatile int interrupt_input_blocked;
@@ -1434,8 +1425,7 @@ command_loop_1 (void)
1434 Fkill_emacs (Qnil); 1425 Fkill_emacs (Qnil);
1435 1426
1436 /* Make sure the current window's buffer is selected. */ 1427 /* Make sure the current window's buffer is selected. */
1437 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 1428 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1438 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1439 1429
1440 /* Display any malloc warning that just came out. Use while because 1430 /* Display any malloc warning that just came out. Use while because
1441 displaying one warning can cause another. */ 1431 displaying one warning can cause another. */
@@ -1513,8 +1503,7 @@ command_loop_1 (void)
1513 /* A filter may have run while we were reading the input. */ 1503 /* A filter may have run while we were reading the input. */
1514 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 1504 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
1515 Fkill_emacs (Qnil); 1505 Fkill_emacs (Qnil);
1516 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 1506 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1517 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1518 1507
1519 ++num_input_keys; 1508 ++num_input_keys;
1520 1509
@@ -4350,9 +4339,8 @@ struct input_event last_timer_event EXTERNALLY_VISIBLE;
4350 ...). Each element has the form (FUN . ARGS). */ 4339 ...). Each element has the form (FUN . ARGS). */
4351Lisp_Object pending_funcalls; 4340Lisp_Object pending_funcalls;
4352 4341
4353/* If TIMER is a valid timer, return nonzero and place its value into 4342/* Return true if TIMER is a valid timer, placing its value into *RESULT. */
4354 *RESULT. Otherwise return zero. */ 4343static bool
4355static int
4356decode_timer (Lisp_Object timer, EMACS_TIME *result) 4344decode_timer (Lisp_Object timer, EMACS_TIME *result)
4357{ 4345{
4358 Lisp_Object *vector; 4346 Lisp_Object *vector;
@@ -4419,7 +4407,6 @@ timer_check_2 (void)
4419 4407
4420 while (CONSP (timers) || CONSP (idle_timers)) 4408 while (CONSP (timers) || CONSP (idle_timers))
4421 { 4409 {
4422 Lisp_Object *vector;
4423 Lisp_Object timer = Qnil, idle_timer = Qnil; 4410 Lisp_Object timer = Qnil, idle_timer = Qnil;
4424 EMACS_TIME timer_time, idle_timer_time; 4411 EMACS_TIME timer_time, idle_timer_time;
4425 EMACS_TIME difference; 4412 EMACS_TIME difference;
@@ -4495,15 +4482,14 @@ timer_check_2 (void)
4495 /* If timer is ripe, run it if it hasn't been run. */ 4482 /* If timer is ripe, run it if it hasn't been run. */
4496 if (ripe) 4483 if (ripe)
4497 { 4484 {
4498 vector = XVECTOR (chosen_timer)->contents; 4485 if (NILP (AREF (chosen_timer, 0)))
4499 if (NILP (vector[0]))
4500 { 4486 {
4501 ptrdiff_t count = SPECPDL_INDEX (); 4487 ptrdiff_t count = SPECPDL_INDEX ();
4502 Lisp_Object old_deactivate_mark = Vdeactivate_mark; 4488 Lisp_Object old_deactivate_mark = Vdeactivate_mark;
4503 4489
4504 /* Mark the timer as triggered to prevent problems if the lisp 4490 /* Mark the timer as triggered to prevent problems if the lisp
4505 code fails to reschedule it right. */ 4491 code fails to reschedule it right. */
4506 vector[0] = Qt; 4492 ASET (chosen_timer, 0, Qt);
4507 4493
4508 specbind (Qinhibit_quit, Qt); 4494 specbind (Qinhibit_quit, Qt);
4509 4495
@@ -8447,7 +8433,6 @@ init_tool_bar_items (Lisp_Object reuse)
8447static void 8433static void
8448append_tool_bar_item (void) 8434append_tool_bar_item (void)
8449{ 8435{
8450 Lisp_Object *to, *from;
8451 ptrdiff_t incr = 8436 ptrdiff_t incr =
8452 (ntool_bar_items 8437 (ntool_bar_items
8453 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); 8438 - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS));
@@ -8459,9 +8444,8 @@ append_tool_bar_item (void)
8459 8444
8460 /* Append entries from tool_bar_item_properties to the end of 8445 /* Append entries from tool_bar_item_properties to the end of
8461 tool_bar_items_vector. */ 8446 tool_bar_items_vector. */
8462 to = XVECTOR (tool_bar_items_vector)->contents + ntool_bar_items; 8447 vcopy (tool_bar_items_vector, ntool_bar_items,
8463 from = XVECTOR (tool_bar_item_properties)->contents; 8448 XVECTOR (tool_bar_item_properties)->contents, TOOL_BAR_ITEM_NSLOTS);
8464 memcpy (to, from, TOOL_BAR_ITEM_NSLOTS * sizeof *to);
8465 ntool_bar_items += TOOL_BAR_ITEM_NSLOTS; 8449 ntool_bar_items += TOOL_BAR_ITEM_NSLOTS;
8466} 8450}
8467 8451
@@ -9578,7 +9562,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9578 because we may get input from a subprocess which 9562 because we may get input from a subprocess which
9579 wants to change the selected window and stuff (say, 9563 wants to change the selected window and stuff (say,
9580 emacsclient). */ 9564 emacsclient). */
9581 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 9565 record_unwind_current_buffer ();
9582 9566
9583 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9567 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9584 Fkill_emacs (Qnil); 9568 Fkill_emacs (Qnil);
@@ -10490,10 +10474,10 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0,
10490 else 10474 else
10491 { 10475 {
10492 val = Fvector (NUM_RECENT_KEYS, keys); 10476 val = Fvector (NUM_RECENT_KEYS, keys);
10493 memcpy (XVECTOR (val)->contents, keys + recent_keys_index, 10477 vcopy (val, 0, keys + recent_keys_index,
10494 (NUM_RECENT_KEYS - recent_keys_index) * word_size); 10478 NUM_RECENT_KEYS - recent_keys_index);
10495 memcpy (XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index, 10479 vcopy (val, NUM_RECENT_KEYS - recent_keys_index,
10496 keys, recent_keys_index * word_size); 10480 keys, recent_keys_index);
10497 return val; 10481 return val;
10498 } 10482 }
10499} 10483}
@@ -11255,7 +11239,7 @@ The `posn-' functions access elements of such lists. */)
11255 11239
11256 if (WINDOWP (frame_or_window)) 11240 if (WINDOWP (frame_or_window))
11257 { 11241 {
11258 struct window *w = decode_valid_window (frame_or_window); 11242 struct window *w = decode_live_window (frame_or_window);
11259 11243
11260 XSETINT (x, (XINT (x) 11244 XSETINT (x, (XINT (x)
11261 + WINDOW_LEFT_EDGE_X (w) 11245 + WINDOW_LEFT_EDGE_X (w)
diff --git a/src/keymap.c b/src/keymap.c
index 21f7dcb5d37..85c384b8180 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1570,9 +1570,7 @@ like in the respective argument of `key-binding'. */)
1570 would not be a problem here, but it is easier to keep 1570 would not be a problem here, but it is easier to keep
1571 things the same. 1571 things the same.
1572 */ 1572 */
1573 1573 record_unwind_current_buffer ();
1574 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
1575
1576 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 1574 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
1577 } 1575 }
1578 } 1576 }
@@ -2159,7 +2157,7 @@ The `kbd' macro is an approximate inverse of this. */)
2159char * 2157char *
2160push_key_description (EMACS_INT ch, char *p, int force_multibyte) 2158push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2161{ 2159{
2162 int c, c2; 2160 int c, c2, tab_as_ci;
2163 2161
2164 /* Clear all the meaningless bits above the meta bit. */ 2162 /* Clear all the meaningless bits above the meta bit. */
2165 c = ch & (meta_modifier | ~ - meta_modifier); 2163 c = ch & (meta_modifier | ~ - meta_modifier);
@@ -2173,6 +2171,8 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2173 return p; 2171 return p;
2174 } 2172 }
2175 2173
2174 tab_as_ci = (c2 == '\t' && (c & meta_modifier));
2175
2176 if (c & alt_modifier) 2176 if (c & alt_modifier)
2177 { 2177 {
2178 *p++ = 'A'; 2178 *p++ = 'A';
@@ -2180,7 +2180,8 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2180 c -= alt_modifier; 2180 c -= alt_modifier;
2181 } 2181 }
2182 if ((c & ctrl_modifier) != 0 2182 if ((c & ctrl_modifier) != 0
2183 || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))) 2183 || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))
2184 || tab_as_ci)
2184 { 2185 {
2185 *p++ = 'C'; 2186 *p++ = 'C';
2186 *p++ = '-'; 2187 *p++ = '-';
@@ -2218,6 +2219,10 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2218 *p++ = 'S'; 2219 *p++ = 'S';
2219 *p++ = 'C'; 2220 *p++ = 'C';
2220 } 2221 }
2222 else if (tab_as_ci)
2223 {
2224 *p++ = 'i';
2225 }
2221 else if (c == '\t') 2226 else if (c == '\t')
2222 { 2227 {
2223 *p++ = 'T'; 2228 *p++ = 'T';
diff --git a/src/lisp.h b/src/lisp.h
index 5c7e8dc2f82..07a3ae17469 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -126,7 +126,7 @@ extern _Noreturn void die (const char *, const char *, int);
126 eassert macro altogether, e.g., if XSTRING (x) uses eassert to test 126 eassert macro altogether, e.g., if XSTRING (x) uses eassert to test
127 STRINGP (x), but a particular use of XSTRING is invoked only after 127 STRINGP (x), but a particular use of XSTRING is invoked only after
128 testing that STRINGP (x) is true, making the test redundant. */ 128 testing that STRINGP (x) is true, making the test redundant. */
129extern int suppress_checking EXTERNALLY_VISIBLE; 129extern bool suppress_checking EXTERNALLY_VISIBLE;
130 130
131# define eassert(cond) \ 131# define eassert(cond) \
132 ((cond) || suppress_checking \ 132 ((cond) || suppress_checking \
@@ -617,10 +617,8 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
617 617
618#define AREF(ARRAY, IDX) XVECTOR ((ARRAY))->contents[IDX] 618#define AREF(ARRAY, IDX) XVECTOR ((ARRAY))->contents[IDX]
619#define ASIZE(ARRAY) XVECTOR ((ARRAY))->header.size 619#define ASIZE(ARRAY) XVECTOR ((ARRAY))->header.size
620/* The IDX==IDX tries to detect when the macro argument is side-effecting. */
621#define ASET(ARRAY, IDX, VAL) \ 620#define ASET(ARRAY, IDX, VAL) \
622 (eassert ((IDX) == (IDX)), \ 621 (eassert (0 <= (IDX) && (IDX) < ASIZE (ARRAY)), \
623 eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \
624 XVECTOR (ARRAY)->contents[IDX] = (VAL)) 622 XVECTOR (ARRAY)->contents[IDX] = (VAL))
625 623
626/* Convenience macros for dealing with Lisp strings. */ 624/* Convenience macros for dealing with Lisp strings. */
@@ -713,7 +711,7 @@ struct Lisp_Cons
713#define CDR_SAFE(c) \ 711#define CDR_SAFE(c) \
714 (CONSP ((c)) ? XCDR ((c)) : Qnil) 712 (CONSP ((c)) ? XCDR ((c)) : Qnil)
715 713
716/* Nonzero if STR is a multibyte string. */ 714/* True if STR is a multibyte string. */
717#define STRING_MULTIBYTE(STR) \ 715#define STRING_MULTIBYTE(STR) \
718 (XSTRING (STR)->size_byte >= 0) 716 (XSTRING (STR)->size_byte >= 0)
719 717
@@ -1929,11 +1927,7 @@ typedef struct {
1929 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object) 1927 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
1930 1928
1931/* Non-zero if OBJ is a Lisp function. */ 1929/* Non-zero if OBJ is a Lisp function. */
1932#define FUNCTIONP(OBJ) \ 1930#define FUNCTIONP(OBJ) functionp(OBJ)
1933 ((CONSP (OBJ) && EQ (XCAR (OBJ), Qlambda)) \
1934 || (SYMBOLP (OBJ) && !NILP (Ffboundp (OBJ))) \
1935 || COMPILEDP (OBJ) \
1936 || SUBRP (OBJ))
1937 1931
1938/* defsubr (Sname); 1932/* defsubr (Sname);
1939 is how we define the symbol for function `name' at start-up time. */ 1933 is how we define the symbol for function `name' at start-up time. */
@@ -2357,6 +2351,17 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
2357 XVECTOR (array)->contents[idx] = val; 2351 XVECTOR (array)->contents[idx] = val;
2358} 2352}
2359 2353
2354/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */
2355
2356LISP_INLINE void
2357vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count)
2358{
2359 eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
2360 memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
2361}
2362
2363/* Functions to modify hash tables. */
2364
2360LISP_INLINE void 2365LISP_INLINE void
2361set_hash_key_and_value (struct Lisp_Hash_Table *h, Lisp_Object key_and_value) 2366set_hash_key_and_value (struct Lisp_Hash_Table *h, Lisp_Object key_and_value)
2362{ 2367{
@@ -2582,8 +2587,7 @@ extern Lisp_Object Qoverflow_error, Qunderflow_error;
2582extern Lisp_Object Qfloatp; 2587extern Lisp_Object Qfloatp;
2583extern Lisp_Object Qnumberp, Qnumber_or_marker_p; 2588extern Lisp_Object Qnumberp, Qnumber_or_marker_p;
2584 2589
2585extern Lisp_Object Qinteger, Qinterval, Qsymbol, Qstring; 2590extern Lisp_Object Qbuffer, Qinteger, Qsymbol;
2586extern Lisp_Object Qmisc, Qvector, Qfloat, Qcons, Qbuffer;
2587 2591
2588extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; 2592extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
2589 2593
@@ -2630,7 +2634,7 @@ extern _Noreturn void args_out_of_range_3 (Lisp_Object, Lisp_Object,
2630 Lisp_Object); 2634 Lisp_Object);
2631extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); 2635extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
2632extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); 2636extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *);
2633extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, int); 2637extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool);
2634extern void syms_of_data (void); 2638extern void syms_of_data (void);
2635extern void init_data (void); 2639extern void init_data (void);
2636extern void swap_in_global_binding (struct Lisp_Symbol *); 2640extern void swap_in_global_binding (struct Lisp_Symbol *);
@@ -2642,7 +2646,7 @@ extern void keys_of_cmds (void);
2642/* Defined in coding.c */ 2646/* Defined in coding.c */
2643extern Lisp_Object Qcharset; 2647extern Lisp_Object Qcharset;
2644extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, 2648extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
2645 ptrdiff_t, int, int, Lisp_Object); 2649 ptrdiff_t, bool, bool, Lisp_Object);
2646extern void init_coding (void); 2650extern void init_coding (void);
2647extern void init_coding_once (void); 2651extern void init_coding_once (void);
2648extern void syms_of_coding (void); 2652extern void syms_of_coding (void);
@@ -2730,43 +2734,43 @@ extern void move_gap_both (ptrdiff_t, ptrdiff_t);
2730extern _Noreturn void buffer_overflow (void); 2734extern _Noreturn void buffer_overflow (void);
2731extern void make_gap (ptrdiff_t); 2735extern void make_gap (ptrdiff_t);
2732extern ptrdiff_t copy_text (const unsigned char *, unsigned char *, 2736extern ptrdiff_t copy_text (const unsigned char *, unsigned char *,
2733 ptrdiff_t, int, int); 2737 ptrdiff_t, bool, bool);
2734extern int count_combining_before (const unsigned char *, 2738extern int count_combining_before (const unsigned char *,
2735 ptrdiff_t, ptrdiff_t, ptrdiff_t); 2739 ptrdiff_t, ptrdiff_t, ptrdiff_t);
2736extern int count_combining_after (const unsigned char *, 2740extern int count_combining_after (const unsigned char *,
2737 ptrdiff_t, ptrdiff_t, ptrdiff_t); 2741 ptrdiff_t, ptrdiff_t, ptrdiff_t);
2738extern void insert (const char *, ptrdiff_t); 2742extern void insert (const char *, ptrdiff_t);
2739extern void insert_and_inherit (const char *, ptrdiff_t); 2743extern void insert_and_inherit (const char *, ptrdiff_t);
2740extern void insert_1 (const char *, ptrdiff_t, int, int, int); 2744extern void insert_1 (const char *, ptrdiff_t, bool, bool, bool);
2741extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t, 2745extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t,
2742 int, int, int); 2746 bool, bool, bool);
2743extern void insert_from_gap (ptrdiff_t, ptrdiff_t); 2747extern void insert_from_gap (ptrdiff_t, ptrdiff_t);
2744extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t, 2748extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t,
2745 ptrdiff_t, ptrdiff_t, int); 2749 ptrdiff_t, ptrdiff_t, bool);
2746extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, int); 2750extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
2747extern void insert_char (int); 2751extern void insert_char (int);
2748extern void insert_string (const char *); 2752extern void insert_string (const char *);
2749extern void insert_before_markers (const char *, ptrdiff_t); 2753extern void insert_before_markers (const char *, ptrdiff_t);
2750extern void insert_before_markers_and_inherit (const char *, ptrdiff_t); 2754extern void insert_before_markers_and_inherit (const char *, ptrdiff_t);
2751extern void insert_from_string_before_markers (Lisp_Object, ptrdiff_t, 2755extern void insert_from_string_before_markers (Lisp_Object, ptrdiff_t,
2752 ptrdiff_t, ptrdiff_t, 2756 ptrdiff_t, ptrdiff_t,
2753 ptrdiff_t, int); 2757 ptrdiff_t, bool);
2754extern void del_range (ptrdiff_t, ptrdiff_t); 2758extern void del_range (ptrdiff_t, ptrdiff_t);
2755extern Lisp_Object del_range_1 (ptrdiff_t, ptrdiff_t, int, int); 2759extern Lisp_Object del_range_1 (ptrdiff_t, ptrdiff_t, bool, bool);
2756extern void del_range_byte (ptrdiff_t, ptrdiff_t, int); 2760extern void del_range_byte (ptrdiff_t, ptrdiff_t, bool);
2757extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, int); 2761extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool);
2758extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t, 2762extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t,
2759 ptrdiff_t, ptrdiff_t, int); 2763 ptrdiff_t, ptrdiff_t, bool);
2760extern void modify_region (struct buffer *, ptrdiff_t, ptrdiff_t, int); 2764extern void modify_region (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
2761extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); 2765extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
2762extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); 2766extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
2763extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, 2767extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
2764 ptrdiff_t, ptrdiff_t); 2768 ptrdiff_t, ptrdiff_t);
2765extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t, 2769extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t,
2766 ptrdiff_t, ptrdiff_t); 2770 ptrdiff_t, ptrdiff_t);
2767extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, int, int, int); 2771extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool, bool);
2768extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, 2772extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
2769 const char *, ptrdiff_t, ptrdiff_t, int); 2773 const char *, ptrdiff_t, ptrdiff_t, bool);
2770extern void syms_of_insdel (void); 2774extern void syms_of_insdel (void);
2771 2775
2772/* Defined in dispnew.c */ 2776/* Defined in dispnew.c */
@@ -2776,7 +2780,7 @@ _Noreturn void __executable_start (void);
2776#endif 2780#endif
2777extern Lisp_Object selected_frame; 2781extern Lisp_Object selected_frame;
2778extern Lisp_Object Vwindow_system; 2782extern Lisp_Object Vwindow_system;
2779extern Lisp_Object sit_for (Lisp_Object, int, int); 2783extern Lisp_Object sit_for (Lisp_Object, bool, int);
2780extern void init_display (void); 2784extern void init_display (void);
2781extern void syms_of_display (void); 2785extern void syms_of_display (void);
2782 2786
@@ -2802,7 +2806,7 @@ extern Lisp_Object echo_area_buffer[2];
2802extern void add_to_log (const char *, Lisp_Object, Lisp_Object); 2806extern void add_to_log (const char *, Lisp_Object, Lisp_Object);
2803extern void check_message_stack (void); 2807extern void check_message_stack (void);
2804extern void setup_echo_area_for_printing (int); 2808extern void setup_echo_area_for_printing (int);
2805extern int push_message (void); 2809extern bool push_message (void);
2806extern Lisp_Object pop_message_unwind (Lisp_Object); 2810extern Lisp_Object pop_message_unwind (Lisp_Object);
2807extern Lisp_Object restore_message_unwind (Lisp_Object); 2811extern Lisp_Object restore_message_unwind (Lisp_Object);
2808extern void restore_message (void); 2812extern void restore_message (void);
@@ -2845,7 +2849,7 @@ extern void uninterrupt_malloc (void);
2845extern void malloc_warning (const char *); 2849extern void malloc_warning (const char *);
2846extern _Noreturn void memory_full (size_t); 2850extern _Noreturn void memory_full (size_t);
2847extern _Noreturn void buffer_memory_full (ptrdiff_t); 2851extern _Noreturn void buffer_memory_full (ptrdiff_t);
2848extern int survives_gc_p (Lisp_Object); 2852extern bool survives_gc_p (Lisp_Object);
2849extern void mark_object (Lisp_Object); 2853extern void mark_object (Lisp_Object);
2850#if defined REL_ALLOC && !defined SYSTEM_MALLOC 2854#if defined REL_ALLOC && !defined SYSTEM_MALLOC
2851extern void refill_memory_reserve (void); 2855extern void refill_memory_reserve (void);
@@ -2887,8 +2891,8 @@ extern Lisp_Object make_uninit_string (EMACS_INT);
2887extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT); 2891extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT);
2888extern Lisp_Object make_string_from_bytes (const char *, ptrdiff_t, ptrdiff_t); 2892extern Lisp_Object make_string_from_bytes (const char *, ptrdiff_t, ptrdiff_t);
2889extern Lisp_Object make_specified_string (const char *, 2893extern Lisp_Object make_specified_string (const char *,
2890 ptrdiff_t, ptrdiff_t, int); 2894 ptrdiff_t, ptrdiff_t, bool);
2891extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, int); 2895extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, bool);
2892extern Lisp_Object make_pure_c_string (const char *, ptrdiff_t); 2896extern Lisp_Object make_pure_c_string (const char *, ptrdiff_t);
2893 2897
2894/* Make a string allocated in pure space, use STR as string data. */ 2898/* Make a string allocated in pure space, use STR as string data. */
@@ -2922,8 +2926,8 @@ extern struct window *allocate_window (void);
2922extern struct frame *allocate_frame (void); 2926extern struct frame *allocate_frame (void);
2923extern struct Lisp_Process *allocate_process (void); 2927extern struct Lisp_Process *allocate_process (void);
2924extern struct terminal *allocate_terminal (void); 2928extern struct terminal *allocate_terminal (void);
2925extern int gc_in_progress; 2929extern bool gc_in_progress;
2926extern int abort_on_gc; 2930extern bool abort_on_gc;
2927extern Lisp_Object make_float (double); 2931extern Lisp_Object make_float (double);
2928extern void display_malloc_warning (void); 2932extern void display_malloc_warning (void);
2929extern ptrdiff_t inhibit_garbage_collection (void); 2933extern ptrdiff_t inhibit_garbage_collection (void);
@@ -3001,6 +3005,7 @@ extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char const *, ptrdiff_t,
3001/* Defined in lread.c. */ 3005/* Defined in lread.c. */
3002extern Lisp_Object Qvariable_documentation, Qstandard_input; 3006extern Lisp_Object Qvariable_documentation, Qstandard_input;
3003extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; 3007extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
3008extern Lisp_Object Qlexical_binding;
3004extern Lisp_Object check_obarray (Lisp_Object); 3009extern Lisp_Object check_obarray (Lisp_Object);
3005extern Lisp_Object intern_1 (const char *, ptrdiff_t); 3010extern Lisp_Object intern_1 (const char *, ptrdiff_t);
3006extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t); 3011extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t);
@@ -3034,7 +3039,7 @@ intern_c_string (const char *str)
3034 3039
3035/* Defined in eval.c. */ 3040/* Defined in eval.c. */
3036extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro; 3041extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qmacro;
3037extern Lisp_Object Qinhibit_quit, Qclosure; 3042extern Lisp_Object Qinhibit_quit, Qinternal_interpreter_environment, Qclosure;
3038extern Lisp_Object Qand_rest; 3043extern Lisp_Object Qand_rest;
3039extern Lisp_Object Vautoload_queue; 3044extern Lisp_Object Vautoload_queue;
3040extern Lisp_Object Vsignaling_function; 3045extern Lisp_Object Vsignaling_function;
@@ -3109,23 +3114,23 @@ extern Lisp_Object save_restriction_save (void);
3109extern Lisp_Object save_excursion_restore (Lisp_Object); 3114extern Lisp_Object save_excursion_restore (Lisp_Object);
3110extern Lisp_Object save_restriction_restore (Lisp_Object); 3115extern Lisp_Object save_restriction_restore (Lisp_Object);
3111extern _Noreturn void time_overflow (void); 3116extern _Noreturn void time_overflow (void);
3112extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, int); 3117extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
3113extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, 3118extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
3114 ptrdiff_t, int); 3119 ptrdiff_t, bool);
3115extern void init_editfns (void); 3120extern void init_editfns (void);
3116const char *get_system_name (void); 3121const char *get_system_name (void);
3117extern void syms_of_editfns (void); 3122extern void syms_of_editfns (void);
3118extern void set_time_zone_rule (const char *); 3123extern void set_time_zone_rule (const char *);
3119 3124
3120/* Defined in buffer.c. */ 3125/* Defined in buffer.c. */
3121extern int mouse_face_overlay_overlaps (Lisp_Object); 3126extern bool mouse_face_overlay_overlaps (Lisp_Object);
3122extern _Noreturn void nsberror (Lisp_Object); 3127extern _Noreturn void nsberror (Lisp_Object);
3123extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t); 3128extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t);
3124extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t); 3129extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t);
3125extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t); 3130extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t);
3126extern void report_overlay_modification (Lisp_Object, Lisp_Object, int, 3131extern void report_overlay_modification (Lisp_Object, Lisp_Object, bool,
3127 Lisp_Object, Lisp_Object, Lisp_Object); 3132 Lisp_Object, Lisp_Object, Lisp_Object);
3128extern int overlay_touches_p (ptrdiff_t); 3133extern bool overlay_touches_p (ptrdiff_t);
3129extern Lisp_Object Vbuffer_alist; 3134extern Lisp_Object Vbuffer_alist;
3130extern Lisp_Object set_buffer_if_live (Lisp_Object); 3135extern Lisp_Object set_buffer_if_live (Lisp_Object);
3131extern Lisp_Object other_buffer_safely (Lisp_Object); 3136extern Lisp_Object other_buffer_safely (Lisp_Object);
@@ -3272,7 +3277,7 @@ extern void syms_of_frame (void);
3272extern char **initial_argv; 3277extern char **initial_argv;
3273extern int initial_argc; 3278extern int initial_argc;
3274#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 3279#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
3275extern int display_arg; 3280extern bool display_arg;
3276#endif 3281#endif
3277extern Lisp_Object decode_env_path (const char *, const char *); 3282extern Lisp_Object decode_env_path (const char *, const char *);
3278extern Lisp_Object empty_unibyte_string, empty_multibyte_string; 3283extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
@@ -3291,22 +3296,26 @@ void synchronize_system_time_locale (void);
3291#define synchronize_system_messages_locale() 3296#define synchronize_system_messages_locale()
3292#define synchronize_system_time_locale() 3297#define synchronize_system_time_locale()
3293#endif 3298#endif
3294void shut_down_emacs (int, int, Lisp_Object); 3299extern void shut_down_emacs (int, Lisp_Object);
3295/* Nonzero means don't do interactive redisplay and don't change tty modes. */ 3300
3296extern int noninteractive; 3301/* True means don't do interactive redisplay and don't change tty modes. */
3302extern bool noninteractive;
3297 3303
3298/* Nonzero means remove site-lisp directories from load-path. */ 3304/* True means remove site-lisp directories from load-path. */
3299extern int no_site_lisp; 3305extern bool no_site_lisp;
3300 3306
3301/* Pipe used to send exit notification to the daemon parent at 3307/* Pipe used to send exit notification to the daemon parent at
3302 startup. */ 3308 startup. */
3303extern int daemon_pipe[2]; 3309extern int daemon_pipe[2];
3304#define IS_DAEMON (daemon_pipe[1] != 0) 3310#define IS_DAEMON (daemon_pipe[1] != 0)
3305 3311
3306/* Nonzero means don't do use window-system-specific display code. */ 3312/* True if handling a fatal error already. */
3307extern int inhibit_window_system; 3313extern bool fatal_error_in_progress;
3308/* Nonzero means that a filter or a sentinel is running. */ 3314
3309extern int running_asynch_code; 3315/* True means don't do use window-system-specific display code. */
3316extern bool inhibit_window_system;
3317/* True means that a filter or a sentinel is running. */
3318extern bool running_asynch_code;
3310 3319
3311/* Defined in process.c. */ 3320/* Defined in process.c. */
3312extern Lisp_Object QCtype, Qlocal; 3321extern Lisp_Object QCtype, Qlocal;
@@ -3338,7 +3347,7 @@ extern void setup_process_coding_systems (Lisp_Object);
3338#ifndef DOS_NT 3347#ifndef DOS_NT
3339 _Noreturn 3348 _Noreturn
3340#endif 3349#endif
3341extern int child_setup (int, int, int, char **, int, Lisp_Object); 3350extern int child_setup (int, int, int, char **, bool, Lisp_Object);
3342extern void init_callproc_1 (void); 3351extern void init_callproc_1 (void);
3343extern void init_callproc (void); 3352extern void init_callproc (void);
3344extern void set_initial_environment (void); 3353extern void set_initial_environment (void);
@@ -3347,9 +3356,9 @@ extern void syms_of_callproc (void);
3347/* Defined in doc.c */ 3356/* Defined in doc.c */
3348extern Lisp_Object Qfunction_documentation; 3357extern Lisp_Object Qfunction_documentation;
3349extern Lisp_Object read_doc_string (Lisp_Object); 3358extern Lisp_Object read_doc_string (Lisp_Object);
3350extern Lisp_Object get_doc_string (Lisp_Object, int, int); 3359extern Lisp_Object get_doc_string (Lisp_Object, bool, bool);
3351extern void syms_of_doc (void); 3360extern void syms_of_doc (void);
3352extern int read_bytecode_char (int); 3361extern int read_bytecode_char (bool);
3353 3362
3354/* Defined in bytecode.c */ 3363/* Defined in bytecode.c */
3355extern Lisp_Object Qbytecode; 3364extern Lisp_Object Qbytecode;
@@ -3419,7 +3428,8 @@ extern void child_setup_tty (int);
3419extern void setup_pty (int); 3428extern void setup_pty (int);
3420extern int set_window_size (int, int, int); 3429extern int set_window_size (int, int, int);
3421extern EMACS_INT get_random (void); 3430extern EMACS_INT get_random (void);
3422extern void seed_random (long); 3431extern void seed_random (void *, ptrdiff_t);
3432extern void init_random (void);
3423extern int emacs_open (const char *, int, int); 3433extern int emacs_open (const char *, int, int);
3424extern int emacs_close (int); 3434extern int emacs_close (int);
3425extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); 3435extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
@@ -3448,11 +3458,10 @@ extern void syms_of_ccl (void);
3448extern void syms_of_dired (void); 3458extern void syms_of_dired (void);
3449extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, 3459extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
3450 Lisp_Object, Lisp_Object, 3460 Lisp_Object, Lisp_Object,
3451 int, Lisp_Object); 3461 bool, Lisp_Object);
3452 3462
3453/* Defined in term.c */ 3463/* Defined in term.c */
3454extern int *char_ins_del_vector; 3464extern int *char_ins_del_vector;
3455extern void mark_ttys (void);
3456extern void syms_of_term (void); 3465extern void syms_of_term (void);
3457extern _Noreturn void fatal (const char *msgid, ...) 3466extern _Noreturn void fatal (const char *msgid, ...)
3458 ATTRIBUTE_FORMAT_PRINTF (1, 2); 3467 ATTRIBUTE_FORMAT_PRINTF (1, 2);
@@ -3480,6 +3489,9 @@ extern Lisp_Object Qface;
3480extern Lisp_Object Qnormal; 3489extern Lisp_Object Qnormal;
3481extern Lisp_Object QCfamily, QCweight, QCslant; 3490extern Lisp_Object QCfamily, QCweight, QCslant;
3482extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground; 3491extern Lisp_Object QCheight, QCname, QCwidth, QCforeground, QCbackground;
3492extern Lisp_Object Qextra_light, Qlight, Qsemi_light, Qsemi_bold;
3493extern Lisp_Object Qbold, Qextra_bold, Qultra_bold;
3494extern Lisp_Object Qoblique, Qitalic;
3483extern Lisp_Object Vface_alternative_font_family_alist; 3495extern Lisp_Object Vface_alternative_font_family_alist;
3484extern Lisp_Object Vface_alternative_font_registry_alist; 3496extern Lisp_Object Vface_alternative_font_registry_alist;
3485extern void syms_of_xfaces (void); 3497extern void syms_of_xfaces (void);
@@ -3524,9 +3536,9 @@ void syms_of_dbusbind (void);
3524extern char *emacs_root_dir (void); 3536extern char *emacs_root_dir (void);
3525#endif /* DOS_NT */ 3537#endif /* DOS_NT */
3526 3538
3527/* Nonzero means Emacs has already been initialized. 3539/* True means Emacs has already been initialized.
3528 Used during startup to detect startup of dumped Emacs. */ 3540 Used during startup to detect startup of dumped Emacs. */
3529extern int initialized; 3541extern bool initialized;
3530 3542
3531extern int immediate_quit; /* Nonzero means ^G can quit instantly */ 3543extern int immediate_quit; /* Nonzero means ^G can quit instantly */
3532 3544
@@ -3593,7 +3605,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3593extern void *record_xmalloc (size_t); 3605extern void *record_xmalloc (size_t);
3594 3606
3595#define USE_SAFE_ALLOCA \ 3607#define USE_SAFE_ALLOCA \
3596 ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 3608 ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = 0
3597 3609
3598/* SAFE_ALLOCA allocates a simple buffer. */ 3610/* SAFE_ALLOCA allocates a simple buffer. */
3599 3611
@@ -3664,6 +3676,38 @@ maybe_gc (void)
3664 Fgarbage_collect (); 3676 Fgarbage_collect ();
3665} 3677}
3666 3678
3679LISP_INLINE int
3680functionp (Lisp_Object object)
3681{
3682 if (SYMBOLP (object) && !NILP (Ffboundp (object)))
3683 {
3684 object = Findirect_function (object, Qt);
3685
3686 if (CONSP (object) && EQ (XCAR (object), Qautoload))
3687 {
3688 /* Autoloaded symbols are functions, except if they load
3689 macros or keymaps. */
3690 int i;
3691 for (i = 0; i < 4 && CONSP (object); i++)
3692 object = XCDR (object);
3693
3694 return ! (CONSP (object) && !NILP (XCAR (object)));
3695 }
3696 }
3697
3698 if (SUBRP (object))
3699 return XSUBR (object)->max_args != UNEVALLED;
3700 else if (COMPILEDP (object))
3701 return 1;
3702 else if (CONSP (object))
3703 {
3704 Lisp_Object car = XCAR (object);
3705 return EQ (car, Qlambda) || EQ (car, Qclosure);
3706 }
3707 else
3708 return 0;
3709}
3710
3667INLINE_HEADER_END 3711INLINE_HEADER_END
3668 3712
3669#endif /* EMACS_LISP_H */ 3713#endif /* EMACS_LISP_H */
diff --git a/src/lread.c b/src/lread.c
index e2ad03b349f..1dd6275684b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -89,8 +89,6 @@ static Lisp_Object Qget_emacs_mule_file_char;
89 89
90static Lisp_Object Qload_force_doc_strings; 90static Lisp_Object Qload_force_doc_strings;
91 91
92extern Lisp_Object Qinternal_interpreter_environment;
93
94static Lisp_Object Qload_in_progress; 92static Lisp_Object Qload_in_progress;
95 93
96/* The association list of objects read with the #n=object form. 94/* The association list of objects read with the #n=object form.
@@ -189,7 +187,7 @@ static int readbyte_from_string (int, Lisp_Object);
189static int unread_char; 187static int unread_char;
190 188
191static int 189static int
192readchar (Lisp_Object readcharfun, int *multibyte) 190readchar (Lisp_Object readcharfun, bool *multibyte)
193{ 191{
194 Lisp_Object tem; 192 Lisp_Object tem;
195 register int c; 193 register int c;
@@ -2354,9 +2352,9 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix)
2354static Lisp_Object 2352static Lisp_Object
2355read1 (register Lisp_Object readcharfun, int *pch, int first_in_list) 2353read1 (register Lisp_Object readcharfun, int *pch, int first_in_list)
2356{ 2354{
2357 register int c; 2355 int c;
2358 unsigned uninterned_symbol = 0; 2356 bool uninterned_symbol = 0;
2359 int multibyte; 2357 bool multibyte;
2360 2358
2361 *pch = 0; 2359 *pch = 0;
2362 load_each_byte = 0; 2360 load_each_byte = 0;
@@ -3406,7 +3404,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag)
3406 /* Delay handling the bytecode slot until we know whether 3404 /* Delay handling the bytecode slot until we know whether
3407 it is lazily-loaded (we can tell by whether the 3405 it is lazily-loaded (we can tell by whether the
3408 constants slot is nil). */ 3406 constants slot is nil). */
3409 ptr[COMPILED_CONSTANTS] = item; 3407 ASET (vector, COMPILED_CONSTANTS, item);
3410 item = Qnil; 3408 item = Qnil;
3411 } 3409 }
3412 else if (i == COMPILED_CONSTANTS) 3410 else if (i == COMPILED_CONSTANTS)
@@ -3432,7 +3430,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag)
3432 } 3430 }
3433 3431
3434 /* Now handle the bytecode slot. */ 3432 /* Now handle the bytecode slot. */
3435 ptr[COMPILED_BYTECODE] = bytestr; 3433 ASET (vector, COMPILED_BYTECODE, bytestr);
3436 } 3434 }
3437 else if (i == COMPILED_DOC_STRING 3435 else if (i == COMPILED_DOC_STRING
3438 && STRINGP (item) 3436 && STRINGP (item)
@@ -3444,7 +3442,7 @@ read_vector (Lisp_Object readcharfun, int bytecodeflag)
3444 item = Fstring_as_multibyte (item); 3442 item = Fstring_as_multibyte (item);
3445 } 3443 }
3446 } 3444 }
3447 ptr[i] = item; 3445 ASET (vector, i, item);
3448 otem = XCONS (tem); 3446 otem = XCONS (tem);
3449 tem = Fcdr (tem); 3447 tem = Fcdr (tem);
3450 free_cons (otem); 3448 free_cons (otem);
@@ -4253,9 +4251,12 @@ init_lread (void)
4253 { 4251 {
4254 tem = Fexpand_file_name (build_string ("site-lisp"), 4252 tem = Fexpand_file_name (build_string ("site-lisp"),
4255 Vsource_directory); 4253 Vsource_directory);
4256 4254 tem1 = Ffile_exists_p (tem);
4257 if (NILP (Fmember (tem, Vload_path))) 4255 if (!NILP (tem1))
4258 Vload_path = Fcons (tem, Vload_path); 4256 {
4257 if (NILP (Fmember (tem, Vload_path)))
4258 Vload_path = Fcons (tem, Vload_path);
4259 }
4259 } 4260 }
4260 } 4261 }
4261 } /* Vinstallation_directory != Vsource_directory */ 4262 } /* Vinstallation_directory != Vsource_directory */
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index bdb292099bc..a8dcf5f2ae8 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -390,6 +390,7 @@ SYSTIME_H = $(SRC)/systime.h \
390 $(NT_INC)/sys/time.h \ 390 $(NT_INC)/sys/time.h \
391 $(GNU_LIB)/timespec.h 391 $(GNU_LIB)/timespec.h
392ATIMER_H = $(SRC)/atimer.h \ 392ATIMER_H = $(SRC)/atimer.h \
393 $(NT_INC)/stdbool.h \
393 $(SYSTIME_H) 394 $(SYSTIME_H)
394BLOCKINPUT_H = $(SRC)/blockinput.h \ 395BLOCKINPUT_H = $(SRC)/blockinput.h \
395 $(ATIMER_H) 396 $(ATIMER_H)
@@ -401,6 +402,8 @@ CAREADLINKAT_H = $(GNU_LIB)/careadlinkat.h \
401 $(NT_INC)/unistd.h 402 $(NT_INC)/unistd.h
402CHARACTER_H = $(SRC)/character.h \ 403CHARACTER_H = $(SRC)/character.h \
403 $(GNU_LIB)/verify.h 404 $(GNU_LIB)/verify.h
405CCL_H = $(SRC)/ccl.h \
406 $(CHARACTER_H)
404CHARSET_H = $(SRC)/charset.h \ 407CHARSET_H = $(SRC)/charset.h \
405 $(GNU_LIB)/verify.h 408 $(GNU_LIB)/verify.h
406CODING_H = $(SRC)/coding.h \ 409CODING_H = $(SRC)/coding.h \
@@ -422,7 +425,7 @@ DISPEXTERN_H = $(SRC)/dispextern.h \
422FILEMODE_H = $(GNU_LIB)/filemode.h \ 425FILEMODE_H = $(GNU_LIB)/filemode.h \
423 $(NT_INC)/sys/stat.h 426 $(NT_INC)/sys/stat.h
424FONT_H = $(SRC)/font.h \ 427FONT_H = $(SRC)/font.h \
425 $(SRC)/ccl.h 428 $(CCL_H)
426FRAME_H = $(SRC)/frame.h \ 429FRAME_H = $(SRC)/frame.h \
427 $(DISPEXTERN_H) 430 $(DISPEXTERN_H)
428FTOASTR_H = $(GNU_LIB)/ftoastr.h \ 431FTOASTR_H = $(GNU_LIB)/ftoastr.h \
@@ -469,6 +472,8 @@ SYSTTY_H = $(SRC)/systty.h \
469 $(NT_INC)/unistd.h 472 $(NT_INC)/unistd.h
470TERMHOOKS_H = $(SRC)/termhooks.h \ 473TERMHOOKS_H = $(SRC)/termhooks.h \
471 $(SYSTIME_H) 474 $(SYSTIME_H)
475W32FONT_H = $(SRC)/w32font.h \
476 $(FONT_H)
472W32TERM_H = $(SRC)/w32term.h \ 477W32TERM_H = $(SRC)/w32term.h \
473 $(W32GUI_H) 478 $(W32GUI_H)
474WINDOW_H = $(SRC)/window.h \ 479WINDOW_H = $(SRC)/window.h \
@@ -553,7 +558,6 @@ $(BLD)/callint.$(O) : \
553 558
554$(BLD)/callproc.$(O) : \ 559$(BLD)/callproc.$(O) : \
555 $(SRC)/callproc.c \ 560 $(SRC)/callproc.c \
556 $(SRC)/ccl.h \
557 $(SRC)/commands.h \ 561 $(SRC)/commands.h \
558 $(SRC)/composite.h \ 562 $(SRC)/composite.h \
559 $(SRC)/epaths.h \ 563 $(SRC)/epaths.h \
@@ -563,6 +567,7 @@ $(BLD)/callproc.$(O) : \
563 $(NT_INC)/unistd.h \ 567 $(NT_INC)/unistd.h \
564 $(BLOCKINPUT_H) \ 568 $(BLOCKINPUT_H) \
565 $(BUFFER_H) \ 569 $(BUFFER_H) \
570 $(CCL_H) \
566 $(CHARACTER_H) \ 571 $(CHARACTER_H) \
567 $(CODING_H) \ 572 $(CODING_H) \
568 $(CONFIG_H) \ 573 $(CONFIG_H) \
@@ -602,7 +607,7 @@ $(BLD)/category.$(O) : \
602 607
603$(BLD)/ccl.$(O) : \ 608$(BLD)/ccl.$(O) : \
604 $(SRC)/ccl.c \ 609 $(SRC)/ccl.c \
605 $(SRC)/ccl.h \ 610 $(CCL_H) \
606 $(CHARACTER_H) \ 611 $(CHARACTER_H) \
607 $(CHARSET_H) \ 612 $(CHARSET_H) \
608 $(CODING_H) \ 613 $(CODING_H) \
@@ -634,7 +639,7 @@ $(BLD)/charset.$(O) : \
634 639
635$(BLD)/chartab.$(O) : \ 640$(BLD)/chartab.$(O) : \
636 $(SRC)/chartab.c \ 641 $(SRC)/chartab.c \
637 $(SRC)/ccl.h \ 642 $(CCL_H) \
638 $(CHARACTER_H) \ 643 $(CHARACTER_H) \
639 $(CHARSET_H) \ 644 $(CHARSET_H) \
640 $(CONFIG_H) \ 645 $(CONFIG_H) \
@@ -656,9 +661,9 @@ $(BLD)/cmds.$(O) : \
656 661
657$(BLD)/coding.$(O) : \ 662$(BLD)/coding.$(O) : \
658 $(SRC)/coding.c \ 663 $(SRC)/coding.c \
659 $(SRC)/ccl.h \
660 $(SRC)/composite.h \ 664 $(SRC)/composite.h \
661 $(BUFFER_H) \ 665 $(BUFFER_H) \
666 $(CCL_H) \
662 $(CHARACTER_H) \ 667 $(CHARACTER_H) \
663 $(CHARSET_H) \ 668 $(CHARSET_H) \
664 $(CODING_H) \ 669 $(CODING_H) \
@@ -802,6 +807,7 @@ $(BLD)/emacs.$(O) : \
802 $(PROCESS_H) \ 807 $(PROCESS_H) \
803 $(SYSTTY_H) \ 808 $(SYSTTY_H) \
804 $(TERMHOOKS_H) \ 809 $(TERMHOOKS_H) \
810 $(W32TERM_H) \
805 $(WINDOW_H) 811 $(WINDOW_H)
806 812
807$(BLD)/eval.$(O) : \ 813$(BLD)/eval.$(O) : \
@@ -897,10 +903,10 @@ $(BLD)/font.$(O) : \
897 903
898$(BLD)/fontset.$(O) : \ 904$(BLD)/fontset.$(O) : \
899 $(SRC)/fontset.c \ 905 $(SRC)/fontset.c \
900 $(SRC)/ccl.h \
901 $(SRC)/fontset.h \ 906 $(SRC)/fontset.h \
902 $(BLOCKINPUT_H) \ 907 $(BLOCKINPUT_H) \
903 $(BUFFER_H) \ 908 $(BUFFER_H) \
909 $(CCL_H) \
904 $(CHARACTER_H) \ 910 $(CHARACTER_H) \
905 $(CHARSET_H) \ 911 $(CHARSET_H) \
906 $(CONFIG_H) \ 912 $(CONFIG_H) \
@@ -1268,6 +1274,7 @@ $(BLD)/process.$(O) : \
1268 $(SYSTIME_H) \ 1274 $(SYSTIME_H) \
1269 $(SYSTTY_H) \ 1275 $(SYSTTY_H) \
1270 $(TERMHOOKS_H) \ 1276 $(TERMHOOKS_H) \
1277 $(W32TERM_H) \
1271 $(WINDOW_H) 1278 $(WINDOW_H)
1272 1279
1273$(BLD)/ralloc.$(O) : \ 1280$(BLD)/ralloc.$(O) : \
@@ -1523,14 +1530,13 @@ $(BLD)/xfaces.$(O) : \
1523 1530
1524$(BLD)/w32fns.$(O) : \ 1531$(BLD)/w32fns.$(O) : \
1525 $(SRC)/w32fns.c \ 1532 $(SRC)/w32fns.c \
1526 $(SRC)/ccl.h \
1527 $(SRC)/epaths.h \ 1533 $(SRC)/epaths.h \
1528 $(SRC)/fontset.h \ 1534 $(SRC)/fontset.h \
1529 $(SRC)/w32.h \ 1535 $(SRC)/w32.h \
1530 $(SRC)/w32font.h \
1531 $(SRC)/w32heap.h \ 1536 $(SRC)/w32heap.h \
1532 $(BLOCKINPUT_H) \ 1537 $(BLOCKINPUT_H) \
1533 $(BUFFER_H) \ 1538 $(BUFFER_H) \
1539 $(CCL_H) \
1534 $(CHARACTER_H) \ 1540 $(CHARACTER_H) \
1535 $(CHARSET_H) \ 1541 $(CHARSET_H) \
1536 $(CODING_H) \ 1542 $(CODING_H) \
@@ -1543,6 +1549,7 @@ $(BLD)/w32fns.$(O) : \
1543 $(LISP_H) \ 1549 $(LISP_H) \
1544 $(SYSTIME_H) \ 1550 $(SYSTIME_H) \
1545 $(TERMHOOKS_H) \ 1551 $(TERMHOOKS_H) \
1552 $(W32FONT_H) \
1546 $(W32TERM_H) \ 1553 $(W32TERM_H) \
1547 $(WINDOW_H) 1554 $(WINDOW_H)
1548 1555
@@ -1567,18 +1574,17 @@ $(BLD)/w32menu.$(O) : \
1567 1574
1568$(BLD)/w32term.$(O) : \ 1575$(BLD)/w32term.$(O) : \
1569 $(SRC)/w32term.c \ 1576 $(SRC)/w32term.c \
1570 $(SRC)/ccl.h \
1571 $(SRC)/disptab.h \ 1577 $(SRC)/disptab.h \
1572 $(SRC)/fontset.h \ 1578 $(SRC)/fontset.h \
1573 $(SRC)/keymap.h \ 1579 $(SRC)/keymap.h \
1574 $(SRC)/termchar.h \ 1580 $(SRC)/termchar.h \
1575 $(SRC)/termopts.h \ 1581 $(SRC)/termopts.h \
1576 $(SRC)/w32font.h \
1577 $(SRC)/w32heap.h \ 1582 $(SRC)/w32heap.h \
1578 $(NT_INC)/sys/stat.h \ 1583 $(NT_INC)/sys/stat.h \
1579 $(ATIMER_H) \ 1584 $(ATIMER_H) \
1580 $(BLOCKINPUT_H) \ 1585 $(BLOCKINPUT_H) \
1581 $(BUFFER_H) \ 1586 $(BUFFER_H) \
1587 $(CCL_H) \
1582 $(CHARACTER_H) \ 1588 $(CHARACTER_H) \
1583 $(CHARSET_H) \ 1589 $(CHARSET_H) \
1584 $(CODING_H) \ 1590 $(CODING_H) \
@@ -1593,6 +1599,7 @@ $(BLD)/w32term.$(O) : \
1593 $(SYSTIME_H) \ 1599 $(SYSTIME_H) \
1594 $(SYSTTY_H) \ 1600 $(SYSTTY_H) \
1595 $(TERMHOOKS_H) \ 1601 $(TERMHOOKS_H) \
1602 $(W32FONT_H) \
1596 $(W32TERM_H) \ 1603 $(W32TERM_H) \
1597 $(WINDOW_H) 1604 $(WINDOW_H)
1598 1605
@@ -1628,7 +1635,6 @@ $(BLD)/w32xfns.$(O) : \
1628$(BLD)/w32font.$(O) : \ 1635$(BLD)/w32font.$(O) : \
1629 $(SRC)/w32font.c \ 1636 $(SRC)/w32font.c \
1630 $(SRC)/fontset.h \ 1637 $(SRC)/fontset.h \
1631 $(SRC)/w32font.h \
1632 $(CHARACTER_H) \ 1638 $(CHARACTER_H) \
1633 $(CHARSET_H) \ 1639 $(CHARSET_H) \
1634 $(CODING_H) \ 1640 $(CODING_H) \
@@ -1637,13 +1643,13 @@ $(BLD)/w32font.$(O) : \
1637 $(FONT_H) \ 1643 $(FONT_H) \
1638 $(FRAME_H) \ 1644 $(FRAME_H) \
1639 $(LISP_H) \ 1645 $(LISP_H) \
1646 $(W32FONT_H) \
1640 $(W32TERM_H) 1647 $(W32TERM_H)
1641 1648
1642$(BLD)/w32uniscribe.$(O) : \ 1649$(BLD)/w32uniscribe.$(O) : \
1643 $(SRC)/w32uniscribe.c \ 1650 $(SRC)/w32uniscribe.c \
1644 $(SRC)/composite.h \ 1651 $(SRC)/composite.h \
1645 $(SRC)/fontset.h \ 1652 $(SRC)/fontset.h \
1646 $(SRC)/w32font.h \
1647 $(CHARACTER_H) \ 1653 $(CHARACTER_H) \
1648 $(CHARSET_H) \ 1654 $(CHARSET_H) \
1649 $(CONFIG_H) \ 1655 $(CONFIG_H) \
@@ -1651,6 +1657,7 @@ $(BLD)/w32uniscribe.$(O) : \
1651 $(FONT_H) \ 1657 $(FONT_H) \
1652 $(FRAME_H) \ 1658 $(FRAME_H) \
1653 $(LISP_H) \ 1659 $(LISP_H) \
1660 $(W32FONT_H) \
1654 $(W32TERM_H) 1661 $(W32TERM_H)
1655 1662
1656# Each object file depends on stamp_BLD, because in parallel builds we must 1663# Each object file depends on stamp_BLD, because in parallel builds we must
diff --git a/src/menu.c b/src/menu.c
index 3e466b46aa3..20770537326 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -36,24 +36,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#include "../lwlib/lwlib.h" 36#include "../lwlib/lwlib.h"
37#endif 37#endif
38 38
39#ifdef HAVE_X_WINDOWS 39#ifdef HAVE_WINDOW_SYSTEM
40#include "xterm.h" 40#include TERM_HEADER
41#endif 41#endif /* HAVE_WINDOW_SYSTEM */
42
43#ifdef HAVE_NS
44#include "nsterm.h"
45#endif
46
47#ifdef USE_GTK
48#include "gtkutil.h"
49#endif
50 42
51#ifdef HAVE_NTGUI 43#ifdef HAVE_NTGUI
52#include "w32term.h"
53
54extern AppendMenuW_Proc unicode_append_menu; 44extern AppendMenuW_Proc unicode_append_menu;
55extern HMENU current_popup_menu; 45extern HMENU current_popup_menu;
56
57#endif /* HAVE_NTGUI */ 46#endif /* HAVE_NTGUI */
58 47
59#include "menu.h" 48#include "menu.h"
diff --git a/src/minibuf.c b/src/minibuf.c
index 2154d1654df..2035a3e3985 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -817,7 +817,7 @@ get_minibuffer (EMACS_INT depth)
817 while the buffer doesn't know about them any more. */ 817 while the buffer doesn't know about them any more. */
818 delete_all_overlays (XBUFFER (buf)); 818 delete_all_overlays (XBUFFER (buf));
819 reset_buffer (XBUFFER (buf)); 819 reset_buffer (XBUFFER (buf));
820 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 820 record_unwind_current_buffer ();
821 Fset_buffer (buf); 821 Fset_buffer (buf);
822 if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode")))) 822 if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode"))))
823 call0 (intern ("minibuffer-inactive-mode")); 823 call0 (intern ("minibuffer-inactive-mode"));
@@ -1860,7 +1860,6 @@ the values STRING, PREDICATE and `lambda'. */)
1860} 1860}
1861 1861
1862static Lisp_Object Qmetadata; 1862static Lisp_Object Qmetadata;
1863extern Lisp_Object Qbuffer;
1864 1863
1865DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0, 1864DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0,
1866 doc: /* Perform completion on buffer names. 1865 doc: /* Perform completion on buffer names.
diff --git a/src/msdos.c b/src/msdos.c
index 30435820d9e..ac348e94375 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1029,7 +1029,6 @@ IT_clear_end_of_line (struct frame *f, int first_unused)
1029{ 1029{
1030 char *spaces, *sp; 1030 char *spaces, *sp;
1031 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); 1031 int i, j, offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
1032 extern int fatal_error_in_progress;
1033 struct tty_display_info *tty = FRAME_TTY (f); 1032 struct tty_display_info *tty = FRAME_TTY (f);
1034 1033
1035 if (new_pos_X >= first_unused || fatal_error_in_progress) 1034 if (new_pos_X >= first_unused || fatal_error_in_progress)
@@ -2434,10 +2433,10 @@ and then the scan code. */)
2434 else 2433 else
2435 { 2434 {
2436 val = Fvector (NUM_RECENT_DOSKEYS, keys); 2435 val = Fvector (NUM_RECENT_DOSKEYS, keys);
2437 memcpy (XVECTOR (val)->contents, keys + recent_doskeys_index, 2436 vcopy (val, 0, keys + recent_doskeys_index,
2438 (NUM_RECENT_DOSKEYS - recent_doskeys_index) * word_size); 2437 NUM_RECENT_DOSKEYS - recent_doskeys_index);
2439 memcpy (XVECTOR (val)->contents + NUM_RECENT_DOSKEYS - recent_doskeys_index, 2438 vcopy (val, NUM_RECENT_DOSKEYS - recent_doskeys_index,
2440 keys, recent_doskeys_index * word_size); 2439 keys, recent_doskeys_index);
2441 return val; 2440 return val;
2442 } 2441 }
2443} 2442}
diff --git a/src/nsmenu.m b/src/nsmenu.m
index e8a0b43a01b..9e290486213 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1497,6 +1497,8 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1497 FlippedView *contentView; 1497 FlippedView *contentView;
1498 NSImage *img; 1498 NSImage *img;
1499 1499
1500 dialog_return = Qundefined;
1501 button_values = NULL;
1500 area.origin.x = 3*SPACER; 1502 area.origin.x = 3*SPACER;
1501 area.origin.y = 2*SPACER; 1503 area.origin.y = 2*SPACER;
1502 area.size.width = ICONSIZE; 1504 area.size.width = ICONSIZE;
@@ -1578,44 +1580,65 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1578 [self setOneShot: YES]; 1580 [self setOneShot: YES];
1579 [self setReleasedWhenClosed: YES]; 1581 [self setReleasedWhenClosed: YES];
1580 [self setHidesOnDeactivate: YES]; 1582 [self setHidesOnDeactivate: YES];
1583 [self setStyleMask:
1584 NSTitledWindowMask|NSClosableWindowMask|NSUtilityWindowMask];
1585
1581 return self; 1586 return self;
1582} 1587}
1583 1588
1584 1589
1585- (BOOL)windowShouldClose: (id)sender 1590- (BOOL)windowShouldClose: (id)sender
1586{ 1591{
1587 [NSApp stopModalWithCode: XHASH (Qnil)]; // FIXME: BIG UGLY HACK!! 1592 window_closed = YES;
1593 [NSApp stop:self];
1588 return NO; 1594 return NO;
1589} 1595}
1590 1596
1597- (void)dealloc
1598{
1599 xfree (button_values);
1600 [super dealloc];
1601}
1591 1602
1592void process_dialog (id window, Lisp_Object list) 1603- (void)process_dialog: (Lisp_Object) list
1593{ 1604{
1594 Lisp_Object item; 1605 Lisp_Object item, lst = list;
1595 int row = 0; 1606 int row = 0;
1607 int buttons = 0, btnnr = 0;
1608
1609 for (; XTYPE (lst) == Lisp_Cons; lst = XCDR (lst))
1610 {
1611 item = XCAR (list);
1612 if (XTYPE (item) == Lisp_Cons)
1613 ++buttons;
1614 }
1615
1616 if (buttons > 0)
1617 button_values = (Lisp_Object *) xmalloc (buttons * sizeof (*button_values));
1596 1618
1597 for (; XTYPE (list) == Lisp_Cons; list = XCDR (list)) 1619 for (; XTYPE (list) == Lisp_Cons; list = XCDR (list))
1598 { 1620 {
1599 item = XCAR (list); 1621 item = XCAR (list);
1600 if (XTYPE (item) == Lisp_String) 1622 if (XTYPE (item) == Lisp_String)
1601 { 1623 {
1602 [window addString: SSDATA (item) row: row++]; 1624 [self addString: SSDATA (item) row: row++];
1603 } 1625 }
1604 else if (XTYPE (item) == Lisp_Cons) 1626 else if (XTYPE (item) == Lisp_Cons)
1605 { 1627 {
1606 [window addButton: SSDATA (XCAR (item)) 1628 button_values[btnnr] = XCDR (item);
1607 value: XCDR (item) row: row++]; 1629 [self addButton: SSDATA (XCAR (item)) value: btnnr row: row++];
1630 ++btnnr;
1608 } 1631 }
1609 else if (NILP (item)) 1632 else if (NILP (item))
1610 { 1633 {
1611 [window addSplit]; 1634 [self addSplit];
1612 row = 0; 1635 row = 0;
1613 } 1636 }
1614 } 1637 }
1615} 1638}
1616 1639
1617 1640
1618- addButton: (char *)str value: (Lisp_Object)val row: (int)row 1641- (void)addButton: (char *)str value: (int)tag row: (int)row
1619{ 1642{
1620 id cell; 1643 id cell;
1621 1644
@@ -1628,15 +1651,13 @@ void process_dialog (id window, Lisp_Object list)
1628 [cell setTarget: self]; 1651 [cell setTarget: self];
1629 [cell setAction: @selector (clicked: )]; 1652 [cell setAction: @selector (clicked: )];
1630 [cell setTitle: [NSString stringWithUTF8String: str]]; 1653 [cell setTitle: [NSString stringWithUTF8String: str]];
1631 [cell setTag: XHASH (val)]; // FIXME: BIG UGLY HACK!! 1654 [cell setTag: tag];
1632 [cell setBordered: YES]; 1655 [cell setBordered: YES];
1633 [cell setEnabled: YES]; 1656 [cell setEnabled: YES];
1634
1635 return self;
1636} 1657}
1637 1658
1638 1659
1639- addString: (char *)str row: (int)row 1660- (void)addString: (char *)str row: (int)row
1640{ 1661{
1641 id cell; 1662 id cell;
1642 1663
@@ -1649,32 +1670,28 @@ void process_dialog (id window, Lisp_Object list)
1649 [cell setTitle: [NSString stringWithUTF8String: str]]; 1670 [cell setTitle: [NSString stringWithUTF8String: str]];
1650 [cell setBordered: YES]; 1671 [cell setBordered: YES];
1651 [cell setEnabled: NO]; 1672 [cell setEnabled: NO];
1652
1653 return self;
1654} 1673}
1655 1674
1656 1675
1657- addSplit 1676- (void)addSplit
1658{ 1677{
1659 [matrix addColumn]; 1678 [matrix addColumn];
1660 cols++; 1679 cols++;
1661 return self;
1662} 1680}
1663 1681
1664 1682
1665- clicked: sender 1683- (void)clicked: sender
1666{ 1684{
1667 NSArray *sellist = nil; 1685 NSArray *sellist = nil;
1668 EMACS_INT seltag; 1686 EMACS_INT seltag;
1669 1687
1670 sellist = [sender selectedCells]; 1688 sellist = [sender selectedCells];
1671 if ([sellist count]<1) 1689 if ([sellist count] < 1)
1672 return self; 1690 return;
1673 1691
1674 seltag = [[sellist objectAtIndex: 0] tag]; 1692 seltag = [[sellist objectAtIndex: 0] tag];
1675 if (seltag != XHASH (Qundefined)) // FIXME: BIG UGLY HACK!! 1693 dialog_return = button_values[seltag];
1676 [NSApp stopModalWithCode: seltag]; 1694 [NSApp stop:self];
1677 return self;
1678} 1695}
1679 1696
1680 1697
@@ -1686,7 +1703,7 @@ void process_dialog (id window, Lisp_Object list)
1686 if (XTYPE (contents) == Lisp_Cons) 1703 if (XTYPE (contents) == Lisp_Cons)
1687 { 1704 {
1688 head = Fcar (contents); 1705 head = Fcar (contents);
1689 process_dialog (self, Fcdr (contents)); 1706 [self process_dialog: Fcdr (contents)];
1690 } 1707 }
1691 else 1708 else
1692 head = contents; 1709 head = contents;
@@ -1706,7 +1723,7 @@ void process_dialog (id window, Lisp_Object list)
1706 if (cols == 1 && rows > 1) /* Never told where to split */ 1723 if (cols == 1 && rows > 1) /* Never told where to split */
1707 { 1724 {
1708 [matrix addColumn]; 1725 [matrix addColumn];
1709 for (i = 0; i<rows/2; i++) 1726 for (i = 0; i < rows/2; i++)
1710 { 1727 {
1711 [matrix putCell: [matrix cellAtRow: (rows+1)/2 column: 0] 1728 [matrix putCell: [matrix cellAtRow: (rows+1)/2 column: 0]
1712 atRow: i column: 1]; 1729 atRow: i column: 1];
@@ -1756,13 +1773,27 @@ void process_dialog (id window, Lisp_Object list)
1756 1773
1757- (void)timeout_handler: (NSTimer *)timedEntry 1774- (void)timeout_handler: (NSTimer *)timedEntry
1758{ 1775{
1759 timer_fired = 1; 1776 NSEvent *nxev = [NSEvent otherEventWithType: NSApplicationDefined
1760 [NSApp abortModal]; 1777 location: NSMakePoint (0, 0)
1778 modifierFlags: 0
1779 timestamp: 0
1780 windowNumber: [[NSApp mainWindow] windowNumber]
1781 context: [NSApp context]
1782 subtype: 0
1783 data1: 0
1784 data2: 0];
1785
1786 timer_fired = YES;
1787 /* We use sto because stopModal/abortModal out of the main loop does not
1788 seem to work in 10.6. But as we use stop we must send a real event so
1789 the stop is seen and acted upon. */
1790 [NSApp stop:self];
1791 [NSApp postEvent: nxev atStart: NO];
1761} 1792}
1762 1793
1763- (Lisp_Object)runDialogAt: (NSPoint)p 1794- (Lisp_Object)runDialogAt: (NSPoint)p
1764{ 1795{
1765 NSInteger ret = 0; 1796 Lisp_Object ret = Qundefined;
1766 1797
1767 while (popup_activated_flag) 1798 while (popup_activated_flag)
1768 { 1799 {
@@ -1780,8 +1811,10 @@ void process_dialog (id window, Lisp_Object list)
1780 [[NSRunLoop currentRunLoop] addTimer: tmo 1811 [[NSRunLoop currentRunLoop] addTimer: tmo
1781 forMode: NSModalPanelRunLoopMode]; 1812 forMode: NSModalPanelRunLoopMode];
1782 } 1813 }
1783 timer_fired = 0; 1814 timer_fired = NO;
1784 ret = [NSApp runModalForWindow: self]; 1815 dialog_return = Qundefined;
1816 [NSApp runModalForWindow: self];
1817 ret = dialog_return;
1785 if (! timer_fired) 1818 if (! timer_fired)
1786 { 1819 {
1787 if (tmo != nil) [tmo invalidate]; /* Cancels timer */ 1820 if (tmo != nil) [tmo invalidate]; /* Cancels timer */
@@ -1789,11 +1822,11 @@ void process_dialog (id window, Lisp_Object list)
1789 } 1822 }
1790 } 1823 }
1791 1824
1792 { /* FIXME: BIG UGLY HACK!!! */ 1825 if (EQ (ret, Qundefined) && window_closed)
1793 Lisp_Object tmp; 1826 /* Make close button pressed equivalent to C-g. */
1794 *(EMACS_INT*)(&tmp) = ret; 1827 Fsignal (Qquit, Qnil);
1795 return tmp; 1828
1796 } 1829 return ret;
1797} 1830}
1798 1831
1799@end 1832@end
diff --git a/src/nsterm.h b/src/nsterm.h
index 54f4a4ec89e..f0cae193005 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -195,12 +195,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
195 NSTextField *title; 195 NSTextField *title;
196 NSMatrix *matrix; 196 NSMatrix *matrix;
197 int rows, cols; 197 int rows, cols;
198 int timer_fired; 198 BOOL timer_fired, window_closed;
199 Lisp_Object dialog_return;
200 Lisp_Object *button_values;
199 } 201 }
200- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ; 202- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
201- addButton: (char *)str value: (Lisp_Object)val row: (int)row; 203- (void)process_dialog: (Lisp_Object)list;
202- addString: (char *)str row: (int)row; 204- (void)addButton: (char *)str value: (int)tag row: (int)row;
203- addSplit; 205- (void)addString: (char *)str row: (int)row;
206- (void)addSplit;
204- (Lisp_Object)runDialogAt: (NSPoint)p; 207- (Lisp_Object)runDialogAt: (NSPoint)p;
205- (void)timeout_handler: (NSTimer *)timedEntry; 208- (void)timeout_handler: (NSTimer *)timedEntry;
206@end 209@end
@@ -628,6 +631,8 @@ struct x_output
628/* This is the `Display *' which frame F is on. */ 631/* This is the `Display *' which frame F is on. */
629#define FRAME_NS_DISPLAY(f) (0) 632#define FRAME_NS_DISPLAY(f) (0)
630#define FRAME_X_DISPLAY(f) (0) 633#define FRAME_X_DISPLAY(f) (0)
634#define FRAME_X_SCREEN(f) (0)
635#define FRAME_X_VISUAL(f) FRAME_NS_DISPLAY_INFO(f)->visual
631 636
632#define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color) 637#define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
633#define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color) 638#define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
@@ -777,31 +782,6 @@ extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f,
777extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, 782extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
778 Lisp_Object header); 783 Lisp_Object header);
779 784
780/* More prototypes that should be moved to a more general include file */
781extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
782extern void x_set_window_size (struct frame *f, int change_grav,
783 int cols, int rows);
784extern void x_sync (struct frame *);
785extern Lisp_Object x_get_focus_frame (struct frame *);
786extern void x_set_mouse_position (struct frame *f, int h, int v);
787extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
788extern void x_make_frame_visible (struct frame *f);
789extern void x_make_frame_invisible (struct frame *f);
790extern void x_iconify_frame (struct frame *f);
791extern int x_char_width (struct frame *f);
792extern int x_char_height (struct frame *f);
793extern int x_pixel_width (struct frame *f);
794extern int x_pixel_height (struct frame *f);
795extern void x_set_frame_alpha (struct frame *f);
796extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
797extern void x_set_tool_bar_lines (struct frame *f,
798 Lisp_Object value,
799 Lisp_Object oldval);
800extern void x_activate_menubar (struct frame *);
801extern void free_frame_menubar (struct frame *);
802extern void x_free_frame_resources (struct frame *);
803extern void x_destroy_window (struct frame *);
804
805#define NSAPP_DATA2_RUNASSCRIPT 10 785#define NSAPP_DATA2_RUNASSCRIPT 10
806extern void ns_run_ascript (void); 786extern void ns_run_ascript (void);
807 787
diff --git a/src/nsterm.m b/src/nsterm.m
index 3ab9358467a..c892a5486a7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4600,11 +4600,15 @@ not_in_argv (NSString *arg)
4600 4600
4601 SELECT_TYPE readfds, writefds, *wfds; 4601 SELECT_TYPE readfds, writefds, *wfds;
4602 EMACS_TIME timeout, *tmo; 4602 EMACS_TIME timeout, *tmo;
4603 NSAutoreleasePool *pool = nil;
4603 4604
4604 /* NSTRACE (fd_handler); */ 4605 /* NSTRACE (fd_handler); */
4605 4606
4606 for (;;) 4607 for (;;)
4607 { 4608 {
4609 [pool release];
4610 pool = [[NSAutoreleasePool alloc] init];
4611
4608 if (waiting) 4612 if (waiting)
4609 { 4613 {
4610 SELECT_TYPE fds; 4614 SELECT_TYPE fds;
@@ -5087,7 +5091,8 @@ not_in_argv (NSString *arg)
5087 /* TODO: still need this? */ 5091 /* TODO: still need this? */
5088 if (code == 0x2DC) 5092 if (code == 0x2DC)
5089 code = '~'; /* 0x7E */ 5093 code = '~'; /* 0x7E */
5090 emacs_event->modifiers = 0; 5094 if (code != 32) /* Space */
5095 emacs_event->modifiers = 0;
5091 emacs_event->kind 5096 emacs_event->kind
5092 = code > 0xFF ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT; 5097 = code > 0xFF ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
5093 emacs_event->code = code; 5098 emacs_event->code = code;
diff --git a/src/print.c b/src/print.c
index e8309109f1d..3cf5fc7348d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -197,8 +197,7 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1;
197 ? PT - start_point : 0), \ 197 ? PT - start_point : 0), \
198 old_point_byte + (old_point_byte >= start_point_byte \ 198 old_point_byte + (old_point_byte >= start_point_byte \
199 ? PT_BYTE - start_point_byte : 0)); \ 199 ? PT_BYTE - start_point_byte : 0)); \
200 if (old != current_buffer) \ 200 set_buffer_internal (old);
201 set_buffer_internal (old);
202 201
203#define PRINTCHAR(ch) printchar (ch, printcharfun) 202#define PRINTCHAR(ch) printchar (ch, printcharfun)
204 203
@@ -488,7 +487,7 @@ temp_output_buffer_setup (const char *bufname)
488 register struct buffer *old = current_buffer; 487 register struct buffer *old = current_buffer;
489 register Lisp_Object buf; 488 register Lisp_Object buf;
490 489
491 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 490 record_unwind_current_buffer ();
492 491
493 Fset_buffer (Fget_buffer_create (build_string (bufname))); 492 Fset_buffer (Fget_buffer_create (build_string (bufname)));
494 493
@@ -586,6 +585,7 @@ A printed representation of an object is text which describes that object. */)
586 (Lisp_Object object, Lisp_Object noescape) 585 (Lisp_Object object, Lisp_Object noescape)
587{ 586{
588 Lisp_Object printcharfun; 587 Lisp_Object printcharfun;
588 bool prev_abort_on_gc;
589 /* struct gcpro gcpro1, gcpro2; */ 589 /* struct gcpro gcpro1, gcpro2; */
590 Lisp_Object save_deactivate_mark; 590 Lisp_Object save_deactivate_mark;
591 ptrdiff_t count = SPECPDL_INDEX (); 591 ptrdiff_t count = SPECPDL_INDEX ();
@@ -601,7 +601,8 @@ A printed representation of an object is text which describes that object. */)
601 No need for specbind, since errors deactivate the mark. */ 601 No need for specbind, since errors deactivate the mark. */
602 save_deactivate_mark = Vdeactivate_mark; 602 save_deactivate_mark = Vdeactivate_mark;
603 /* GCPRO2 (object, save_deactivate_mark); */ 603 /* GCPRO2 (object, save_deactivate_mark); */
604 abort_on_gc++; 604 prev_abort_on_gc = abort_on_gc;
605 abort_on_gc = 1;
605 606
606 printcharfun = Vprin1_to_string_buffer; 607 printcharfun = Vprin1_to_string_buffer;
607 PRINTPREPARE; 608 PRINTPREPARE;
@@ -625,7 +626,7 @@ A printed representation of an object is text which describes that object. */)
625 Vdeactivate_mark = save_deactivate_mark; 626 Vdeactivate_mark = save_deactivate_mark;
626 /* UNGCPRO; */ 627 /* UNGCPRO; */
627 628
628 abort_on_gc--; 629 abort_on_gc = prev_abort_on_gc;
629 return unbind_to (count, object); 630 return unbind_to (count, object);
630} 631}
631 632
diff --git a/src/process.c b/src/process.c
index fa138027ec1..dbbb23b8627 100644
--- a/src/process.c
+++ b/src/process.c
@@ -116,12 +116,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
116#include "gnutls.h" 116#include "gnutls.h"
117#endif 117#endif
118 118
119#ifdef HAVE_WINDOW_SYSTEM
120#include TERM_HEADER
121#endif /* HAVE_WINDOW_SYSTEM */
122
119#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 123#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
120#include "xgselect.h" 124#include "xgselect.h"
121#endif 125#endif
122#ifdef HAVE_NS
123#include "nsterm.h"
124#endif
125 126
126/* Work around GCC 4.7.0 bug with strict overflow checking; see 127/* Work around GCC 4.7.0 bug with strict overflow checking; see
127 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 128 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
@@ -164,16 +165,6 @@ static Lisp_Object QClocal, QCremote, QCcoding;
164static Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; 165static Lisp_Object QCserver, QCnowait, QCnoquery, QCstop;
165static Lisp_Object QCsentinel, QClog, QCoptions, QCplist; 166static Lisp_Object QCsentinel, QClog, QCoptions, QCplist;
166static Lisp_Object Qlast_nonmenu_event; 167static Lisp_Object Qlast_nonmenu_event;
167/* QCfamily is declared and initialized in xfaces.c,
168 QCfilter in keyboard.c. */
169extern Lisp_Object QCfamily, QCfilter;
170
171/* Qexit is declared and initialized in eval.c. */
172
173/* QCfamily is defined in xfaces.c. */
174extern Lisp_Object QCfamily;
175/* QCfilter is defined in keyboard.c. */
176extern Lisp_Object QCfilter;
177 168
178#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) 169#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork))
179#define NETCONN1_P(p) (EQ (p->type, Qnetwork)) 170#define NETCONN1_P(p) (EQ (p->type, Qnetwork))
@@ -5039,15 +5030,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5039 for (channel = 0; channel <= max_input_desc; ++channel) 5030 for (channel = 0; channel <= max_input_desc; ++channel)
5040 { 5031 {
5041 struct fd_callback_data *d = &fd_callback_info[channel]; 5032 struct fd_callback_data *d = &fd_callback_info[channel];
5042 if (FD_ISSET (channel, &Available) 5033 if (d->func
5043 && d->func != 0 5034 && ((d->flags & FOR_READ
5044 && (d->flags & FOR_READ) != 0) 5035 && FD_ISSET (channel, &Available))
5045 d->func (channel, d->data, 1); 5036 || (d->flags & FOR_WRITE
5046 if (FD_ISSET (channel, &Writeok) 5037 && FD_ISSET (channel, &Writeok))))
5047 && d->func != 0 5038 d->func (channel, d->data);
5048 && (d->flags & FOR_WRITE) != 0) 5039 }
5049 d->func (channel, d->data, 0);
5050 }
5051 5040
5052 for (channel = 0; channel <= max_process_desc; channel++) 5041 for (channel = 0; channel <= max_process_desc; channel++)
5053 { 5042 {
@@ -5361,14 +5350,14 @@ read_process_output (Lisp_Object proc, register int channel)
5361 /* There's no good reason to let process filters change the current 5350 /* There's no good reason to let process filters change the current
5362 buffer, and many callers of accept-process-output, sit-for, and 5351 buffer, and many callers of accept-process-output, sit-for, and
5363 friends don't expect current-buffer to be changed from under them. */ 5352 friends don't expect current-buffer to be changed from under them. */
5364 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 5353 record_unwind_current_buffer ();
5365 5354
5366 /* Read and dispose of the process output. */ 5355 /* Read and dispose of the process output. */
5367 outstream = p->filter; 5356 outstream = p->filter;
5368 if (!NILP (outstream)) 5357 if (!NILP (outstream))
5369 { 5358 {
5370 Lisp_Object text; 5359 Lisp_Object text;
5371 int outer_running_asynch_code = running_asynch_code; 5360 bool outer_running_asynch_code = running_asynch_code;
5372 int waiting = waiting_for_user_input_p; 5361 int waiting = waiting_for_user_input_p;
5373 5362
5374 /* No need to gcpro these, because all we do with them later 5363 /* No need to gcpro these, because all we do with them later
@@ -5605,7 +5594,7 @@ send_process_trap (int ignore)
5605{ 5594{
5606 SIGNAL_THREAD_CHECK (SIGPIPE); 5595 SIGNAL_THREAD_CHECK (SIGPIPE);
5607 sigunblock (sigmask (SIGPIPE)); 5596 sigunblock (sigmask (SIGPIPE));
5608 longjmp (send_process_frame, 1); 5597 _longjmp (send_process_frame, 1);
5609} 5598}
5610 5599
5611/* In send_process, when a write fails temporarily, 5600/* In send_process, when a write fails temporarily,
@@ -5808,7 +5797,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5808 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5797 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2,
5809 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5798 CFLAGS="-g -O": The value of the parameter `proc' is clobbered
5810 when returning with longjmp despite being declared volatile. */ 5799 when returning with longjmp despite being declared volatile. */
5811 if (!setjmp (send_process_frame)) 5800 if (!_setjmp (send_process_frame))
5812 { 5801 {
5813 p = XPROCESS (proc); /* Repair any setjmp clobbering. */ 5802 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5814 process_sent_to = proc; 5803 process_sent_to = proc;
@@ -6725,9 +6714,9 @@ static void
6725exec_sentinel (Lisp_Object proc, Lisp_Object reason) 6714exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6726{ 6715{
6727 Lisp_Object sentinel, odeactivate; 6716 Lisp_Object sentinel, odeactivate;
6728 register struct Lisp_Process *p = XPROCESS (proc); 6717 struct Lisp_Process *p = XPROCESS (proc);
6729 ptrdiff_t count = SPECPDL_INDEX (); 6718 ptrdiff_t count = SPECPDL_INDEX ();
6730 int outer_running_asynch_code = running_asynch_code; 6719 bool outer_running_asynch_code = running_asynch_code;
6731 int waiting = waiting_for_user_input_p; 6720 int waiting = waiting_for_user_input_p;
6732 6721
6733 if (inhibit_sentinels) 6722 if (inhibit_sentinels)
@@ -6745,7 +6734,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6745 /* There's no good reason to let sentinels change the current 6734 /* There's no good reason to let sentinels change the current
6746 buffer, and many callers of accept-process-output, sit-for, and 6735 buffer, and many callers of accept-process-output, sit-for, and
6747 friends don't expect current-buffer to be changed from under them. */ 6736 friends don't expect current-buffer to be changed from under them. */
6748 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 6737 record_unwind_current_buffer ();
6749 6738
6750 sentinel = p->sentinel; 6739 sentinel = p->sentinel;
6751 if (NILP (sentinel)) 6740 if (NILP (sentinel))
diff --git a/src/process.h b/src/process.h
index db000464cb5..e89ba478187 100644
--- a/src/process.h
+++ b/src/process.h
@@ -187,7 +187,7 @@ pset_gnutls_cred_type (struct Lisp_Process *p, Lisp_Object val)
187 187
188/* True if we are about to fork off a synchronous process or if we 188/* True if we are about to fork off a synchronous process or if we
189 are waiting for it. */ 189 are waiting for it. */
190extern int synch_process_alive; 190extern bool synch_process_alive;
191 191
192/* Communicate exit status of sync process to from sigchld_handler 192/* Communicate exit status of sync process to from sigchld_handler
193 to Fcall_process. */ 193 to Fcall_process. */
@@ -222,7 +222,7 @@ extern void hold_keyboard_input (void);
222extern void unhold_keyboard_input (void); 222extern void unhold_keyboard_input (void);
223extern int kbd_on_hold_p (void); 223extern int kbd_on_hold_p (void);
224 224
225typedef void (*fd_callback)(int fd, void *data, int for_read); 225typedef void (*fd_callback) (int fd, void *data);
226 226
227extern void add_read_fd (int fd, fd_callback func, void *data); 227extern void add_read_fd (int fd, fd_callback func, void *data);
228extern void delete_read_fd (int fd); 228extern void delete_read_fd (int fd);
diff --git a/src/ralloc.c b/src/ralloc.c
index c40258693f5..3877e21d4f6 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -670,6 +670,7 @@ static void
670free_bloc (bloc_ptr bloc) 670free_bloc (bloc_ptr bloc)
671{ 671{
672 heap_ptr heap = bloc->heap; 672 heap_ptr heap = bloc->heap;
673 heap_ptr h;
673 674
674 if (r_alloc_freeze_level) 675 if (r_alloc_freeze_level)
675 { 676 {
@@ -699,20 +700,38 @@ free_bloc (bloc_ptr bloc)
699 bloc->prev->next = bloc->next; 700 bloc->prev->next = bloc->next;
700 } 701 }
701 702
702 /* Update the records of which blocs are in HEAP. */ 703 /* Sometimes, 'heap' obtained from bloc->heap above is not really a
703 if (heap->first_bloc == bloc) 704 'heap' structure. It can even be beyond the current break point,
705 which will cause crashes when we dereference it below (see
706 bug#12242). Evidently, the reason is bloc allocations done while
707 use_relocatable_buffers was non-positive, because additional
708 memory we get then is not recorded in the heaps we manage. If
709 bloc->heap records such a "heap", we cannot (and don't need to)
710 update its records. So we validate the 'heap' value by making
711 sure it is one of the heaps we manage via the heaps linked list,
712 and don't touch a 'heap' that isn't found there. This avoids
713 accessing memory we know nothing about. */
714 for (h = first_heap; h != NIL_HEAP; h = h->next)
715 if (heap == h)
716 break;
717
718 if (h)
704 { 719 {
705 if (bloc->next != 0 && bloc->next->heap == heap) 720 /* Update the records of which blocs are in HEAP. */
706 heap->first_bloc = bloc->next; 721 if (heap->first_bloc == bloc)
707 else 722 {
708 heap->first_bloc = heap->last_bloc = NIL_BLOC; 723 if (bloc->next != 0 && bloc->next->heap == heap)
709 } 724 heap->first_bloc = bloc->next;
710 if (heap->last_bloc == bloc) 725 else
711 { 726 heap->first_bloc = heap->last_bloc = NIL_BLOC;
712 if (bloc->prev != 0 && bloc->prev->heap == heap) 727 }
713 heap->last_bloc = bloc->prev; 728 if (heap->last_bloc == bloc)
714 else 729 {
715 heap->first_bloc = heap->last_bloc = NIL_BLOC; 730 if (bloc->prev != 0 && bloc->prev->heap == heap)
731 heap->last_bloc = bloc->prev;
732 else
733 heap->first_bloc = heap->last_bloc = NIL_BLOC;
734 }
716 } 735 }
717 736
718 relinquish (); 737 relinquish ();
diff --git a/src/sysdep.c b/src/sysdep.c
index 183ee005227..b84e6a4ea3a 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1765,19 +1765,37 @@ init_signals (void)
1765#endif /* !RAND_BITS */ 1765#endif /* !RAND_BITS */
1766 1766
1767void 1767void
1768seed_random (long int arg) 1768seed_random (void *seed, ptrdiff_t seed_size)
1769{ 1769{
1770#if defined HAVE_RANDOM || ! defined HAVE_LRAND48
1771 unsigned int arg = 0;
1772#else
1773 long int arg = 0;
1774#endif
1775 unsigned char *argp = (unsigned char *) &arg;
1776 unsigned char *seedp = seed;
1777 ptrdiff_t i;
1778 for (i = 0; i < seed_size; i++)
1779 argp[i % sizeof arg] ^= seedp[i];
1770#ifdef HAVE_RANDOM 1780#ifdef HAVE_RANDOM
1771 srandom ((unsigned int)arg); 1781 srandom (arg);
1772#else 1782#else
1773# ifdef HAVE_LRAND48 1783# ifdef HAVE_LRAND48
1774 srand48 (arg); 1784 srand48 (arg);
1775# else 1785# else
1776 srand ((unsigned int)arg); 1786 srand (arg);
1777# endif 1787# endif
1778#endif 1788#endif
1779} 1789}
1780 1790
1791void
1792init_random (void)
1793{
1794 EMACS_TIME t = current_emacs_time ();
1795 uintmax_t v = getpid () ^ EMACS_SECS (t) ^ EMACS_NSECS (t);
1796 seed_random (&v, sizeof v);
1797}
1798
1781/* 1799/*
1782 * Return a nonnegative random integer out of whatever we've got. 1800 * Return a nonnegative random integer out of whatever we've got.
1783 * It contains enough bits to make a random (signed) Emacs fixnum. 1801 * It contains enough bits to make a random (signed) Emacs fixnum.
diff --git a/src/systime.h b/src/systime.h
index d3bdeb83019..9ce7ce646fb 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -154,8 +154,8 @@ extern void set_waiting_for_input (EMACS_TIME *);
154#ifdef GCPRO1 154#ifdef GCPRO1
155/* defined in editfns.c */ 155/* defined in editfns.c */
156extern Lisp_Object make_lisp_time (EMACS_TIME); 156extern Lisp_Object make_lisp_time (EMACS_TIME);
157extern int decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, 157extern bool decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object,
158 Lisp_Object, EMACS_TIME *, double *); 158 Lisp_Object, EMACS_TIME *, double *);
159extern EMACS_TIME lisp_time_argument (Lisp_Object); 159extern EMACS_TIME lisp_time_argument (Lisp_Object);
160#endif 160#endif
161 161
diff --git a/src/term.c b/src/term.c
index 23e074287c1..f1a09b39cf9 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3001,6 +3001,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3001#else 3001#else
3002 tty = xzalloc (sizeof *tty); 3002 tty = xzalloc (sizeof *tty);
3003#endif 3003#endif
3004 tty->top_frame = Qnil;
3004 tty->next = tty_list; 3005 tty->next = tty_list;
3005 tty_list = tty; 3006 tty_list = tty;
3006 3007
@@ -3541,22 +3542,6 @@ delete_tty (struct terminal *terminal)
3541 xfree (tty); 3542 xfree (tty);
3542} 3543}
3543 3544
3544
3545
3546/* Mark the pointers in the tty_display_info objects.
3547 Called by Fgarbage_collect. */
3548
3549void
3550mark_ttys (void)
3551{
3552 struct tty_display_info *tty;
3553
3554 for (tty = tty_list; tty; tty = tty->next)
3555 mark_object (tty->top_frame);
3556}
3557
3558
3559
3560void 3545void
3561syms_of_term (void) 3546syms_of_term (void)
3562{ 3547{
diff --git a/src/textprop.c b/src/textprop.c
index 20d98b0e6f3..b6895fc426a 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -760,7 +760,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
760 760
761 if (BUFFERP (object) && current_buffer != XBUFFER (object)) 761 if (BUFFERP (object) && current_buffer != XBUFFER (object))
762 { 762 {
763 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 763 record_unwind_current_buffer ();
764 Fset_buffer (object); 764 Fset_buffer (object);
765 } 765 }
766 766
@@ -843,7 +843,7 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT. */)
843 843
844 if (BUFFERP (object) && current_buffer != XBUFFER (object)) 844 if (BUFFERP (object) && current_buffer != XBUFFER (object))
845 { 845 {
846 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 846 record_unwind_current_buffer ();
847 Fset_buffer (object); 847 Fset_buffer (object);
848 } 848 }
849 849
diff --git a/src/undo.c b/src/undo.c
index 777e3291806..9cd1d5f9f67 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -324,7 +324,7 @@ truncate_undo_list (struct buffer *b)
324 /* Make the buffer current to get its local values of variables such 324 /* Make the buffer current to get its local values of variables such
325 as undo_limit. Also so that Vundo_outer_limit_function can 325 as undo_limit. Also so that Vundo_outer_limit_function can
326 tell which buffer to operate on. */ 326 tell which buffer to operate on. */
327 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 327 record_unwind_current_buffer ();
328 set_buffer_internal (b); 328 set_buffer_internal (b);
329 329
330 list = BVAR (b, undo_list); 330 list = BVAR (b, undo_list);
diff --git a/src/w32.c b/src/w32.c
index b460660cb8c..fe612687f48 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4098,7 +4098,7 @@ symlink (char const *filename, char const *linkname)
4098 dir_access = sys_access (filename, D_OK); 4098 dir_access = sys_access (filename, D_OK);
4099 4099
4100 /* Since Windows distinguishes between symlinks to directories and 4100 /* Since Windows distinguishes between symlinks to directories and
4101 to files, we provide a kludgey feature: if FILENAME doesn't 4101 to files, we provide a kludgy feature: if FILENAME doesn't
4102 exist, but ends in a slash, we create a symlink to directory. If 4102 exist, but ends in a slash, we create a symlink to directory. If
4103 FILENAME exists and is a directory, we always create a symlink to 4103 FILENAME exists and is a directory, we always create a symlink to
4104 directory. */ 4104 directory. */
@@ -4165,7 +4165,7 @@ symlink (char const *filename, char const *linkname)
4165 whether the underlying volume actually supports symlinks, by 4165 whether the underlying volume actually supports symlinks, by
4166 testing the FILE_SUPPORTS_REPARSE_POINTS bit in volume's flags, and 4166 testing the FILE_SUPPORTS_REPARSE_POINTS bit in volume's flags, and
4167 avoid the call to this function if it doesn't. That's because the 4167 avoid the call to this function if it doesn't. That's because the
4168 call to GetFileAttributes takes a non-negligible time, expecially 4168 call to GetFileAttributes takes a non-negligible time, especially
4169 on non-local or removable filesystems. See stat_worker for an 4169 on non-local or removable filesystems. See stat_worker for an
4170 example of how to do that. */ 4170 example of how to do that. */
4171static int 4171static int
@@ -6773,7 +6773,7 @@ shutdown_handler (DWORD type)
6773 || type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */ 6773 || type == CTRL_SHUTDOWN_EVENT) /* User shutsdown. */
6774 { 6774 {
6775 /* Shut down cleanly, making sure autosave files are up to date. */ 6775 /* Shut down cleanly, making sure autosave files are up to date. */
6776 shut_down_emacs (0, 0, Qnil); 6776 shut_down_emacs (0, Qnil);
6777 } 6777 }
6778 6778
6779 /* Allow other handlers to handle this signal. */ 6779 /* Allow other handlers to handle this signal. */
diff --git a/src/w32fns.c b/src/w32fns.c
index 9c5231f9d93..5a1b6dfabab 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -4735,7 +4735,7 @@ x_display_info_for_name (Lisp_Object name)
4735 CHECK_STRING (name); 4735 CHECK_STRING (name);
4736 4736
4737 for (dpyinfo = &one_w32_display_info, names = w32_display_name_list; 4737 for (dpyinfo = &one_w32_display_info, names = w32_display_name_list;
4738 dpyinfo; 4738 dpyinfo && !NILP (w32_display_name_list);
4739 dpyinfo = dpyinfo->next, names = XCDR (names)) 4739 dpyinfo = dpyinfo->next, names = XCDR (names))
4740 { 4740 {
4741 Lisp_Object tem; 4741 Lisp_Object tem;
diff --git a/src/w32font.h b/src/w32font.h
index b08d48a3d36..a29ddbe778c 100644
--- a/src/w32font.h
+++ b/src/w32font.h
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#ifndef EMACS_W32FONT_H 19#ifndef EMACS_W32FONT_H
20#define EMACS_W32FONT_H 20#define EMACS_W32FONT_H
21 21
22#include "font.h"
22 23
23/* Bit 17 of ntmFlags in NEWTEXTMETRIC is set for PostScript OpenType fonts, 24/* Bit 17 of ntmFlags in NEWTEXTMETRIC is set for PostScript OpenType fonts,
24 bit 18 for TrueType OpenType fonts, bit 20 for Type1 fonts. */ 25 bit 18 for TrueType OpenType fonts, bit 20 for Type1 fonts. */
@@ -83,4 +84,7 @@ int uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec);
83 84
84Lisp_Object intern_font_name (char *); 85Lisp_Object intern_font_name (char *);
85 86
87extern void syms_of_w32font (void);
88extern void globals_of_w32font (void);
89
86#endif 90#endif
diff --git a/src/w32term.h b/src/w32term.h
index ccbf3c42c0e..5d756f435e4 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -302,9 +302,6 @@ struct w32_output
302 /* Non-hourglass cursor that is currently active. */ 302 /* Non-hourglass cursor that is currently active. */
303 Cursor current_cursor; 303 Cursor current_cursor;
304 304
305 /* Flag to set when the window needs to be completely repainted. */
306 int needs_exposure;
307
308 DWORD dwStyle; 305 DWORD dwStyle;
309 306
310 /* This is the Emacs structure for the display this frame is on. */ 307 /* This is the Emacs structure for the display this frame is on. */
@@ -345,7 +342,7 @@ extern struct w32_output w32term_display;
345 342
346/* Return the window associated with the frame F. */ 343/* Return the window associated with the frame F. */
347#define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc) 344#define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc)
348#define FRAME_X_WINDOW(f) ((f)->output_data.w32->window_desc) 345#define FRAME_X_WINDOW(f) FRAME_W32_WINDOW (f)
349 346
350#define FRAME_FONT(f) ((f)->output_data.w32->font) 347#define FRAME_FONT(f) ((f)->output_data.w32->font)
351#define FRAME_FONTSET(f) ((f)->output_data.w32->fontset) 348#define FRAME_FONTSET(f) ((f)->output_data.w32->fontset)
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 06f7b1bd192..bc45e2c648c 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -320,7 +320,7 @@ uniscribe_shape (Lisp_Object lgstring)
320 } 320 }
321 if (SUCCEEDED (result)) 321 if (SUCCEEDED (result))
322 { 322 {
323 int j, from, to; 323 int j, from, to, adj_offset = 0;
324 324
325 from = 0; 325 from = 0;
326 to = from; 326 to = from;
@@ -364,6 +364,32 @@ uniscribe_shape (Lisp_Object lgstring)
364 } 364 }
365 } 365 }
366 } 366 }
367
368 /* For RTL text, the Uniscribe shaper prepares
369 the values in ADVANCES array for layout in
370 reverse order, whereby "advance width" is
371 applied to move the pen in reverse direction
372 and _before_ drawing the glyph. Since we
373 draw glyphs in their normal left-to-right
374 order, we need to adjust the coordinates of
375 each non-base glyph in a grapheme cluster via
376 X-OFF component of the gstring's ADJUSTMENT
377 sub-vector. This loop computes, for each
378 grapheme cluster, the initial value of the
379 adjustment for the base character, which is
380 then updated for each successive glyph in the
381 grapheme cluster. */
382 if (items[i].a.fRTL)
383 {
384 int j1 = j;
385
386 adj_offset = 0;
387 while (j1 < nglyphs && !attributes[j1].fClusterStart)
388 {
389 adj_offset += advances[j1];
390 j1++;
391 }
392 }
367 } 393 }
368 394
369 LGLYPH_SET_CHAR (lglyph, chars[items[i].iCharPos 395 LGLYPH_SET_CHAR (lglyph, chars[items[i].iCharPos
@@ -392,9 +418,11 @@ uniscribe_shape (Lisp_Object lgstring)
392 418
393 if (SUCCEEDED (result)) 419 if (SUCCEEDED (result))
394 { 420 {
395 LGLYPH_SET_LBEARING (lglyph, char_metric.abcA); 421 int lbearing = char_metric.abcA;
396 LGLYPH_SET_RBEARING (lglyph, (char_metric.abcA 422 int rbearing = char_metric.abcA + char_metric.abcB;
397 + char_metric.abcB)); 423
424 LGLYPH_SET_LBEARING (lglyph, lbearing);
425 LGLYPH_SET_RBEARING (lglyph, rbearing);
398 } 426 }
399 else 427 else
400 { 428 {
@@ -402,18 +430,43 @@ uniscribe_shape (Lisp_Object lgstring)
402 LGLYPH_SET_RBEARING (lglyph, advances[j]); 430 LGLYPH_SET_RBEARING (lglyph, advances[j]);
403 } 431 }
404 432
405 if (offsets[j].du || offsets[j].dv) 433 if (offsets[j].du || offsets[j].dv
434 /* For non-base glyphs of RTL grapheme clusters,
435 adjust the X offset even if both DU and DV
436 are zero. */
437 || (!attributes[j].fClusterStart && items[i].a.fRTL))
406 { 438 {
407 Lisp_Object vec; 439 Lisp_Object vec;
408 vec = Fmake_vector (make_number (3), Qnil); 440 vec = Fmake_vector (make_number (3), Qnil);
409 ASET (vec, 0, make_number (offsets[j].du)); 441 if (items[i].a.fRTL)
442 {
443 /* Empirically, it looks like Uniscribe
444 interprets DU in reverse direction for
445 RTL clusters. E.g., if we don't reverse
446 the direction, the Hebrew point HOLAM is
447 drawn above the right edge of the base
448 consonant, instead of above the left edge. */
449 ASET (vec, 0, make_number (-offsets[j].du
450 + adj_offset));
451 /* Update the adjustment value for the width
452 advance of the glyph we just emitted. */
453 adj_offset -= 2 * advances[j];
454 }
455 else
456 ASET (vec, 0, make_number (offsets[j].du + adj_offset));
410 ASET (vec, 1, make_number (offsets[j].dv)); 457 ASET (vec, 1, make_number (offsets[j].dv));
411 /* Based on what ftfont.c does... */ 458 /* Based on what ftfont.c does... */
412 ASET (vec, 2, make_number (advances[j])); 459 ASET (vec, 2, make_number (advances[j]));
413 LGLYPH_SET_ADJUSTMENT (lglyph, vec); 460 LGLYPH_SET_ADJUSTMENT (lglyph, vec);
414 } 461 }
415 else 462 else
416 LGLYPH_SET_ADJUSTMENT (lglyph, Qnil); 463 {
464 LGLYPH_SET_ADJUSTMENT (lglyph, Qnil);
465 /* Update the adjustment value to compensate for
466 the width of the base character. */
467 if (items[i].a.fRTL)
468 adj_offset -= advances[j];
469 }
417 } 470 }
418 } 471 }
419 } 472 }
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 745a5cfe3e7..62e45dd987b 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -438,6 +438,6 @@ XParseGeometry (char *string,
438 438
439/* x_sync is a no-op on W32. */ 439/* x_sync is a no-op on W32. */
440void 440void
441x_sync (void *f) 441x_sync (struct frame *f)
442{ 442{
443} 443}
diff --git a/src/widget.c b/src/widget.c
index b94c30f4e9c..ea9bdb61b13 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -671,8 +671,6 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs
671 update_wm_hints (ew); 671 update_wm_hints (ew);
672} 672}
673 673
674extern void free_frame_faces (struct frame *);
675
676static void 674static void
677EmacsFrameDestroy (Widget widget) 675EmacsFrameDestroy (Widget widget)
678{ 676{
diff --git a/src/window.c b/src/window.c
index 20325711e73..732d5060d29 100644
--- a/src/window.c
+++ b/src/window.c
@@ -54,14 +54,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
54#include "nsterm.h" 54#include "nsterm.h"
55#endif 55#endif
56 56
57Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_valid_p; 57Lisp_Object Qwindowp, Qwindow_live_p;
58static Lisp_Object Qwindow_valid_p;
58static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; 59static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
59static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; 60static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
60static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; 61static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
61static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; 62static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
62static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 63static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
63static Lisp_Object Qsafe, Qabove, Qbelow; 64static Lisp_Object Qsafe, Qabove, Qbelow;
64static Lisp_Object Qauto_buffer_name, Qclone_of; 65static Lisp_Object Qclone_of;
65 66
66static int displayed_window_lines (struct window *); 67static int displayed_window_lines (struct window *);
67static int count_windows (struct window *); 68static int count_windows (struct window *);
@@ -268,7 +269,7 @@ decode_any_window (register Lisp_Object window)
268 return w; 269 return w;
269} 270}
270 271
271struct window * 272static struct window *
272decode_valid_window (register Lisp_Object window) 273decode_valid_window (register Lisp_Object window)
273{ 274{
274 struct window *w; 275 struct window *w;
@@ -1407,22 +1408,21 @@ DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
1407 doc: /* Return current value of point in WINDOW. 1408 doc: /* Return current value of point in WINDOW.
1408WINDOW must be a live window and defaults to the selected one. 1409WINDOW must be a live window and defaults to the selected one.
1409 1410
1410For a nonselected window, this is the value point would have 1411For a nonselected window, this is the value point would have if that
1411if that window were selected. 1412window were selected.
1412 1413
1413Note that, when WINDOW is the selected window and its buffer 1414Note that, when WINDOW is selected, the value returned is the same as
1414is also currently selected, the value returned is the same as (point). 1415that returned by `point' for WINDOW's buffer. It would be more strictly
1415It would be more strictly correct to return the `top-level' value 1416correct to return the `top-level' value of `point', outside of any
1416of point, outside of any save-excursion forms. 1417`save-excursion' forms. But that is hard to define. */)
1417But that is hard to define. */)
1418 (Lisp_Object window) 1418 (Lisp_Object window)
1419{ 1419{
1420 register struct window *w = decode_live_window (window); 1420 register struct window *w = decode_live_window (window);
1421 1421
1422 if (w == XWINDOW (selected_window) 1422 if (w == XWINDOW (selected_window))
1423 && current_buffer == XBUFFER (w->buffer)) 1423 return make_number (BUF_PT (XBUFFER (w->buffer)));
1424 return Fpoint (); 1424 else
1425 return Fmarker_position (w->pointm); 1425 return Fmarker_position (w->pointm);
1426} 1426}
1427 1427
1428DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, 1428DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0,
@@ -1532,16 +1532,27 @@ Return POS. */)
1532 register struct window *w = decode_live_window (window); 1532 register struct window *w = decode_live_window (window);
1533 1533
1534 CHECK_NUMBER_COERCE_MARKER (pos); 1534 CHECK_NUMBER_COERCE_MARKER (pos);
1535 if (w == XWINDOW (selected_window)
1536 && XBUFFER (w->buffer) == current_buffer)
1537 Fgoto_char (pos);
1538 else
1539 set_marker_restricted (w->pointm, pos, w->buffer);
1540 1535
1541 /* We have to make sure that redisplay updates the window to show 1536 if (w == XWINDOW (selected_window))
1542 the new value of point. */ 1537 {
1543 if (!EQ (window, selected_window)) 1538 if (XBUFFER (w->buffer) == current_buffer)
1544 ++windows_or_buffers_changed; 1539 Fgoto_char (pos);
1540 else
1541 {
1542 struct buffer *old_buffer = current_buffer;
1543
1544 set_buffer_internal (XBUFFER (w->buffer));
1545 Fgoto_char (pos);
1546 set_buffer_internal (old_buffer);
1547 }
1548 }
1549 else
1550 {
1551 set_marker_restricted (w->pointm, pos, w->buffer);
1552 /* We have to make sure that redisplay updates the window to show
1553 the new value of point. */
1554 ++windows_or_buffers_changed;
1555 }
1545 1556
1546 return pos; 1557 return pos;
1547} 1558}
@@ -1958,6 +1969,9 @@ unshow_buffer (register struct window *w)
1958 is actually stored in that buffer, and the window's pointm isn't used. 1969 is actually stored in that buffer, and the window's pointm isn't used.
1959 So don't clobber point in that buffer. */ 1970 So don't clobber point in that buffer. */
1960 if (! EQ (buf, XWINDOW (selected_window)->buffer) 1971 if (! EQ (buf, XWINDOW (selected_window)->buffer)
1972 /* Don't clobber point in current buffer either (this could be
1973 useful in connection with bug#12208).
1974 && XBUFFER (buf) != current_buffer */
1961 /* This line helps to fix Horsley's testbug.el bug. */ 1975 /* This line helps to fix Horsley's testbug.el bug. */
1962 && !(WINDOWP (BVAR (b, last_selected_window)) 1976 && !(WINDOWP (BVAR (b, last_selected_window))
1963 && w != XWINDOW (BVAR (b, last_selected_window)) 1977 && w != XWINDOW (BVAR (b, last_selected_window))
@@ -3087,7 +3101,7 @@ run_window_configuration_change_hook (struct frame *f)
3087 /* Use the right buffer. Matters when running the local hooks. */ 3101 /* Use the right buffer. Matters when running the local hooks. */
3088 if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) 3102 if (current_buffer != XBUFFER (Fwindow_buffer (Qnil)))
3089 { 3103 {
3090 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 3104 record_unwind_current_buffer ();
3091 Fset_buffer (Fwindow_buffer (Qnil)); 3105 Fset_buffer (Fwindow_buffer (Qnil));
3092 } 3106 }
3093 3107
@@ -3124,7 +3138,7 @@ run_window_configuration_change_hook (struct frame *f)
3124DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, 3138DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
3125 Srun_window_configuration_change_hook, 1, 1, 0, 3139 Srun_window_configuration_change_hook, 1, 1, 0,
3126 doc: /* Run `window-configuration-change-hook' for FRAME. */) 3140 doc: /* Run `window-configuration-change-hook' for FRAME. */)
3127 (Lisp_Object frame) 3141 (Lisp_Object frame)
3128{ 3142{
3129 CHECK_LIVE_FRAME (frame); 3143 CHECK_LIVE_FRAME (frame);
3130 run_window_configuration_change_hook (XFRAME (frame)); 3144 run_window_configuration_change_hook (XFRAME (frame));
@@ -3191,7 +3205,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int
3191 because that might itself be a local variable. */ 3205 because that might itself be a local variable. */
3192 if (window_initialized) 3206 if (window_initialized)
3193 { 3207 {
3194 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 3208 record_unwind_current_buffer ();
3195 Fset_buffer (buffer); 3209 Fset_buffer (buffer);
3196 } 3210 }
3197 3211
@@ -5526,7 +5540,6 @@ the return value is nil. Otherwise the value is t. */)
5526 struct Lisp_Vector *saved_windows; 5540 struct Lisp_Vector *saved_windows;
5527 Lisp_Object new_current_buffer; 5541 Lisp_Object new_current_buffer;
5528 Lisp_Object frame; 5542 Lisp_Object frame;
5529 Lisp_Object auto_buffer_name;
5530 FRAME_PTR f; 5543 FRAME_PTR f;
5531 ptrdiff_t old_point = -1; 5544 ptrdiff_t old_point = -1;
5532 5545
@@ -5602,6 +5615,21 @@ the return value is nil. Otherwise the value is t. */)
5602 int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f); 5615 int previous_frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
5603 int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f); 5616 int previous_frame_tool_bar_lines = FRAME_TOOL_BAR_LINES (f);
5604 5617
5618 /* Don't do this within the main loop below: This may call Lisp
5619 code and is thus potentially unsafe while input is blocked. */
5620 for (k = 0; k < saved_windows->header.size; k++)
5621 {
5622 p = SAVED_WINDOW_N (saved_windows, k);
5623 window = p->window;
5624 w = XWINDOW (window);
5625 if (!NILP (w->buffer)
5626 && !EQ (w->buffer, p->buffer)
5627 && !NILP (BVAR (XBUFFER (p->buffer), name)))
5628 /* If a window we restore gets another buffer, record the
5629 window's old buffer. */
5630 call1 (Qrecord_window_buffer, window);
5631 }
5632
5605 /* The mouse highlighting code could get screwed up 5633 /* The mouse highlighting code could get screwed up
5606 if it runs during this. */ 5634 if it runs during this. */
5607 BLOCK_INPUT; 5635 BLOCK_INPUT;
@@ -5780,18 +5808,6 @@ the return value is nil. Otherwise the value is t. */)
5780 BUF_PT_BYTE (XBUFFER (w->buffer))); 5808 BUF_PT_BYTE (XBUFFER (w->buffer)));
5781 w->start_at_line_beg = 1; 5809 w->start_at_line_beg = 1;
5782 } 5810 }
5783 else if (STRINGP (auto_buffer_name =
5784 Fwindow_parameter (window, Qauto_buffer_name))
5785 && SCHARS (auto_buffer_name) != 0
5786 && (wset_buffer (w, Fget_buffer_create (auto_buffer_name)),
5787 !NILP (w->buffer)))
5788 {
5789 set_marker_restricted (w->start,
5790 make_number (0), w->buffer);
5791 set_marker_restricted (w->pointm,
5792 make_number (0), w->buffer);
5793 w->start_at_line_beg = 1;
5794 }
5795 else 5811 else
5796 /* Window has no live buffer, get one. */ 5812 /* Window has no live buffer, get one. */
5797 { 5813 {
@@ -5889,7 +5905,13 @@ the return value is nil. Otherwise the value is t. */)
5889 } 5905 }
5890 5906
5891 if (!NILP (new_current_buffer)) 5907 if (!NILP (new_current_buffer))
5892 Fset_buffer (new_current_buffer); 5908 {
5909 Fset_buffer (new_current_buffer);
5910 /* If the new current buffer doesn't appear in the selected
5911 window, go to its old point (see bug#12208). */
5912 if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer))
5913 Fgoto_char (make_number (old_point));
5914 }
5893 5915
5894 Vminibuf_scroll_window = data->minibuf_scroll_window; 5916 Vminibuf_scroll_window = data->minibuf_scroll_window;
5895 minibuf_selected_window = data->minibuf_selected_window; 5917 minibuf_selected_window = data->minibuf_selected_window;
@@ -6691,7 +6713,6 @@ syms_of_window (void)
6691 DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); 6713 DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook");
6692 DEFSYM (Qabove, "above"); 6714 DEFSYM (Qabove, "above");
6693 DEFSYM (Qbelow, "below"); 6715 DEFSYM (Qbelow, "below");
6694 DEFSYM (Qauto_buffer_name, "auto-buffer-name");
6695 DEFSYM (Qclone_of, "clone-of"); 6716 DEFSYM (Qclone_of, "clone-of");
6696 6717
6697 staticpro (&Vwindow_list); 6718 staticpro (&Vwindow_list);
diff --git a/src/window.h b/src/window.h
index 28b9678b667..dfb88b2cf3c 100644
--- a/src/window.h
+++ b/src/window.h
@@ -972,7 +972,6 @@ struct glyph *get_phys_cursor_glyph (struct window *w);
972extern Lisp_Object Qwindowp, Qwindow_live_p; 972extern Lisp_Object Qwindowp, Qwindow_live_p;
973extern Lisp_Object Vwindow_list; 973extern Lisp_Object Vwindow_list;
974 974
975extern struct window *decode_valid_window (Lisp_Object);
976extern struct window *decode_live_window (Lisp_Object); 975extern struct window *decode_live_window (Lisp_Object);
977extern int compare_window_configurations (Lisp_Object, Lisp_Object, int); 976extern int compare_window_configurations (Lisp_Object, Lisp_Object, int);
978extern void mark_window_cursors_off (struct window *); 977extern void mark_window_cursors_off (struct window *);
diff --git a/src/xdisp.c b/src/xdisp.c
index e41783d03c1..86f041dea4d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -768,9 +768,9 @@ static int clear_image_cache_count;
768static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 }; 768static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
769#endif 769#endif
770 770
771/* Non-zero while redisplay_internal is in progress. */ 771/* True while redisplay_internal is in progress. */
772 772
773int redisplaying_p; 773bool redisplaying_p;
774 774
775static Lisp_Object Qinhibit_free_realized_faces; 775static Lisp_Object Qinhibit_free_realized_faces;
776static Lisp_Object Qmode_line_default_help_echo; 776static Lisp_Object Qmode_line_default_help_echo;
@@ -2420,7 +2420,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
2420static Lisp_Object 2420static Lisp_Object
2421safe_eval_handler (Lisp_Object arg, ptrdiff_t nargs, Lisp_Object *args) 2421safe_eval_handler (Lisp_Object arg, ptrdiff_t nargs, Lisp_Object *args)
2422{ 2422{
2423 add_to_log ("Error during redisplay: %S signalled %S", 2423 add_to_log ("Error during redisplay: %S signaled %S",
2424 Flist (nargs, args), arg); 2424 Flist (nargs, args), arg);
2425 return Qnil; 2425 return Qnil;
2426} 2426}
@@ -10480,11 +10480,10 @@ current_message_1 (ptrdiff_t a1, Lisp_Object a2, ptrdiff_t a3, ptrdiff_t a4)
10480 empty. This is a relatively infrequent operation, so it's not 10480 empty. This is a relatively infrequent operation, so it's not
10481 worth optimizing. */ 10481 worth optimizing. */
10482 10482
10483int 10483bool
10484push_message (void) 10484push_message (void)
10485{ 10485{
10486 Lisp_Object msg; 10486 Lisp_Object msg = current_message ();
10487 msg = current_message ();
10488 Vmessage_stack = Fcons (msg, Vmessage_stack); 10487 Vmessage_stack = Fcons (msg, Vmessage_stack);
10489 return STRINGP (msg); 10488 return STRINGP (msg);
10490} 10489}
@@ -12967,12 +12966,11 @@ redisplay_internal (void)
12967 if (redisplaying_p) 12966 if (redisplaying_p)
12968 return; 12967 return;
12969 12968
12970 /* Record a function that resets redisplaying_p to its old value 12969 /* Record a function that clears redisplaying_p
12971 when we leave this function. */ 12970 when we leave this function. */
12972 count = SPECPDL_INDEX (); 12971 count = SPECPDL_INDEX ();
12973 record_unwind_protect (unwind_redisplay, 12972 record_unwind_protect (unwind_redisplay, selected_frame);
12974 Fcons (make_number (redisplaying_p), selected_frame)); 12973 redisplaying_p = 1;
12975 ++redisplaying_p;
12976 specbind (Qinhibit_free_realized_faces, Qnil); 12974 specbind (Qinhibit_free_realized_faces, Qnil);
12977 12975
12978 { 12976 {
@@ -13710,21 +13708,15 @@ redisplay_preserve_echo_area (int from_where)
13710} 13708}
13711 13709
13712 13710
13713/* Function registered with record_unwind_protect in 13711/* Function registered with record_unwind_protect in redisplay_internal.
13714 redisplay_internal. Reset redisplaying_p to the value it had 13712 Clear redisplaying_p. Also, select the previously
13715 before redisplay_internal was called, and clear
13716 prevent_freeing_realized_faces_p. It also selects the previously
13717 selected frame, unless it has been deleted (by an X connection 13713 selected frame, unless it has been deleted (by an X connection
13718 failure during redisplay, for example). */ 13714 failure during redisplay, for example). */
13719 13715
13720static Lisp_Object 13716static Lisp_Object
13721unwind_redisplay (Lisp_Object val) 13717unwind_redisplay (Lisp_Object old_frame)
13722{ 13718{
13723 Lisp_Object old_redisplaying_p, old_frame; 13719 redisplaying_p = 0;
13724
13725 old_redisplaying_p = XCAR (val);
13726 redisplaying_p = XFASTINT (old_redisplaying_p);
13727 old_frame = XCDR (val);
13728 if (! EQ (old_frame, selected_frame) 13720 if (! EQ (old_frame, selected_frame)
13729 && FRAME_LIVE_P (XFRAME (old_frame))) 13721 && FRAME_LIVE_P (XFRAME (old_frame)))
13730 select_frame_for_redisplay (old_frame); 13722 select_frame_for_redisplay (old_frame);
@@ -14552,8 +14544,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14552 make_number (CHARPOS (startp))); 14544 make_number (CHARPOS (startp)));
14553 SET_TEXT_POS_FROM_MARKER (startp, w->start); 14545 SET_TEXT_POS_FROM_MARKER (startp, w->start);
14554 /* In case the hook functions switch buffers. */ 14546 /* In case the hook functions switch buffers. */
14555 if (current_buffer != XBUFFER (w->buffer)) 14547 set_buffer_internal (XBUFFER (w->buffer));
14556 set_buffer_internal_1 (XBUFFER (w->buffer));
14557 } 14548 }
14558 14549
14559 return startp; 14550 return startp;
@@ -15381,7 +15372,7 @@ set_vertical_scroll_bar (struct window *w)
15381 selected_window is redisplayed. 15372 selected_window is redisplayed.
15382 15373
15383 We can return without actually redisplaying the window if 15374 We can return without actually redisplaying the window if
15384 fonts_changed_p is nonzero. In that case, redisplay_internal will 15375 fonts_changed_p. In that case, redisplay_internal will
15385 retry. */ 15376 retry. */
15386 15377
15387static void 15378static void
@@ -16225,7 +16216,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16225 } 16216 }
16226#endif /* HAVE_WINDOW_SYSTEM */ 16217#endif /* HAVE_WINDOW_SYSTEM */
16227 16218
16228 /* We go to this label, with fonts_changed_p nonzero, 16219 /* We go to this label, with fonts_changed_p set,
16229 if it is necessary to try again using larger glyph matrices. 16220 if it is necessary to try again using larger glyph matrices.
16230 We have to redeem the scroll bar even in this case, 16221 We have to redeem the scroll bar even in this case,
16231 because the loop in redisplay_internal expects that. */ 16222 because the loop in redisplay_internal expects that. */
@@ -17706,15 +17697,15 @@ try_window_id (struct window *w)
17706 { 17697 {
17707 rotate_matrix (current_matrix, first_unchanged_at_end_vpos + dvpos, 17698 rotate_matrix (current_matrix, first_unchanged_at_end_vpos + dvpos,
17708 bottom_vpos, dvpos); 17699 bottom_vpos, dvpos);
17709 enable_glyph_matrix_rows (current_matrix, bottom_vpos + dvpos, 17700 clear_glyph_matrix_rows (current_matrix, bottom_vpos + dvpos,
17710 bottom_vpos, 0); 17701 bottom_vpos);
17711 } 17702 }
17712 else if (dvpos > 0) 17703 else if (dvpos > 0)
17713 { 17704 {
17714 rotate_matrix (current_matrix, first_unchanged_at_end_vpos, 17705 rotate_matrix (current_matrix, first_unchanged_at_end_vpos,
17715 bottom_vpos, dvpos); 17706 bottom_vpos, dvpos);
17716 enable_glyph_matrix_rows (current_matrix, first_unchanged_at_end_vpos, 17707 clear_glyph_matrix_rows (current_matrix, first_unchanged_at_end_vpos,
17717 first_unchanged_at_end_vpos + dvpos, 0); 17708 first_unchanged_at_end_vpos + dvpos);
17718 } 17709 }
17719 17710
17720 /* For frame-based redisplay, make sure that current frame and window 17711 /* For frame-based redisplay, make sure that current frame and window
diff --git a/src/xfaces.c b/src/xfaces.c
index 46121d66606..4df5caf6f2a 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -225,11 +225,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
225#include "dosfns.h" 225#include "dosfns.h"
226#endif 226#endif
227 227
228#ifdef WINDOWSNT 228#ifdef HAVE_WINDOW_SYSTEM
229#include "w32term.h" 229#include TERM_HEADER
230#include "fontset.h" 230#include "fontset.h"
231/* Redefine X specifics to W32 equivalents to avoid cluttering the 231#ifdef WINDOWSNT
232 code with #ifdef blocks. */
233#undef FRAME_X_DISPLAY_INFO 232#undef FRAME_X_DISPLAY_INFO
234#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO 233#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
235#define x_display_info w32_display_info 234#define x_display_info w32_display_info
@@ -238,13 +237,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
238#endif /* WINDOWSNT */ 237#endif /* WINDOWSNT */
239 238
240#ifdef HAVE_NS 239#ifdef HAVE_NS
241#include "nsterm.h"
242#undef FRAME_X_DISPLAY_INFO 240#undef FRAME_X_DISPLAY_INFO
243#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO 241#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
244#define x_display_info ns_display_info 242#define x_display_info ns_display_info
245#define check_x check_ns 243#define check_x check_ns
246#define GCGraphicsExposures 0 244#define GCGraphicsExposures 0
247#endif /* HAVE_NS */ 245#endif /* HAVE_NS */
246#endif /* HAVE_WINDOW_SYSTEM */
248 247
249#include "buffer.h" 248#include "buffer.h"
250#include "dispextern.h" 249#include "dispextern.h"
@@ -254,9 +253,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
254#include "termchar.h" 253#include "termchar.h"
255 254
256#include "font.h" 255#include "font.h"
257#ifdef HAVE_WINDOW_SYSTEM
258#include "fontset.h"
259#endif /* HAVE_WINDOW_SYSTEM */
260 256
261#ifdef HAVE_X_WINDOWS 257#ifdef HAVE_X_WINDOWS
262 258
@@ -319,9 +315,10 @@ static Lisp_Object QCfontset;
319Lisp_Object Qnormal; 315Lisp_Object Qnormal;
320Lisp_Object Qbold; 316Lisp_Object Qbold;
321static Lisp_Object Qline, Qwave; 317static Lisp_Object Qline, Qwave;
322Lisp_Object Qultra_light, Qextra_light, Qlight; 318static Lisp_Object Qultra_light, Qreverse_oblique, Qreverse_italic;
319Lisp_Object Qextra_light, Qlight;
323Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; 320Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold;
324Lisp_Object Qoblique, Qreverse_oblique, Qreverse_italic; 321Lisp_Object Qoblique;
325Lisp_Object Qitalic; 322Lisp_Object Qitalic;
326static Lisp_Object Qultra_condensed, Qextra_condensed; 323static Lisp_Object Qultra_condensed, Qextra_condensed;
327Lisp_Object Qcondensed; 324Lisp_Object Qcondensed;
@@ -456,18 +453,7 @@ static int menu_face_changed_default;
456struct table_entry; 453struct table_entry;
457struct named_merge_point; 454struct named_merge_point;
458 455
459static void map_tty_color (struct frame *, struct face *,
460 enum lface_attribute_index, int *);
461static Lisp_Object resolve_face_name (Lisp_Object, int);
462static void set_font_frame_param (Lisp_Object, Lisp_Object); 456static void set_font_frame_param (Lisp_Object, Lisp_Object);
463static int get_lface_attributes (struct frame *, Lisp_Object, Lisp_Object *,
464 int, struct named_merge_point *);
465static ptrdiff_t load_pixmap (struct frame *, Lisp_Object,
466 unsigned *, unsigned *);
467static struct frame *frame_or_selected_frame (Lisp_Object, int);
468static void load_face_colors (struct frame *, struct face *, Lisp_Object *);
469static void free_face_colors (struct frame *, struct face *);
470static int face_color_gray_p (struct frame *, const char *);
471static struct face *realize_face (struct face_cache *, Lisp_Object *, 457static struct face *realize_face (struct face_cache *, Lisp_Object *,
472 int); 458 int);
473static struct face *realize_non_ascii_face (struct frame *, Lisp_Object, 459static struct face *realize_non_ascii_face (struct frame *, Lisp_Object,
@@ -477,38 +463,11 @@ static struct face *realize_tty_face (struct face_cache *, Lisp_Object *);
477static int realize_basic_faces (struct frame *); 463static int realize_basic_faces (struct frame *);
478static int realize_default_face (struct frame *); 464static int realize_default_face (struct frame *);
479static void realize_named_face (struct frame *, Lisp_Object, int); 465static void realize_named_face (struct frame *, Lisp_Object, int);
480static int lface_fully_specified_p (Lisp_Object *);
481static int lface_equal_p (Lisp_Object *, Lisp_Object *);
482static unsigned hash_string_case_insensitive (Lisp_Object);
483static unsigned lface_hash (Lisp_Object *);
484static int lface_same_font_attributes_p (Lisp_Object *, Lisp_Object *);
485static struct face_cache *make_face_cache (struct frame *); 466static struct face_cache *make_face_cache (struct frame *);
486static void clear_face_gcs (struct face_cache *); 467static void clear_face_gcs (struct face_cache *);
487static void free_face_cache (struct face_cache *); 468static void free_face_cache (struct face_cache *);
488static int face_fontset (Lisp_Object *);
489static void merge_face_vectors (struct frame *, Lisp_Object *, Lisp_Object*,
490 struct named_merge_point *);
491static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, 469static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *,
492 int, struct named_merge_point *); 470 int, struct named_merge_point *);
493static int set_lface_from_font (struct frame *, Lisp_Object, Lisp_Object,
494 int);
495static Lisp_Object lface_from_face_name (struct frame *, Lisp_Object, int);
496static struct face *make_realized_face (Lisp_Object *);
497static void cache_face (struct face_cache *, struct face *, unsigned);
498static void uncache_face (struct face_cache *, struct face *);
499
500#ifdef HAVE_WINDOW_SYSTEM
501
502static GC x_create_gc (struct frame *, unsigned long, XGCValues *);
503static void x_free_gc (struct frame *, GC);
504
505#ifdef USE_X_TOOLKIT
506static void x_update_menu_appearance (struct frame *);
507
508extern void free_frame_menubar (struct frame *);
509#endif /* USE_X_TOOLKIT */
510
511#endif /* HAVE_WINDOW_SYSTEM */
512 471
513 472
514/*********************************************************************** 473/***********************************************************************
@@ -2565,13 +2524,13 @@ merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
2565 } 2524 }
2566 else if (EQ (keyword, QCstipple)) 2525 else if (EQ (keyword, QCstipple))
2567 { 2526 {
2568#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 2527#if defined (HAVE_WINDOW_SYSTEM)
2569 Lisp_Object pixmap_p = Fbitmap_spec_p (value); 2528 Lisp_Object pixmap_p = Fbitmap_spec_p (value);
2570 if (!NILP (pixmap_p)) 2529 if (!NILP (pixmap_p))
2571 to[LFACE_STIPPLE_INDEX] = value; 2530 to[LFACE_STIPPLE_INDEX] = value;
2572 else 2531 else
2573 err = 1; 2532 err = 1;
2574#endif 2533#endif /* HAVE_WINDOW_SYSTEM */
2575 } 2534 }
2576 else if (EQ (keyword, QCwidth)) 2535 else if (EQ (keyword, QCwidth))
2577 { 2536 {
@@ -2781,8 +2740,7 @@ The value is TO. */)
2781 copy = Finternal_make_lisp_face (to, new_frame); 2740 copy = Finternal_make_lisp_face (to, new_frame);
2782 } 2741 }
2783 2742
2784 memcpy (XVECTOR (copy)->contents, XVECTOR (lface)->contents, 2743 vcopy (copy, 0, XVECTOR (lface)->contents, LFACE_VECTOR_SIZE);
2785 LFACE_VECTOR_SIZE * word_size);
2786 2744
2787 /* Changing a named face means that all realized faces depending on 2745 /* Changing a named face means that all realized faces depending on
2788 that face are invalid. Since we cannot tell which realized faces 2746 that face are invalid. Since we cannot tell which realized faces
@@ -3126,14 +3084,14 @@ FRAME 0 means change the face on all frames, and change the default
3126 } 3084 }
3127 else if (EQ (attr, QCstipple)) 3085 else if (EQ (attr, QCstipple))
3128 { 3086 {
3129#if defined (HAVE_X_WINDOWS) || defined (HAVE_NS) 3087#if defined (HAVE_WINDOW_SYSTEM)
3130 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value) 3088 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)
3131 && !NILP (value) 3089 && !NILP (value)
3132 && NILP (Fbitmap_spec_p (value))) 3090 && NILP (Fbitmap_spec_p (value)))
3133 signal_error ("Invalid stipple attribute", value); 3091 signal_error ("Invalid stipple attribute", value);
3134 old_value = LFACE_STIPPLE (lface); 3092 old_value = LFACE_STIPPLE (lface);
3135 ASET (lface, LFACE_STIPPLE_INDEX, value); 3093 ASET (lface, LFACE_STIPPLE_INDEX, value);
3136#endif /* HAVE_X_WINDOWS || HAVE_NS */ 3094#endif /* HAVE_WINDOW_SYSTEM */
3137 } 3095 }
3138 else if (EQ (attr, QCwidth)) 3096 else if (EQ (attr, QCwidth))
3139 { 3097 {
@@ -3831,9 +3789,9 @@ Default face attributes override any local face attributes. */)
3831 gvec = XVECTOR (global_lface)->contents; 3789 gvec = XVECTOR (global_lface)->contents;
3832 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) 3790 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
3833 if (IGNORE_DEFFACE_P (gvec[i])) 3791 if (IGNORE_DEFFACE_P (gvec[i]))
3834 lvec[i] = Qunspecified; 3792 ASET (local_lface, i, Qunspecified);
3835 else if (! UNSPECIFIEDP (gvec[i])) 3793 else if (! UNSPECIFIEDP (gvec[i]))
3836 lvec[i] = gvec[i]; 3794 ASET (local_lface, i, AREF (global_lface, i));
3837 3795
3838 /* If the default face was changed, update the face cache and the 3796 /* If the default face was changed, update the face cache and the
3839 `font' frame parameter. */ 3797 `font' frame parameter. */
@@ -3850,7 +3808,7 @@ Default face attributes override any local face attributes. */)
3850 the previously-cached vector. */ 3808 the previously-cached vector. */
3851 memcpy (attrs, oldface->lface, sizeof attrs); 3809 memcpy (attrs, oldface->lface, sizeof attrs);
3852 merge_face_vectors (f, lvec, attrs, 0); 3810 merge_face_vectors (f, lvec, attrs, 0);
3853 memcpy (lvec, attrs, sizeof attrs); 3811 vcopy (local_lface, 0, attrs, LFACE_VECTOR_SIZE);
3854 newface = realize_face (c, lvec, DEFAULT_FACE_ID); 3812 newface = realize_face (c, lvec, DEFAULT_FACE_ID);
3855 3813
3856 if ((! UNSPECIFIEDP (gvec[LFACE_FAMILY_INDEX]) 3814 if ((! UNSPECIFIEDP (gvec[LFACE_FAMILY_INDEX])
diff --git a/src/xfont.c b/src/xfont.c
index 072bce7bb0a..be9556d585a 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -46,7 +46,6 @@ struct xfont_info
46}; 46};
47 47
48/* Prototypes of support functions. */ 48/* Prototypes of support functions. */
49extern void x_clear_errors (Display *);
50 49
51static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *); 50static XCharStruct *xfont_get_pcm (XFontStruct *, XChar2b *);
52 51
@@ -390,7 +389,7 @@ xfont_list_pattern (Display *display, const char *pattern,
390 Lisp_Object scripts = Qnil; 389 Lisp_Object scripts = Qnil;
391 390
392 for (i = 0; i < ASIZE (xfont_scratch_props); i++) 391 for (i = 0; i < ASIZE (xfont_scratch_props); i++)
393 props[i] = Qnil; 392 ASET (xfont_scratch_props, i, Qnil);
394 for (i = 0; i < num_fonts; i++) 393 for (i = 0; i < num_fonts; i++)
395 indices[i] = names[i]; 394 indices[i] = names[i];
396 qsort (indices, num_fonts, sizeof (char *), compare_font_names); 395 qsort (indices, num_fonts, sizeof (char *), compare_font_names);
@@ -467,9 +466,9 @@ xfont_list_pattern (Display *display, const char *pattern,
467 word_size * 7) 466 word_size * 7)
468 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7])) 467 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
469 { 468 {
470 memcpy (props, aref_addr (entity, FONT_FOUNDRY_INDEX), 469 vcopy (xfont_scratch_props, 0,
471 word_size * 7); 470 aref_addr (entity, FONT_FOUNDRY_INDEX), 7);
472 props[7] = AREF (entity, FONT_SPACING_INDEX); 471 ASET (xfont_scratch_props, 7, AREF (entity, FONT_SPACING_INDEX));
473 scripts = xfont_supported_scripts (display, indices[i], 472 scripts = xfont_supported_scripts (display, indices[i],
474 xfont_scratch_props, encoding); 473 xfont_scratch_props, encoding);
475 } 474 }
diff --git a/src/xgselect.c b/src/xgselect.c
index 04ca00274e8..0c00d815820 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -29,9 +29,6 @@ along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */
29#include <setjmp.h> 29#include <setjmp.h>
30#include "xterm.h" 30#include "xterm.h"
31 31
32static GPollFD *gfds;
33static ptrdiff_t gfds_size;
34
35int 32int
36xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 33xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
37 EMACS_TIME *timeout, sigset_t *sigmask) 34 EMACS_TIME *timeout, sigset_t *sigmask)
@@ -41,35 +38,31 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
41 38
42 GMainContext *context; 39 GMainContext *context;
43 int have_wfds = wfds != NULL; 40 int have_wfds = wfds != NULL;
44 int n_gfds = 0, retval = 0, our_fds = 0, max_fds = fds_lim - 1; 41 GPollFD gfds_buf[128];
42 GPollFD *gfds = gfds_buf;
43 int gfds_size = sizeof gfds_buf / sizeof *gfds_buf;
44 int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1;
45 int i, nfds, tmo_in_millisec; 45 int i, nfds, tmo_in_millisec;
46 USE_SAFE_ALLOCA;
46 47
47 if (!x_in_use) 48 if (! (x_in_use
48 return pselect (fds_lim, rfds, wfds, efds, tmop, sigmask); 49 && g_main_context_pending (context = g_main_context_default ())))
50 return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask);
49 51
50 if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds)); 52 if (rfds) memcpy (&all_rfds, rfds, sizeof (all_rfds));
51 else FD_ZERO (&all_rfds); 53 else FD_ZERO (&all_rfds);
52 if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds)); 54 if (wfds) memcpy (&all_wfds, wfds, sizeof (all_rfds));
53 else FD_ZERO (&all_wfds); 55 else FD_ZERO (&all_wfds);
54 56
55 /* Update event sources in GLib. */ 57 n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec,
56 context = g_main_context_default (); 58 gfds, gfds_size);
57 g_main_context_pending (context); 59 if (gfds_size < n_gfds)
58 60 {
59 do { 61 SAFE_NALLOCA (gfds, sizeof *gfds, n_gfds);
60 if (n_gfds > gfds_size) 62 gfds_size = n_gfds;
61 { 63 n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec,
62 xfree (gfds); 64 gfds, gfds_size);
63 gfds = xpalloc (0, &gfds_size, n_gfds - gfds_size, INT_MAX, 65 }
64 sizeof *gfds);
65 }
66
67 n_gfds = g_main_context_query (context,
68 G_PRIORITY_LOW,
69 &tmo_in_millisec,
70 gfds,
71 gfds_size);
72 } while (n_gfds > gfds_size);
73 66
74 for (i = 0; i < n_gfds; ++i) 67 for (i = 0; i < n_gfds; ++i)
75 { 68 {
@@ -86,6 +79,8 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
86 } 79 }
87 } 80 }
88 81
82 SAFE_FREE ();
83
89 if (tmo_in_millisec >= 0) 84 if (tmo_in_millisec >= 0)
90 { 85 {
91 tmo = make_emacs_time (tmo_in_millisec / 1000, 86 tmo = make_emacs_time (tmo_in_millisec / 1000,
@@ -147,12 +142,3 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
147 return retval; 142 return retval;
148} 143}
149#endif /* USE_GTK || HAVE_GCONF || HAVE_GSETTINGS */ 144#endif /* USE_GTK || HAVE_GCONF || HAVE_GSETTINGS */
150
151void
152xgselect_initialize (void)
153{
154#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
155 gfds_size = 128;
156 gfds = xmalloc (gfds_size * sizeof *gfds);
157#endif
158}
diff --git a/src/xgselect.h b/src/xgselect.h
index 8e5614ea972..5509e23c5c0 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -31,6 +31,4 @@ extern int xg_select (int max_fds,
31 EMACS_TIME *timeout, 31 EMACS_TIME *timeout,
32 sigset_t *sigmask); 32 sigset_t *sigmask);
33 33
34extern void xgselect_initialize (void);
35
36#endif /* XGSELECT_H */ 34#endif /* XGSELECT_H */
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 1f6eb84260e..cddbb2aae86 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -97,7 +97,7 @@ ice_connection_closed (void)
97 open to a session manager, just return. */ 97 open to a session manager, just return. */
98 98
99static void 99static void
100x_session_check_input (int fd, void *data, int for_read) 100x_session_check_input (int fd, void *data)
101{ 101{
102 int ret; 102 int ret;
103 103
diff --git a/src/xterm.c b/src/xterm.c
index 118c8767c23..f497b5322bf 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -165,13 +165,6 @@ struct x_display_info *x_display_list;
165 165
166Lisp_Object x_display_name_list; 166Lisp_Object x_display_name_list;
167 167
168/* Frame being updated by update_frame. This is declared in term.c.
169 This is set by update_begin and looked at by all the XT functions.
170 It is zero while not inside an update. In that case, the XT
171 functions assume that `selected_frame' is the frame to apply to. */
172
173extern struct frame *updating_frame;
174
175/* This is a frame waiting to be auto-raised, within XTread_socket. */ 168/* This is a frame waiting to be auto-raised, within XTread_socket. */
176 169
177static struct frame *pending_autoraise_frame; 170static struct frame *pending_autoraise_frame;
@@ -7850,7 +7843,7 @@ x_connection_closed (Display *dpy, const char *error_message)
7850 (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once, 7843 (https://bugzilla.gnome.org/show_bug.cgi?id=85715). Once,
7851 the resulting Glib error message loop filled a user's disk. 7844 the resulting Glib error message loop filled a user's disk.
7852 To avoid this, kill Emacs unconditionally on disconnect. */ 7845 To avoid this, kill Emacs unconditionally on disconnect. */
7853 shut_down_emacs (0, 0, Qnil); 7846 shut_down_emacs (0, Qnil);
7854 fprintf (stderr, "%s\n\ 7847 fprintf (stderr, "%s\n\
7855When compiled with GTK, Emacs cannot recover from X disconnects.\n\ 7848When compiled with GTK, Emacs cannot recover from X disconnects.\n\
7856This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ 7849This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
@@ -10609,8 +10602,6 @@ x_activate_timeout_atimer (void)
10609 10602
10610/* Set up use of X before we make the first connection. */ 10603/* Set up use of X before we make the first connection. */
10611 10604
10612extern frame_parm_handler x_frame_parm_handlers[];
10613
10614static struct redisplay_interface x_redisplay_interface = 10605static struct redisplay_interface x_redisplay_interface =
10615 { 10606 {
10616 x_frame_parm_handlers, 10607 x_frame_parm_handlers,
@@ -10815,8 +10806,6 @@ x_initialize (void)
10815 XSetIOErrorHandler (x_io_error_quitter); 10806 XSetIOErrorHandler (x_io_error_quitter);
10816 10807
10817 signal (SIGPIPE, x_connection_signal); 10808 signal (SIGPIPE, x_connection_signal);
10818
10819 xgselect_initialize ();
10820} 10809}
10821 10810
10822 10811
diff --git a/src/xterm.h b/src/xterm.h
index 86a76fd81a9..2d718f49118 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -16,6 +16,9 @@ GNU General Public License for more details.
16You should have received a copy of the GNU General Public License 16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#ifndef XTERM_H
20#define XTERM_H
21
19#include <X11/Xlib.h> 22#include <X11/Xlib.h>
20#include <X11/cursorfont.h> 23#include <X11/cursorfont.h>
21 24
@@ -367,13 +370,14 @@ extern int use_xim;
367extern void check_x (void); 370extern void check_x (void);
368 371
369extern struct frame *x_window_to_frame (struct x_display_info *, int); 372extern struct frame *x_window_to_frame (struct x_display_info *, int);
370
371extern struct frame *x_any_window_to_frame (struct x_display_info *, int); 373extern struct frame *x_any_window_to_frame (struct x_display_info *, int);
372extern struct frame *x_menubar_window_to_frame (struct x_display_info *, 374extern struct frame *x_menubar_window_to_frame (struct x_display_info *,
373 XEvent *); 375 XEvent *);
374
375extern struct frame *x_top_window_to_frame (struct x_display_info *, int); 376extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
376 377
378extern struct frame *x_menubar_window_to_frame (struct x_display_info *,
379 XEvent *);
380
377#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) 381#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
378#define x_any_window_to_frame x_window_to_frame 382#define x_any_window_to_frame x_window_to_frame
379#define x_top_window_to_frame x_window_to_frame 383#define x_top_window_to_frame x_window_to_frame
@@ -389,7 +393,6 @@ extern struct x_display_info *x_display_list;
389extern Lisp_Object x_display_name_list; 393extern Lisp_Object x_display_name_list;
390 394
391extern struct x_display_info *x_display_info_for_display (Display *); 395extern struct x_display_info *x_display_info_for_display (Display *);
392extern void x_set_frame_alpha (struct frame *);
393 396
394extern struct x_display_info *x_term_init (Lisp_Object, char *, char *); 397extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
395extern int x_display_ok (const char *); 398extern int x_display_ok (const char *);
@@ -544,9 +547,6 @@ struct x_output
544 /* Non-zero means hourglass cursor is currently displayed. */ 547 /* Non-zero means hourglass cursor is currently displayed. */
545 unsigned hourglass_p : 1; 548 unsigned hourglass_p : 1;
546 549
547 /* Flag to set when the X window needs to be completely repainted. */
548 int needs_exposure;
549
550 /* These are the current window manager hints. It seems that 550 /* These are the current window manager hints. It seems that
551 XSetWMHints, when presented with an unset bit in the `flags' 551 XSetWMHints, when presented with an unset bit in the `flags'
552 member of the hints structure, does not leave the corresponding 552 member of the hints structure, does not leave the corresponding
@@ -944,7 +944,6 @@ XrmDatabase x_load_resources (Display *, const char *, const char *,
944/* Defined in xterm.c */ 944/* Defined in xterm.c */
945 945
946extern int x_text_icon (struct frame *, const char *); 946extern int x_text_icon (struct frame *, const char *);
947extern int x_bitmap_icon (struct frame *, Lisp_Object);
948extern void x_catch_errors (Display *); 947extern void x_catch_errors (Display *);
949extern void x_check_errors (Display *, const char *) 948extern void x_check_errors (Display *, const char *)
950 ATTRIBUTE_FORMAT_PRINTF (2, 0); 949 ATTRIBUTE_FORMAT_PRINTF (2, 0);
@@ -956,11 +955,6 @@ extern void x_set_mouse_position (struct frame *, int, int);
956extern void x_set_mouse_pixel_position (struct frame *, int, int); 955extern void x_set_mouse_pixel_position (struct frame *, int, int);
957extern void xembed_request_focus (struct frame *); 956extern void xembed_request_focus (struct frame *);
958extern void x_ewmh_activate_frame (struct frame *); 957extern void x_ewmh_activate_frame (struct frame *);
959extern void x_make_frame_visible (struct frame *);
960extern void x_make_frame_invisible (struct frame *);
961extern void x_iconify_frame (struct frame *);
962extern void x_free_frame_resources (struct frame *);
963extern void x_wm_set_size_hint (struct frame *, long, int);
964extern void x_delete_terminal (struct terminal *terminal); 958extern void x_delete_terminal (struct terminal *terminal);
965extern unsigned long x_copy_color (struct frame *, unsigned long); 959extern unsigned long x_copy_color (struct frame *, unsigned long);
966#ifdef USE_X_TOOLKIT 960#ifdef USE_X_TOOLKIT
@@ -973,7 +967,6 @@ extern int x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
973 double, int); 967 double, int);
974#endif 968#endif
975extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *); 969extern int x_alloc_nearest_color (struct frame *, Colormap, XColor *);
976extern void x_query_colors (struct frame *f, XColor *, int);
977extern void x_query_color (struct frame *f, XColor *); 970extern void x_query_color (struct frame *f, XColor *);
978extern void x_clear_area (Display *, Window, int, int, int, int, int); 971extern void x_clear_area (Display *, Window, int, int, int, int, int);
979#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK 972#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK
@@ -1032,8 +1025,6 @@ extern int xg_set_icon (struct frame *, Lisp_Object);
1032extern int xg_set_icon_from_xpm_data (struct frame *, const char**); 1025extern int xg_set_icon_from_xpm_data (struct frame *, const char**);
1033#endif /* USE_GTK */ 1026#endif /* USE_GTK */
1034 1027
1035extern void x_real_positions (struct frame *, int *, int *);
1036extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1037extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); 1028extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
1038extern void xic_free_xfontset (struct frame *); 1029extern void xic_free_xfontset (struct frame *);
1039extern void create_frame_xic (struct frame *); 1030extern void create_frame_xic (struct frame *);
@@ -1043,9 +1034,6 @@ extern void xic_set_statusarea (struct frame *);
1043extern void xic_set_xfontset (struct frame *, const char *); 1034extern void xic_set_xfontset (struct frame *, const char *);
1044extern int x_pixel_width (struct frame *); 1035extern int x_pixel_width (struct frame *);
1045extern int x_pixel_height (struct frame *); 1036extern int x_pixel_height (struct frame *);
1046extern int x_char_width (struct frame *);
1047extern int x_char_height (struct frame *);
1048extern void x_sync (struct frame *);
1049extern int x_defined_color (struct frame *, const char *, XColor *, int); 1037extern int x_defined_color (struct frame *, const char *, XColor *, int);
1050#ifdef HAVE_X_I18N 1038#ifdef HAVE_X_I18N
1051extern void free_frame_xic (struct frame *); 1039extern void free_frame_xic (struct frame *);
@@ -1053,7 +1041,6 @@ extern void free_frame_xic (struct frame *);
1053extern char * xic_create_fontsetname (const char *base_fontname, int motif); 1041extern char * xic_create_fontsetname (const char *base_fontname, int motif);
1054# endif 1042# endif
1055#endif 1043#endif
1056extern void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
1057 1044
1058/* Defined in xfaces.c */ 1045/* Defined in xfaces.c */
1059 1046
@@ -1070,10 +1057,8 @@ extern void x_menu_set_in_use (int);
1070#ifdef USE_MOTIF 1057#ifdef USE_MOTIF
1071extern void x_menu_wait_for_event (void *data); 1058extern void x_menu_wait_for_event (void *data);
1072#endif 1059#endif
1073extern void x_activate_menubar (struct frame *);
1074extern int popup_activated (void); 1060extern int popup_activated (void);
1075extern void initialize_frame_menubar (struct frame *); 1061extern void initialize_frame_menubar (struct frame *);
1076extern void free_frame_menubar (struct frame *);
1077 1062
1078/* Defined in widget.c */ 1063/* Defined in widget.c */
1079 1064
@@ -1115,3 +1100,5 @@ extern Lisp_Object Qx_gtk_map_stock;
1115 (nr).y = (ry), \ 1100 (nr).y = (ry), \
1116 (nr).width = (rwidth), \ 1101 (nr).width = (rwidth), \
1117 (nr).height = (rheight)) 1102 (nr).height = (rheight))
1103
1104#endif /* XTERM_H */