aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2012-08-28 22:44:20 +0900
committerKenichi Handa2012-08-28 22:44:20 +0900
commit4eb4de01df384be9b8d811f7ab476eeb37ece748 (patch)
treed04f0dae31dd8b533a0c3cd738430841ce7ebb84 /src
parentfabc1281e9cde34ff9a19d843316d2ceca8647ad (diff)
parent4f2daf31078e2cc059710e129dffe0beed8fc7c2 (diff)
downloademacs-4eb4de01df384be9b8d811f7ab476eeb37ece748.tar.gz
emacs-4eb4de01df384be9b8d811f7ab476eeb37ece748.zip
merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog308
-rw-r--r--src/Makefile.in5
-rw-r--r--src/alloc.c26
-rw-r--r--src/atimer.c2
-rw-r--r--src/atimer.h3
-rw-r--r--src/bidi.c63
-rw-r--r--src/buffer.c146
-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/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/data.c55
-rw-r--r--src/dbusbind.c7
-rw-r--r--src/dired.c38
-rw-r--r--src/dispextern.h36
-rw-r--r--src/dispnew.c273
-rw-r--r--src/editfns.c7
-rw-r--r--src/emacs.c8
-rw-r--r--src/eval.c28
-rw-r--r--src/fileio.c8
-rw-r--r--src/fns.c10
-rw-r--r--src/frame.c1
-rw-r--r--src/frame.h16
-rw-r--r--src/insdel.c8
-rw-r--r--src/keyboard.c10
-rw-r--r--src/keymap.c4
-rw-r--r--src/lisp.h63
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/minibuf.c2
-rw-r--r--src/nsmenu.m29
-rw-r--r--src/nsterm.h1
-rw-r--r--src/nsterm.m3
-rw-r--r--src/print.c5
-rw-r--r--src/process.c20
-rw-r--r--src/process.h4
-rw-r--r--src/textprop.c4
-rw-r--r--src/undo.c2
-rw-r--r--src/w32.c4
-rw-r--r--src/window.c22
-rw-r--r--src/window.h1
-rw-r--r--src/xdisp.c17
-rw-r--r--src/xgselect.c52
-rw-r--r--src/xgselect.h2
-rw-r--r--src/xsmfns.c2
-rw-r--r--src/xterm.c2
59 files changed, 1111 insertions, 902 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c43404fa438..1040b93fe70 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,307 @@
12012-08-28 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Do not allow to set major mode for a dead buffer.
4 * buffer.c (Fset_buffer_major_mode): Signal an error
5 if the buffer is dead.
6 (Fother_buffer, other_buffer_safely): Remove redundant
7 nested declaration.
8
92012-08-28 Dmitry Antipov <dmantipov@yandex.ru>
10
11 Always use set_buffer_if_live to restore original buffer at unwind.
12 * buffer.h (record_unwind_current_buffer): New function.
13 * bytecode.c, dispnew.c, editfns.c, fileio.c, fns.c, insdel.c:
14 * keyboard.c, keymap.c, minibuf.c, print.c, process.c, textprop.c:
15 * undo.c, window.c: Adjust users.
16 * buffer.c (set_buffer_if_live): Fix comment.
17
182012-08-28 Dmitry Antipov <dmantipov@yandex.ru>
19
20 Fix usage of set_buffer_internal.
21 * buffer.h (set_buffer_internal): Make it BUFFER_INLINE.
22 * buffer.c (set_buffer_if_live): Use set_buffer_internal.
23 * coding.c (decode_coding): Omit redundant test.
24 * fileio.c (decide_coding_unwind): Likewise.
25 * fns.c (secure_hash): Likewise.
26 * insdel.c (modify_region): Likewise.
27 * keyboard.c (command_loop_1): Likewise.
28 * print.c (PRINTFINISH): Likewise.
29 * xdisp.c (run_window_scroll_functions): Use set_buffer_internal.
30
312012-08-27 Paul Eggert <eggert@cs.ucla.edu>
32
33 * dispnew.c: Use bool for boolean.
34 (frame_garbaged, display_completed, delayed_size_change)
35 (fonts_changed_p, add_window_display_history)
36 (add_frame_display_history, verify_row_hash)
37 (adjust_glyph_matrix, clear_window_matrices, glyph_row_slice_p)
38 (row_equal_p, realloc_glyph_pool)
39 (allocate_matrices_for_frame_redisplay)
40 (showing_window_margins_p)
41 (adjust_frame_glyphs_for_frame_redisplay)
42 (build_frame_matrix_from_leaf_window, make_current)
43 (mirrored_line_dance, mirror_line_dance, update_frame)
44 (update_window_tree, update_single_window)
45 (check_current_matrix_flags, update_window, update_text_area)
46 (update_window_line, set_window_update_flags, scrolling_window)
47 (update_frame_1, scrolling, buffer_posn_from_coords)
48 (do_pending_window_change, change_frame_size)
49 (change_frame_size_1, sit_for):
50 Use bool for boolean.
51 (clear_glyph_matrix_rows): Rename from enable_glyph_matrix_rows,
52 and remove last int (actually boolean) argument, which was always 0.
53 All callers changed.
54 * dispextern.h, frame.h, lisp.h: Reflect above API changes.
55 * dispextern.h (struct composition_it): Use bool for boolean.
56 (struct glyph_matrix): Don't assume buffer sizes can fit in 'int'.
57 (struct bidi_it): Use unsigned:1, not int, for boolean prev_was_pdf.
58 * dired.c (file_name_completion):
59 Use bool for boolean. (This was missed in an earlier change.)
60
612012-08-27 Martin Rudalics <rudalics@gmx.at>
62
63 * window.c (Fset_window_configuration): Revert first part of
64 last change.
65
662012-08-27 Jan Djärv <jan.h.d@swipnet.se>
67
68 * nsterm.h (NSPanel): New class variable dialog_return.
69
70 * nsmenu.m (initWithContentRect:styleMask:backing:defer:): Initialize
71 dialog_return.
72 (windowShouldClose:): Use stop instead of stopModalWithCode.
73 (clicked:): Ditto, and also set dialog_return (Bug#12258).
74 (timeout_handler:): Use stop instead of abortModal. Send a dummy
75 event.
76 (runDialogAt:): Make ret Lisp_Object. Set it from dialog_return when
77 modal loop returns.
78
792012-08-27 Paul Eggert <eggert@cs.ucla.edu>
80
81 * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans.
82 * composite.c (find_composition, composition_gstring_p)
83 (composition_reseat_it, find_automatic_composition):
84 * data.c (let_shadows_buffer_binding_p)
85 (let_shadows_global_binding_p, set_internal, make_blv)
86 (Fmake_variable_buffer_local, Fmake_local_variable)
87 (Fmake_variable_frame_local, arithcompare, cons_to_unsigned)
88 (cons_to_signed, arith_driver):
89 * dbusbind.c (xd_in_read_queued_messages):
90 * dired.c (directory_files_internal, file_name_completion):
91 Use bool for booleans.
92 * dired.c (file_name_completion):
93 * process.h (fd_callback):
94 Omit int (actually boolean) argument. It wasn't being used.
95 All uses changed.
96 * composite.h, lisp.h: Reflect above API changes.
97
98 * cmds.c, coding.c: Use bool for booleans.
99 * cmds.c (move_point, Fself_insert_command):
100 * coding.h (struct composition status, struct coding_system):
101 * coding.c (detect_coding_utf_8, encode_coding_utf_8)
102 (detect_coding_utf_16, encode_coding_utf_16, detect_coding_emacs_mule)
103 (emacs_mule_char, decode_coding_emacs_mule)
104 (encode_coding_emacs_mule, detect_coding_iso_2022)
105 (decode_coding_iso_2022, encode_invocation_designation)
106 (encode_designation_at_bol, encode_coding_iso_2022)
107 (detect_coding_sjis, detect_coding_big5, decode_coding_sjis)
108 (decode_coding_big5, encode_coding_sjis, encode_coding_big5)
109 (detect_coding_ccl, encode_coding_ccl, decode_coding_raw_text)
110 (encode_coding_raw_text, detect_coding_charset)
111 (decode_coding_charset, encode_coding_charset, detect_eol)
112 (detect_coding, get_translation_table, produce_chars)
113 (consume_chars, reused_workbuf_in_use)
114 (make_conversion_work_buffer, code_conversion_save)
115 (decode_coding_object, encode_coding_object)
116 (detect_coding_system, char_encodable_p)
117 (Funencodable_char_position, code_convert_region)
118 (code_convert_string, code_convert_string_norecord)
119 (Fset_coding_system_priority):
120 * fileio.c (Finsert_file_contents):
121 Use bool for booleans.
122 * coding.h, lisp.h: Reflect above API changes.
123 * coding.c: Remove unnecessary static function decls.
124 (detect_coding): Use unsigned, not signed, to copy an unsigned field.
125 (decode_coding, encode_coding, decode_coding_gap): Return 'void',
126 not a boolean 'int', since callers never look at the return value.
127 (ALLOC_CONVERSION_WORK_AREA): Assume caller returns 'void', not 'int'.
128 * coding.h (decoding_buffer_size, encoding_buffer_size)
129 (emacs_mule_string_char): Remove unused extern decls.
130 (struct iso_2022_spec, struct coding_system):
131 Use 'unsigned int : 1' for boolean fields, since there's more than one.
132 (struct emacs_mule_spec): Remove unused field 'full_support'.
133 All initializations removed.
134 * cmds.c (internal_self_insert): Don't assume EMACS_INT fits in 'int'.
135
1362012-08-27 Dmitry Antipov <dmantipov@yandex.ru>
137
138 Fix spare memory change (Bug#12286).
139 * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE.
140 (valid_lisp_object_p): Likewise.
141
1422012-08-27 Martin Rudalics <rudalics@gmx.at>
143
144 * window.c (Fset_window_configuration): Record any window's old
145 buffer if it's replaced (see Bug#8789). If the new current
146 buffer doesn't appear in the selected window, go to its old
147 point (Bug#12208).
148
1492012-08-27 Dmitry Antipov <dmantipov@yandex.ru>
150
151 Special MEM_TYPE_SPARE to denote reserved memory.
152 * alloc.c (enum mem_type): New memory type.
153 (refill_memory_reserve): Use new type for spare memory.
154 This prevents live_cons_p and live_string_p from incorrect
155 detection of uninitialized objects from spare memory as live.
156
1572012-08-26 Paul Eggert <eggert@cs.ucla.edu>
158
159 Spelling fixes.
160 * Makefile.in (.PHONY): versioclean -> versionclean.
161
162 Remove unused external symbols.
163 * data.c (Qcons, Qfloat, Qmisc, Qstring, Qvector):
164 * window.c (Qwindow_valid_p, decode_valid_window):
165 Now static, not extern.
166 * data.c (Qinterval): Remove; unused.
167 (syms_of_data): Do not define 'interval'.
168 * lisp.h (Qinteger, Qstring, Qmisc, Qvector, Qfloat, Qcons):
169 * window.h (decode_valid_window):
170 Remove decls.
171
172 * character.c, charset.c, chartab.c: Use bool for booleans.
173 * character.c (lisp_string_width, string_count_byte8)
174 (string_escape_byte8):
175 * charset.c (charset_map_loaded, load_charset_map, read_hex):
176 (load_charset_map_from_file, map_charset_chars)
177 (Fdefine_charset_internal, define_charset_internal)
178 (Fdeclare_equiv_charset, find_charsets_in_text)
179 (Ffind_charset_region, char_charset, Fiso_charset):
180 * chartab.c (sub_char_table_ref, sub_char_table_ref_and_range)
181 (sub_char_table_set, sub_char_table_set_range)
182 (char_table_set_range, optimize_sub_char_table)
183 (map_sub_char_table):
184 Use bool for boolean.
185 * character.c (str_to_unibyte): Omit last boolean argument; it was
186 always 0. All callers changed.
187 * character.h, charset.h: Adjust to match previous changes.
188 * character.h (char_printable_p): Remove decl of nonexistent function.
189 * charset.h (struct charset): Members code_linear_p, iso_chars_96,
190 ascii_compatible_p, supplementary_p, compact_codes_p, unified_p
191 are all boolean, so make them single-bit bitfields.
192
193 * lisp.h (ASET): Remove attempt to detect side effects.
194 It was meant to be temporary and it often doesn't work,
195 because when IDX has side effects the behavior of IDX==IDX
196 is undefined. See Stefan Monnier in
197 <http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00762.html>.
198
1992012-08-26 Barry OReilly <gundaetiapo@gmail.com> (tiny change)
200
201 * lisp.h (functionp): New function (extracted from Ffunctionp).
202 (FUNCTIONP): Use it.
203 * eval.c (Ffunctionp): Use it.
204
2052012-08-25 Paul Eggert <eggert@cs.ucla.edu>
206
207 * xgselect.c (xg_select): Use auto storage for the GPollFD buffer
208 as that's faster and simpler than static storage. Don't bother
209 with the g_main_context_query overhead if g_main_context_pending
210 says no events are pending.
211 (gfds, gfds_size): Remove these static vars.
212 (xgselect_initialize): Remove; no longer needed.
213 All uses and decls removed.
214
215 * emacs.c (fatal_error_signal_hook): Remove.
216 All uses removed. This leftover from old code was always 0.
217
218 * casefiddle.c, casetab.c, category.c: Use bool for boolean.
219 * casefiddle.c (casify_object, casify_region):
220 * casetab.c (set_case_table):
221 * category.c, category.h (word_boundary_p):
222 * category.h (CHAR_HAS_CATEGORY):
223 Use bool for booleans, instead of int.
224
2252012-08-25 Eli Zaretskii <eliz@gnu.org>
226
227 * makefile.w32-in ($(BLD)/alloc.$(O)): Depend on $(GNU_LIB)/execinfo.h.
228
2292012-08-25 Paul Eggert <eggert@cs.ucla.edu>
230
231 On assertion failure, print backtrace if available.
232 * alloc.c [ENABLE_CHECKING]: Include <execinfo.h>.
233 (die) [ENABLE_CHECKING]: Print a backtrace if available.
234 * Makefile.in (LIB_EXECINFO): New macro.
235 (LIBES): Use it.
236
237 * bytecode.c, callint.c, callproc.c: Use bool for boolean.
238 * bytecode.c (exec_byte_code):
239 * callint.c (check_mark, Fcall_interactively):
240 * callproc.c (Fcall_process, add_env, child_setup, getenv_internal_1)
241 (getenv_internal, sync_process_alive, call_process_exited):
242 * lisp.h (USE_SAFE_ALLOCA):
243 Use bool for booleans, instead of int.
244 * lisp.h, process.h: Adjust prototypes to match above changes.
245 * callint.c (Fcall_interactively): Don't assume the mark's
246 offset fits in 'int'.
247
2482012-08-24 Paul Eggert <eggert@cs.ucla.edu>
249
250 * buffer.c, buffer.h: Use bool for boolean.
251 * buffer.c (reset_buffer_local_variables)
252 (buffer_lisp_local_variables, Fset_buffer_modified_p)
253 (Frestore_buffer_modified_p, Fset_buffer_multibyte):
254 (overlays_at, overlays_in, mouse_face_overlay_overlaps)
255 (overlay_touches_p, overlay_strings, Foverlay_put)
256 (report_overlay_modification, call_overlay_mod_hooks):
257 (mmap_enlarge, mmap_set_vars):
258 * buffer.h (buffer_has_overlays, uppercasep, lowercasep):
259 Use bool for booleans, instead of int.
260 * buffer.c (compact_buffer, mmap_free_1): Return void, not int,
261 since the 1-or-0 return value is always ignored anyway.
262 (mmap_initialized_p):
263 * buffer.h (struct buffer_text.inhibit_shrinking): Now bool, not int.
264 * buffer.h, lisp.h: Adjust prototypes to match above changes.
265
2662012-08-23 Paul Eggert <eggert@cs.ucla.edu>
267
268 * bidi.c: Use bool for boolean.
269 This is a bit more readable, and makes the text segment of bidi.o
270 0.4% smaller on my platform (GCC 4.7.1 x86-64, Fedora 15).
271 Presumably it's faster too.
272 (bidi_initialized, bidi_ignore_explicit_marks_for_paragraph_level):
273 Now bool.
274 (bidi_cache_find_level_change, bidi_cache_iterator_state)
275 (bidi_unshelve_cache, bidi_init_it, bidi_count_bytes)
276 (bidi_char_at_pos, bidi_fetch_char, bidi_paragraph_init)
277 (bidi_explicit_dir_char, bidi_level_of_next_char)
278 (bidi_find_other_level_edge, bidi_move_to_visually_next):
279 Use bool for booleans, instead of int.
280 * dispextern.h (bidi_init_it, bidi_paragraph_init)
281 (bidi_unshelve_cache): Adjust decls to match code.
282
2832012-08-23 Martin Rudalics <rudalics@gmx.at>
284
285 * keyboard.c (Fposn_at_x_y): Do not allow internal window as
286 argument.
287
2882012-08-23 Paul Eggert <eggert@cs.ucla.edu>
289
290 * atimer.c, atimer.h (turn_on_atimers): Use bool for boolean.
291 * atimer.h: Include <stdbool.h>.
292
2932012-08-22 Dan Nicolaescu <dann@gnu.org>
294
295 * frame.h (FRAME_W32_P, FRAME_MSDOS_P, FRAME_NS_P): Change to
296 compile time tests instead of run time tests on systems that do
297 not use them.
298 (FRAME_MAC_P): Remove leftover from deleted code.
299 * frame.c (syms_of_frame): Remove leftover from deleted code.
300
3012012-08-22 Jan Djärv <jan.h.d@swipnet.se>
302
303 * nsterm.m (insertText:): Don't clear modifiers if code is space.
304
12012-08-22 Paul Eggert <eggert@cs.ucla.edu> 3052012-08-22 Paul Eggert <eggert@cs.ucla.edu>
2 306
3 * fontset.c (FONTSET_ADD): Return void, not Lisp_Object. 307 * fontset.c (FONTSET_ADD): Return void, not Lisp_Object.
@@ -60,8 +364,8 @@
60 * w32uniscribe.c (uniscribe_shape): Fix producing gstring 364 * w32uniscribe.c (uniscribe_shape): Fix producing gstring
61 components for RTL text (Bug#11860). Adjust X-OFFSET of each 365 components for RTL text (Bug#11860). Adjust X-OFFSET of each
62 non-base glyph for the width of the base character, according to 366 non-base glyph for the width of the base character, according to
63 what x_draw_composite_glyph_string_foreground expects. Generate 367 what x_draw_composite_glyph_string_foreground expects.
64 WADJUST value according to composition_gstring_width's 368 Generate WADJUST value according to composition_gstring_width's
65 expectations, to produce correct width of the composed character. 369 expectations, to produce correct width of the composed character.
66 Reverse the sign of the DU offset produced by ScriptPlace. 370 Reverse the sign of the DU offset produced by ScriptPlace.
67 371
diff --git a/src/Makefile.in b/src/Makefile.in
index 1d89af31401..60df1f1c677 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
@@ -383,6 +385,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
383## with GCC, we might need LIB_GCC again after them. 385## with GCC, we might need LIB_GCC again after them.
384LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ 386LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \
385 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \ 387 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) \
388 $(LIB_EXECINFO) \
386 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 389 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
387 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 390 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
388 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 391 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
@@ -499,7 +502,7 @@ doc.o: buildobj.h
499@ns_frag@ 502@ns_frag@
500 503
501.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean 504.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
502.PHONY: versioclean extraclean frc 505.PHONY: versionclean extraclean frc
503 506
504mostlyclean: 507mostlyclean:
505 rm -f temacs$(EXEEXT) core *.core \#* *.o libXMenu11.a liblw.a 508 rm -f temacs$(EXEEXT) core *.core \#* *.o libXMenu11.a liblw.a
diff --git a/src/alloc.c b/src/alloc.c
index f0da9416ece..36ba22cc535 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -305,7 +305,9 @@ enum mem_type
305 and runtime slowdown. Minor but pointless. */ 305 and runtime slowdown. Minor but pointless. */
306 MEM_TYPE_VECTORLIKE, 306 MEM_TYPE_VECTORLIKE,
307 /* Special type to denote vector blocks. */ 307 /* Special type to denote vector blocks. */
308 MEM_TYPE_VECTOR_BLOCK 308 MEM_TYPE_VECTOR_BLOCK,
309 /* Special type to denote reserved memory. */
310 MEM_TYPE_SPARE
309}; 311};
310 312
311static void *lisp_malloc (size_t, enum mem_type); 313static void *lisp_malloc (size_t, enum mem_type);
@@ -3816,22 +3818,22 @@ refill_memory_reserve (void)
3816 spare_memory[0] = malloc (SPARE_MEMORY); 3818 spare_memory[0] = malloc (SPARE_MEMORY);
3817 if (spare_memory[1] == 0) 3819 if (spare_memory[1] == 0)
3818 spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block), 3820 spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block),
3819 MEM_TYPE_CONS); 3821 MEM_TYPE_SPARE);
3820 if (spare_memory[2] == 0) 3822 if (spare_memory[2] == 0)
3821 spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block), 3823 spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block),
3822 MEM_TYPE_CONS); 3824 MEM_TYPE_SPARE);
3823 if (spare_memory[3] == 0) 3825 if (spare_memory[3] == 0)
3824 spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block), 3826 spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block),
3825 MEM_TYPE_CONS); 3827 MEM_TYPE_SPARE);
3826 if (spare_memory[4] == 0) 3828 if (spare_memory[4] == 0)
3827 spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block), 3829 spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block),
3828 MEM_TYPE_CONS); 3830 MEM_TYPE_SPARE);
3829 if (spare_memory[5] == 0) 3831 if (spare_memory[5] == 0)
3830 spare_memory[5] = lisp_malloc (sizeof (struct string_block), 3832 spare_memory[5] = lisp_malloc (sizeof (struct string_block),
3831 MEM_TYPE_STRING); 3833 MEM_TYPE_SPARE);
3832 if (spare_memory[6] == 0) 3834 if (spare_memory[6] == 0)
3833 spare_memory[6] = lisp_malloc (sizeof (struct string_block), 3835 spare_memory[6] = lisp_malloc (sizeof (struct string_block),
3834 MEM_TYPE_STRING); 3836 MEM_TYPE_SPARE);
3835 if (spare_memory[0] && spare_memory[1] && spare_memory[5]) 3837 if (spare_memory[0] && spare_memory[1] && spare_memory[5])
3836 Vmemory_full = Qnil; 3838 Vmemory_full = Qnil;
3837#endif 3839#endif
@@ -4561,6 +4563,7 @@ mark_maybe_pointer (void *p)
4561 switch (m->type) 4563 switch (m->type)
4562 { 4564 {
4563 case MEM_TYPE_NON_LISP: 4565 case MEM_TYPE_NON_LISP:
4566 case MEM_TYPE_SPARE:
4564 /* Nothing to do; not a pointer to Lisp memory. */ 4567 /* Nothing to do; not a pointer to Lisp memory. */
4565 break; 4568 break;
4566 4569
@@ -5017,6 +5020,7 @@ valid_lisp_object_p (Lisp_Object obj)
5017 switch (m->type) 5020 switch (m->type)
5018 { 5021 {
5019 case MEM_TYPE_NON_LISP: 5022 case MEM_TYPE_NON_LISP:
5023 case MEM_TYPE_SPARE:
5020 return 0; 5024 return 0;
5021 5025
5022 case MEM_TYPE_BUFFER: 5026 case MEM_TYPE_BUFFER:
@@ -6681,13 +6685,21 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6681} 6685}
6682 6686
6683#ifdef ENABLE_CHECKING 6687#ifdef ENABLE_CHECKING
6688
6689# include <execinfo.h>
6690
6684bool suppress_checking; 6691bool suppress_checking;
6685 6692
6686void 6693void
6687die (const char *msg, const char *file, int line) 6694die (const char *msg, const char *file, int line)
6688{ 6695{
6696 enum { NPOINTERS_MAX = 500 };
6697 void *buffer[NPOINTERS_MAX];
6698 int npointers;
6689 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", 6699 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
6690 file, line, msg); 6700 file, line, msg);
6701 npointers = backtrace (buffer, NPOINTERS_MAX);
6702 backtrace_symbols_fd (buffer, npointers, STDERR_FILENO);
6691 abort (); 6703 abort ();
6692} 6704}
6693#endif 6705#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 c900ef8c5a8..0e2e50d9f51 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -110,10 +110,10 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
110int last_per_buffer_idx; 110int last_per_buffer_idx;
111 111
112static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, 112static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
113 int after, Lisp_Object arg1, 113 bool after, Lisp_Object arg1,
114 Lisp_Object arg2, Lisp_Object arg3); 114 Lisp_Object arg2, Lisp_Object arg3);
115static void swap_out_buffer_local_variables (struct buffer *b); 115static void swap_out_buffer_local_variables (struct buffer *b);
116static void reset_buffer_local_variables (struct buffer *b, int permanent_too); 116static void reset_buffer_local_variables (struct buffer *, bool);
117 117
118/* Alist of all buffer names vs the buffers. */ 118/* Alist of all buffer names vs the buffers. */
119/* This used to be a variable, but is no longer, 119/* This used to be a variable, but is no longer,
@@ -155,7 +155,7 @@ static void alloc_buffer_text (struct buffer *, ptrdiff_t);
155static void free_buffer_text (struct buffer *b); 155static void free_buffer_text (struct buffer *b);
156static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); 156static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *);
157static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); 157static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
158static Lisp_Object buffer_lisp_local_variables (struct buffer *, int); 158static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool);
159 159
160/* These setters are used only in this file, so they can be private. */ 160/* These setters are used only in this file, so they can be private. */
161static inline void 161static inline void
@@ -979,15 +979,13 @@ reset_buffer (register struct buffer *b)
979 it does not treat permanent locals consistently. 979 it does not treat permanent locals consistently.
980 Instead, use Fkill_all_local_variables. 980 Instead, use Fkill_all_local_variables.
981 981
982 If PERMANENT_TOO is 1, then we reset permanent 982 If PERMANENT_TOO, reset permanent buffer-local variables.
983 buffer-local variables. If PERMANENT_TOO is 0, 983 If not, preserve those. */
984 we preserve those. */
985 984
986static void 985static void
987reset_buffer_local_variables (register struct buffer *b, int permanent_too) 986reset_buffer_local_variables (struct buffer *b, bool permanent_too)
988{ 987{
989 register int offset; 988 int offset, i;
990 int i;
991 989
992 /* Reset the major mode to Fundamental, together with all the 990 /* Reset the major mode to Fundamental, together with all the
993 things that depend on the major mode. 991 things that depend on the major mode.
@@ -1253,14 +1251,14 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
1253/* Return an alist of the Lisp-level buffer-local bindings of 1251/* Return an alist of the Lisp-level buffer-local bindings of
1254 buffer BUF. That is, don't include the variables maintained 1252 buffer BUF. That is, don't include the variables maintained
1255 in special slots in the buffer object. 1253 in special slots in the buffer object.
1256 If CLONE is zero elements of the form (VAR . unbound) are replaced 1254 If not CLONE, replace elements of the form (VAR . unbound)
1257 by VAR. */ 1255 by VAR. */
1258 1256
1259static Lisp_Object 1257static Lisp_Object
1260buffer_lisp_local_variables (struct buffer *buf, int clone) 1258buffer_lisp_local_variables (struct buffer *buf, bool clone)
1261{ 1259{
1262 Lisp_Object result = Qnil; 1260 Lisp_Object result = Qnil;
1263 register Lisp_Object tail; 1261 Lisp_Object tail;
1264 for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail)) 1262 for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail))
1265 { 1263 {
1266 Lisp_Object val, elt; 1264 Lisp_Object val, elt;
@@ -1351,11 +1349,9 @@ DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p,
1351 1, 1, 0, 1349 1, 1, 0,
1352 doc: /* Mark current buffer as modified or unmodified according to FLAG. 1350 doc: /* Mark current buffer as modified or unmodified according to FLAG.
1353A non-nil FLAG means mark the buffer modified. */) 1351A non-nil FLAG means mark the buffer modified. */)
1354 (register Lisp_Object flag) 1352 (Lisp_Object flag)
1355{ 1353{
1356 register int already; 1354 Lisp_Object fn, buffer, window;
1357 register Lisp_Object fn;
1358 Lisp_Object buffer, window;
1359 1355
1360#ifdef CLASH_DETECTION 1356#ifdef CLASH_DETECTION
1361 /* If buffer becoming modified, lock the file. 1357 /* If buffer becoming modified, lock the file.
@@ -1365,7 +1361,7 @@ A non-nil FLAG means mark the buffer modified. */)
1365 /* Test buffer-file-name so that binding it to nil is effective. */ 1361 /* Test buffer-file-name so that binding it to nil is effective. */
1366 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) 1362 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
1367 { 1363 {
1368 already = SAVE_MODIFF < MODIFF; 1364 bool already = SAVE_MODIFF < MODIFF;
1369 if (!already && !NILP (flag)) 1365 if (!already && !NILP (flag))
1370 lock_file (fn); 1366 lock_file (fn);
1371 else if (already && NILP (flag)) 1367 else if (already && NILP (flag))
@@ -1432,7 +1428,7 @@ state of the current buffer. Use with care. */)
1432 /* Test buffer-file-name so that binding it to nil is effective. */ 1428 /* Test buffer-file-name so that binding it to nil is effective. */
1433 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) 1429 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
1434 { 1430 {
1435 int already = SAVE_MODIFF < MODIFF; 1431 bool already = SAVE_MODIFF < MODIFF;
1436 if (!already && !NILP (flag)) 1432 if (!already && !NILP (flag))
1437 lock_file (fn); 1433 lock_file (fn);
1438 else if (already && NILP (flag)) 1434 else if (already && NILP (flag))
@@ -1557,7 +1553,6 @@ list first, followed by the list of all buffers. If no other buffer
1557exists, return the buffer `*scratch*' (creating it if necessary). */) 1553exists, return the buffer `*scratch*' (creating it if necessary). */)
1558 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) 1554 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
1559{ 1555{
1560 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1561 Lisp_Object tail, buf, pred; 1556 Lisp_Object tail, buf, pred;
1562 Lisp_Object notsogood = Qnil; 1557 Lisp_Object notsogood = Qnil;
1563 1558
@@ -1628,7 +1623,6 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1628Lisp_Object 1623Lisp_Object
1629other_buffer_safely (Lisp_Object buffer) 1624other_buffer_safely (Lisp_Object buffer)
1630{ 1625{
1631 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1632 Lisp_Object tail, buf; 1626 Lisp_Object tail, buf;
1633 1627
1634 tail = Vbuffer_alist; 1628 tail = Vbuffer_alist;
@@ -1676,7 +1670,7 @@ No argument or nil as argument means do this for the current buffer. */)
1676 1670
1677/* Truncate undo list and shrink the gap of BUFFER. */ 1671/* Truncate undo list and shrink the gap of BUFFER. */
1678 1672
1679int 1673void
1680compact_buffer (struct buffer *buffer) 1674compact_buffer (struct buffer *buffer)
1681{ 1675{
1682 /* Verify indirection counters. */ 1676 /* Verify indirection counters. */
@@ -1718,9 +1712,7 @@ compact_buffer (struct buffer *buffer)
1718 } 1712 }
1719 } 1713 }
1720 buffer->text->compact = buffer->text->modiff; 1714 buffer->text->compact = buffer->text->modiff;
1721 return 1;
1722 } 1715 }
1723 return 0;
1724} 1716}
1725 1717
1726DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", 1718DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
@@ -2070,8 +2062,10 @@ the current buffer's major mode. */)
2070 2062
2071 CHECK_BUFFER (buffer); 2063 CHECK_BUFFER (buffer);
2072 2064
2073 if (STRINGP (BVAR (XBUFFER (buffer), name)) 2065 if (NILP (BVAR (XBUFFER (buffer), name)))
2074 && strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) 2066 error ("Attempt to set major mode for a dead buffer");
2067
2068 if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0)
2075 function = find_symbol_value (intern ("initial-major-mode")); 2069 function = find_symbol_value (intern ("initial-major-mode"));
2076 else 2070 else
2077 { 2071 {
@@ -2105,22 +2099,6 @@ DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
2105 XSETBUFFER (buf, current_buffer); 2099 XSETBUFFER (buf, current_buffer);
2106 return buf; 2100 return buf;
2107} 2101}
2108
2109/* Set the current buffer to B.
2110
2111 We previously set windows_or_buffers_changed here to invalidate
2112 global unchanged information in beg_unchanged and end_unchanged.
2113 This is no longer necessary because we now compute unchanged
2114 information on a buffer-basis. Every action affecting other
2115 windows than the selected one requires a select_window at some
2116 time, and that increments windows_or_buffers_changed. */
2117
2118void
2119set_buffer_internal (register struct buffer *b)
2120{
2121 if (current_buffer != b)
2122 set_buffer_internal_1 (b);
2123}
2124 2102
2125/* Set the current buffer to B, and do not set windows_or_buffers_changed. 2103/* Set the current buffer to B, and do not set windows_or_buffers_changed.
2126 This is used by redisplay. */ 2104 This is used by redisplay. */
@@ -2226,13 +2204,13 @@ ends when the current command terminates. Use `switch-to-buffer' or
2226 return buffer; 2204 return buffer;
2227} 2205}
2228 2206
2229/* Set the current buffer to BUFFER provided it is alive. */ 2207/* Set the current buffer to BUFFER provided if it is alive. */
2230 2208
2231Lisp_Object 2209Lisp_Object
2232set_buffer_if_live (Lisp_Object buffer) 2210set_buffer_if_live (Lisp_Object buffer)
2233{ 2211{
2234 if (! NILP (BVAR (XBUFFER (buffer), name))) 2212 if (! NILP (BVAR (XBUFFER (buffer), name)))
2235 Fset_buffer (buffer); 2213 set_buffer_internal (XBUFFER (buffer));
2236 return Qnil; 2214 return Qnil;
2237} 2215}
2238 2216
@@ -2471,8 +2449,8 @@ current buffer is cleared. */)
2471 struct Lisp_Marker *tail, *markers; 2449 struct Lisp_Marker *tail, *markers;
2472 struct buffer *other; 2450 struct buffer *other;
2473 ptrdiff_t begv, zv; 2451 ptrdiff_t begv, zv;
2474 int narrowed = (BEG != BEGV || Z != ZV); 2452 bool narrowed = (BEG != BEGV || Z != ZV);
2475 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2453 bool modified_p = !NILP (Fbuffer_modified_p (Qnil));
2476 Lisp_Object old_undo = BVAR (current_buffer, undo_list); 2454 Lisp_Object old_undo = BVAR (current_buffer, undo_list);
2477 struct gcpro gcpro1; 2455 struct gcpro gcpro1;
2478 2456
@@ -2821,19 +2799,19 @@ swap_out_buffer_local_variables (struct buffer *b)
2821 *VEC_PTR and *LEN_PTR should contain a valid vector and size 2799 *VEC_PTR and *LEN_PTR should contain a valid vector and size
2822 when this function is called. 2800 when this function is called.
2823 2801
2824 If EXTEND is non-zero, we make the vector bigger if necessary. 2802 If EXTEND, make the vector bigger if necessary.
2825 If EXTEND is zero, we never extend the vector, 2803 If not, never extend the vector,
2826 and we store only as many overlays as will fit. 2804 and store only as many overlays as will fit.
2827 But we still return the total number of overlays. 2805 But still return the total number of overlays.
2828 2806
2829 If CHANGE_REQ is true, then any position written into *PREV_PTR or 2807 If CHANGE_REQ, any position written into *PREV_PTR or
2830 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the 2808 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the
2831 default (BEGV or ZV). */ 2809 default (BEGV or ZV). */
2832 2810
2833ptrdiff_t 2811ptrdiff_t
2834overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, 2812overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr,
2835 ptrdiff_t *len_ptr, 2813 ptrdiff_t *len_ptr,
2836 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, int change_req) 2814 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req)
2837{ 2815{
2838 Lisp_Object overlay, start, end; 2816 Lisp_Object overlay, start, end;
2839 struct Lisp_Overlay *tail; 2817 struct Lisp_Overlay *tail;
@@ -2842,7 +2820,7 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
2842 Lisp_Object *vec = *vec_ptr; 2820 Lisp_Object *vec = *vec_ptr;
2843 ptrdiff_t next = ZV; 2821 ptrdiff_t next = ZV;
2844 ptrdiff_t prev = BEGV; 2822 ptrdiff_t prev = BEGV;
2845 int inhibit_storing = 0; 2823 bool inhibit_storing = 0;
2846 2824
2847 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2825 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2848 { 2826 {
@@ -2959,13 +2937,13 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
2959 *VEC_PTR and *LEN_PTR should contain a valid vector and size 2937 *VEC_PTR and *LEN_PTR should contain a valid vector and size
2960 when this function is called. 2938 when this function is called.
2961 2939
2962 If EXTEND is non-zero, we make the vector bigger if necessary. 2940 If EXTEND, make the vector bigger if necessary.
2963 If EXTEND is zero, we never extend the vector, 2941 If not, never extend the vector,
2964 and we store only as many overlays as will fit. 2942 and store only as many overlays as will fit.
2965 But we still return the total number of overlays. */ 2943 But still return the total number of overlays. */
2966 2944
2967static ptrdiff_t 2945static ptrdiff_t
2968overlays_in (EMACS_INT beg, EMACS_INT end, int extend, 2946overlays_in (EMACS_INT beg, EMACS_INT end, bool extend,
2969 Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, 2947 Lisp_Object **vec_ptr, ptrdiff_t *len_ptr,
2970 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) 2948 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr)
2971{ 2949{
@@ -2976,8 +2954,8 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
2976 Lisp_Object *vec = *vec_ptr; 2954 Lisp_Object *vec = *vec_ptr;
2977 ptrdiff_t next = ZV; 2955 ptrdiff_t next = ZV;
2978 ptrdiff_t prev = BEGV; 2956 ptrdiff_t prev = BEGV;
2979 int inhibit_storing = 0; 2957 bool inhibit_storing = 0;
2980 int end_is_Z = end == Z; 2958 bool end_is_Z = end == Z;
2981 2959
2982 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2960 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2983 { 2961 {
@@ -3078,10 +3056,10 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
3078} 3056}
3079 3057
3080 3058
3081/* Return non-zero if there exists an overlay with a non-nil 3059/* Return true if there exists an overlay with a non-nil
3082 `mouse-face' property overlapping OVERLAY. */ 3060 `mouse-face' property overlapping OVERLAY. */
3083 3061
3084int 3062bool
3085mouse_face_overlay_overlaps (Lisp_Object overlay) 3063mouse_face_overlay_overlaps (Lisp_Object overlay)
3086{ 3064{
3087 ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay)); 3065 ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay));
@@ -3110,7 +3088,7 @@ mouse_face_overlay_overlaps (Lisp_Object overlay)
3110 3088
3111 3089
3112/* Fast function to just test if we're at an overlay boundary. */ 3090/* Fast function to just test if we're at an overlay boundary. */
3113int 3091bool
3114overlay_touches_p (ptrdiff_t pos) 3092overlay_touches_p (ptrdiff_t pos)
3115{ 3093{
3116 Lisp_Object overlay; 3094 Lisp_Object overlay;
@@ -3327,7 +3305,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
3327 Lisp_Object overlay, window, str; 3305 Lisp_Object overlay, window, str;
3328 struct Lisp_Overlay *ov; 3306 struct Lisp_Overlay *ov;
3329 ptrdiff_t startpos, endpos; 3307 ptrdiff_t startpos, endpos;
3330 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 3308 bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
3331 3309
3332 overlay_heads.used = overlay_heads.bytes = 0; 3310 overlay_heads.used = overlay_heads.bytes = 0;
3333 overlay_tails.used = overlay_tails.bytes = 0; 3311 overlay_tails.used = overlay_tails.bytes = 0;
@@ -4321,7 +4299,7 @@ VALUE will be returned.*/)
4321 (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value) 4299 (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value)
4322{ 4300{
4323 Lisp_Object tail, buffer; 4301 Lisp_Object tail, buffer;
4324 int changed; 4302 bool changed;
4325 4303
4326 CHECK_OVERLAY (overlay); 4304 CHECK_OVERLAY (overlay);
4327 4305
@@ -4396,7 +4374,7 @@ add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
4396 and the insert-after-hooks of overlay ending at START. 4374 and the insert-after-hooks of overlay ending at START.
4397 4375
4398 This is called both before and after the modification. 4376 This is called both before and after the modification.
4399 AFTER is nonzero when we call after the modification. 4377 AFTER is true when we call after the modification.
4400 4378
4401 ARG1, ARG2, ARG3 are arguments to pass to the hook functions. 4379 ARG1, ARG2, ARG3 are arguments to pass to the hook functions.
4402 When AFTER is nonzero, they are the start position, 4380 When AFTER is nonzero, they are the start position,
@@ -4404,13 +4382,13 @@ add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
4404 and the length of deleted or replaced old text. */ 4382 and the length of deleted or replaced old text. */
4405 4383
4406void 4384void
4407report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, 4385report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after,
4408 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) 4386 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
4409{ 4387{
4410 Lisp_Object prop, overlay; 4388 Lisp_Object prop, overlay;
4411 struct Lisp_Overlay *tail; 4389 struct Lisp_Overlay *tail;
4412 /* 1 if this change is an insertion. */ 4390 /* True if this change is an insertion. */
4413 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); 4391 bool insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
4414 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4392 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4415 4393
4416 overlay = Qnil; 4394 overlay = Qnil;
@@ -4530,7 +4508,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4530} 4508}
4531 4509
4532static void 4510static void
4533call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, int after, 4511call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, bool after,
4534 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) 4512 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
4535{ 4513{
4536 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4514 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -4689,7 +4667,7 @@ static int mmap_page_size;
4689 4667
4690/* 1 means mmap has been initialized. */ 4668/* 1 means mmap has been initialized. */
4691 4669
4692static int mmap_initialized_p; 4670static bool mmap_initialized_p;
4693 4671
4694/* Value is X rounded up to the next multiple of N. */ 4672/* Value is X rounded up to the next multiple of N. */
4695 4673
@@ -4785,9 +4763,9 @@ mmap_find (void *start, void *end)
4785 4763
4786 4764
4787/* Unmap a region. P is a pointer to the start of the user-araa of 4765/* Unmap a region. P is a pointer to the start of the user-araa of
4788 the region. Value is non-zero if successful. */ 4766 the region. */
4789 4767
4790static int 4768static void
4791mmap_free_1 (struct mmap_region *r) 4769mmap_free_1 (struct mmap_region *r)
4792{ 4770{
4793 if (r->next) 4771 if (r->next)
@@ -4798,24 +4776,19 @@ mmap_free_1 (struct mmap_region *r)
4798 mmap_regions = r->next; 4776 mmap_regions = r->next;
4799 4777
4800 if (munmap (r, r->nbytes_mapped) == -1) 4778 if (munmap (r, r->nbytes_mapped) == -1)
4801 { 4779 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4802 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4803 return 0;
4804 }
4805
4806 return 1;
4807} 4780}
4808 4781
4809 4782
4810/* Enlarge region R by NPAGES pages. NPAGES < 0 means shrink R. 4783/* Enlarge region R by NPAGES pages. NPAGES < 0 means shrink R.
4811 Value is non-zero if successful. */ 4784 Value is true if successful. */
4812 4785
4813static int 4786static bool
4814mmap_enlarge (struct mmap_region *r, int npages) 4787mmap_enlarge (struct mmap_region *r, int npages)
4815{ 4788{
4816 char *region_end = (char *) r + r->nbytes_mapped; 4789 char *region_end = (char *) r + r->nbytes_mapped;
4817 size_t nbytes; 4790 size_t nbytes;
4818 int success = 0; 4791 bool success = 0;
4819 4792
4820 if (npages < 0) 4793 if (npages < 0)
4821 { 4794 {
@@ -4865,17 +4838,16 @@ mmap_enlarge (struct mmap_region *r, int npages)
4865} 4838}
4866 4839
4867 4840
4868/* Set or reset variables holding references to mapped regions. If 4841/* Set or reset variables holding references to mapped regions.
4869 RESTORE_P is zero, set all variables to null. If RESTORE_P is 4842 If not RESTORE_P, set all variables to null. If RESTORE_P, set all
4870 non-zero, set all variables to the start of the user-areas 4843 variables to the start of the user-areas of mapped regions.
4871 of mapped regions.
4872 4844
4873 This function is called from Fdump_emacs to ensure that the dumped 4845 This function is called from Fdump_emacs to ensure that the dumped
4874 Emacs doesn't contain references to memory that won't be mapped 4846 Emacs doesn't contain references to memory that won't be mapped
4875 when Emacs starts. */ 4847 when Emacs starts. */
4876 4848
4877void 4849void
4878mmap_set_vars (int restore_p) 4850mmap_set_vars (bool restore_p)
4879{ 4851{
4880 struct mmap_region *r; 4852 struct mmap_region *r;
4881 4853
diff --git a/src/buffer.h b/src/buffer.h
index 6c63c52dc47..3acf1423816 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. */
@@ -1006,23 +1006,46 @@ extern struct buffer buffer_local_symbols;
1006 1006
1007extern void delete_all_overlays (struct buffer *); 1007extern void delete_all_overlays (struct buffer *);
1008extern void reset_buffer (struct buffer *); 1008extern void reset_buffer (struct buffer *);
1009extern int compact_buffer (struct buffer *); 1009extern void compact_buffer (struct buffer *);
1010extern void evaporate_overlays (ptrdiff_t); 1010extern void evaporate_overlays (ptrdiff_t);
1011extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, 1011extern ptrdiff_t overlays_at (EMACS_INT, bool, Lisp_Object **,
1012 ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, 1012 ptrdiff_t *, ptrdiff_t *, ptrdiff_t *, bool);
1013 ptrdiff_t *prev_ptr, int change_req);
1014extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *); 1013extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *);
1015extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); 1014extern void recenter_overlay_lists (struct buffer *, ptrdiff_t);
1016extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); 1015extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **);
1017extern void validate_region (Lisp_Object *, Lisp_Object *); 1016extern void validate_region (Lisp_Object *, Lisp_Object *);
1018extern void set_buffer_internal (struct buffer *);
1019extern void set_buffer_internal_1 (struct buffer *); 1017extern void set_buffer_internal_1 (struct buffer *);
1020extern void set_buffer_temp (struct buffer *); 1018extern void set_buffer_temp (struct buffer *);
1021extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); 1019extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object);
1022extern void record_buffer (Lisp_Object); 1020extern void record_buffer (Lisp_Object);
1023extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int); 1021extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int);
1024extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); 1022extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t);
1025extern void mmap_set_vars (int); 1023extern void mmap_set_vars (bool);
1024
1025/* Set the current buffer to B.
1026
1027 We previously set windows_or_buffers_changed here to invalidate
1028 global unchanged information in beg_unchanged and end_unchanged.
1029 This is no longer necessary because we now compute unchanged
1030 information on a buffer-basis. Every action affecting other
1031 windows than the selected one requires a select_window at some
1032 time, and that increments windows_or_buffers_changed. */
1033
1034BUFFER_INLINE void
1035set_buffer_internal (struct buffer *b)
1036{
1037 if (current_buffer != b)
1038 set_buffer_internal_1 (b);
1039}
1040
1041/* Arrange to go back to the original buffer after the next
1042 call to unbind_to if the original buffer is still alive. */
1043
1044BUFFER_INLINE void
1045record_unwind_current_buffer (void)
1046{
1047 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
1048}
1026 1049
1027/* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. 1050/* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements.
1028 If NEXTP is non-NULL, return next overlay there. 1051 If NEXTP is non-NULL, return next overlay there.
@@ -1067,7 +1090,7 @@ set_buffer_intervals (struct buffer *b, INTERVAL i)
1067 1090
1068/* Non-zero if current buffer has overlays. */ 1091/* Non-zero if current buffer has overlays. */
1069 1092
1070BUFFER_INLINE int 1093BUFFER_INLINE bool
1071buffer_has_overlays (void) 1094buffer_has_overlays (void)
1072{ 1095{
1073 return current_buffer->overlays_before || current_buffer->overlays_after; 1096 return current_buffer->overlays_before || current_buffer->overlays_after;
@@ -1243,7 +1266,7 @@ downcase (int c)
1243} 1266}
1244 1267
1245/* 1 if C is upper case. */ 1268/* 1 if C is upper case. */
1246BUFFER_INLINE int uppercasep (int c) { return downcase (c) != c; } 1269BUFFER_INLINE bool uppercasep (int c) { return downcase (c) != c; }
1247 1270
1248/* Upcase a character C known to be not upper case. */ 1271/* Upcase a character C known to be not upper case. */
1249BUFFER_INLINE int 1272BUFFER_INLINE int
@@ -1255,8 +1278,11 @@ upcase1 (int c)
1255} 1278}
1256 1279
1257/* 1 if C is lower case. */ 1280/* 1 if C is lower case. */
1258BUFFER_INLINE int lowercasep (int c) 1281BUFFER_INLINE bool
1259{ return !uppercasep (c) && upcase1 (c) != c; } 1282lowercasep (int c)
1283{
1284 return !uppercasep (c) && upcase1 (c) != c;
1285}
1260 1286
1261/* Upcase a character C, or make no change if that cannot be done. */ 1287/* Upcase a character C, or make no change if that cannot be done. */
1262BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } 1288BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
diff --git a/src/bytecode.c b/src/bytecode.c
index 5ac8b4fa2bd..40729cbd453 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -553,7 +553,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
553 if (INTEGERP (args_template)) 553 if (INTEGERP (args_template))
554 { 554 {
555 ptrdiff_t at = XINT (args_template); 555 ptrdiff_t at = XINT (args_template);
556 int rest = at & 128; 556 bool rest = (at & 128) != 0;
557 int mandatory = at & 127; 557 int mandatory = at & 127;
558 ptrdiff_t nonrest = at >> 8; 558 ptrdiff_t nonrest = at >> 8;
559 eassert (mandatory <= nonrest); 559 eassert (mandatory <= nonrest);
@@ -1051,7 +1051,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1051 1051
1052 CASE (Bsave_current_buffer): /* Obsolete since ??. */ 1052 CASE (Bsave_current_buffer): /* Obsolete since ??. */
1053 CASE (Bsave_current_buffer_1): 1053 CASE (Bsave_current_buffer_1):
1054 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 1054 record_unwind_current_buffer ();
1055 NEXT; 1055 NEXT;
1056 1056
1057 CASE (Bsave_window_excursion): /* Obsolete since 24.1. */ 1057 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/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/data.c b/src/data.c
index f812c280b40..d8b7f42ea3f 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;
@@ -1080,10 +1080,10 @@ DEFUN ("set", Fset, Sset, 2, 2, 0,
1080 return newval; 1080 return newval;
1081} 1081}
1082 1082
1083/* Return 1 if SYMBOL currently has a let-binding 1083/* Return true if SYMBOL currently has a let-binding
1084 which was made in the buffer that is now current. */ 1084 which was made in the buffer that is now current. */
1085 1085
1086static int 1086static bool
1087let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol) 1087let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol)
1088{ 1088{
1089 struct specbinding *p; 1089 struct specbinding *p;
@@ -1102,7 +1102,7 @@ let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol)
1102 return 0; 1102 return 0;
1103} 1103}
1104 1104
1105static int 1105static bool
1106let_shadows_global_binding_p (Lisp_Object symbol) 1106let_shadows_global_binding_p (Lisp_Object symbol)
1107{ 1107{
1108 struct specbinding *p; 1108 struct specbinding *p;
@@ -1118,14 +1118,15 @@ let_shadows_global_binding_p (Lisp_Object symbol)
1118 If buffer/frame-locality is an issue, WHERE specifies which context to use. 1118 If buffer/frame-locality is an issue, WHERE specifies which context to use.
1119 (nil stands for the current buffer/frame). 1119 (nil stands for the current buffer/frame).
1120 1120
1121 If BINDFLAG is zero, then if this symbol is supposed to become 1121 If BINDFLAG is false, then if this symbol is supposed to become
1122 local in every buffer where it is set, then we make it local. 1122 local in every buffer where it is set, then we make it local.
1123 If BINDFLAG is nonzero, we don't do that. */ 1123 If BINDFLAG is true, we don't do that. */
1124 1124
1125void 1125void
1126set_internal (register Lisp_Object symbol, register Lisp_Object newval, register Lisp_Object where, int bindflag) 1126set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1127 bool bindflag)
1127{ 1128{
1128 int voide = EQ (newval, Qunbound); 1129 bool voide = EQ (newval, Qunbound);
1129 struct Lisp_Symbol *sym; 1130 struct Lisp_Symbol *sym;
1130 Lisp_Object tem1; 1131 Lisp_Object tem1;
1131 1132
@@ -1464,7 +1465,8 @@ union Lisp_Val_Fwd
1464 }; 1465 };
1465 1466
1466static struct Lisp_Buffer_Local_Value * 1467static struct Lisp_Buffer_Local_Value *
1467make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd valcontents) 1468make_blv (struct Lisp_Symbol *sym, bool forwarded,
1469 union Lisp_Val_Fwd valcontents)
1468{ 1470{
1469 struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv); 1471 struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv);
1470 Lisp_Object symbol; 1472 Lisp_Object symbol;
@@ -1508,7 +1510,7 @@ The function `default-value' gets the default value and `set-default' sets it.
1508 struct Lisp_Symbol *sym; 1510 struct Lisp_Symbol *sym;
1509 struct Lisp_Buffer_Local_Value *blv = NULL; 1511 struct Lisp_Buffer_Local_Value *blv = NULL;
1510 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); 1512 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO});
1511 int forwarded IF_LINT (= 0); 1513 bool forwarded IF_LINT (= 0);
1512 1514
1513 CHECK_SYMBOL (variable); 1515 CHECK_SYMBOL (variable);
1514 sym = XSYMBOL (variable); 1516 sym = XSYMBOL (variable);
@@ -1580,10 +1582,10 @@ See also `make-variable-buffer-local'.
1580 1582
1581Do not use `make-local-variable' to make a hook variable buffer-local. 1583Do not use `make-local-variable' to make a hook variable buffer-local.
1582Instead, use `add-hook' and specify t for the LOCAL argument. */) 1584Instead, use `add-hook' and specify t for the LOCAL argument. */)
1583 (register Lisp_Object variable) 1585 (Lisp_Object variable)
1584{ 1586{
1585 register Lisp_Object tem; 1587 Lisp_Object tem;
1586 int forwarded IF_LINT (= 0); 1588 bool forwarded IF_LINT (= 0);
1587 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO}); 1589 union Lisp_Val_Fwd valcontents IF_LINT (= {LISP_INITIALLY_ZERO});
1588 struct Lisp_Symbol *sym; 1590 struct Lisp_Symbol *sym;
1589 struct Lisp_Buffer_Local_Value *blv = NULL; 1591 struct Lisp_Buffer_Local_Value *blv = NULL;
@@ -1767,9 +1769,9 @@ is to set the VARIABLE frame parameter of that frame. See
1767Note that since Emacs 23.1, variables cannot be both buffer-local and 1769Note that since Emacs 23.1, variables cannot be both buffer-local and
1768frame-local any more (buffer-local bindings used to take precedence over 1770frame-local any more (buffer-local bindings used to take precedence over
1769frame-local bindings). */) 1771frame-local bindings). */)
1770 (register Lisp_Object variable) 1772 (Lisp_Object variable)
1771{ 1773{
1772 int forwarded; 1774 bool forwarded;
1773 union Lisp_Val_Fwd valcontents; 1775 union Lisp_Val_Fwd valcontents;
1774 struct Lisp_Symbol *sym; 1776 struct Lisp_Symbol *sym;
1775 struct Lisp_Buffer_Local_Value *blv = NULL; 1777 struct Lisp_Buffer_Local_Value *blv = NULL;
@@ -2225,7 +2227,7 @@ static Lisp_Object
2225arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison) 2227arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
2226{ 2228{
2227 double f1 = 0, f2 = 0; 2229 double f1 = 0, f2 = 0;
2228 int floatp = 0; 2230 bool floatp = 0;
2229 2231
2230 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1); 2232 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1);
2231 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2); 2233 CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2);
@@ -2342,7 +2344,7 @@ DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0,
2342uintmax_t 2344uintmax_t
2343cons_to_unsigned (Lisp_Object c, uintmax_t max) 2345cons_to_unsigned (Lisp_Object c, uintmax_t max)
2344{ 2346{
2345 int valid = 0; 2347 bool valid = 0;
2346 uintmax_t val IF_LINT (= 0); 2348 uintmax_t val IF_LINT (= 0);
2347 if (INTEGERP (c)) 2349 if (INTEGERP (c))
2348 { 2350 {
@@ -2395,7 +2397,7 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
2395intmax_t 2397intmax_t
2396cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max) 2398cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max)
2397{ 2399{
2398 int valid = 0; 2400 bool valid = 0;
2399 intmax_t val IF_LINT (= 0); 2401 intmax_t val IF_LINT (= 0);
2400 if (INTEGERP (c)) 2402 if (INTEGERP (c))
2401 { 2403 {
@@ -2513,14 +2515,11 @@ static Lisp_Object float_arith_driver (double, ptrdiff_t, enum arithop,
2513static Lisp_Object 2515static Lisp_Object
2514arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) 2516arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args)
2515{ 2517{
2516 register Lisp_Object val; 2518 Lisp_Object val;
2517 ptrdiff_t argnum; 2519 ptrdiff_t argnum, ok_args;
2518 register EMACS_INT accum = 0; 2520 EMACS_INT accum = 0;
2519 register EMACS_INT next; 2521 EMACS_INT next, ok_accum;
2520 2522 bool overflow = 0;
2521 int overflow = 0;
2522 ptrdiff_t ok_args;
2523 EMACS_INT ok_accum;
2524 2523
2525 switch (code) 2524 switch (code)
2526 { 2525 {
@@ -3090,8 +3089,6 @@ syms_of_data (void)
3090 DEFSYM (Qchar_table, "char-table"); 3089 DEFSYM (Qchar_table, "char-table");
3091 DEFSYM (Qbool_vector, "bool-vector"); 3090 DEFSYM (Qbool_vector, "bool-vector");
3092 DEFSYM (Qhash_table, "hash-table"); 3091 DEFSYM (Qhash_table, "hash-table");
3093 /* Used by Fgarbage_collect. */
3094 DEFSYM (Qinterval, "interval");
3095 DEFSYM (Qmisc, "misc"); 3092 DEFSYM (Qmisc, "misc");
3096 3093
3097 DEFSYM (Qdefun, "defun"); 3094 DEFSYM (Qdefun, "defun");
diff --git a/src/dbusbind.c b/src/dbusbind.c
index f63f2948304..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
@@ -1686,7 +1685,7 @@ xd_read_message (Lisp_Object bus)
1686 1685
1687/* Callback called when something is ready to read or write. */ 1686/* Callback called when something is ready to read or write. */
1688static void 1687static void
1689xd_read_queued_messages (int fd, void *data, int for_read) 1688xd_read_queued_messages (int fd, void *data)
1690{ 1689{
1691 Lisp_Object busp = xd_registered_buses; 1690 Lisp_Object busp = xd_registered_buses;
1692 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..1140d98f8a7 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
@@ -3304,7 +3304,7 @@ extern Lisp_Object marginal_area_string (struct window *, enum window_part,
3304extern void redraw_frame (struct frame *); 3304extern void redraw_frame (struct frame *);
3305extern void cancel_line (int, struct frame *); 3305extern void cancel_line (int, struct frame *);
3306extern void init_desired_glyphs (struct frame *); 3306extern void init_desired_glyphs (struct frame *);
3307extern int update_frame (struct frame *, int, int); 3307extern bool update_frame (struct frame *, bool, bool);
3308extern void bitch_at_user (void); 3308extern void bitch_at_user (void);
3309void adjust_glyphs (struct frame *); 3309void adjust_glyphs (struct frame *);
3310void free_glyphs (struct frame *); 3310void free_glyphs (struct frame *);
@@ -3320,13 +3320,13 @@ void rotate_matrix (struct glyph_matrix *, int, int, int);
3320void increment_matrix_positions (struct glyph_matrix *, 3320void increment_matrix_positions (struct glyph_matrix *,
3321 int, int, ptrdiff_t, ptrdiff_t); 3321 int, int, ptrdiff_t, ptrdiff_t);
3322void blank_row (struct window *, struct glyph_row *, int); 3322void blank_row (struct window *, struct glyph_row *, int);
3323void enable_glyph_matrix_rows (struct glyph_matrix *, int, int, int); 3323void clear_glyph_matrix_rows (struct glyph_matrix *, int, int);
3324void clear_glyph_row (struct glyph_row *); 3324void clear_glyph_row (struct glyph_row *);
3325void prepare_desired_row (struct glyph_row *); 3325void prepare_desired_row (struct glyph_row *);
3326void set_window_update_flags (struct window *, int); 3326void set_window_update_flags (struct window *, bool);
3327void update_single_window (struct window *, int); 3327void update_single_window (struct window *, bool);
3328void do_pending_window_change (int); 3328void do_pending_window_change (bool);
3329void change_frame_size (struct frame *, int, int, int, int, int); 3329void change_frame_size (struct frame *, int, int, bool, bool, bool);
3330void init_display (void); 3330void init_display (void);
3331void syms_of_display (void); 3331void syms_of_display (void);
3332extern Lisp_Object Qredisplay_dont_pause; 3332extern Lisp_Object Qredisplay_dont_pause;
diff --git a/src/dispnew.c b/src/dispnew.c
index ce7c4ebcb4c..4e307880111 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -88,7 +88,7 @@ static void update_frame_line (struct frame *, int);
88static int required_matrix_height (struct window *); 88static int required_matrix_height (struct window *);
89static int required_matrix_width (struct window *); 89static int required_matrix_width (struct window *);
90static void adjust_frame_glyphs (struct frame *); 90static void adjust_frame_glyphs (struct frame *);
91static void change_frame_size_1 (struct frame *, int, int, int, int, int); 91static void change_frame_size_1 (struct frame *, int, int, bool, bool, bool);
92static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t); 92static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t);
93static void fill_up_frame_row_with_spaces (struct glyph_row *, int); 93static void fill_up_frame_row_with_spaces (struct glyph_row *, int);
94static void build_frame_matrix_from_window_tree (struct glyph_matrix *, 94static void build_frame_matrix_from_window_tree (struct glyph_matrix *,
@@ -98,20 +98,20 @@ static void build_frame_matrix_from_leaf_window (struct glyph_matrix *,
98static void adjust_frame_message_buffer (struct frame *); 98static void adjust_frame_message_buffer (struct frame *);
99static void adjust_decode_mode_spec_buffer (struct frame *); 99static void adjust_decode_mode_spec_buffer (struct frame *);
100static void fill_up_glyph_row_with_spaces (struct glyph_row *); 100static void fill_up_glyph_row_with_spaces (struct glyph_row *);
101static void clear_window_matrices (struct window *, int); 101static void clear_window_matrices (struct window *, bool);
102static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int); 102static void fill_up_glyph_row_area_with_spaces (struct glyph_row *, int);
103static int scrolling_window (struct window *, int); 103static int scrolling_window (struct window *, bool);
104static int update_window_line (struct window *, int, int *); 104static bool update_window_line (struct window *, int, bool *);
105static void mirror_make_current (struct window *, int); 105static void mirror_make_current (struct window *, int);
106#ifdef GLYPH_DEBUG 106#ifdef GLYPH_DEBUG
107static void check_matrix_pointers (struct glyph_matrix *, 107static void check_matrix_pointers (struct glyph_matrix *,
108 struct glyph_matrix *); 108 struct glyph_matrix *);
109#endif 109#endif
110static void mirror_line_dance (struct window *, int, int, int *, char *); 110static void mirror_line_dance (struct window *, int, int, int *, char *);
111static int update_window_tree (struct window *, int); 111static bool update_window_tree (struct window *, bool);
112static int update_window (struct window *, int); 112static bool update_window (struct window *, bool);
113static int update_frame_1 (struct frame *, int, int); 113static bool update_frame_1 (struct frame *, bool, bool);
114static int scrolling (struct frame *); 114static bool scrolling (struct frame *);
115static void set_window_cursor_after_update (struct window *); 115static void set_window_cursor_after_update (struct window *);
116static void adjust_frame_glyphs_for_window_redisplay (struct frame *); 116static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
117static void adjust_frame_glyphs_for_frame_redisplay (struct frame *); 117static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
@@ -122,14 +122,14 @@ static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
122static EMACS_TIME preemption_period; 122static EMACS_TIME preemption_period;
123static EMACS_TIME preemption_next_check; 123static EMACS_TIME preemption_next_check;
124 124
125/* Nonzero upon entry to redisplay means do not assume anything about 125/* True upon entry to redisplay means do not assume anything about
126 current contents of actual terminal frame; clear and redraw it. */ 126 current contents of actual terminal frame; clear and redraw it. */
127 127
128int frame_garbaged; 128bool frame_garbaged;
129 129
130/* Nonzero means last display completed. Zero means it was preempted. */ 130/* True means last display completed. False means it was preempted. */
131 131
132int display_completed; 132bool display_completed;
133 133
134Lisp_Object Qdisplay_table, Qredisplay_dont_pause; 134Lisp_Object Qdisplay_table, Qredisplay_dont_pause;
135 135
@@ -146,13 +146,13 @@ Lisp_Object selected_frame;
146 146
147struct frame *last_nonminibuf_frame; 147struct frame *last_nonminibuf_frame;
148 148
149/* 1 means SIGWINCH happened when not safe. */ 149/* True means SIGWINCH happened when not safe. */
150 150
151static int delayed_size_change; 151static bool delayed_size_change;
152 152
153/* 1 means glyph initialization has been completed at startup. */ 153/* 1 means glyph initialization has been completed at startup. */
154 154
155static int glyphs_initialized_initially_p; 155static bool glyphs_initialized_initially_p;
156 156
157/* Updated window if != 0. Set by update_window. */ 157/* Updated window if != 0. Set by update_window. */
158 158
@@ -178,15 +178,15 @@ static int glyph_pool_count;
178 178
179static struct frame *frame_matrix_frame; 179static struct frame *frame_matrix_frame;
180 180
181/* Non-zero means that fonts have been loaded since the last glyph 181/* True means that fonts have been loaded since the last glyph
182 matrix adjustments. Redisplay must stop, and glyph matrices must 182 matrix adjustments. Redisplay must stop, and glyph matrices must
183 be adjusted when this flag becomes non-zero during display. The 183 be adjusted when this flag becomes true during display. The
184 reason fonts can be loaded so late is that fonts of fontsets are 184 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 185 loaded on demand. Another reason is that a line contains many
186 characters displayed by zero width or very narrow glyphs of 186 characters displayed by zero width or very narrow glyphs of
187 variable-width fonts. */ 187 variable-width fonts. */
188 188
189int fonts_changed_p; 189bool fonts_changed_p;
190 190
191/* Convert vpos and hpos from frame to window and vice versa. 191/* Convert vpos and hpos from frame to window and vice versa.
192 This may only be used for terminal frames. */ 192 This may only be used for terminal frames. */
@@ -222,16 +222,14 @@ static int history_idx;
222 history. */ 222 history. */
223 223
224static uprintmax_t history_tick; 224static uprintmax_t history_tick;
225
226static void add_frame_display_history (struct frame *, int);
227 225
228/* Add to the redisplay history how window W has been displayed. 226/* Add to the redisplay history how window W has been displayed.
229 MSG is a trace containing the information how W's glyph matrix 227 MSG is a trace containing the information how W's glyph matrix
230 has been constructed. PAUSED_P non-zero means that the update 228 has been constructed. PAUSED_P means that the update
231 has been interrupted for pending input. */ 229 has been interrupted for pending input. */
232 230
233static void 231static void
234add_window_display_history (struct window *w, const char *msg, int paused_p) 232add_window_display_history (struct window *w, const char *msg, bool paused_p)
235{ 233{
236 char *buf; 234 char *buf;
237 235
@@ -254,11 +252,11 @@ add_window_display_history (struct window *w, const char *msg, int paused_p)
254 252
255 253
256/* Add to the redisplay history that frame F has been displayed. 254/* Add to the redisplay history that frame F has been displayed.
257 PAUSED_P non-zero means that the update has been interrupted for 255 PAUSED_P means that the update has been interrupted for
258 pending input. */ 256 pending input. */
259 257
260static void 258static void
261add_frame_display_history (struct frame *f, int paused_p) 259add_frame_display_history (struct frame *f, bool paused_p)
262{ 260{
263 char *buf; 261 char *buf;
264 262
@@ -395,10 +393,10 @@ margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin
395 return n; 393 return n;
396} 394}
397 395
398/* Return non-zero if ROW's hash value is correct, zero if not. 396/* Return true if ROW's hash value is correct.
399 Optimized away if ENABLE_CHECKING is not defined. */ 397 Optimized away if ENABLE_CHECKING is not defined. */
400 398
401static int 399static bool
402verify_row_hash (struct glyph_row *row) 400verify_row_hash (struct glyph_row *row)
403{ 401{
404 return row->hash == row_hash (row); 402 return row->hash == row_hash (row);
@@ -431,9 +429,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
431{ 429{
432 int i; 430 int i;
433 int new_rows; 431 int new_rows;
434 int marginal_areas_changed_p = 0; 432 bool marginal_areas_changed_p = 0;
435 int header_line_changed_p = 0; 433 bool header_line_changed_p = 0;
436 int header_line_p = 0; 434 bool header_line_p = 0;
437 int left = -1, right = -1; 435 int left = -1, right = -1;
438 int window_width = -1, window_height = -1; 436 int window_width = -1, window_height = -1;
439 437
@@ -736,30 +734,28 @@ increment_matrix_positions (struct glyph_matrix *matrix, int start, int end,
736} 734}
737 735
738 736
739/* Enable a range of rows in glyph matrix MATRIX. START and END are 737/* 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 738 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 739
743void 740void
744enable_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end, int enabled_p) 741clear_glyph_matrix_rows (struct glyph_matrix *matrix, int start, int end)
745{ 742{
746 eassert (start <= end); 743 eassert (start <= end);
747 eassert (start >= 0 && start < matrix->nrows); 744 eassert (start >= 0 && start < matrix->nrows);
748 eassert (end >= 0 && end <= matrix->nrows); 745 eassert (end >= 0 && end <= matrix->nrows);
749 746
750 for (; start < end; ++start) 747 for (; start < end; ++start)
751 matrix->rows[start].enabled_p = enabled_p != 0; 748 matrix->rows[start].enabled_p = 0;
752} 749}
753 750
754 751
755/* Clear MATRIX. 752/* Clear MATRIX.
756 753
757 This empties all rows in MATRIX by setting the enabled_p flag for 754 Empty all rows in MATRIX by clearing their enabled_p flags.
758 all rows of the matrix to zero. The function prepare_desired_row 755 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 756 when it sees one with a false enabled_p flag.
760 enabled_p flag.
761 757
762 Resets update hints to defaults value. The only update hint 758 Reset update hints to default values. The only update hint
763 currently present is the flag MATRIX->no_scrolling_p. */ 759 currently present is the flag MATRIX->no_scrolling_p. */
764 760
765void 761void
@@ -767,7 +763,7 @@ clear_glyph_matrix (struct glyph_matrix *matrix)
767{ 763{
768 if (matrix) 764 if (matrix)
769 { 765 {
770 enable_glyph_matrix_rows (matrix, 0, matrix->nrows, 0); 766 clear_glyph_matrix_rows (matrix, 0, matrix->nrows);
771 matrix->no_scrolling_p = 0; 767 matrix->no_scrolling_p = 0;
772 } 768 }
773} 769}
@@ -853,11 +849,11 @@ clear_desired_matrices (register struct frame *f)
853} 849}
854 850
855 851
856/* Clear matrices in window tree rooted in W. If DESIRED_P is 852/* Clear matrices in window tree rooted in W. If DESIRED_P,
857 non-zero clear desired matrices, otherwise clear current matrices. */ 853 clear desired matrices, otherwise clear current matrices. */
858 854
859static void 855static void
860clear_window_matrices (struct window *w, int desired_p) 856clear_window_matrices (struct window *w, bool desired_p)
861{ 857{
862 while (w) 858 while (w)
863 { 859 {
@@ -1109,12 +1105,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 1105/* 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 1106 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 1107 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 1108 is true if the glyph memory of WINDOW_ROW is part of the glyph
1113 memory of FRAME_ROW. */ 1109 memory of FRAME_ROW. */
1114 1110
1115#ifdef GLYPH_DEBUG 1111#ifdef GLYPH_DEBUG
1116 1112
1117static int 1113static bool
1118glyph_row_slice_p (struct glyph_row *window_row, struct glyph_row *frame_row) 1114glyph_row_slice_p (struct glyph_row *window_row, struct glyph_row *frame_row)
1119{ 1115{
1120 struct glyph *window_glyph_start = window_row->glyphs[0]; 1116 struct glyph *window_glyph_start = window_row->glyphs[0];
@@ -1161,7 +1157,7 @@ prepare_desired_row (struct glyph_row *row)
1161{ 1157{
1162 if (!row->enabled_p) 1158 if (!row->enabled_p)
1163 { 1159 {
1164 int rp = row->reversed_p; 1160 bool rp = row->reversed_p;
1165 1161
1166 clear_glyph_row (row); 1162 clear_glyph_row (row);
1167 row->enabled_p = 1; 1163 row->enabled_p = 1;
@@ -1260,12 +1256,11 @@ line_draw_cost (struct glyph_matrix *matrix, int vpos)
1260} 1256}
1261 1257
1262 1258
1263/* Test two glyph rows A and B for equality. Value is non-zero if A 1259/* 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 1260 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 1261
1267static inline int 1262static inline bool
1268row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) 1263row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p)
1269{ 1264{
1270 eassert (verify_row_hash (a)); 1265 eassert (verify_row_hash (a));
1271 eassert (verify_row_hash (b)); 1266 eassert (verify_row_hash (b));
@@ -1380,14 +1375,14 @@ free_glyph_pool (struct glyph_pool *pool)
1380 is changed from a large value to a smaller one. But, if someone 1375 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. 1376 does it once, we can expect that he will do it again.
1382 1377
1383 Value is non-zero if the pool changed in a way which makes 1378 Return true if the pool changed in a way which makes
1384 re-adjusting window glyph matrices necessary. */ 1379 re-adjusting window glyph matrices necessary. */
1385 1380
1386static int 1381static bool
1387realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) 1382realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim)
1388{ 1383{
1389 ptrdiff_t needed; 1384 ptrdiff_t needed;
1390 int changed_p; 1385 bool changed_p;
1391 1386
1392 changed_p = (pool->glyphs == 0 1387 changed_p = (pool->glyphs == 0
1393 || matrix_dim.height != pool->nrows 1388 || matrix_dim.height != pool->nrows
@@ -1561,7 +1556,7 @@ check_matrix_invariants (struct window *w)
1561 1556
1562 X and Y are column/row within the frame glyph matrix where 1557 X and Y are column/row within the frame glyph matrix where
1563 sub-matrices for the window tree rooted at WINDOW must be 1558 sub-matrices for the window tree rooted at WINDOW must be
1564 allocated. DIM_ONLY_P non-zero means that the caller of this 1559 allocated. DIM_ONLY_P means that the caller of this
1565 function is only interested in the result matrix dimension, and 1560 function is only interested in the result matrix dimension, and
1566 matrix adjustments should not be performed. 1561 matrix adjustments should not be performed.
1567 1562
@@ -1638,7 +1633,7 @@ check_matrix_invariants (struct window *w)
1638 1633
1639static struct dim 1634static struct dim
1640allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y, 1635allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1641 int dim_only_p, int *window_change_flags) 1636 bool dim_only_p, int *window_change_flags)
1642{ 1637{
1643 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window))); 1638 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
1644 int x0 = x, y0 = y; 1639 int x0 = x, y0 = y;
@@ -1646,7 +1641,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1646 struct dim total; 1641 struct dim total;
1647 struct dim dim; 1642 struct dim dim;
1648 struct window *w; 1643 struct window *w;
1649 int in_horz_combination_p; 1644 bool in_horz_combination_p;
1650 1645
1651 /* What combination is WINDOW part of? Compute this once since the 1646 /* What combination is WINDOW part of? Compute this once since the
1652 result is the same for all windows in the `next' chain. The 1647 result is the same for all windows in the `next' chain. The
@@ -1704,7 +1699,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1704 /* Actually change matrices, if allowed. Do not consider 1699 /* Actually change matrices, if allowed. Do not consider
1705 CHANGED_LEAF_MATRIX computed above here because the pool 1700 CHANGED_LEAF_MATRIX computed above here because the pool
1706 may have been changed which we don't now here. We trust 1701 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 1702 that we only will be called with DIM_ONLY_P when
1708 necessary. */ 1703 necessary. */
1709 if (!dim_only_p) 1704 if (!dim_only_p)
1710 { 1705 {
@@ -1919,9 +1914,9 @@ adjust_frame_glyphs (struct frame *f)
1919 f->glyphs_initialized_p = 1; 1914 f->glyphs_initialized_p = 1;
1920} 1915}
1921 1916
1922/* Return 1 if any window in the tree has nonzero window margins. See 1917/* 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. */ 1918 the hack at the end of adjust_frame_glyphs_for_frame_redisplay. */
1924static int 1919static bool
1925showing_window_margins_p (struct window *w) 1920showing_window_margins_p (struct window *w)
1926{ 1921{
1927 while (w) 1922 while (w)
@@ -2052,7 +2047,7 @@ static void
2052adjust_frame_glyphs_for_frame_redisplay (struct frame *f) 2047adjust_frame_glyphs_for_frame_redisplay (struct frame *f)
2053{ 2048{
2054 struct dim matrix_dim; 2049 struct dim matrix_dim;
2055 int pool_changed_p; 2050 bool pool_changed_p;
2056 int window_change_flags; 2051 int window_change_flags;
2057 int top_window_y; 2052 int top_window_y;
2058 2053
@@ -2468,7 +2463,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 2463 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 2464 current matrix is to be added to FRAME_MATRIX. W's flag
2470 must_be_updated_p determines which matrix it contributes to 2465 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 2466 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. 2467 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 2468 Adding a desired matrix means setting up used counters and such in
2474 frame rows, while adding a current window matrix to FRAME_MATRIX 2469 frame rows, while adding a current window matrix to FRAME_MATRIX
@@ -2519,7 +2514,7 @@ build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct w
2519 { 2514 {
2520 struct glyph_row *frame_row = frame_matrix->rows + frame_y; 2515 struct glyph_row *frame_row = frame_matrix->rows + frame_y;
2521 struct glyph_row *window_row = window_matrix->rows + window_y; 2516 struct glyph_row *window_row = window_matrix->rows + window_y;
2522 int current_row_p = window_matrix == w->current_matrix; 2517 bool current_row_p = window_matrix == w->current_matrix;
2523 2518
2524 /* Fill up the frame row with spaces up to the left margin of the 2519 /* Fill up the frame row with spaces up to the left margin of the
2525 window row. */ 2520 window row. */
@@ -2692,7 +2687,7 @@ make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_
2692{ 2687{
2693 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row); 2688 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row);
2694 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row); 2689 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, row);
2695 int mouse_face_p = current_row->mouse_face_p; 2690 bool mouse_face_p = current_row->mouse_face_p;
2696 2691
2697 /* Do current_row = desired_row. This exchanges glyph pointers 2692 /* Do current_row = desired_row. This exchanges glyph pointers
2698 between both rows, and does a structure assignment otherwise. */ 2693 between both rows, and does a structure assignment otherwise. */
@@ -2789,7 +2784,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
2789 /* Assign new rows, maybe clear lines. */ 2784 /* Assign new rows, maybe clear lines. */
2790 for (i = 0; i < nlines; ++i) 2785 for (i = 0; i < nlines; ++i)
2791 { 2786 {
2792 int enabled_before_p = new_rows[i].enabled_p; 2787 bool enabled_before_p = new_rows[i].enabled_p;
2793 2788
2794 eassert (i + unchanged_at_top < matrix->nrows); 2789 eassert (i + unchanged_at_top < matrix->nrows);
2795 eassert (unchanged_at_top + copy_from[i] < matrix->nrows); 2790 eassert (unchanged_at_top + copy_from[i] < matrix->nrows);
@@ -2897,7 +2892,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 2892 /* W is a leaf window, and we are working on its current
2898 matrix m. */ 2893 matrix m. */
2899 struct glyph_matrix *m = w->current_matrix; 2894 struct glyph_matrix *m = w->current_matrix;
2900 int i, sync_p = 0; 2895 int i;
2896 bool sync_p = 0;
2901 struct glyph_row *old_rows; 2897 struct glyph_row *old_rows;
2902 2898
2903 /* Make a copy of the original rows of matrix m. */ 2899 /* Make a copy of the original rows of matrix m. */
@@ -2919,22 +2915,19 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
2919 int window_from = frame_from - m->matrix_y; 2915 int window_from = frame_from - m->matrix_y;
2920 2916
2921 /* Is assigned line inside window? */ 2917 /* Is assigned line inside window? */
2922 int from_inside_window_p 2918 bool from_inside_window_p
2923 = window_from >= 0 && window_from < m->matrix_h; 2919 = window_from >= 0 && window_from < m->matrix_h;
2924 2920
2925 /* Is assigned to line inside window? */ 2921 /* Is assigned to line inside window? */
2926 int to_inside_window_p 2922 bool to_inside_window_p
2927 = window_to >= 0 && window_to < m->matrix_h; 2923 = window_to >= 0 && window_to < m->matrix_h;
2928 2924
2929 if (from_inside_window_p && to_inside_window_p) 2925 if (from_inside_window_p && to_inside_window_p)
2930 { 2926 {
2931 /* Enabled setting before assignment. */
2932 int enabled_before_p;
2933
2934 /* Do the assignment. The enabled_p flag is saved 2927 /* Do the assignment. The enabled_p flag is saved
2935 over the assignment because the old redisplay did 2928 over the assignment because the old redisplay did
2936 that. */ 2929 that. */
2937 enabled_before_p = m->rows[window_to].enabled_p; 2930 bool enabled_before_p = m->rows[window_to].enabled_p;
2938 m->rows[window_to] = old_rows[window_from]; 2931 m->rows[window_to] = old_rows[window_from];
2939 m->rows[window_to].enabled_p = enabled_before_p; 2932 m->rows[window_to].enabled_p = enabled_before_p;
2940 2933
@@ -3155,17 +3148,16 @@ DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
3155 3148
3156/* Update frame F based on the data in desired matrices. 3149/* Update frame F based on the data in desired matrices.
3157 3150
3158 If FORCE_P is non-zero, don't let redisplay be stopped by detecting 3151 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 3152 If INHIBIT_HAIRY_ID_P, don't try scrolling.
3160 scrolling.
3161 3153
3162 Value is non-zero if redisplay was stopped due to pending input. */ 3154 Value is true if redisplay was stopped due to pending input. */
3163 3155
3164int 3156bool
3165update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p) 3157update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
3166{ 3158{
3167 /* 1 means display has been paused because of pending input. */ 3159 /* True means display has been paused because of pending input. */
3168 int paused_p; 3160 bool paused_p;
3169 struct window *root_window = XWINDOW (f->root_window); 3161 struct window *root_window = XWINDOW (f->root_window);
3170 3162
3171 if (redisplay_dont_pause) 3163 if (redisplay_dont_pause)
@@ -3283,13 +3275,13 @@ update_frame (struct frame *f, int force_p, int inhibit_hairy_id_p)
3283 Window-based updates 3275 Window-based updates
3284 ************************************************************************/ 3276 ************************************************************************/
3285 3277
3286/* Perform updates in window tree rooted at W. FORCE_P non-zero means 3278/* Perform updates in window tree rooted at W.
3287 don't stop updating when input is pending. */ 3279 If FORCE_P, don't stop updating if input is pending. */
3288 3280
3289static int 3281static bool
3290update_window_tree (struct window *w, int force_p) 3282update_window_tree (struct window *w, bool force_p)
3291{ 3283{
3292 int paused_p = 0; 3284 bool paused_p = 0;
3293 3285
3294 while (w && !paused_p) 3286 while (w && !paused_p)
3295 { 3287 {
@@ -3307,11 +3299,11 @@ update_window_tree (struct window *w, int force_p)
3307} 3299}
3308 3300
3309 3301
3310/* Update window W if its flag must_be_updated_p is non-zero. If 3302/* 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. */ 3303 If FORCE_P, don't stop updating if input is pending. */
3312 3304
3313void 3305void
3314update_single_window (struct window *w, int force_p) 3306update_single_window (struct window *w, bool force_p)
3315{ 3307{
3316 if (w->must_be_updated_p) 3308 if (w->must_be_updated_p)
3317 { 3309 {
@@ -3460,7 +3452,7 @@ redraw_overlapping_rows (struct window *w, int yb)
3460static void 3452static void
3461check_current_matrix_flags (struct window *w) 3453check_current_matrix_flags (struct window *w)
3462{ 3454{
3463 int last_seen_p = 0; 3455 bool last_seen_p = 0;
3464 int i, yb = window_text_bottom_y (w); 3456 int i, yb = window_text_bottom_y (w);
3465 3457
3466 for (i = 0; i < w->current_matrix->nrows - 1; ++i) 3458 for (i = 0; i < w->current_matrix->nrows - 1; ++i)
@@ -3476,14 +3468,14 @@ check_current_matrix_flags (struct window *w)
3476#endif /* GLYPH_DEBUG */ 3468#endif /* GLYPH_DEBUG */
3477 3469
3478 3470
3479/* Update display of window W. FORCE_P non-zero means that we should 3471/* Update display of window W.
3480 not stop when detecting pending input. */ 3472 If FORCE_P, don't stop updating when input is pending. */
3481 3473
3482static int 3474static bool
3483update_window (struct window *w, int force_p) 3475update_window (struct window *w, bool force_p)
3484{ 3476{
3485 struct glyph_matrix *desired_matrix = w->desired_matrix; 3477 struct glyph_matrix *desired_matrix = w->desired_matrix;
3486 int paused_p; 3478 bool paused_p;
3487#if !PERIODIC_PREEMPTION_CHECKING 3479#if !PERIODIC_PREEMPTION_CHECKING
3488 int preempt_count = baud_rate / 2400 + 1; 3480 int preempt_count = baud_rate / 2400 + 1;
3489#endif 3481#endif
@@ -3506,7 +3498,8 @@ update_window (struct window *w, int force_p)
3506 struct glyph_row *row, *end; 3498 struct glyph_row *row, *end;
3507 struct glyph_row *mode_line_row; 3499 struct glyph_row *mode_line_row;
3508 struct glyph_row *header_line_row; 3500 struct glyph_row *header_line_row;
3509 int yb, changed_p = 0, mouse_face_overwritten_p = 0; 3501 int yb;
3502 bool changed_p = 0, mouse_face_overwritten_p = 0;
3510#if ! PERIODIC_PREEMPTION_CHECKING 3503#if ! PERIODIC_PREEMPTION_CHECKING
3511 int n_updated = 0; 3504 int n_updated = 0;
3512#endif 3505#endif
@@ -3693,15 +3686,15 @@ update_marginal_area (struct window *w, int area, int vpos)
3693 3686
3694 3687
3695/* Update the display of the text area of row VPOS in window W. 3688/* Update the display of the text area of row VPOS in window W.
3696 Value is non-zero if display has changed. */ 3689 Value is true if display has changed. */
3697 3690
3698static int 3691static bool
3699update_text_area (struct window *w, int vpos) 3692update_text_area (struct window *w, int vpos)
3700{ 3693{
3701 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); 3694 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
3702 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); 3695 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
3703 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 3696 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
3704 int changed_p = 0; 3697 bool changed_p = 0;
3705 3698
3706 /* Let functions in xterm.c know what area subsequent X positions 3699 /* Let functions in xterm.c know what area subsequent X positions
3707 will be relative to. */ 3700 will be relative to. */
@@ -3751,9 +3744,9 @@ update_text_area (struct window *w, int vpos)
3751 int stop, i, x; 3744 int stop, i, x;
3752 struct glyph *current_glyph = current_row->glyphs[TEXT_AREA]; 3745 struct glyph *current_glyph = current_row->glyphs[TEXT_AREA];
3753 struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA]; 3746 struct glyph *desired_glyph = desired_row->glyphs[TEXT_AREA];
3754 int overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p; 3747 bool overlapping_glyphs_p = current_row->contains_overlapping_glyphs_p;
3755 int desired_stop_pos = desired_row->used[TEXT_AREA]; 3748 int desired_stop_pos = desired_row->used[TEXT_AREA];
3756 int abort_skipping = 0; 3749 bool abort_skipping = 0;
3757 3750
3758 /* If the desired row extends its face to the text area end, and 3751 /* 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, 3752 unless the current row also does so at the same position,
@@ -3773,7 +3766,7 @@ update_text_area (struct window *w, int vpos)
3773 in common. */ 3766 in common. */
3774 while (i < stop) 3767 while (i < stop)
3775 { 3768 {
3776 int can_skip_p = !abort_skipping; 3769 bool can_skip_p = !abort_skipping;
3777 3770
3778 /* Skip over glyphs that both rows have in common. These 3771 /* Skip over glyphs that both rows have in common. These
3779 don't have to be written. We can't skip if the last 3772 don't have to be written. We can't skip if the last
@@ -3847,7 +3840,7 @@ update_text_area (struct window *w, int vpos)
3847 int start_x = x, start_hpos = i; 3840 int start_x = x, start_hpos = i;
3848 struct glyph *start = desired_glyph; 3841 struct glyph *start = desired_glyph;
3849 int current_x = x; 3842 int current_x = x;
3850 int skip_first_p = !can_skip_p; 3843 bool skip_first_p = !can_skip_p;
3851 3844
3852 /* Find the next glyph that's equal again. */ 3845 /* Find the next glyph that's equal again. */
3853 while (i < stop 3846 while (i < stop
@@ -3938,16 +3931,15 @@ update_text_area (struct window *w, int vpos)
3938} 3931}
3939 3932
3940 3933
3941/* Update row VPOS in window W. Value is non-zero if display has been 3934/* Update row VPOS in window W. Value is true if display has been changed. */
3942 changed. */
3943 3935
3944static int 3936static bool
3945update_window_line (struct window *w, int vpos, int *mouse_face_overwritten_p) 3937update_window_line (struct window *w, int vpos, bool *mouse_face_overwritten_p)
3946{ 3938{
3947 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos); 3939 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, vpos);
3948 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos); 3940 struct glyph_row *desired_row = MATRIX_ROW (w->desired_matrix, vpos);
3949 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 3941 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
3950 int changed_p = 0; 3942 bool changed_p = 0;
3951 3943
3952 /* Set the row being updated. This is important to let xterm.c 3944 /* Set the row being updated. This is important to let xterm.c
3953 know what line height values are in effect. */ 3945 know what line height values are in effect. */
@@ -4095,7 +4087,7 @@ set_window_cursor_after_update (struct window *w)
4095 tree rooted at W. */ 4087 tree rooted at W. */
4096 4088
4097void 4089void
4098set_window_update_flags (struct window *w, int on_p) 4090set_window_update_flags (struct window *w, bool on_p)
4099{ 4091{
4100 while (w) 4092 while (w)
4101 { 4093 {
@@ -4198,7 +4190,7 @@ add_row_entry (struct glyph_row *row)
4198 4190
4199 4191
4200/* Try to reuse part of the current display of W by scrolling lines. 4192/* 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. 4193 HEADER_LINE_P means W has a header line.
4202 4194
4203 The algorithm is taken from Communications of the ACM, Apr78 "A 4195 The algorithm is taken from Communications of the ACM, Apr78 "A
4204 Technique for Isolating Differences Between Files." It should take 4196 Technique for Isolating Differences Between Files." It should take
@@ -4224,7 +4216,7 @@ add_row_entry (struct glyph_row *row)
4224 1 if we did scroll. */ 4216 1 if we did scroll. */
4225 4217
4226static int 4218static int
4227scrolling_window (struct window *w, int header_line_p) 4219scrolling_window (struct window *w, bool header_line_p)
4228{ 4220{
4229 struct glyph_matrix *desired_matrix = w->desired_matrix; 4221 struct glyph_matrix *desired_matrix = w->desired_matrix;
4230 struct glyph_matrix *current_matrix = w->current_matrix; 4222 struct glyph_matrix *current_matrix = w->current_matrix;
@@ -4237,7 +4229,7 @@ scrolling_window (struct window *w, int header_line_p)
4237 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 4229 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
4238 4230
4239 /* Skip over rows equal at the start. */ 4231 /* Skip over rows equal at the start. */
4240 for (i = header_line_p ? 1 : 0; i < current_matrix->nrows - 1; ++i) 4232 for (i = header_line_p; i < current_matrix->nrows - 1; ++i)
4241 { 4233 {
4242 struct glyph_row *d = MATRIX_ROW (desired_matrix, i); 4234 struct glyph_row *d = MATRIX_ROW (desired_matrix, i);
4243 struct glyph_row *c = MATRIX_ROW (current_matrix, i); 4235 struct glyph_row *c = MATRIX_ROW (current_matrix, i);
@@ -4496,7 +4488,7 @@ scrolling_window (struct window *w, int header_line_p)
4496 for (j = nruns - 1; j > i; --j) 4488 for (j = nruns - 1; j > i; --j)
4497 { 4489 {
4498 struct run *p = runs[j]; 4490 struct run *p = runs[j];
4499 int truncated_p = 0; 4491 bool truncated_p = 0;
4500 4492
4501 if (p->nrows > 0 4493 if (p->nrows > 0
4502 && p->desired_y < r->desired_y + r->height 4494 && p->desired_y < r->desired_y + r->height
@@ -4559,7 +4551,7 @@ scrolling_window (struct window *w, int header_line_p)
4559 for (j = 0; j < r->nrows; ++j) 4551 for (j = 0; j < r->nrows; ++j)
4560 { 4552 {
4561 struct glyph_row *from, *to; 4553 struct glyph_row *from, *to;
4562 int to_overlapped_p; 4554 bool to_overlapped_p;
4563 4555
4564 to = MATRIX_ROW (current_matrix, r->desired_vpos + j); 4556 to = MATRIX_ROW (current_matrix, r->desired_vpos + j);
4565 from = MATRIX_ROW (desired_matrix, r->desired_vpos + j); 4557 from = MATRIX_ROW (desired_matrix, r->desired_vpos + j);
@@ -4594,20 +4586,19 @@ scrolling_window (struct window *w, int header_line_p)
4594 4586
4595/* Update the desired frame matrix of frame F. 4587/* Update the desired frame matrix of frame F.
4596 4588
4597 FORCE_P non-zero means that the update should not be stopped by 4589 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 4590 INHIBIT_HAIRY_ID_P means that scrolling should not be tried.
4599 should not be tried.
4600 4591
4601 Value is non-zero if update was stopped due to pending input. */ 4592 Value is true if update was stopped due to pending input. */
4602 4593
4603static int 4594static bool
4604update_frame_1 (struct frame *f, int force_p, int inhibit_id_p) 4595update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
4605{ 4596{
4606 /* Frame matrices to work on. */ 4597 /* Frame matrices to work on. */
4607 struct glyph_matrix *current_matrix = f->current_matrix; 4598 struct glyph_matrix *current_matrix = f->current_matrix;
4608 struct glyph_matrix *desired_matrix = f->desired_matrix; 4599 struct glyph_matrix *desired_matrix = f->desired_matrix;
4609 int i; 4600 int i;
4610 int pause_p; 4601 bool pause_p;
4611 int preempt_count = baud_rate / 2400 + 1; 4602 int preempt_count = baud_rate / 2400 + 1;
4612 4603
4613 eassert (current_matrix && desired_matrix); 4604 eassert (current_matrix && desired_matrix);
@@ -4699,7 +4690,7 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
4699 } 4690 }
4700 } 4691 }
4701 4692
4702 pause_p = (i < FRAME_LINES (f) - 1) ? i : 0; 4693 pause_p = 0 < i && i < FRAME_LINES (f) - 1;
4703 4694
4704 /* Now just clean up termcap drivers and set cursor, etc. */ 4695 /* Now just clean up termcap drivers and set cursor, etc. */
4705 if (!pause_p) 4696 if (!pause_p)
@@ -4809,7 +4800,7 @@ update_frame_1 (struct frame *f, int force_p, int inhibit_id_p)
4809 4800
4810/* Do line insertions/deletions on frame F for frame-based redisplay. */ 4801/* Do line insertions/deletions on frame F for frame-based redisplay. */
4811 4802
4812static int 4803static bool
4813scrolling (struct frame *frame) 4804scrolling (struct frame *frame)
4814{ 4805{
4815 int unchanged_at_top, unchanged_at_bottom; 4806 int unchanged_at_top, unchanged_at_bottom;
@@ -4952,10 +4943,10 @@ update_frame_line (struct frame *f, int vpos)
4952 struct glyph_matrix *desired_matrix = f->desired_matrix; 4943 struct glyph_matrix *desired_matrix = f->desired_matrix;
4953 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos); 4944 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos);
4954 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos); 4945 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos);
4955 int must_write_whole_line_p; 4946 bool must_write_whole_line_p;
4956 int write_spaces_p = FRAME_MUST_WRITE_SPACES (f); 4947 bool write_spaces_p = FRAME_MUST_WRITE_SPACES (f);
4957 int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background 4948 bool colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
4958 != FACE_TTY_DEFAULT_BG_COLOR); 4949 != FACE_TTY_DEFAULT_BG_COLOR);
4959 4950
4960 if (colored_spaces_p) 4951 if (colored_spaces_p)
4961 write_spaces_p = 1; 4952 write_spaces_p = 1;
@@ -5289,7 +5280,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 5280 /* 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 5281 vpos still counts from the glyph row that includes the window's
5291 start position. Adjust for a possible header-line row. */ 5282 start position. Adjust for a possible header-line row. */
5292 it.vpos += WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0; 5283 it.vpos += WINDOW_WANTS_HEADER_LINE_P (w);
5293 5284
5294 x0 = *x; 5285 x0 = *x;
5295 5286
@@ -5613,12 +5604,12 @@ window_change_signal (int signalnum) /* If we don't have an argument, */
5613#endif /* SIGWINCH */ 5604#endif /* SIGWINCH */
5614 5605
5615 5606
5616/* Do any change in frame size that was requested by a signal. SAFE 5607/* 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 5608 SAFE means this function is called from a place where it is
5618 safe to change frame sizes while a redisplay is in progress. */ 5609 safe to change frame sizes while a redisplay is in progress. */
5619 5610
5620void 5611void
5621do_pending_window_change (int safe) 5612do_pending_window_change (bool safe)
5622{ 5613{
5623 /* If window_change_signal should have run before, run it now. */ 5614 /* If window_change_signal should have run before, run it now. */
5624 if (redisplaying_p && !safe) 5615 if (redisplaying_p && !safe)
@@ -5645,16 +5636,17 @@ do_pending_window_change (int safe)
5645/* Change the frame height and/or width. Values may be given as zero to 5636/* Change the frame height and/or width. Values may be given as zero to
5646 indicate no change is to take place. 5637 indicate no change is to take place.
5647 5638
5648 If DELAY is non-zero, then assume we're being called from a signal 5639 If DELAY, assume we're being called from a signal handler, and
5649 handler, and queue the change for later - perhaps the next 5640 queue the change for later - perhaps the next redisplay.
5650 redisplay. Since this tries to resize windows, we can't call it 5641 Since this tries to resize windows, we can't call it
5651 from a signal handler. 5642 from a signal handler.
5652 5643
5653 SAFE non-zero means this function is called from a place where it's 5644 SAFE means this function is called from a place where it's
5654 safe to change frame sizes while a redisplay is in progress. */ 5645 safe to change frame sizes while a redisplay is in progress. */
5655 5646
5656void 5647void
5657change_frame_size (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) 5648change_frame_size (struct frame *f, int newheight, int newwidth,
5649 bool pretend, bool delay, bool safe)
5658{ 5650{
5659 Lisp_Object tail, frame; 5651 Lisp_Object tail, frame;
5660 5652
@@ -5673,7 +5665,8 @@ change_frame_size (register struct frame *f, int newheight, int newwidth, int pr
5673} 5665}
5674 5666
5675static void 5667static void
5676change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int pretend, int delay, int safe) 5668change_frame_size_1 (struct frame *f, int newheight, int newwidth,
5669 bool pretend, bool delay, bool safe)
5677{ 5670{
5678 int new_frame_total_cols; 5671 int new_frame_total_cols;
5679 ptrdiff_t count = SPECPDL_INDEX (); 5672 ptrdiff_t count = SPECPDL_INDEX ();
@@ -5769,7 +5762,7 @@ change_frame_size_1 (register struct frame *f, int newheight, int newwidth, int
5769 5762
5770 UNBLOCK_INPUT; 5763 UNBLOCK_INPUT;
5771 5764
5772 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 5765 record_unwind_current_buffer ();
5773 5766
5774 run_window_configuration_change_hook (f); 5767 run_window_configuration_change_hook (f);
5775 5768
@@ -5929,13 +5922,13 @@ additional wait period, in milliseconds; this is for backwards compatibility.
5929 5922
5930 TIMEOUT is number of seconds to wait (float or integer), 5923 TIMEOUT is number of seconds to wait (float or integer),
5931 or t to wait forever. 5924 or t to wait forever.
5932 READING is 1 if reading input. 5925 READING is true if reading input.
5933 If DO_DISPLAY is >0 display process output while waiting. 5926 If DO_DISPLAY is >0 display process output while waiting.
5934 If DO_DISPLAY is >1 perform an initial redisplay before waiting. 5927 If DO_DISPLAY is >1 perform an initial redisplay before waiting.
5935*/ 5928*/
5936 5929
5937Lisp_Object 5930Lisp_Object
5938sit_for (Lisp_Object timeout, int reading, int do_display) 5931sit_for (Lisp_Object timeout, bool reading, int do_display)
5939{ 5932{
5940 intmax_t sec; 5933 intmax_t sec;
5941 int nsec; 5934 int nsec;
diff --git a/src/editfns.c b/src/editfns.c
index 0bd632d14b7..7b451e4e443 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -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,
diff --git a/src/emacs.c b/src/emacs.c
index 9e7efcabbf7..7ff5c43dbea 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -279,11 +279,6 @@ static int fatal_error_code;
279/* Nonzero if handling a fatal error already. */ 279/* Nonzero if handling a fatal error already. */
280int fatal_error_in_progress; 280int fatal_error_in_progress;
281 281
282/* If non-null, call this function from fatal_error_signal before
283 committing suicide. */
284
285static void (*fatal_error_signal_hook) (void);
286
287#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD 282#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
288/* When compiled with GTK and running under Gnome, 283/* When compiled with GTK and running under Gnome,
289 multiple threads may be created. Keep track of our main 284 multiple threads may be created. Keep track of our main
@@ -331,9 +326,6 @@ fatal_error_signal (int sig)
331 sigunblock (sigmask (fatal_error_code)); 326 sigunblock (sigmask (fatal_error_code));
332#endif 327#endif
333 328
334 if (fatal_error_signal_hook)
335 fatal_error_signal_hook ();
336
337 kill (getpid (), fatal_error_code); 329 kill (getpid (), fatal_error_code);
338} 330}
339 331
diff --git a/src/eval.c b/src/eval.c
index c41e3f54d4d..df44c87dc25 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2722,33 +2722,9 @@ DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0,
2722 doc: /* Non-nil if OBJECT is a function. */) 2722 doc: /* Non-nil if OBJECT is a function. */)
2723 (Lisp_Object object) 2723 (Lisp_Object object)
2724{ 2724{
2725 if (SYMBOLP (object) && !NILP (Ffboundp (object))) 2725 if (FUNCTIONP (object))
2726 {
2727 object = Findirect_function (object, Qt);
2728
2729 if (CONSP (object) && EQ (XCAR (object), Qautoload))
2730 {
2731 /* Autoloaded symbols are functions, except if they load
2732 macros or keymaps. */
2733 int i;
2734 for (i = 0; i < 4 && CONSP (object); i++)
2735 object = XCDR (object);
2736
2737 return (CONSP (object) && !NILP (XCAR (object))) ? Qnil : Qt;
2738 }
2739 }
2740
2741 if (SUBRP (object))
2742 return (XSUBR (object)->max_args != UNEVALLED) ? Qt : Qnil;
2743 else if (COMPILEDP (object))
2744 return Qt; 2726 return Qt;
2745 else if (CONSP (object)) 2727 return Qnil;
2746 {
2747 Lisp_Object car = XCAR (object);
2748 return (EQ (car, Qlambda) || EQ (car, Qclosure)) ? Qt : Qnil;
2749 }
2750 else
2751 return Qnil;
2752} 2728}
2753 2729
2754DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, 2730DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
diff --git a/src/fileio.c b/src/fileio.c
index 6deca0bf1e1..7466914af1c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -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
diff --git a/src/fns.c b/src/fns.c
index 3225fefc5e3..f6acdcada3f 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1100,7 +1100,7 @@ an error is signaled. */)
1100 { 1100 {
1101 ptrdiff_t chars = SCHARS (string); 1101 ptrdiff_t chars = SCHARS (string);
1102 unsigned char *str = xmalloc (chars); 1102 unsigned char *str = xmalloc (chars);
1103 ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0); 1103 ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars);
1104 1104
1105 if (converted < chars) 1105 if (converted < chars)
1106 error ("Can't convert the %"pD"dth character to unibyte", converted); 1106 error ("Can't convert the %"pD"dth character to unibyte", converted);
@@ -4656,13 +4656,12 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4656 { 4656 {
4657 struct buffer *prev = current_buffer; 4657 struct buffer *prev = current_buffer;
4658 4658
4659 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 4659 record_unwind_current_buffer ();
4660 4660
4661 CHECK_BUFFER (object); 4661 CHECK_BUFFER (object);
4662 4662
4663 bp = XBUFFER (object); 4663 bp = XBUFFER (object);
4664 if (bp != current_buffer) 4664 set_buffer_internal (bp);
4665 set_buffer_internal (bp);
4666 4665
4667 if (NILP (start)) 4666 if (NILP (start))
4668 b = BEGV; 4667 b = BEGV;
@@ -4749,8 +4748,7 @@ secure_hash (Lisp_Object algorithm, Lisp_Object object, Lisp_Object start, Lisp_
4749 } 4748 }
4750 4749
4751 object = make_buffer_string (b, e, 0); 4750 object = make_buffer_string (b, e, 0);
4752 if (prev != current_buffer) 4751 set_buffer_internal (prev);
4753 set_buffer_internal (prev);
4754 /* Discard the unwind protect for recovering the current 4752 /* Discard the unwind protect for recovering the current
4755 buffer. */ 4753 buffer. */
4756 specpdl_ptr--; 4754 specpdl_ptr--;
diff --git a/src/frame.c b/src/frame.c
index a00f44a1e5a..4785840a95f 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4247,7 +4247,6 @@ syms_of_frame (void)
4247 DEFSYM (Qx, "x"); 4247 DEFSYM (Qx, "x");
4248 DEFSYM (Qw32, "w32"); 4248 DEFSYM (Qw32, "w32");
4249 DEFSYM (Qpc, "pc"); 4249 DEFSYM (Qpc, "pc");
4250 DEFSYM (Qmac, "mac");
4251 DEFSYM (Qns, "ns"); 4250 DEFSYM (Qns, "ns");
4252 DEFSYM (Qvisible, "visible"); 4251 DEFSYM (Qvisible, "visible");
4253 DEFSYM (Qbuffer_predicate, "buffer-predicate"); 4252 DEFSYM (Qbuffer_predicate, "buffer-predicate");
diff --git a/src/frame.h b/src/frame.h
index 92fbda42c70..9421aa45414 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. */
@@ -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
diff --git a/src/insdel.c b/src/insdel.c
index 1dceb67bffa..8cb98566085 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1779,8 +1779,7 @@ modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end,
1779{ 1779{
1780 struct buffer *old_buffer = current_buffer; 1780 struct buffer *old_buffer = current_buffer;
1781 1781
1782 if (buffer != old_buffer) 1782 set_buffer_internal (buffer);
1783 set_buffer_internal (buffer);
1784 1783
1785 prepare_to_modify_buffer (start, end, NULL); 1784 prepare_to_modify_buffer (start, end, NULL);
1786 1785
@@ -1794,8 +1793,7 @@ modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end,
1794 1793
1795 bset_point_before_scroll (buffer, Qnil); 1794 bset_point_before_scroll (buffer, Qnil);
1796 1795
1797 if (buffer != old_buffer) 1796 set_buffer_internal (old_buffer);
1798 set_buffer_internal (old_buffer);
1799} 1797}
1800 1798
1801/* Check that it is okay to modify the buffer between START and END, 1799/* Check that it is okay to modify the buffer between START and END,
@@ -2119,7 +2117,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
2119 return Qnil; 2117 return Qnil;
2120 } 2118 }
2121 2119
2122 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 2120 record_unwind_current_buffer ();
2123 2121
2124 Fset_buffer (combine_after_change_buffer); 2122 Fset_buffer (combine_after_change_buffer);
2125 2123
diff --git a/src/keyboard.c b/src/keyboard.c
index 3d4061accfc..d9b88a8a911 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1434,8 +1434,7 @@ command_loop_1 (void)
1434 Fkill_emacs (Qnil); 1434 Fkill_emacs (Qnil);
1435 1435
1436 /* Make sure the current window's buffer is selected. */ 1436 /* Make sure the current window's buffer is selected. */
1437 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 1437 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1438 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1439 1438
1440 /* Display any malloc warning that just came out. Use while because 1439 /* Display any malloc warning that just came out. Use while because
1441 displaying one warning can cause another. */ 1440 displaying one warning can cause another. */
@@ -1513,8 +1512,7 @@ command_loop_1 (void)
1513 /* A filter may have run while we were reading the input. */ 1512 /* A filter may have run while we were reading the input. */
1514 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 1513 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
1515 Fkill_emacs (Qnil); 1514 Fkill_emacs (Qnil);
1516 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 1515 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1517 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
1518 1516
1519 ++num_input_keys; 1517 ++num_input_keys;
1520 1518
@@ -9574,7 +9572,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9574 because we may get input from a subprocess which 9572 because we may get input from a subprocess which
9575 wants to change the selected window and stuff (say, 9573 wants to change the selected window and stuff (say,
9576 emacsclient). */ 9574 emacsclient). */
9577 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 9575 record_unwind_current_buffer ();
9578 9576
9579 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9577 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9580 Fkill_emacs (Qnil); 9578 Fkill_emacs (Qnil);
@@ -11251,7 +11249,7 @@ The `posn-' functions access elements of such lists. */)
11251 11249
11252 if (WINDOWP (frame_or_window)) 11250 if (WINDOWP (frame_or_window))
11253 { 11251 {
11254 struct window *w = decode_valid_window (frame_or_window); 11252 struct window *w = decode_live_window (frame_or_window);
11255 11253
11256 XSETINT (x, (XINT (x) 11254 XSETINT (x, (XINT (x)
11257 + WINDOW_LEFT_EDGE_X (w) 11255 + WINDOW_LEFT_EDGE_X (w)
diff --git a/src/keymap.c b/src/keymap.c
index 21f7dcb5d37..4031091501c 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 }
diff --git a/src/lisp.h b/src/lisp.h
index d9a7c9d0bdc..49a2832d686 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -606,10 +606,8 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
606 606
607#define AREF(ARRAY, IDX) XVECTOR ((ARRAY))->contents[IDX] 607#define AREF(ARRAY, IDX) XVECTOR ((ARRAY))->contents[IDX]
608#define ASIZE(ARRAY) XVECTOR ((ARRAY))->header.size 608#define ASIZE(ARRAY) XVECTOR ((ARRAY))->header.size
609/* The IDX==IDX tries to detect when the macro argument is side-effecting. */
610#define ASET(ARRAY, IDX, VAL) \ 609#define ASET(ARRAY, IDX, VAL) \
611 (eassert ((IDX) == (IDX)), \ 610 (eassert (0 <= (IDX) && (IDX) < ASIZE (ARRAY)), \
612 eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)), \
613 XVECTOR (ARRAY)->contents[IDX] = (VAL)) 611 XVECTOR (ARRAY)->contents[IDX] = (VAL))
614 612
615/* Convenience macros for dealing with Lisp strings. */ 613/* Convenience macros for dealing with Lisp strings. */
@@ -1906,11 +1904,7 @@ typedef struct {
1906 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object) 1904 Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
1907 1905
1908/* Non-zero if OBJ is a Lisp function. */ 1906/* Non-zero if OBJ is a Lisp function. */
1909#define FUNCTIONP(OBJ) \ 1907#define FUNCTIONP(OBJ) functionp(OBJ)
1910 ((CONSP (OBJ) && EQ (XCAR (OBJ), Qlambda)) \
1911 || (SYMBOLP (OBJ) && !NILP (Ffboundp (OBJ))) \
1912 || COMPILEDP (OBJ) \
1913 || SUBRP (OBJ))
1914 1908
1915/* defsubr (Sname); 1909/* defsubr (Sname);
1916 is how we define the symbol for function `name' at start-up time. */ 1910 is how we define the symbol for function `name' at start-up time. */
@@ -2579,8 +2573,7 @@ extern Lisp_Object Qoverflow_error, Qunderflow_error;
2579extern Lisp_Object Qfloatp; 2573extern Lisp_Object Qfloatp;
2580extern Lisp_Object Qnumberp, Qnumber_or_marker_p; 2574extern Lisp_Object Qnumberp, Qnumber_or_marker_p;
2581 2575
2582extern Lisp_Object Qinteger, Qinterval, Qsymbol, Qstring; 2576extern Lisp_Object Qbuffer, Qinteger, Qsymbol;
2583extern Lisp_Object Qmisc, Qvector, Qfloat, Qcons, Qbuffer;
2584 2577
2585extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; 2578extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
2586 2579
@@ -2627,7 +2620,7 @@ extern _Noreturn void args_out_of_range_3 (Lisp_Object, Lisp_Object,
2627 Lisp_Object); 2620 Lisp_Object);
2628extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object); 2621extern _Noreturn Lisp_Object wrong_type_argument (Lisp_Object, Lisp_Object);
2629extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *); 2622extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *);
2630extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, int); 2623extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool);
2631extern void syms_of_data (void); 2624extern void syms_of_data (void);
2632extern void init_data (void); 2625extern void init_data (void);
2633extern void swap_in_global_binding (struct Lisp_Symbol *); 2626extern void swap_in_global_binding (struct Lisp_Symbol *);
@@ -2639,7 +2632,7 @@ extern void keys_of_cmds (void);
2639/* Defined in coding.c */ 2632/* Defined in coding.c */
2640extern Lisp_Object Qcharset; 2633extern Lisp_Object Qcharset;
2641extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, 2634extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
2642 ptrdiff_t, int, int, Lisp_Object); 2635 ptrdiff_t, bool, bool, Lisp_Object);
2643extern void init_coding (void); 2636extern void init_coding (void);
2644extern void init_coding_once (void); 2637extern void init_coding_once (void);
2645extern void syms_of_coding (void); 2638extern void syms_of_coding (void);
@@ -2773,7 +2766,7 @@ _Noreturn void __executable_start (void);
2773#endif 2766#endif
2774extern Lisp_Object selected_frame; 2767extern Lisp_Object selected_frame;
2775extern Lisp_Object Vwindow_system; 2768extern Lisp_Object Vwindow_system;
2776extern Lisp_Object sit_for (Lisp_Object, int, int); 2769extern Lisp_Object sit_for (Lisp_Object, bool, int);
2777extern void init_display (void); 2770extern void init_display (void);
2778extern void syms_of_display (void); 2771extern void syms_of_display (void);
2779 2772
@@ -3110,14 +3103,14 @@ extern void syms_of_editfns (void);
3110extern void set_time_zone_rule (const char *); 3103extern void set_time_zone_rule (const char *);
3111 3104
3112/* Defined in buffer.c. */ 3105/* Defined in buffer.c. */
3113extern int mouse_face_overlay_overlaps (Lisp_Object); 3106extern bool mouse_face_overlay_overlaps (Lisp_Object);
3114extern _Noreturn void nsberror (Lisp_Object); 3107extern _Noreturn void nsberror (Lisp_Object);
3115extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t); 3108extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t);
3116extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t); 3109extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t);
3117extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t); 3110extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t);
3118extern void report_overlay_modification (Lisp_Object, Lisp_Object, int, 3111extern void report_overlay_modification (Lisp_Object, Lisp_Object, bool,
3119 Lisp_Object, Lisp_Object, Lisp_Object); 3112 Lisp_Object, Lisp_Object, Lisp_Object);
3120extern int overlay_touches_p (ptrdiff_t); 3113extern bool overlay_touches_p (ptrdiff_t);
3121extern Lisp_Object Vbuffer_alist; 3114extern Lisp_Object Vbuffer_alist;
3122extern Lisp_Object set_buffer_if_live (Lisp_Object); 3115extern Lisp_Object set_buffer_if_live (Lisp_Object);
3123extern Lisp_Object other_buffer_safely (Lisp_Object); 3116extern Lisp_Object other_buffer_safely (Lisp_Object);
@@ -3330,7 +3323,7 @@ extern void setup_process_coding_systems (Lisp_Object);
3330#ifndef DOS_NT 3323#ifndef DOS_NT
3331 _Noreturn 3324 _Noreturn
3332#endif 3325#endif
3333extern int child_setup (int, int, int, char **, int, Lisp_Object); 3326extern int child_setup (int, int, int, char **, bool, Lisp_Object);
3334extern void init_callproc_1 (void); 3327extern void init_callproc_1 (void);
3335extern void init_callproc (void); 3328extern void init_callproc (void);
3336extern void set_initial_environment (void); 3329extern void set_initial_environment (void);
@@ -3441,7 +3434,7 @@ extern void syms_of_ccl (void);
3441extern void syms_of_dired (void); 3434extern void syms_of_dired (void);
3442extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object, 3435extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
3443 Lisp_Object, Lisp_Object, 3436 Lisp_Object, Lisp_Object,
3444 int, Lisp_Object); 3437 bool, Lisp_Object);
3445 3438
3446/* Defined in term.c */ 3439/* Defined in term.c */
3447extern int *char_ins_del_vector; 3440extern int *char_ins_del_vector;
@@ -3586,7 +3579,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
3586extern void *record_xmalloc (size_t); 3579extern void *record_xmalloc (size_t);
3587 3580
3588#define USE_SAFE_ALLOCA \ 3581#define USE_SAFE_ALLOCA \
3589 ptrdiff_t sa_count = SPECPDL_INDEX (); int sa_must_free = 0 3582 ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = 0
3590 3583
3591/* SAFE_ALLOCA allocates a simple buffer. */ 3584/* SAFE_ALLOCA allocates a simple buffer. */
3592 3585
@@ -3656,6 +3649,38 @@ maybe_gc (void)
3656 Fgarbage_collect (); 3649 Fgarbage_collect ();
3657} 3650}
3658 3651
3652LISP_INLINE int
3653functionp (Lisp_Object object)
3654{
3655 if (SYMBOLP (object) && !NILP (Ffboundp (object)))
3656 {
3657 object = Findirect_function (object, Qt);
3658
3659 if (CONSP (object) && EQ (XCAR (object), Qautoload))
3660 {
3661 /* Autoloaded symbols are functions, except if they load
3662 macros or keymaps. */
3663 int i;
3664 for (i = 0; i < 4 && CONSP (object); i++)
3665 object = XCDR (object);
3666
3667 return ! (CONSP (object) && !NILP (XCAR (object)));
3668 }
3669 }
3670
3671 if (SUBRP (object))
3672 return XSUBR (object)->max_args != UNEVALLED;
3673 else if (COMPILEDP (object))
3674 return 1;
3675 else if (CONSP (object))
3676 {
3677 Lisp_Object car = XCAR (object);
3678 return EQ (car, Qlambda) || EQ (car, Qclosure);
3679 }
3680 else
3681 return 0;
3682}
3683
3659INLINE_HEADER_END 3684INLINE_HEADER_END
3660 3685
3661#endif /* EMACS_LISP_H */ 3686#endif /* EMACS_LISP_H */
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index bdb292099bc..e5959e0b1a5 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -480,6 +480,7 @@ $(BLD)/alloc.$(O) : \
480 $(SRC)/syssignal.h \ 480 $(SRC)/syssignal.h \
481 $(SRC)/w32.h \ 481 $(SRC)/w32.h \
482 $(NT_INC)/unistd.h \ 482 $(NT_INC)/unistd.h \
483 $(GNU_LIB)/execinfo.h \
483 $(GNU_LIB)/verify.h \ 484 $(GNU_LIB)/verify.h \
484 $(BLOCKINPUT_H) \ 485 $(BLOCKINPUT_H) \
485 $(BUFFER_H) \ 486 $(BUFFER_H) \
diff --git a/src/minibuf.c b/src/minibuf.c
index 2154d1654df..41cc48017eb 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"));
diff --git a/src/nsmenu.m b/src/nsmenu.m
index e8a0b43a01b..ab285f26df2 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1497,6 +1497,7 @@ 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;
1500 area.origin.x = 3*SPACER; 1501 area.origin.x = 3*SPACER;
1501 area.origin.y = 2*SPACER; 1502 area.origin.y = 2*SPACER;
1502 area.size.width = ICONSIZE; 1503 area.size.width = ICONSIZE;
@@ -1584,7 +1585,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
1584 1585
1585- (BOOL)windowShouldClose: (id)sender 1586- (BOOL)windowShouldClose: (id)sender
1586{ 1587{
1587 [NSApp stopModalWithCode: XHASH (Qnil)]; // FIXME: BIG UGLY HACK!! 1588 [NSApp stop:self];
1588 return NO; 1589 return NO;
1589} 1590}
1590 1591
@@ -1673,7 +1674,11 @@ void process_dialog (id window, Lisp_Object list)
1673 1674
1674 seltag = [[sellist objectAtIndex: 0] tag]; 1675 seltag = [[sellist objectAtIndex: 0] tag];
1675 if (seltag != XHASH (Qundefined)) // FIXME: BIG UGLY HACK!! 1676 if (seltag != XHASH (Qundefined)) // FIXME: BIG UGLY HACK!!
1676 [NSApp stopModalWithCode: seltag]; 1677 {
1678 dialog_return = seltag;
1679 [NSApp stop:self];
1680 }
1681
1677 return self; 1682 return self;
1678} 1683}
1679 1684
@@ -1756,13 +1761,27 @@ void process_dialog (id window, Lisp_Object list)
1756 1761
1757- (void)timeout_handler: (NSTimer *)timedEntry 1762- (void)timeout_handler: (NSTimer *)timedEntry
1758{ 1763{
1764 NSEvent *nxev = [NSEvent otherEventWithType: NSApplicationDefined
1765 location: NSMakePoint (0, 0)
1766 modifierFlags: 0
1767 timestamp: 0
1768 windowNumber: [[NSApp mainWindow] windowNumber]
1769 context: [NSApp context]
1770 subtype: 0
1771 data1: 0
1772 data2: 0];
1773
1759 timer_fired = 1; 1774 timer_fired = 1;
1760 [NSApp abortModal]; 1775 /* We use sto because stopModal/abortModal out of the main loop does not
1776 seem to work in 10.6. But as we use stop we must send a real event so
1777 the stop is seen and acted upon. */
1778 [NSApp stop:self];
1779 [NSApp postEvent: nxev atStart: NO];
1761} 1780}
1762 1781
1763- (Lisp_Object)runDialogAt: (NSPoint)p 1782- (Lisp_Object)runDialogAt: (NSPoint)p
1764{ 1783{
1765 NSInteger ret = 0; 1784 Lisp_Object ret = Qundefined;
1766 1785
1767 while (popup_activated_flag) 1786 while (popup_activated_flag)
1768 { 1787 {
@@ -1781,7 +1800,9 @@ void process_dialog (id window, Lisp_Object list)
1781 forMode: NSModalPanelRunLoopMode]; 1800 forMode: NSModalPanelRunLoopMode];
1782 } 1801 }
1783 timer_fired = 0; 1802 timer_fired = 0;
1803 dialog_return = Qundefined;
1784 ret = [NSApp runModalForWindow: self]; 1804 ret = [NSApp runModalForWindow: self];
1805 ret = dialog_return;
1785 if (! timer_fired) 1806 if (! timer_fired)
1786 { 1807 {
1787 if (tmo != nil) [tmo invalidate]; /* Cancels timer */ 1808 if (tmo != nil) [tmo invalidate]; /* Cancels timer */
diff --git a/src/nsterm.h b/src/nsterm.h
index 54f4a4ec89e..72b8d13cc47 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -196,6 +196,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
196 NSMatrix *matrix; 196 NSMatrix *matrix;
197 int rows, cols; 197 int rows, cols;
198 int timer_fired; 198 int timer_fired;
199 Lisp_Object dialog_return;
199 } 200 }
200- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ; 201- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
201- addButton: (char *)str value: (Lisp_Object)val row: (int)row; 202- addButton: (char *)str value: (Lisp_Object)val row: (int)row;
diff --git a/src/nsterm.m b/src/nsterm.m
index 12ca52684e6..c892a5486a7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5091,7 +5091,8 @@ not_in_argv (NSString *arg)
5091 /* TODO: still need this? */ 5091 /* TODO: still need this? */
5092 if (code == 0x2DC) 5092 if (code == 0x2DC)
5093 code = '~'; /* 0x7E */ 5093 code = '~'; /* 0x7E */
5094 emacs_event->modifiers = 0; 5094 if (code != 32) /* Space */
5095 emacs_event->modifiers = 0;
5095 emacs_event->kind 5096 emacs_event->kind
5096 = code > 0xFF ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT; 5097 = code > 0xFF ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT;
5097 emacs_event->code = code; 5098 emacs_event->code = code;
diff --git a/src/print.c b/src/print.c
index 64449aeaf2a..52c07c79122 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
diff --git a/src/process.c b/src/process.c
index 7f6f6bafbea..fbe56ebcb54 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4870,15 +4870,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4870 for (channel = 0; channel <= max_input_desc; ++channel) 4870 for (channel = 0; channel <= max_input_desc; ++channel)
4871 { 4871 {
4872 struct fd_callback_data *d = &fd_callback_info[channel]; 4872 struct fd_callback_data *d = &fd_callback_info[channel];
4873 if (FD_ISSET (channel, &Available) 4873 if (d->func
4874 && d->func != 0 4874 && ((d->condition & FOR_READ
4875 && (d->condition & FOR_READ) != 0) 4875 && FD_ISSET (channel, &Available))
4876 d->func (channel, d->data, 1); 4876 || (d->condition & FOR_WRITE
4877 if (FD_ISSET (channel, &write_mask) 4877 && FD_ISSET (channel, &write_mask))))
4878 && d->func != 0 4878 d->func (channel, d->data);
4879 && (d->condition & FOR_WRITE) != 0) 4879 }
4880 d->func (channel, d->data, 0);
4881 }
4882 4880
4883 for (channel = 0; channel <= max_process_desc; channel++) 4881 for (channel = 0; channel <= max_process_desc; channel++)
4884 { 4882 {
@@ -5198,7 +5196,7 @@ read_process_output (Lisp_Object proc, register int channel)
5198 /* There's no good reason to let process filters change the current 5196 /* There's no good reason to let process filters change the current
5199 buffer, and many callers of accept-process-output, sit-for, and 5197 buffer, and many callers of accept-process-output, sit-for, and
5200 friends don't expect current-buffer to be changed from under them. */ 5198 friends don't expect current-buffer to be changed from under them. */
5201 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 5199 record_unwind_current_buffer ();
5202 5200
5203 /* Read and dispose of the process output. */ 5201 /* Read and dispose of the process output. */
5204 outstream = p->filter; 5202 outstream = p->filter;
@@ -6589,7 +6587,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6589 /* There's no good reason to let sentinels change the current 6587 /* There's no good reason to let sentinels change the current
6590 buffer, and many callers of accept-process-output, sit-for, and 6588 buffer, and many callers of accept-process-output, sit-for, and
6591 friends don't expect current-buffer to be changed from under them. */ 6589 friends don't expect current-buffer to be changed from under them. */
6592 record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); 6590 record_unwind_current_buffer ();
6593 6591
6594 sentinel = p->sentinel; 6592 sentinel = p->sentinel;
6595 if (NILP (sentinel)) 6593 if (NILP (sentinel))
diff --git a/src/process.h b/src/process.h
index 55a572117c6..ce3d2e702cc 100644
--- a/src/process.h
+++ b/src/process.h
@@ -184,7 +184,7 @@ pset_gnutls_cred_type (struct Lisp_Process *p, Lisp_Object val)
184 184
185/* True if we are about to fork off a synchronous process or if we 185/* True if we are about to fork off a synchronous process or if we
186 are waiting for it. */ 186 are waiting for it. */
187extern int synch_process_alive; 187extern bool synch_process_alive;
188 188
189/* Communicate exit status of sync process to from sigchld_handler 189/* Communicate exit status of sync process to from sigchld_handler
190 to Fcall_process. */ 190 to Fcall_process. */
@@ -219,7 +219,7 @@ extern void hold_keyboard_input (void);
219extern void unhold_keyboard_input (void); 219extern void unhold_keyboard_input (void);
220extern int kbd_on_hold_p (void); 220extern int kbd_on_hold_p (void);
221 221
222typedef void (*fd_callback)(int fd, void *data, int for_read); 222typedef void (*fd_callback) (int fd, void *data);
223 223
224extern void add_read_fd (int fd, fd_callback func, void *data); 224extern void add_read_fd (int fd, fd_callback func, void *data);
225extern void delete_read_fd (int fd); 225extern void delete_read_fd (int fd);
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..84a46e522bb 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
diff --git a/src/window.c b/src/window.c
index 4d92566b243..ba1ec2544f8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -54,7 +54,8 @@ 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;
@@ -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;
@@ -1968,6 +1969,9 @@ unshow_buffer (register struct window *w)
1968 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.
1969 So don't clobber point in that buffer. */ 1970 So don't clobber point in that buffer. */
1970 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 */
1971 /* This line helps to fix Horsley's testbug.el bug. */ 1975 /* This line helps to fix Horsley's testbug.el bug. */
1972 && !(WINDOWP (BVAR (b, last_selected_window)) 1976 && !(WINDOWP (BVAR (b, last_selected_window))
1973 && w != XWINDOW (BVAR (b, last_selected_window)) 1977 && w != XWINDOW (BVAR (b, last_selected_window))
@@ -3097,7 +3101,7 @@ run_window_configuration_change_hook (struct frame *f)
3097 /* Use the right buffer. Matters when running the local hooks. */ 3101 /* Use the right buffer. Matters when running the local hooks. */
3098 if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) 3102 if (current_buffer != XBUFFER (Fwindow_buffer (Qnil)))
3099 { 3103 {
3100 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 3104 record_unwind_current_buffer ();
3101 Fset_buffer (Fwindow_buffer (Qnil)); 3105 Fset_buffer (Fwindow_buffer (Qnil));
3102 } 3106 }
3103 3107
@@ -3134,7 +3138,7 @@ run_window_configuration_change_hook (struct frame *f)
3134DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, 3138DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook,
3135 Srun_window_configuration_change_hook, 1, 1, 0, 3139 Srun_window_configuration_change_hook, 1, 1, 0,
3136 doc: /* Run `window-configuration-change-hook' for FRAME. */) 3140 doc: /* Run `window-configuration-change-hook' for FRAME. */)
3137 (Lisp_Object frame) 3141 (Lisp_Object frame)
3138{ 3142{
3139 CHECK_LIVE_FRAME (frame); 3143 CHECK_LIVE_FRAME (frame);
3140 run_window_configuration_change_hook (XFRAME (frame)); 3144 run_window_configuration_change_hook (XFRAME (frame));
@@ -3201,7 +3205,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int
3201 because that might itself be a local variable. */ 3205 because that might itself be a local variable. */
3202 if (window_initialized) 3206 if (window_initialized)
3203 { 3207 {
3204 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 3208 record_unwind_current_buffer ();
3205 Fset_buffer (buffer); 3209 Fset_buffer (buffer);
3206 } 3210 }
3207 3211
@@ -5899,7 +5903,13 @@ the return value is nil. Otherwise the value is t. */)
5899 } 5903 }
5900 5904
5901 if (!NILP (new_current_buffer)) 5905 if (!NILP (new_current_buffer))
5902 Fset_buffer (new_current_buffer); 5906 {
5907 Fset_buffer (new_current_buffer);
5908 /* If the new current buffer doesn't appear in the selected
5909 window, go to its old point (see bug#12208). */
5910 if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer))
5911 Fgoto_char (make_number (old_point));
5912 }
5903 5913
5904 Vminibuf_scroll_window = data->minibuf_scroll_window; 5914 Vminibuf_scroll_window = data->minibuf_scroll_window;
5905 minibuf_selected_window = data->minibuf_selected_window; 5915 minibuf_selected_window = data->minibuf_selected_window;
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 f5edb4b16f8..13b03736bde 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -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}
@@ -14551,8 +14551,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14551 make_number (CHARPOS (startp))); 14551 make_number (CHARPOS (startp)));
14552 SET_TEXT_POS_FROM_MARKER (startp, w->start); 14552 SET_TEXT_POS_FROM_MARKER (startp, w->start);
14553 /* In case the hook functions switch buffers. */ 14553 /* In case the hook functions switch buffers. */
14554 if (current_buffer != XBUFFER (w->buffer)) 14554 set_buffer_internal (XBUFFER (w->buffer));
14555 set_buffer_internal_1 (XBUFFER (w->buffer));
14556 } 14555 }
14557 14556
14558 return startp; 14557 return startp;
@@ -15380,7 +15379,7 @@ set_vertical_scroll_bar (struct window *w)
15380 selected_window is redisplayed. 15379 selected_window is redisplayed.
15381 15380
15382 We can return without actually redisplaying the window if 15381 We can return without actually redisplaying the window if
15383 fonts_changed_p is nonzero. In that case, redisplay_internal will 15382 fonts_changed_p. In that case, redisplay_internal will
15384 retry. */ 15383 retry. */
15385 15384
15386static void 15385static void
@@ -16224,7 +16223,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16224 } 16223 }
16225#endif /* HAVE_WINDOW_SYSTEM */ 16224#endif /* HAVE_WINDOW_SYSTEM */
16226 16225
16227 /* We go to this label, with fonts_changed_p nonzero, 16226 /* We go to this label, with fonts_changed_p set,
16228 if it is necessary to try again using larger glyph matrices. 16227 if it is necessary to try again using larger glyph matrices.
16229 We have to redeem the scroll bar even in this case, 16228 We have to redeem the scroll bar even in this case,
16230 because the loop in redisplay_internal expects that. */ 16229 because the loop in redisplay_internal expects that. */
@@ -17705,15 +17704,15 @@ try_window_id (struct window *w)
17705 { 17704 {
17706 rotate_matrix (current_matrix, first_unchanged_at_end_vpos + dvpos, 17705 rotate_matrix (current_matrix, first_unchanged_at_end_vpos + dvpos,
17707 bottom_vpos, dvpos); 17706 bottom_vpos, dvpos);
17708 enable_glyph_matrix_rows (current_matrix, bottom_vpos + dvpos, 17707 clear_glyph_matrix_rows (current_matrix, bottom_vpos + dvpos,
17709 bottom_vpos, 0); 17708 bottom_vpos);
17710 } 17709 }
17711 else if (dvpos > 0) 17710 else if (dvpos > 0)
17712 { 17711 {
17713 rotate_matrix (current_matrix, first_unchanged_at_end_vpos, 17712 rotate_matrix (current_matrix, first_unchanged_at_end_vpos,
17714 bottom_vpos, dvpos); 17713 bottom_vpos, dvpos);
17715 enable_glyph_matrix_rows (current_matrix, first_unchanged_at_end_vpos, 17714 clear_glyph_matrix_rows (current_matrix, first_unchanged_at_end_vpos,
17716 first_unchanged_at_end_vpos + dvpos, 0); 17715 first_unchanged_at_end_vpos + dvpos);
17717 } 17716 }
17718 17717
17719 /* For frame-based redisplay, make sure that current frame and window 17718 /* For frame-based redisplay, make sure that current frame and window
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..7e61cc4d8ea 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10815,8 +10815,6 @@ x_initialize (void)
10815 XSetIOErrorHandler (x_io_error_quitter); 10815 XSetIOErrorHandler (x_io_error_quitter);
10816 10816
10817 signal (SIGPIPE, x_connection_signal); 10817 signal (SIGPIPE, x_connection_signal);
10818
10819 xgselect_initialize ();
10820} 10818}
10821 10819
10822 10820