aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog373
-rw-r--r--src/Makefile.in28
-rw-r--r--src/alloc.c15
-rw-r--r--src/commands.h3
-rw-r--r--src/conf_post.h14
-rw-r--r--src/cygw32.c169
-rw-r--r--src/cygw32.h53
-rw-r--r--src/dispextern.h4
-rw-r--r--src/dispnew.c10
-rw-r--r--src/emacs.c61
-rw-r--r--src/font.c4
-rw-r--r--src/font.h5
-rw-r--r--src/fontset.c2
-rw-r--r--src/frame.c12
-rw-r--r--src/frame.h5
-rw-r--r--src/image.c80
-rw-r--r--src/indent.c1
-rw-r--r--src/keyboard.c324
-rw-r--r--src/keyboard.h30
-rw-r--r--src/keymap.c159
-rw-r--r--src/keymap.h13
-rw-r--r--src/lisp.h27
-rw-r--r--src/makefile.w32-in28
-rw-r--r--src/marker.c2
-rw-r--r--src/menu.c6
-rw-r--r--src/nsfont.m13
-rw-r--r--src/nsmenu.m3
-rw-r--r--src/nsterm.m7
-rw-r--r--src/process.c15
-rw-r--r--src/ralloc.c5
-rw-r--r--src/regex.c1
-rw-r--r--src/search.c16
-rw-r--r--src/term.c1
-rw-r--r--src/termhooks.h6
-rw-r--r--src/termopts.h11
-rw-r--r--src/unexcw.c1
-rw-r--r--src/unexw32.c3
-rw-r--r--src/w32.c20
-rw-r--r--src/w32.h17
-rw-r--r--src/w32common.h53
-rw-r--r--src/w32console.c51
-rw-r--r--src/w32fns.c811
-rw-r--r--src/w32font.c4
-rw-r--r--src/w32heap.c55
-rw-r--r--src/w32heap.h23
-rw-r--r--src/w32inevt.c172
-rw-r--r--src/w32menu.c29
-rw-r--r--src/w32proc.c15
-rw-r--r--src/w32select.c9
-rw-r--r--src/w32select.h28
-rw-r--r--src/w32term.c50
-rw-r--r--src/w32term.h59
-rw-r--r--src/w32xfns.c32
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c7
-rw-r--r--src/xfaces.c18
-rw-r--r--src/xsettings.c1
-rw-r--r--src/xsmfns.c1
58 files changed, 1996 insertions, 971 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 492b966a256..0b274598986 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,10 +1,368 @@
12012-10-11 Paul Eggert <eggert@cs.ucla.edu>
2
3 * marker.c (cached_modiff): EMACS_INT, not int.
4
5 * w32select.c (waiting_for_input): Declare by including "keyboard.h"
6 instead of having a wrong decl.
7 * nsmenu.m (waiting_for_input): Remove wrong decl.
8
92012-10-10 Paul Eggert <eggert@cs.ucla.edu>
10
11 keyboard.c, keymap.c: Use bool for booleans.
12 * dispnew.c (sit_for): Distinguish between 3-way display_option
13 and boolean do_display.
14 * keyboard.c (single_kboard, this_command_key_count_reset)
15 (waiting_for_input, echoing, immediate_quit, input_pending)
16 (interrupt_input, interrupts_deferred, pop_kboard)
17 (temporarily_switch_to_single_kboard, ignore_mouse_drag_p)
18 (command_loop_1, adjust_point_for_property)
19 (safe_run_hooks_error, input_polling_used, read_char):
20 (help_char_p, readable_events, kbd_buffer_events_waiting)
21 (kbd_buffer_get_event, timer_check_2, make_lispy_event)
22 (lucid_event_type_list_p, get_input_pending):
23 (gobble_input, menu_separator_name_p, menu_bar_item)
24 (parse_menu_item, parse_tool_bar_item, read_char_x_menu_prompt)
25 (read_char_minibuf_menu_prompt, access_keymap_keyremap)
26 (keyremap_step, test_undefined, read_key_sequence)
27 (detect_input_pending, detect_input_pending_ignore_squeezables)
28 (detect_input_pending_run_timers, requeued_events_pending_p)
29 (quit_throw_to_read_char, Fset_input_interrupt_mode):
30 * keymap.c (get_keymap, keymap_parent, keymap_memberp)
31 (access_keymap_1, access_keymap, map_keymap, get_keyelt)
32 (Fdefine_key, Flookup_key, struct accessible_keymaps_data)
33 (accessible_keymaps_1, Fkey_description, push_key_description):
34 (shadow_lookup, struct where_is_internal_data)
35 (where_is_internal, Fwhere_is_internal, where_is_internal_1)
36 (Fdescribe_buffer_bindings, describe_map_tree, struct describe_map_elt)
37 (describe_map, describe_vector):
38 * menu.c (single_menu_item):
39 * nsmenu.m (ns_update_menubar):
40 * process.c (wait_reading_process_output):
41 * search.c (scan_buffer, scan_newline):
42 Use bool for boolean.
43 * keyboard.c (timers_run, swallow_events)
44 (detect_input_pending_run_timers):
45 * process.c (wait_reading_process_output):
46 Use unsigned for counter where wraparound-on-overflow is desired,
47 since unsigned is guaranteed to have that behavior and signed is not.
48 (read_char): Use ptrdiff_t for string length.
49 (get_input_pending): Remove first argument, since it was always
50 the same pointer-to-int (now pointer-to-boolean) &input_pending,
51 and behave as if it had that value. Return new value of
52 input_pending. All callers changed.
53 * keyboard.h (struct kboard): Use unsigned : 1 for boolean member
54 immediate_echo. Use ptrdiff_t for echo_after_prompt, since it's
55 a string length.
56 * keymap.c (push_key_description): Omit last arg, which was always 1.
57 All callers changed.
58
59 * regex.c (immediate_quit) [emacs]: Remove duplicate decl.
60
612012-10-10 Juanma Barranquero <lekktu@gmail.com>
62
63 * makefile.w32-in ($(BLD)/dispnew.$(O), $(BLD)/indent.$(O))
64 ($(BLD)/term.$(O)): Update dependencies.
65
662012-10-10 Dmitry Antipov <dmantipov@yandex.ru>
67
68 * alloc.c (mark_object): Use meaningful PVEC_NORMAL_VECTOR.
69 * lisp.h (enum pvec_type): Adjust comments and omit explicit
70 initializer for PVEC_NORMAL_VECTOR.
71
722012-10-10 Paul Eggert <eggert@cs.ucla.edu>
73
74 Clean out old termopts cruft.
75 * termopts.h (flow_control, meta_key): Remove unused decls.
76 * dispnew.c, indent.c, nsterm.m, term.c, xsettings.c, xsmfns.c:
77 Don't include termopts.h.
78
792012-10-10 Dmitry Antipov <dmantipov@yandex.ru>
80
81 * alloc.c (gc_sweep): Use pointer-to-a-pointer loop for buffers.
82
832012-10-10 Paul Eggert <eggert@cs.ucla.edu>
84
85 * commands.h (immediate_quit): Remove duplicate decl.
86
872012-10-09 Jan Djärv <jan.h.d@swipnet.se>
88
89 * nsfont.m (Vfonts_in_cache): Remove, not needed as font.c handles
90 caching.
91 (nsfont_open): Remove setting of Vfonts_in_cache.
92 (syms_of_nsfont): Remove initialization of Vfonts_in_cache
93
942012-10-09 Eli Zaretskii <eliz@gnu.org>
95
96 * w32fns.c (w32_last_error): Change the return value to DWORD, to
97 match what GetLastError returns. Explain why the function is
98 needed.
99
100 * frame.c (delete_frame): Rename local variable 'tooltip_frame' to
101 'is_tooltip_frame', to avoid confusion with its global namesake.
102
1032012-10-08 Daniel Colascione <dancol@dancol.org>
104
105 * xdisp.c (start_hourglass): Call w32_note_current_window when
106 HAVE_NTGUI, not just WINDOWSNT, resolving a problem in the cygw32
107 build that caused Emacs to display the hourglass cursor forever.
108
109 * w32fns.c (Fx_display_color_cells): Instead of using NCOLORS,
110 which is broken under remote desktop, calculate the number of
111 colors available for a display based on the display's number of
112 planes and number of bits per pixel per plane. (bug#10397).
113
1142012-10-08 Jan Djärv <jan.h.d@swipnet.se>
115
116 * nsfont.m (Vfonts_in_cache): New variable.
117 (nsfont_open): Use unsignedLongLongValue for cache in case wide ints
118 are used. Add cached fonts to Vfonts_in_cache.
119 (syms_of_nsfont): Initialize and staticpro Vfonts_in_cache.
120
1212012-10-08 Juanma Barranquero <lekktu@gmail.com>
122
123 * makefile.w32-in (LOCAL_FLAGS): Don't define HAVE_NTGUI, it's now
124 in nt/config.nt.
125 (FONT_H): Define after FRAME_H.
126 ($(BLD)/emacs.$(O), $(BLD)/process.$(O), $(BLD)/w32heap.$(O)):
127 Update dependencies.
128
129 * w32term.c: Remove leftover declaration of keyboard_codepage.
130
1312012-10-08 Eli Zaretskii <eliz@gnu.org>
132
133 * makefile.w32-in (FONT_H): Add $(FRAME_H).
134 (W32TERM_H): Add $(ATIMER_H) and $(FRAME_H).
135 ($(BLD)/emacs.$(O), $(BLD)/w32console.$(O)): Update dependencies.
136 (GLOBAL_SOURCES): Add cygw32.c.
137 ($(BLD)/unexw32.$(O)):
138 ($(BLD)/w32.$(O)):
139 ($(BLD)/w32console.$(O)):
140 ($(BLD)/w32fns.$(O)):
141 ($(BLD)/w32heap.$(O)):
142 ($(BLD)/w32menu.$(O)):
143 ($(BLD)/w32proc.$(O)): Add w32common.h.
144
145 * w32fns.c (w32_color_map_lookup, x_to_w32_color): Argument is now
146 'const char *'.
147 (x_to_w32_color): Don't modify the argument, modify a copy instead.
148
1492012-10-08 Daniel Colascione <dancol@dancol.org>
150
151 * w32term.h (WM_EMACS_BRINGTOTOP, WM_EMACS_INPUT_READY)
152 (WM_EMACS_END): Change WM_EMACS_BRINGTOTOP from 22 to 21 to close
153 accidental message numbering hole. Change other messages to
154 match.
155
156 * w32select.h (HAVE_W32SELECT): Remove.
157
158 * w32select.c, w32proc.c, w32menu.c, w32console.c, w32.c: Include
159 w32common.h instead of w32heap.h
160
161 * w32heap.h (ROUND_UP, ROUND_DOWN, get_page_size)
162 (get_allocation_unit, get_processor_type, get_w32_major_version)
163 (get_w32_minor_version, sysinfo_cache, osinfo_cache)
164 (w32_major_version, w32_minor_version, w32_build_number, OS_9X)
165 (OS_NT, os_subtype, cache_system_info): Move declarations to
166 w32common.
167
168 * w32heap.c: Include w32common.h.
169 (sysinfo_cache, syspage_mask, osinfo_cache, w32_major_version)
170 (w32_minor_version, w32_build_number, w32_subtype): Remove
171 duplicate definitions.
172
173 * w32fns.c: Include w32common.h; include w32heap.h only in
174 WINDOWSNT.
175
176 (Fx_file_dialog): Clarify comment on GetOpenFileName structure.
177 Use `report_file_error' instead of `error' in order to better
178 inform users of what went wrong. Increase NTGUI_UNICODE file
179 dialog box file name length to 32k, the maximum allowed by the NT
180 kernel.
181
182 * w32common.h: New file.
183 (ROUND_UP, ROUND_DOWN, get_page_size)
184 (get_allocation_unit, get_processor_type, get_w32_major_version)
185 (get_w32_minor_version, sysinfo_cache, osinfo_cache)
186 (w32_major_version, w32_minor_version, w32_build_number, OS_9X)
187 (OS_NT, os_subtype, cache_system_info): Move here.
188
189 * unexw32.c, unexcw.c: Include w32common.h.
190
191 * emacs.c (main): Use (defined (WINDOWSNT) || defined
192 HAVE_NTGUI) instead of removed HAVE_W32SELECT to decide whether
193 to call syms_of_w32select.
194
195 * cygw32.h: Remove obsolete EXFUN declarations.
196
197 * cygw32.c (Qutf_16_le): Rename to Qutf_16le.
198
199 * Makefile.in (SOME_MACHINE_OBJECTS): Reverse accidental removal
200 of w32inevt.o from SOME_MACHINE_OBJECTS.
201
2022012-10-08 Daniel Colascione <dancol@dancol.org>
203
204 * image.c: Permanent fix for JPEG compilation issue --- limit
205 jpeglib `boolean' redefinition to Cygwin builds.
206
2072012-10-08 Eli Zaretskii <eliz@gnu.org>
208
209 * image.c (CHECK_LIB_AVAILABLE): Remove, no longer used.
210
211 * emacs.c (DAEMON_MUST_EXEC) [HAVE_NTGUI]: Define this only on
212 Cygwin.
213
2142012-10-08 Daniel Colascione <dancol@dancol.org>
215
216 * xfaces.c, xdisp.c, window.c, w32xfns.c, w32term.h, w32term.c,
217 w32select.h w32select.c, w32proc.c, w32menu.c, w32inevt.c,
218 w32help.c, w32font.c, w32font.c, w32fns.c, w32console.c, w32.h,
219 w32.c, unexw32.c, termhooks.h, process.c, menu.c, keyboard.h,
220 keyboard.c, image.c, frame.h, frame.c, fontset.c, font.h, font.c,
221 emacs.c, dispextern.h, cygw32.h, cygw32.c, conf_post.h,
222 Makefile.in: use HAVE_NTGUI for W32 GUI and WINDOWSNT for the
223 operating system. defined(HAVE_NTGUI) && !defined(WINDOWSNT) is
224 now a supported configuration.
225
226 * Makefile.in: consolidate image variables into LIBIMAGE; add
227 W32_OBJ and W32_LIBS. Compile new files.
228
229 * conf_post.h:
230 (_DebPrint) declare tracing facility for W32 debugging. We need
231 to unify tracing later.
232
233 (NTGUI_UNICODE) Define when compiling for Cygwin to allow the
234 unconditional use of W32 Unicode functions. Cygwin runs only on
235 100% Unicode operating systems.
236
237 * cygw32.c: New file. Define Cygwin-specific facilities.
238 (Fcygwin_convert_path_to_windows)
239 (Fcygwin_convert_path_from_windows): New user functions for
240 accessing Cygwin path-munging routines.
241
242 * cygw32.h: New file.
243 (WCSDATA, to_unicode, from_unicode): Define facilities for storing
244 UTF-16LE strings temporarily inside non-Lisp-visible string
245 objects.
246
247 (w32_strerror): Just what it says on the tin.
248
249 * emacs.c: Make the NS fork-then-exec code for daemon-launching
250 also run for Cygwin; both systems have the same problem with using
251 GUI facilities in a forked child. Also call syms_of_cygw32,
252 syms_of_w32select in correct places.
253
254 (DAEMON_MUST_EXEC): new macro defined to signal that a platform
255 needs fork-then-exec for daemon launching.
256
257 * font.h: Include frame.h.
258
259 * image.c: Use the image library cache machinery only when we're
260 compiling for native WINDOWSNT; Cygwin can use shared libraries
261 like any other Unixlike system.
262
263 * keyboard.c: Clarify a comment regarding the input loop.
264
265 * menu.c: When NTGUI_UNICODE is defined, use Unicode menu
266 functions directly instead of trying to detect at runtime that our
267 host operating system supports them. We make this change for two
268 reasons: Cygwin lacks support for the multibyte character
269 conversion functions used by the legacy menu code, and Cygwin
270 never needs to rely on non-Unicode APIs.
271
272 * unexw32.c (hinst): Declare extern.
273
274 * w32.c: Change header order;
275 (w32_strerror): Move to w32fns.c because we need it for
276 non-WINDOWSNT builds.
277
278 * w32.h: Add #error macro to make sure we don't include w32.h for
279 Cygwin builds. Remove w32select declarations.
280
281 * w32console.c (w32_sys_ring_bell, Fset_message_beep): Move to
282 w32fns.c. w32console.c is WINDOWSNT-only.
283
284 * w32fns.c: Include cygw32.h or w32.h depending on CYGWIN; more
285 NTGUI_UNICODE tweaks. (See above.) Change _snprintf to the more
286 POSIXy alternative.
287 (faked_key, sysinfo_cache, osinfo_cahce, syspage_mask)
288 (w32_major_version, w32_minor_version, w32_build_number)
289 (os_subtype, sound_type): Define here
290 (w32_defined_color): Make color parameter const for consistency
291 with other _defined_color functions.
292 (w32_createwindow): Unconditionally call w32_init_class instead of
293 doing so only when hprevinst is non-NULL. Plumbing hprevinst
294 through the code is complex and unnecessary because class
295 registration is practically free.
296 (w32_name_of_message): New EMACSDEBUG-only function.
297 (Fset_message_beep): Move here
298 (Fx_open_connection): Require that the display name for Windows be
299 "w32" for consistency, emacsclient disambiguation, and maybe, one
300 day, multi-window-system support.
301 (file_dialog_callback): NTGUI_UNICODE changes; encode and decode
302 Cygwin files for W32 GUI facilities, since these clearly don't
303 expect Cygwin names.
304 (_DebPrint): Define.
305 (w32_strerror, w32_console_toggle_lock_key, w32_kbd_mods_to_emacs)
306 (w32_kbd_patch_key, w32_sys_ring_bell): Move here.
307 (Ssystem_move_file_to_trash): Define only for native WINDOWSNT.
308 (w32_last_error): Remove.
309
310 * w32font.c: Define _strlwr to strlwr for non-WINDOWSNT builds.
311
312 * w32heap.c (syspage_mask): Declare here.
313 (cache_system_info): Remove.
314
315 * w32inevt.c (faked_key): Define globally, not statically.
316 (w32_kbd_mods_to_emacs, w32_kbd_patch_key, faked_key)
317 (w32_console_toggle_lock_key): Move to w32fns.c.
318
319 * w32menu.c: Include setjmp.h. NTGUI_UNICODE changes throughout.
320
321 * w32proc.c (_DebPrint): Move to w32fns.c.
322 * w32select.c: Include string.h, stdio.h for Cygwin.
323 * w32select.h: New File.
324
325 * w32term.c: Include io.h for non-CYGWIN builds; needed for
326 get_osfhandle.
327 (w32_message_fd): New variable. Under Cygwin, holds the file
328 descriptor the system used to tell us about pending thread
329 messages.
330
331 (w32_init_term): Remove incorrect calls to fcntl and init_sigio
332 that prevented compilation under non-WINDOWSNT systems.
333
334 (w32_initialize): Open /dev/windows and assign it to
335 w32_message_fd. Provide w32 feature.
336
337 * w32term.h: Include frame.h, atimer.h. Declare various frame functions.
338 (WM_EMACS_INPUT_READY): add.
339 (prepend_msg, w32_message_fd): Declare globally.
340
341 * w32xfns.c:
342 (keyboard_handle): Use only when WINDOWSNT.
343 (notify_msg_ready): New function. Posts a message to the main
344 thread's message queue under CYGWIN, which wakes up the main
345 thread from select(2) by making the /dev/windows file descriptor
346 ready. Under WINDOWSNT, it sets an event the same way the old
347 code did.
348
349 (post, prepend_msg): Actually call notify_msg_ready instead of
350 setting the input event directly.
351
3522012-10-07 Eli Zaretskii <eliz@gnu.org>
353
354 * ralloc.c (relinquish): If a heap is ready to be relinquished,
355 but it still has blocs in it, don't return it to the system,
356 instead of aborting. (Bug#12402)
357
12012-10-07 Jan Djärv <jan.h.d@swipnet.se> 3582012-10-07 Jan Djärv <jan.h.d@swipnet.se>
2 359
3 * nsterm.m (ns_dumpglyphs_image): Only draw slize of image (Bug#12506). 360 * nsterm.m (ns_dumpglyphs_image): Only draw slice of image (Bug#12506).
4 361
5 * nsterm.m (ns_update_auto_hide_menu_bar): Remove defintion of 362 * nsterm.m (ns_update_auto_hide_menu_bar): Remove defintion of
6 MAC_OS_X_VERSION_10_6. 363 MAC_OS_X_VERSION_10_6.
7 (syms_of_nsterm): Remove comment about Panther and above for ns-antialias-text. 364 (syms_of_nsterm): Remove comment about Panther and above for
365 ns-antialias-text.
8 * nsterm.h (MAC_OS_X_VERSION_10_3, onTiger): Remove. 366 * nsterm.h (MAC_OS_X_VERSION_10_3, onTiger): Remove.
9 (EmacsApp): Remove check for >= MAC_OS_X_VERSION_10_4. 367 (EmacsApp): Remove check for >= MAC_OS_X_VERSION_10_4.
10 (struct nsfont_info): Remove check for >= MAC_OS_X_VERSION_10_3. 368 (struct nsfont_info): Remove check for >= MAC_OS_X_VERSION_10_3.
@@ -12,7 +370,8 @@
12 * nsselect.m (ns_string_from_pasteboard): Remove check for >= 370 * nsselect.m (ns_string_from_pasteboard): Remove check for >=
13 MAC_OS_X_VERSION_10_4. 371 MAC_OS_X_VERSION_10_4.
14 372
15 * nsmenu.m (fillWithWidgetValue:): Remove code for < MAC_OS_X_VERSION_10_2. 373 * nsmenu.m (fillWithWidgetValue:): Remove code for <
374 MAC_OS_X_VERSION_10_2.
16 375
17 * nsimage.m (setPixmapData, getPixelAtX, setAlphaAtX): Remove onTiger. 376 * nsimage.m (setPixmapData, getPixelAtX, setAlphaAtX): Remove onTiger.
18 377
@@ -21,13 +380,13 @@
21 380
22 * nsterm.m (ns_in_resize): Remove (Bug#12479). 381 * nsterm.m (ns_in_resize): Remove (Bug#12479).
23 (ns_resize_handle_rect, mouseDown, mouseUp, mouseDragged): Remove. 382 (ns_resize_handle_rect, mouseDown, mouseUp, mouseDragged): Remove.
24 (ns_clear_frame, sendEvent, windowDidResize, drawRect:): Remove ns_in_resize 383 (ns_clear_frame, sendEvent, windowDidResize, drawRect:): Remove
25 check. 384 ns_in_resize check.
26 (ns_clear_frame_area): Remove resize handle code. 385 (ns_clear_frame_area): Remove resize handle code.
27 386
28 * nsfns.m (ns_in_resize): Remove. 387 * nsfns.m (ns_in_resize): Remove.
29 (x_set_icon_name, ns_set_name, ns_set_name_as_filename): Remove ns_in_resize 388 (x_set_icon_name, ns_set_name, ns_set_name_as_filename): Remove
30 check. 389 ns_in_resize check.
31 390
322012-10-07 Paul Eggert <eggert@cs.ucla.edu> 3912012-10-07 Paul Eggert <eggert@cs.ucla.edu>
33 392
diff --git a/src/Makefile.in b/src/Makefile.in
index f8da0091711..c24e421bbbc 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -135,13 +135,10 @@ LIB_MATH=@LIB_MATH@
135## -lpthreads, or empty. 135## -lpthreads, or empty.
136LIB_PTHREAD=@LIB_PTHREAD@ 136LIB_PTHREAD=@LIB_PTHREAD@
137 137
138LIBTIFF=@LIBTIFF@ 138LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@
139LIBJPEG=@LIBJPEG@ 139
140LIBPNG=@LIBPNG@
141LIBGIF=@LIBGIF@
142LIBXPM=@LIBXPM@
143XFT_LIBS=@XFT_LIBS@ 140XFT_LIBS=@XFT_LIBS@
144LIBX_EXTRA=$(LIBTIFF) $(LIBJPEG) $(LIBPNG) $(LIBGIF) $(LIBXPM) -lX11 $(XFT_LIBS) 141LIBX_EXTRA=-lX11 $(XFT_LIBS)
145 142
146FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ 143FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
147FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ 144FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
@@ -261,6 +258,13 @@ NS_OBJ=@NS_OBJ@
261NS_OBJC_OBJ=@NS_OBJC_OBJ@ 258NS_OBJC_OBJ=@NS_OBJC_OBJ@
262## Only set if NS_IMPL_GNUSTEP. 259## Only set if NS_IMPL_GNUSTEP.
263GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@ 260GNU_OBJC_CFLAGS=@GNU_OBJC_CFLAGS@
261## w32fns.o w32menu.c w32reg.o fringe.o fontset.o w32font.o w32term.o
262## w32xfns.o w32select.o image.o w32uniscribe.o if HAVE_W32, else
263## empty.
264W32_OBJ=@W32_OBJ@
265## -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32 lusp10 -lcomctl32
266## --lwinspool if HAVE_W32, else empty.
267W32_LIBS=@W32_LIBS@
264 268
265## Empty if !HAVE_X_WINDOWS 269## Empty if !HAVE_X_WINDOWS
266## xfont.o ftfont.o xftfont.o ftxfont.o if HAVE_XFT 270## xfont.o ftfont.o xftfont.o ftxfont.o if HAVE_XFT
@@ -342,7 +346,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
342 doprnt.o intervals.o textprop.o composite.o xml.o \ 346 doprnt.o intervals.o textprop.o composite.o xml.o \
343 profiler.o \ 347 profiler.o \
344 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ 348 $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
345 $(WINDOW_SYSTEM_OBJ) 349 $(W32_OBJ) $(WINDOW_SYSTEM_OBJ)
346obj = $(base_obj) $(NS_OBJC_OBJ) 350obj = $(base_obj) $(NS_OBJC_OBJ)
347 351
348## Object files used on some machine or other. 352## Object files used on some machine or other.
@@ -351,7 +355,7 @@ obj = $(base_obj) $(NS_OBJC_OBJ)
351## in the list, in case they ever add any such entries. 355## in the list, in case they ever add any such entries.
352SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ 356SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
353 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \ 357 xterm.o xfns.o xmenu.o xselect.o xrdb.o xsmfns.o fringe.o image.o \
354 fontset.o dbusbind.o \ 358 fontset.o dbusbind.o cygw32.o \
355 nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \ 359 nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o \
356 w32.o w32console.o w32fns.o w32heap.o w32inevt.o \ 360 w32.o w32console.o w32fns.o w32heap.o w32inevt.o \
357 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ 361 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
@@ -385,9 +389,11 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
385## Note that SunOS needs -lm to come before -lc; otherwise, you get 389## Note that SunOS needs -lm to come before -lc; otherwise, you get
386## duplicated symbols. If the standard libraries were compiled 390## duplicated symbols. If the standard libraries were compiled
387## with GCC, we might need LIB_GCC again after them. 391## with GCC, we might need LIB_GCC again after them.
388LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ 392LIBES = $(LIBS) $(W32_LIBS) $(LIBX_BASE) $(LIBIMAGE) \
389 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) $(LIB_TIMER_TIME) \ 393 $(LIBX_OTHER) $(LIBSOUND) \
390 $(DBUS_LIBS) $(LIB_EXECINFO) \ 394 $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
395 $(LIB_TIMER_TIME) $(DBUS_LIBS) \
396 $(LIB_EXECINFO) \
391 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ 397 $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \
392 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ 398 $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
393 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ 399 $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
diff --git a/src/alloc.c b/src/alloc.c
index 3ed8cc2d990..95be8db1614 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5689,7 +5689,7 @@ mark_object (Lisp_Object arg)
5689 pvectype = ((ptr->header.size & PVEC_TYPE_MASK) 5689 pvectype = ((ptr->header.size & PVEC_TYPE_MASK)
5690 >> PSEUDOVECTOR_SIZE_BITS); 5690 >> PSEUDOVECTOR_SIZE_BITS);
5691 else 5691 else
5692 pvectype = 0; 5692 pvectype = PVEC_NORMAL_VECTOR;
5693 5693
5694 if (pvectype != PVEC_SUBR && pvectype != PVEC_BUFFER) 5694 if (pvectype != PVEC_SUBR && pvectype != PVEC_BUFFER)
5695 CHECK_LIVE (live_vector_p); 5695 CHECK_LIVE (live_vector_p);
@@ -6311,19 +6311,14 @@ gc_sweep (void)
6311 6311
6312 /* Free all unmarked buffers */ 6312 /* Free all unmarked buffers */
6313 { 6313 {
6314 register struct buffer *buffer = all_buffers, *prev = 0, *next; 6314 register struct buffer *buffer, **bprev = &all_buffers;
6315 6315
6316 total_buffers = 0; 6316 total_buffers = 0;
6317 while (buffer) 6317 for (buffer = all_buffers; buffer; buffer = *bprev)
6318 if (!VECTOR_MARKED_P (buffer)) 6318 if (!VECTOR_MARKED_P (buffer))
6319 { 6319 {
6320 if (prev) 6320 *bprev = buffer->header.next.buffer;
6321 prev->header.next = buffer->header.next;
6322 else
6323 all_buffers = buffer->header.next.buffer;
6324 next = buffer->header.next.buffer;
6325 lisp_free (buffer); 6321 lisp_free (buffer);
6326 buffer = next;
6327 } 6322 }
6328 else 6323 else
6329 { 6324 {
@@ -6331,7 +6326,7 @@ gc_sweep (void)
6331 /* Do not use buffer_(set|get)_intervals here. */ 6326 /* Do not use buffer_(set|get)_intervals here. */
6332 buffer->text->intervals = balance_intervals (buffer->text->intervals); 6327 buffer->text->intervals = balance_intervals (buffer->text->intervals);
6333 total_buffers++; 6328 total_buffers++;
6334 prev = buffer, buffer = buffer->header.next.buffer; 6329 bprev = &buffer->header.next.buffer;
6335 } 6330 }
6336 } 6331 }
6337 6332
diff --git a/src/commands.h b/src/commands.h
index 36f600cee01..510fce0e182 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -36,9 +36,6 @@ extern Lisp_Object control_x_map;
36 events until a non-ASCII event is acceptable as input. */ 36 events until a non-ASCII event is acceptable as input. */
37extern Lisp_Object unread_switch_frame; 37extern Lisp_Object unread_switch_frame;
38 38
39/* Nonzero means ^G can quit instantly */
40extern int immediate_quit;
41
42/* Nonzero if input is coming from the keyboard */ 39/* Nonzero if input is coming from the keyboard */
43 40
44#define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive) 41#define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive)
diff --git a/src/conf_post.h b/src/conf_post.h
index 0c4d029bc5d..aa008107ba6 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -142,6 +142,20 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
142#endif 142#endif
143#endif 143#endif
144 144
145#if defined HAVE_NTGUI && !defined DebPrint
146# ifdef EMACSDEBUG
147extern void _DebPrint (const char *fmt, ...);
148# define DebPrint(stuff) _DebPrint stuff
149# else
150# define DebPrint(stuff)
151# endif
152#endif
153
154#if defined CYGWIN && defined HAVE_NTGUI
155# define NTGUI_UNICODE /* Cygwin runs only on UNICODE-supporting systems */
156# define _WIN32_WINNT 0x500 /* Win2k */
157#endif
158
145#ifdef emacs /* Don't do this for lib-src. */ 159#ifdef emacs /* Don't do this for lib-src. */
146/* Tell regex.c to use a type compatible with Emacs. */ 160/* Tell regex.c to use a type compatible with Emacs. */
147#define RE_TRANSLATE_TYPE Lisp_Object 161#define RE_TRANSLATE_TYPE Lisp_Object
diff --git a/src/cygw32.c b/src/cygw32.c
new file mode 100644
index 00000000000..c45a45648e9
--- /dev/null
+++ b/src/cygw32.c
@@ -0,0 +1,169 @@
1/* Cygwin support routines.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19
20#include "cygw32.h"
21#include "character.h"
22#include "buffer.h"
23#include <unistd.h>
24#include <fcntl.h>
25static Lisp_Object Qutf_16le;
26
27static Lisp_Object
28fchdir_unwind (Lisp_Object dir_fd)
29{
30 (void) fchdir (XFASTINT (dir_fd));
31 (void) close (XFASTINT (dir_fd));
32 return Qnil;
33}
34
35static void
36chdir_to_default_directory ()
37{
38 Lisp_Object new_cwd;
39 int old_cwd_fd = open (".", O_RDONLY | O_DIRECTORY);
40
41 if (old_cwd_fd == -1)
42 error ("could not open current directory: %s", strerror (errno));
43
44 record_unwind_protect (fchdir_unwind, make_number (old_cwd_fd));
45
46 new_cwd = Funhandled_file_name_directory (
47 Fexpand_file_name (build_string ("."), Qnil));
48 if (!STRINGP (new_cwd))
49 new_cwd = build_string ("/");
50
51 if (chdir (SDATA (ENCODE_FILE (new_cwd))))
52 error ("could not chdir: %s", strerror (errno));
53}
54
55static Lisp_Object
56conv_filename_to_w32_unicode (Lisp_Object in, int absolute_p)
57{
58 ssize_t converted_len;
59 Lisp_Object converted;
60 unsigned flags;
61 int count = SPECPDL_INDEX ();
62
63 chdir_to_default_directory ();
64
65 flags = CCP_POSIX_TO_WIN_W;
66 if (!absolute_p) {
67 flags |= CCP_RELATIVE;
68 }
69
70 in = ENCODE_FILE (in);
71
72 converted_len = cygwin_conv_path (flags, SDATA (in), NULL, 0);
73 if (converted_len < 2)
74 error ("cygwin_conv_path: %s", strerror (errno));
75
76 converted = make_uninit_string (converted_len - 1);
77 if (cygwin_conv_path (flags, SDATA (in),
78 SDATA (converted), converted_len))
79 error ("cygwin_conv_path: %s", strerror (errno));
80
81 return unbind_to (count, converted);
82}
83
84static Lisp_Object
85conv_filename_from_w32_unicode (const wchar_t* in, int absolute_p)
86{
87 ssize_t converted_len;
88 Lisp_Object converted;
89 unsigned flags;
90 int count = SPECPDL_INDEX ();
91
92 chdir_to_default_directory ();
93
94 flags = CCP_WIN_W_TO_POSIX;
95 if (!absolute_p) {
96 flags |= CCP_RELATIVE;
97 }
98
99 converted_len = cygwin_conv_path (flags, in, NULL, 0);
100 if (converted_len < 1)
101 error ("cygwin_conv_path: %s", strerror (errno));
102
103 converted = make_uninit_string (converted_len - 1 /*subtract terminator*/);
104 if (cygwin_conv_path (flags, in, SDATA (converted), converted_len))
105 error ("cygwin_conv_path: %s", strerror (errno));
106
107 return unbind_to (count, DECODE_FILE (converted));
108}
109
110Lisp_Object
111from_unicode (Lisp_Object str)
112{
113 CHECK_STRING (str);
114 if (!STRING_MULTIBYTE (str) &&
115 SBYTES (str) & 1)
116 {
117 str = Fsubstring (str, make_number (0), make_number (-1));
118 }
119
120 return code_convert_string_norecord (str, Qutf_16le, 0);
121}
122
123wchar_t *
124to_unicode (Lisp_Object str, Lisp_Object *buf)
125{
126 *buf = code_convert_string_norecord (str, Qutf_16le, 1);
127 /* We need to make a another copy (in addition to the one made by
128 code_convert_string_norecord) to ensure that the final string is
129 _doubly_ zero terminated --- that is, that the string is
130 terminated by two zero bytes and one utf-16le null character.
131 Because strings are already terminated with a single zero byte,
132 we just add one additional zero. */
133 str = make_uninit_string (SBYTES (*buf) + 1);
134 memcpy (SDATA (str), SDATA (*buf), SBYTES (*buf));
135 SDATA (str) [SBYTES (*buf)] = '\0';
136 *buf = str;
137 return WCSDATA (*buf);
138}
139
140DEFUN ("cygwin-convert-path-to-windows",
141 Fcygwin_convert_path_to_windows, Scygwin_convert_path_to_windows,
142 1, 2, 0,
143 doc: /* Convert PATH to a Windows path. If ABSOLUTE-P if
144 non-nil, return an absolute path.*/)
145 (Lisp_Object path, Lisp_Object absolute_p)
146{
147 return from_unicode (
148 conv_filename_to_w32_unicode (path, absolute_p == Qnil ? 0 : 1));
149}
150
151DEFUN ("cygwin-convert-path-from-windows",
152 Fcygwin_convert_path_from_windows, Scygwin_convert_path_from_windows,
153 1, 2, 0,
154 doc: /* Convert a Windows path to a Cygwin path. If ABSOLUTE-P
155 if non-nil, return an absolute path.*/)
156 (Lisp_Object path, Lisp_Object absolute_p)
157{
158 return conv_filename_from_w32_unicode (to_unicode (path, &path),
159 absolute_p == Qnil ? 0 : 1);
160}
161
162void
163syms_of_cygw32 (void)
164{
165 /* No, not utf-16-le: that one has a BOM. */
166 DEFSYM (Qutf_16le, "utf-16le");
167 defsubr (&Scygwin_convert_path_from_windows);
168 defsubr (&Scygwin_convert_path_to_windows);
169}
diff --git a/src/cygw32.h b/src/cygw32.h
new file mode 100644
index 00000000000..78e77a9a141
--- /dev/null
+++ b/src/cygw32.h
@@ -0,0 +1,53 @@
1/* Header for Cygwin support routines.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef CYGW32_H
20#define CYGW32_H
21#include <config.h>
22#include <windef.h>
23#include <sys/cygwin.h>
24#include <wchar.h>
25
26#include <signal.h>
27#include <stdio.h>
28#include <limits.h>
29#include <errno.h>
30#include <math.h>
31#include <setjmp.h>
32
33#include "lisp.h"
34#include "coding.h"
35
36/* *** Character conversion *** */
37
38/* Access the wide-character string stored in a Lisp string object. */
39#define WCSDATA(x) ((wchar_t *) SDATA (x))
40
41/* Convert the multi-byte string in STR to UTF-16LE encoded unibyte
42 string, and store it in *BUF. BUF may safely point to STR on entry. */
43extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf);
44
45/* Convert STR, a UTF-16LE encoded string embedded in a unibyte string
46 object, to a multi-byte Emacs string, and return it. */
47extern Lisp_Object from_unicode (Lisp_Object str);
48
49/* *** Misc *** */
50extern void syms_of_cygw32 (void);
51extern char * w32_strerror (int error_no);
52
53#endif /* CYGW32_H */
diff --git a/src/dispextern.h b/src/dispextern.h
index f1ea8e97ee8..c5ebb808b05 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3144,7 +3144,7 @@ int draw_window_fringes (struct window *, int);
3144int update_window_fringes (struct window *, int); 3144int update_window_fringes (struct window *, int);
3145void compute_fringe_widths (struct frame *, int); 3145void compute_fringe_widths (struct frame *, int);
3146 3146
3147#ifdef WINDOWSNT 3147#ifdef HAVE_NTGUI
3148void w32_init_fringe (struct redisplay_interface *); 3148void w32_init_fringe (struct redisplay_interface *);
3149void w32_reset_fringes (void); 3149void w32_reset_fringes (void);
3150#endif 3150#endif
@@ -3247,7 +3247,7 @@ extern char unspecified_fg[], unspecified_bg[];
3247#ifdef HAVE_X_WINDOWS 3247#ifdef HAVE_X_WINDOWS
3248void gamma_correct (struct frame *, XColor *); 3248void gamma_correct (struct frame *, XColor *);
3249#endif 3249#endif
3250#ifdef WINDOWSNT 3250#ifdef HAVE_NTGUI
3251void gamma_correct (struct frame *, COLORREF *); 3251void gamma_correct (struct frame *, COLORREF *);
3252#endif 3252#endif
3253 3253
diff --git a/src/dispnew.c b/src/dispnew.c
index 6f8fb10b41d..0956e3f2905 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 26
27#include "lisp.h" 27#include "lisp.h"
28#include "termchar.h" 28#include "termchar.h"
29#include "termopts.h"
30/* cm.h must come after dispextern.h on Windows. */ 29/* cm.h must come after dispextern.h on Windows. */
31#include "dispextern.h" 30#include "dispextern.h"
32#include "cm.h" 31#include "cm.h"
@@ -5919,15 +5918,16 @@ additional wait period, in milliseconds; this is for backwards compatibility.
5919 TIMEOUT is number of seconds to wait (float or integer), 5918 TIMEOUT is number of seconds to wait (float or integer),
5920 or t to wait forever. 5919 or t to wait forever.
5921 READING is true if reading input. 5920 READING is true if reading input.
5922 If DO_DISPLAY is >0 display process output while waiting. 5921 If DISPLAY_OPTION is >0 display process output while waiting.
5923 If DO_DISPLAY is >1 perform an initial redisplay before waiting. 5922 If DISPLAY_OPTION is >1 perform an initial redisplay before waiting.
5924*/ 5923*/
5925 5924
5926Lisp_Object 5925Lisp_Object
5927sit_for (Lisp_Object timeout, bool reading, int do_display) 5926sit_for (Lisp_Object timeout, bool reading, int display_option)
5928{ 5927{
5929 intmax_t sec; 5928 intmax_t sec;
5930 int nsec; 5929 int nsec;
5930 bool do_display = display_option > 0;
5931 5931
5932 swallow_events (do_display); 5932 swallow_events (do_display);
5933 5933
@@ -5935,7 +5935,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display)
5935 || !NILP (Vexecuting_kbd_macro)) 5935 || !NILP (Vexecuting_kbd_macro))
5936 return Qnil; 5936 return Qnil;
5937 5937
5938 if (do_display >= 2) 5938 if (display_option > 1)
5939 redisplay_preserve_echo_area (2); 5939 redisplay_preserve_echo_area (2);
5940 5940
5941 if (INTEGERP (timeout)) 5941 if (INTEGERP (timeout))
diff --git a/src/emacs.c b/src/emacs.c
index bc54f56b98a..0a2a60bee0c 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -33,9 +33,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
33 33
34#ifdef WINDOWSNT 34#ifdef WINDOWSNT
35#include <fcntl.h> 35#include <fcntl.h>
36#include <windows.h> /* just for w32.h */
37#include "w32.h" 36#include "w32.h"
38#include "w32heap.h" /* for prototype of sbrk */ 37#include "w32heap.h"
38#endif
39
40#if defined WINDOWSNT || defined HAVE_NTGUI
41#include "w32select.h"
42#include "w32font.h"
43#endif
44
45#if defined HAVE_NTGUI && defined CYGWIN
46#include "cygw32.h"
39#endif 47#endif
40 48
41#ifdef HAVE_WINDOW_SYSTEM 49#ifdef HAVE_WINDOW_SYSTEM
@@ -156,6 +164,22 @@ static void *my_heap_start;
156static uprintmax_t heap_bss_diff; 164static uprintmax_t heap_bss_diff;
157#endif 165#endif
158 166
167/* To run as a daemon under Cocoa or Windows, we must do a fork+exec,
168 not a simple fork.
169
170 On Cocoa, CoreFoundation lib fails in forked process:
171 http://developer.apple.com/ReleaseNotes/
172 CoreFoundation/CoreFoundation.html)
173
174 On Windows, a Cygwin fork child cannot access the USER subsystem.
175
176 We mark being in the exec'd process by a daemon name argument of
177 form "--daemon=\nFD0,FD1\nNAME" where FD are the pipe file descriptors,
178 NAME is the original daemon name, if any. */
179#if defined NS_IMPL_COCOA || (defined HAVE_NTGUI && defined CYGWIN)
180# define DAEMON_MUST_EXEC
181#endif
182
159/* True means running Emacs without interactive terminal. */ 183/* True means running Emacs without interactive terminal. */
160bool noninteractive; 184bool noninteractive;
161 185
@@ -669,7 +693,7 @@ main (int argc, char **argv)
669 bool no_loadup = 0; 693 bool no_loadup = 0;
670 char *junk = 0; 694 char *junk = 0;
671 char *dname_arg = 0; 695 char *dname_arg = 0;
672#ifdef NS_IMPL_COCOA 696#ifdef DAEMON_MUST_EXEC
673 char dname_arg2[80]; 697 char dname_arg2[80];
674#endif 698#endif
675 char *ch_to_dir; 699 char *ch_to_dir;
@@ -964,25 +988,19 @@ main (int argc, char **argv)
964 exit (1); 988 exit (1);
965 } 989 }
966 990
967#ifndef NS_IMPL_COCOA 991#ifndef DAEMON_MUST_EXEC
968#ifdef USE_GTK 992#ifdef USE_GTK
969 fprintf (stderr, "\nWarning: due to a long standing Gtk+ bug\nhttp://bugzilla.gnome.org/show_bug.cgi?id=85715\n\ 993 fprintf (stderr, "\nWarning: due to a long standing Gtk+ bug\nhttp://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
970Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.\n\ 994Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.\n\
971Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.\n"); 995Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.\n");
972#endif 996#endif /* USE_GTK */
973 f = fork (); 997 f = fork ();
974#else /* NS_IMPL_COCOA */ 998#else /* DAEMON_MUST_EXEC */
975 /* Under Cocoa we must do fork+exec as CoreFoundation lib fails in
976 forked process: http://developer.apple.com/ReleaseNotes/
977 CoreFoundation/CoreFoundation.html)
978 We mark being in the exec'd process by a daemon name argument of
979 form "--daemon=\nFD0,FD1\nNAME" where FD are the pipe file descriptors,
980 NAME is the original daemon name, if any. */
981 if (!dname_arg || !strchr (dname_arg, '\n')) 999 if (!dname_arg || !strchr (dname_arg, '\n'))
982 f = fork (); /* in orig */ 1000 f = fork (); /* in orig */
983 else 1001 else
984 f = 0; /* in exec'd */ 1002 f = 0; /* in exec'd */
985#endif /* NS_IMPL_COCOA */ 1003#endif /* !DAEMON_MUST_EXEC */
986 if (f > 0) 1004 if (f > 0)
987 { 1005 {
988 int retval; 1006 int retval;
@@ -1018,7 +1036,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1018 exit (1); 1036 exit (1);
1019 } 1037 }
1020 1038
1021#ifdef NS_IMPL_COCOA 1039#ifdef DAEMON_MUST_EXEC
1022 { 1040 {
1023 /* In orig process, forked as child, OR in exec'd. */ 1041 /* In orig process, forked as child, OR in exec'd. */
1024 if (!dname_arg || !strchr (dname_arg, '\n')) 1042 if (!dname_arg || !strchr (dname_arg, '\n'))
@@ -1054,7 +1072,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1054 dname_arg2); 1072 dname_arg2);
1055 dname_arg = *dname_arg2 ? dname_arg2 : NULL; 1073 dname_arg = *dname_arg2 ? dname_arg2 : NULL;
1056 } 1074 }
1057#endif /* NS_IMPL_COCOA */ 1075#endif /* DAEMON_MUST_EXEC */
1058 1076
1059 if (dname_arg) 1077 if (dname_arg)
1060 daemon_name = xstrdup (dname_arg); 1078 daemon_name = xstrdup (dname_arg);
@@ -1357,6 +1375,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1357#ifdef WINDOWSNT 1375#ifdef WINDOWSNT
1358 syms_of_ntproc (); 1376 syms_of_ntproc ();
1359#endif /* WINDOWSNT */ 1377#endif /* WINDOWSNT */
1378#if defined CYGWIN && defined HAVE_NTGUI
1379 syms_of_cygw32 ();
1380#endif
1360 syms_of_window (); 1381 syms_of_window ();
1361 syms_of_xdisp (); 1382 syms_of_xdisp ();
1362 syms_of_font (); 1383 syms_of_font ();
@@ -1387,11 +1408,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1387#ifdef HAVE_NTGUI 1408#ifdef HAVE_NTGUI
1388 syms_of_w32term (); 1409 syms_of_w32term ();
1389 syms_of_w32fns (); 1410 syms_of_w32fns ();
1390 syms_of_w32select ();
1391 syms_of_w32menu (); 1411 syms_of_w32menu ();
1392 syms_of_fontset (); 1412 syms_of_fontset ();
1393#endif /* HAVE_NTGUI */ 1413#endif /* HAVE_NTGUI */
1394 1414
1415#if defined WINDOWSNT || defined HAVE_NTGUI
1416 syms_of_w32select ();
1417#endif
1418
1395#ifdef MSDOS 1419#ifdef MSDOS
1396 syms_of_xmenu (); 1420 syms_of_xmenu ();
1397 syms_of_dosfns (); 1421 syms_of_dosfns ();
@@ -1436,8 +1460,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1436 globals_of_w32font (); 1460 globals_of_w32font ();
1437 globals_of_w32fns (); 1461 globals_of_w32fns ();
1438 globals_of_w32menu (); 1462 globals_of_w32menu ();
1439 globals_of_w32select ();
1440#endif /* HAVE_NTGUI */ 1463#endif /* HAVE_NTGUI */
1464
1465#if defined WINDOWSNT || defined HAVE_NTGUI
1466 globals_of_w32select ();
1467#endif
1441 } 1468 }
1442 1469
1443 init_charset (); 1470 init_charset ();
diff --git a/src/font.c b/src/font.c
index 1f22fee88ee..629e8bb977a 100644
--- a/src/font.c
+++ b/src/font.c
@@ -5208,9 +5208,9 @@ EMACS_FONT_LOG is set. Otherwise, it is set to t. */);
5208#ifdef HAVE_BDFFONT 5208#ifdef HAVE_BDFFONT
5209 syms_of_bdffont (); 5209 syms_of_bdffont ();
5210#endif /* HAVE_BDFFONT */ 5210#endif /* HAVE_BDFFONT */
5211#ifdef WINDOWSNT 5211#ifdef HAVE_NTGUI
5212 syms_of_w32font (); 5212 syms_of_w32font ();
5213#endif /* WINDOWSNT */ 5213#endif /* HAVE_NTGUI */
5214#ifdef HAVE_NS 5214#ifdef HAVE_NS
5215 syms_of_nsfont (); 5215 syms_of_nsfont ();
5216#endif /* HAVE_NS */ 5216#endif /* HAVE_NS */
diff --git a/src/font.h b/src/font.h
index 0475eb665dd..3035a909efc 100644
--- a/src/font.h
+++ b/src/font.h
@@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#define EMACS_FONT_H 23#define EMACS_FONT_H
24 24
25#include "ccl.h" 25#include "ccl.h"
26#include "frame.h"
26 27
27/* We have three types of Lisp objects related to font. 28/* We have three types of Lisp objects related to font.
28 29
@@ -818,11 +819,11 @@ extern struct font_driver ftxfont_driver;
818extern void syms_of_bdffont (void); 819extern void syms_of_bdffont (void);
819#endif /* HAVE_BDFFONT */ 820#endif /* HAVE_BDFFONT */
820#endif /* HAVE_X_WINDOWS */ 821#endif /* HAVE_X_WINDOWS */
821#ifdef WINDOWSNT 822#ifdef HAVE_NTGUI
822extern struct font_driver w32font_driver; 823extern struct font_driver w32font_driver;
823extern struct font_driver uniscribe_font_driver; 824extern struct font_driver uniscribe_font_driver;
824extern void syms_of_w32font (void); 825extern void syms_of_w32font (void);
825#endif /* WINDOWSNT */ 826#endif /* HAVE_NTGUI */
826#ifdef HAVE_NS 827#ifdef HAVE_NS
827extern Lisp_Object Qfontsize; 828extern Lisp_Object Qfontsize;
828extern struct font_driver nsfont_driver; 829extern struct font_driver nsfont_driver;
diff --git a/src/fontset.c b/src/fontset.c
index 7b051cbe1f3..da745b31ca1 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -42,7 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#ifdef HAVE_X_WINDOWS 42#ifdef HAVE_X_WINDOWS
43#include "xterm.h" 43#include "xterm.h"
44#endif 44#endif
45#ifdef WINDOWSNT 45#ifdef HAVE_NTGUI
46#include "w32term.h" 46#include "w32term.h"
47#endif 47#endif
48#ifdef HAVE_NS 48#ifdef HAVE_NS
diff --git a/src/frame.c b/src/frame.c
index 2fcf7275f9c..017d051fc1d 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1124,7 +1124,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1124 struct frame *sf = SELECTED_FRAME (); 1124 struct frame *sf = SELECTED_FRAME ();
1125 struct kboard *kb; 1125 struct kboard *kb;
1126 1126
1127 int minibuffer_selected, tooltip_frame; 1127 int minibuffer_selected, is_tooltip_frame;
1128 1128
1129 if (EQ (frame, Qnil)) 1129 if (EQ (frame, Qnil))
1130 { 1130 {
@@ -1176,13 +1176,13 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1176 } 1176 }
1177 } 1177 }
1178 1178
1179 tooltip_frame = !NILP (Fframe_parameter (frame, intern ("tooltip"))); 1179 is_tooltip_frame = !NILP (Fframe_parameter (frame, intern ("tooltip")));
1180 1180
1181 /* Run `delete-frame-functions' unless FORCE is `noelisp' or 1181 /* Run `delete-frame-functions' unless FORCE is `noelisp' or
1182 frame is a tooltip. FORCE is set to `noelisp' when handling 1182 frame is a tooltip. FORCE is set to `noelisp' when handling
1183 a disconnect from the terminal, so we don't dare call Lisp 1183 a disconnect from the terminal, so we don't dare call Lisp
1184 code. */ 1184 code. */
1185 if (NILP (Vrun_hooks) || tooltip_frame) 1185 if (NILP (Vrun_hooks) || is_tooltip_frame)
1186 ; 1186 ;
1187 else if (EQ (force, Qnoelisp)) 1187 else if (EQ (force, Qnoelisp))
1188 pending_funcalls 1188 pending_funcalls
@@ -1461,7 +1461,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1461 } 1461 }
1462 1462
1463 /* Cause frame titles to update--necessary if we now have just one frame. */ 1463 /* Cause frame titles to update--necessary if we now have just one frame. */
1464 if (!tooltip_frame) 1464 if (!is_tooltip_frame)
1465 update_mode_lines = 1; 1465 update_mode_lines = 1;
1466 1466
1467 return Qnil; 1467 return Qnil;
@@ -2697,7 +2697,7 @@ static const struct frame_parm_table frame_parms[] =
2697 {"tool-bar-position", &Qtool_bar_position}, 2697 {"tool-bar-position", &Qtool_bar_position},
2698}; 2698};
2699 2699
2700#ifdef WINDOWSNT 2700#ifdef HAVE_NTGUI
2701 2701
2702/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the 2702/* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the
2703 wanted positions of the WM window (not Emacs window). 2703 wanted positions of the WM window (not Emacs window).
@@ -2741,7 +2741,7 @@ x_fullscreen_adjust (struct frame *f, int *width, int *height, int *top_pos, int
2741 *height = newheight; 2741 *height = newheight;
2742} 2742}
2743 2743
2744#endif /* WINDOWSNT */ 2744#endif /* HAVE_NTGUI */
2745 2745
2746#ifdef HAVE_WINDOW_SYSTEM 2746#ifdef HAVE_WINDOW_SYSTEM
2747 2747
diff --git a/src/frame.h b/src/frame.h
index 26235cc036e..7bf76c21c56 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -618,7 +618,7 @@ typedef struct frame *FRAME_PTR;
618#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial) 618#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
619#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap) 619#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
620#define FRAME_X_P(f) ((f)->output_method == output_x_window) 620#define FRAME_X_P(f) ((f)->output_method == output_x_window)
621#ifndef WINDOWSNT 621#ifndef HAVE_NTGUI
622#define FRAME_W32_P(f) (0) 622#define FRAME_W32_P(f) (0)
623#else 623#else
624#define FRAME_W32_P(f) ((f)->output_method == output_w32) 624#define FRAME_W32_P(f) ((f)->output_method == output_w32)
@@ -1210,7 +1210,7 @@ extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
1210 1210
1211extern Lisp_Object Qface_set_after_frame_default; 1211extern Lisp_Object Qface_set_after_frame_default;
1212 1212
1213#ifdef WINDOWSNT 1213#ifdef HAVE_NTGUI
1214extern void x_fullscreen_adjust (struct frame *f, int *, int *, 1214extern void x_fullscreen_adjust (struct frame *f, int *, int *,
1215 int *, int *); 1215 int *, int *);
1216#endif 1216#endif
@@ -1282,6 +1282,7 @@ extern char *x_get_resource_string (const char *, const char *);
1282#endif 1282#endif
1283 1283
1284extern void x_query_colors (struct frame *f, XColor *, int); 1284extern void x_query_colors (struct frame *f, XColor *, int);
1285extern void x_query_color (struct frame *f, XColor *);
1285 1286
1286#endif /* HAVE_WINDOW_SYSTEM */ 1287#endif /* HAVE_WINDOW_SYSTEM */
1287 1288
diff --git a/src/image.c b/src/image.c
index 91eeb91920c..9b41cf74993 100644
--- a/src/image.c
+++ b/src/image.c
@@ -75,7 +75,12 @@ typedef struct x_bitmap_record Bitmap_Record;
75#endif /* HAVE_X_WINDOWS */ 75#endif /* HAVE_X_WINDOWS */
76 76
77#ifdef HAVE_NTGUI 77#ifdef HAVE_NTGUI
78#include "w32.h" 78
79/* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */
80#ifdef WINDOWSNT
81# include "w32.h"
82#endif
83
79/* W32_TODO : Color tables on W32. */ 84/* W32_TODO : Color tables on W32. */
80#undef COLOR_TABLE_SUPPORT 85#undef COLOR_TABLE_SUPPORT
81 86
@@ -560,8 +565,9 @@ static struct image_type *lookup_image_type (Lisp_Object);
560static void x_laplace (struct frame *, struct image *); 565static void x_laplace (struct frame *, struct image *);
561static void x_emboss (struct frame *, struct image *); 566static void x_emboss (struct frame *, struct image *);
562static void x_build_heuristic_mask (struct frame *, struct image *, 567static void x_build_heuristic_mask (struct frame *, struct image *,
563 Lisp_Object); 568 Lisp_Object);
564#ifdef HAVE_NTGUI 569#ifdef WINDOWSNT
570extern Lisp_Object Vlibrary_cache;
565#define CACHE_IMAGE_TYPE(type, status) \ 571#define CACHE_IMAGE_TYPE(type, status) \
566 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0) 572 do { Vlibrary_cache = Fcons (Fcons (type, status), Vlibrary_cache); } while (0)
567#else 573#else
@@ -589,7 +595,7 @@ define_image_type (struct image_type *type)
589 595
590 if (type->init) 596 if (type->init)
591 { 597 {
592#ifdef HAVE_NTGUI 598#if defined HAVE_NTGUI && defined WINDOWSNT
593 /* If we failed to load the library before, don't try again. */ 599 /* If we failed to load the library before, don't try again. */
594 Lisp_Object tested = Fassq (target_type, Vlibrary_cache); 600 Lisp_Object tested = Fassq (target_type, Vlibrary_cache);
595 if (CONSP (tested) && NILP (XCDR (tested))) 601 if (CONSP (tested) && NILP (XCDR (tested)))
@@ -1834,7 +1840,7 @@ mark_image_cache (struct image_cache *c)
1834 X / NS / W32 support code 1840 X / NS / W32 support code
1835 ***********************************************************************/ 1841 ***********************************************************************/
1836 1842
1837#ifdef HAVE_NTGUI 1843#ifdef WINDOWSNT
1838 1844
1839/* Macro for defining functions that will be loaded from image DLLs. */ 1845/* Macro for defining functions that will be loaded from image DLLs. */
1840#define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args 1846#define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args
@@ -1845,7 +1851,7 @@ mark_image_cache (struct image_cache *c)
1845 if (!fn_##func) return 0; \ 1851 if (!fn_##func) return 0; \
1846 } 1852 }
1847 1853
1848#endif /* HAVE_NTGUI */ 1854#endif /* WINDOWSNT */
1849 1855
1850/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the 1856/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the
1851 windowing system. 1857 windowing system.
@@ -2897,7 +2903,7 @@ xbm_load (struct frame *f, struct image *img)
2897 else 2903 else
2898 bits = (char *) XBOOL_VECTOR (data)->data; 2904 bits = (char *) XBOOL_VECTOR (data)->data;
2899 2905
2900#ifdef WINDOWSNT 2906#ifdef HAVE_NTGUI
2901 { 2907 {
2902 char *invertedBits; 2908 char *invertedBits;
2903 int nbytes, i; 2909 int nbytes, i;
@@ -3008,7 +3014,7 @@ static const struct image_keyword xpm_format[XPM_LAST] =
3008 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 3014 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
3009}; 3015};
3010 3016
3011#ifdef HAVE_NTGUI 3017#if defined HAVE_NTGUI && defined WINDOWSNT
3012static bool init_xpm_functions (void); 3018static bool init_xpm_functions (void);
3013#else 3019#else
3014#define init_xpm_functions NULL 3020#define init_xpm_functions NULL
@@ -3207,7 +3213,7 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *
3207#endif /* ALLOC_XPM_COLORS */ 3213#endif /* ALLOC_XPM_COLORS */
3208 3214
3209 3215
3210#ifdef HAVE_NTGUI 3216#ifdef WINDOWSNT
3211 3217
3212/* XPM library details. */ 3218/* XPM library details. */
3213 3219
@@ -3233,8 +3239,15 @@ init_xpm_functions (void)
3233 return 1; 3239 return 1;
3234} 3240}
3235 3241
3236#endif /* HAVE_NTGUI */ 3242#endif /* WINDOWSNT */
3237 3243
3244#if defined HAVE_NTGUI && !defined WINDOWSNT
3245/* Glue for code below */
3246#define fn_XpmReadFileToImage XpmReadFileToImage
3247#define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer
3248#define fn_XImageFree XImageFree
3249#define fn_XpmFreeAttributes XpmFreeAttributes
3250#endif /* HAVE_NTGUI && !WINDOWSNT */
3238 3251
3239/* Value is true if COLOR_SYMBOLS is a valid color symbols list 3252/* Value is true if COLOR_SYMBOLS is a valid color symbols list
3240 for XPM images. Such a list must consist of conses whose car and 3253 for XPM images. Such a list must consist of conses whose car and
@@ -5340,7 +5353,7 @@ static const struct image_keyword png_format[PNG_LAST] =
5340 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 5353 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
5341}; 5354};
5342 5355
5343#ifdef HAVE_NTGUI 5356#if defined HAVE_NTGUI && defined WINDOWSNT
5344static bool init_png_functions (void); 5357static bool init_png_functions (void);
5345#else 5358#else
5346#define init_png_functions NULL 5359#define init_png_functions NULL
@@ -5378,7 +5391,7 @@ png_image_p (Lisp_Object object)
5378 5391
5379#ifdef HAVE_PNG 5392#ifdef HAVE_PNG
5380 5393
5381#ifdef HAVE_NTGUI 5394#ifdef WINDOWSNT
5382/* PNG library details. */ 5395/* PNG library details. */
5383 5396
5384DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp)); 5397DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp));
@@ -5478,7 +5491,7 @@ init_png_functions (void)
5478#define fn_png_set_longjmp_fn png_set_longjmp_fn 5491#define fn_png_set_longjmp_fn png_set_longjmp_fn
5479#endif /* libpng version >= 1.5 */ 5492#endif /* libpng version >= 1.5 */
5480 5493
5481#endif /* HAVE_NTGUI */ 5494#endif /* WINDOWSNT */
5482 5495
5483/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp. 5496/* Possibly inefficient/inexact substitutes for _setjmp and _longjmp.
5484 Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp 5497 Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp
@@ -5999,7 +6012,7 @@ static const struct image_keyword jpeg_format[JPEG_LAST] =
5999 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 6012 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
6000}; 6013};
6001 6014
6002#ifdef HAVE_NTGUI 6015#if defined HAVE_NTGUI && defined WINDOWSNT
6003static bool init_jpeg_functions (void); 6016static bool init_jpeg_functions (void);
6004#else 6017#else
6005#define init_jpeg_functions NULL 6018#define init_jpeg_functions NULL
@@ -6049,14 +6062,27 @@ jpeg_image_p (Lisp_Object object)
6049#define __WIN32__ 1 6062#define __WIN32__ 1
6050#endif 6063#endif
6051 6064
6065/* rpcndr.h (via windows.h) and jpeglib.h both define boolean types.
6066 Some versions of jpeglib try to detect whether rpcndr.h is loaded,
6067 using the Windows boolean type instead of the jpeglib boolean type
6068 if so. Cygwin jpeglib, however, doesn't try to detect whether its
6069 headers are included along with windows.h, so under Cygwin, jpeglib
6070 attempts to define a conflicting boolean type. Worse, forcing
6071 Cygwin jpeglib headers to use the Windows boolean type doesn't work
6072 because it created an ABI incompatibility between the
6073 already-compiled jpeg library and the header interface definition.
6074
6075 The best we can do is to define jpeglib's boolean type to a
6076 different name. This name, jpeg_boolean, remains in effect through
6077 the rest of image.c.
6078*/
6079#if defined CYGWIN && defined HAVE_NTGUI
6080#define boolean jpeg_boolean
6081#endif
6052#include <jpeglib.h> 6082#include <jpeglib.h>
6053#include <jerror.h> 6083#include <jerror.h>
6054 6084
6055#ifdef HAVE_STLIB_H_1 6085#ifdef WINDOWSNT
6056#define HAVE_STDLIB_H 1
6057#endif
6058
6059#ifdef HAVE_NTGUI
6060 6086
6061/* JPEG library details. */ 6087/* JPEG library details. */
6062DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); 6088DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t));
@@ -6106,7 +6132,7 @@ jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired)
6106#define fn_jpeg_std_error jpeg_std_error 6132#define fn_jpeg_std_error jpeg_std_error
6107#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart 6133#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart
6108 6134
6109#endif /* HAVE_NTGUI */ 6135#endif /* WINDOWSNT */
6110 6136
6111struct my_jpeg_error_mgr 6137struct my_jpeg_error_mgr
6112{ 6138{
@@ -6630,7 +6656,7 @@ tiff_image_p (Lisp_Object object)
6630 6656
6631#include <tiffio.h> 6657#include <tiffio.h>
6632 6658
6633#ifdef HAVE_NTGUI 6659#ifdef WINDOWSNT
6634 6660
6635/* TIFF library details. */ 6661/* TIFF library details. */
6636DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); 6662DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler));
@@ -6674,7 +6700,7 @@ init_tiff_functions (void)
6674#define fn_TIFFReadRGBAImage TIFFReadRGBAImage 6700#define fn_TIFFReadRGBAImage TIFFReadRGBAImage
6675#define fn_TIFFClose TIFFClose 6701#define fn_TIFFClose TIFFClose
6676#define fn_TIFFSetDirectory TIFFSetDirectory 6702#define fn_TIFFSetDirectory TIFFSetDirectory
6677#endif /* HAVE_NTGUI */ 6703#endif /* WINDOWSNT */
6678 6704
6679 6705
6680/* Reading from a memory buffer for TIFF images Based on the PNG 6706/* Reading from a memory buffer for TIFF images Based on the PNG
@@ -7046,7 +7072,7 @@ static const struct image_keyword gif_format[GIF_LAST] =
7046 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 7072 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
7047}; 7073};
7048 7074
7049#ifdef HAVE_NTGUI 7075#if defined HAVE_NTGUI && defined WINDOWSNT
7050static bool init_gif_functions (void); 7076static bool init_gif_functions (void);
7051#else 7077#else
7052#define init_gif_functions NULL 7078#define init_gif_functions NULL
@@ -7110,7 +7136,7 @@ gif_image_p (Lisp_Object object)
7110#endif /* HAVE_NTGUI */ 7136#endif /* HAVE_NTGUI */
7111 7137
7112 7138
7113#ifdef HAVE_NTGUI 7139#ifdef WINDOWSNT
7114 7140
7115/* GIF library details. */ 7141/* GIF library details. */
7116DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); 7142DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *));
@@ -7140,7 +7166,7 @@ init_gif_functions (void)
7140#define fn_DGifOpen DGifOpen 7166#define fn_DGifOpen DGifOpen
7141#define fn_DGifOpenFileName DGifOpenFileName 7167#define fn_DGifOpenFileName DGifOpenFileName
7142 7168
7143#endif /* HAVE_NTGUI */ 7169#endif /* WINDOWSNT */
7144 7170
7145/* Reading a GIF image from memory 7171/* Reading a GIF image from memory
7146 Based on the PNG memory stuff to a certain extent. */ 7172 Based on the PNG memory stuff to a certain extent. */
@@ -8137,7 +8163,7 @@ svg_image_p (Lisp_Object object)
8137 8163
8138#include <librsvg/rsvg.h> 8164#include <librsvg/rsvg.h>
8139 8165
8140#ifdef HAVE_NTGUI 8166#ifdef WINDOWSNT
8141 8167
8142/* SVG library functions. */ 8168/* SVG library functions. */
8143DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new); 8169DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new);
@@ -8215,7 +8241,7 @@ init_svg_functions (void)
8215#define fn_g_type_init g_type_init 8241#define fn_g_type_init g_type_init
8216#define fn_g_object_unref g_object_unref 8242#define fn_g_object_unref g_object_unref
8217#define fn_g_error_free g_error_free 8243#define fn_g_error_free g_error_free
8218#endif /* !HAVE_NTGUI */ 8244#endif /* !WINDOWSNT */
8219 8245
8220/* Load SVG image IMG for use on frame F. Value is true if 8246/* Load SVG image IMG for use on frame F. Value is true if
8221 successful. */ 8247 successful. */
diff --git a/src/indent.c b/src/indent.c
index b368a7aeb09..81a63455ecb 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -30,7 +30,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include "frame.h" 30#include "frame.h"
31#include "window.h" 31#include "window.h"
32#include "termchar.h" 32#include "termchar.h"
33#include "termopts.h"
34#include "disptab.h" 33#include "disptab.h"
35#include "intervals.h" 34#include "intervals.h"
36#include "dispextern.h" 35#include "dispextern.h"
diff --git a/src/keyboard.c b/src/keyboard.c
index d06b02024c5..d58178b7561 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -86,8 +86,8 @@ KBOARD *initial_kboard;
86KBOARD *current_kboard; 86KBOARD *current_kboard;
87KBOARD *all_kboards; 87KBOARD *all_kboards;
88 88
89/* Nonzero in the single-kboard state, 0 in the any-kboard state. */ 89/* True in the single-kboard state, false in the any-kboard state. */
90static int single_kboard; 90static bool single_kboard;
91 91
92/* Non-nil disable property on a command means 92/* Non-nil disable property on a command means
93 do not execute it; call disabled-command-function's value instead. */ 93 do not execute it; call disabled-command-function's value instead. */
@@ -113,9 +113,9 @@ static Lisp_Object recent_keys;
113Lisp_Object this_command_keys; 113Lisp_Object this_command_keys;
114ptrdiff_t this_command_key_count; 114ptrdiff_t this_command_key_count;
115 115
116/* 1 after calling Freset_this_command_lengths. 116/* True after calling Freset_this_command_lengths.
117 Usually it is 0. */ 117 Usually it is false. */
118static int this_command_key_count_reset; 118static bool this_command_key_count_reset;
119 119
120/* This vector is used as a buffer to record the events that were actually read 120/* This vector is used as a buffer to record the events that were actually read
121 by read_key_sequence. */ 121 by read_key_sequence. */
@@ -140,11 +140,11 @@ static ptrdiff_t before_command_echo_length;
140static sys_jmp_buf getcjmp; 140static sys_jmp_buf getcjmp;
141 141
142/* True while doing kbd input. */ 142/* True while doing kbd input. */
143int waiting_for_input; 143bool waiting_for_input;
144 144
145/* True while displaying for echoing. Delays C-g throwing. */ 145/* True while displaying for echoing. Delays C-g throwing. */
146 146
147static int echoing; 147static bool echoing;
148 148
149/* Non-null means we can start echoing at the next input pause even 149/* Non-null means we can start echoing at the next input pause even
150 though there is something in the echo area. */ 150 though there is something in the echo area. */
@@ -163,8 +163,8 @@ struct kboard *echo_kboard;
163 163
164Lisp_Object echo_message_buffer; 164Lisp_Object echo_message_buffer;
165 165
166/* Nonzero means C-g should cause immediate error-signal. */ 166/* True means C-g should cause immediate error-signal. */
167int immediate_quit; 167bool immediate_quit;
168 168
169/* Character that causes a quit. Normally C-g. 169/* Character that causes a quit. Normally C-g.
170 170
@@ -270,7 +270,7 @@ static Lisp_Object Qhelp_form_show;
270static FILE *dribble; 270static FILE *dribble;
271 271
272/* Nonzero if input is available. */ 272/* Nonzero if input is available. */
273int input_pending; 273bool input_pending;
274 274
275/* Circular buffer for pre-read keyboard input. */ 275/* Circular buffer for pre-read keyboard input. */
276 276
@@ -313,7 +313,7 @@ static Lisp_Object Qmouse_fixup_help_message;
313/* Symbols to denote kinds of events. */ 313/* Symbols to denote kinds of events. */
314static Lisp_Object Qfunction_key; 314static Lisp_Object Qfunction_key;
315Lisp_Object Qmouse_click; 315Lisp_Object Qmouse_click;
316#if defined (WINDOWSNT) 316#ifdef HAVE_NTGUI
317Lisp_Object Qlanguage_change; 317Lisp_Object Qlanguage_change;
318#endif 318#endif
319static Lisp_Object Qdrag_n_drop; 319static Lisp_Object Qdrag_n_drop;
@@ -372,18 +372,18 @@ static ptrdiff_t echo_length (void);
372static Lisp_Object Qpolling_period; 372static Lisp_Object Qpolling_period;
373 373
374/* Incremented whenever a timer is run. */ 374/* Incremented whenever a timer is run. */
375int timers_run; 375unsigned timers_run;
376 376
377/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt 377/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
378 happens. */ 378 happens. */
379EMACS_TIME *input_available_clear_time; 379EMACS_TIME *input_available_clear_time;
380 380
381/* Nonzero means use SIGIO interrupts; zero means use CBREAK mode. 381/* True means use SIGIO interrupts; false means use CBREAK mode.
382 Default is 1 if INTERRUPT_INPUT is defined. */ 382 Default is true if INTERRUPT_INPUT is defined. */
383int interrupt_input; 383bool interrupt_input;
384 384
385/* Nonzero while interrupts are temporarily deferred during redisplay. */ 385/* Nonzero while interrupts are temporarily deferred during redisplay. */
386int interrupts_deferred; 386bool interrupts_deferred;
387 387
388/* If we support a window system, turn on the code to poll periodically 388/* If we support a window system, turn on the code to poll periodically
389 to detect C-g. It isn't actually used when doing interrupt input. */ 389 to detect C-g. It isn't actually used when doing interrupt input. */
@@ -411,10 +411,10 @@ static EMACS_TIME timer_last_idleness_start_time;
411/* Function for init_keyboard to call with no args (if nonzero). */ 411/* Function for init_keyboard to call with no args (if nonzero). */
412static void (*keyboard_init_hook) (void); 412static void (*keyboard_init_hook) (void);
413 413
414static void get_input_pending (int *, int); 414static bool get_input_pending (int);
415static int readable_events (int); 415static bool readable_events (int);
416static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, 416static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *,
417 Lisp_Object, int *); 417 Lisp_Object, bool *);
418static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t, 418static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t,
419 Lisp_Object *); 419 Lisp_Object *);
420static Lisp_Object make_lispy_event (struct input_event *); 420static Lisp_Object make_lispy_event (struct input_event *);
@@ -428,7 +428,7 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
428 Lisp_Object, const char *const *, 428 Lisp_Object, const char *const *,
429 Lisp_Object *, ptrdiff_t); 429 Lisp_Object *, ptrdiff_t);
430static Lisp_Object make_lispy_switch_frame (Lisp_Object); 430static Lisp_Object make_lispy_switch_frame (Lisp_Object);
431static int help_char_p (Lisp_Object); 431static bool help_char_p (Lisp_Object);
432static void save_getcjmp (sys_jmp_buf); 432static void save_getcjmp (sys_jmp_buf);
433static void restore_getcjmp (sys_jmp_buf); 433static void restore_getcjmp (sys_jmp_buf);
434static Lisp_Object apply_modifiers (int, Lisp_Object); 434static Lisp_Object apply_modifiers (int, Lisp_Object);
@@ -438,7 +438,7 @@ static Lisp_Object restore_kboard_configuration (Lisp_Object);
438static void deliver_input_available_signal (int signo); 438static void deliver_input_available_signal (int signo);
439#endif 439#endif
440static void handle_interrupt (bool); 440static void handle_interrupt (bool);
441static _Noreturn void quit_throw_to_read_char (int); 441static _Noreturn void quit_throw_to_read_char (bool);
442static void process_special_events (void); 442static void process_special_events (void);
443static void timer_start_idle (void); 443static void timer_start_idle (void);
444static void timer_stop_idle (void); 444static void timer_stop_idle (void);
@@ -516,7 +516,7 @@ echo_char (Lisp_Object c)
516 516
517 if (INTEGERP (c)) 517 if (INTEGERP (c))
518 { 518 {
519 ptr = push_key_description (XINT (c), ptr, 1); 519 ptr = push_key_description (XINT (c), ptr);
520 } 520 }
521 else if (SYMBOLP (c)) 521 else if (SYMBOLP (c))
522 { 522 {
@@ -925,7 +925,7 @@ pop_kboard (void)
925{ 925{
926 struct terminal *t; 926 struct terminal *t;
927 struct kboard_stack *p = kboard_stack; 927 struct kboard_stack *p = kboard_stack;
928 int found = 0; 928 bool found = 0;
929 for (t = terminal_list; t; t = t->next_terminal) 929 for (t = terminal_list; t; t = t->next_terminal)
930 { 930 {
931 if (t->kboard == p->kboard) 931 if (t->kboard == p->kboard)
@@ -958,7 +958,7 @@ pop_kboard (void)
958void 958void
959temporarily_switch_to_single_kboard (struct frame *f) 959temporarily_switch_to_single_kboard (struct frame *f)
960{ 960{
961 int was_locked = single_kboard; 961 bool was_locked = single_kboard;
962 if (was_locked) 962 if (was_locked)
963 { 963 {
964 if (f != NULL && FRAME_KBOARD (f) != current_kboard) 964 if (f != NULL && FRAME_KBOARD (f) != current_kboard)
@@ -1057,12 +1057,7 @@ cmd_error (Lisp_Object data)
1057 Vprint_length = old_length; 1057 Vprint_length = old_length;
1058 1058
1059 Vquit_flag = Qnil; 1059 Vquit_flag = Qnil;
1060
1061 Vinhibit_quit = Qnil; 1060 Vinhibit_quit = Qnil;
1062#if 0 /* This shouldn't be necessary anymore. --lorentey */
1063 if (command_loop_level == 0 && minibuf_level == 0)
1064 any_kboard_state ();
1065#endif
1066 1061
1067 return make_number (0); 1062 return make_number (0);
1068} 1063}
@@ -1149,12 +1144,6 @@ command_loop (void)
1149 while (1) 1144 while (1)
1150 { 1145 {
1151 internal_catch (Qtop_level, top_level_1, Qnil); 1146 internal_catch (Qtop_level, top_level_1, Qnil);
1152#if 0 /* This shouldn't be necessary anymore. --lorentey */
1153 /* Reset single_kboard in case top-level set it while
1154 evaluating an -f option, or we are stuck there for some
1155 other reason. */
1156 any_kboard_state ();
1157#endif
1158 internal_catch (Qtop_level, command_loop_2, Qnil); 1147 internal_catch (Qtop_level, command_loop_2, Qnil);
1159 executing_kbd_macro = Qnil; 1148 executing_kbd_macro = Qnil;
1160 1149
@@ -1265,8 +1254,7 @@ tracking_off (Lisp_Object old_value)
1265 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW)) 1254 if (!readable_events (READABLE_EVENTS_DO_TIMERS_NOW))
1266 { 1255 {
1267 redisplay_preserve_echo_area (6); 1256 redisplay_preserve_echo_area (6);
1268 get_input_pending (&input_pending, 1257 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
1269 READABLE_EVENTS_DO_TIMERS_NOW);
1270 } 1258 }
1271 } 1259 }
1272 return Qnil; 1260 return Qnil;
@@ -1301,7 +1289,7 @@ usage: (track-mouse BODY...) */)
1301#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS 1289#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS
1302static 1290static
1303#endif 1291#endif
1304int ignore_mouse_drag_p; 1292bool ignore_mouse_drag_p;
1305 1293
1306static FRAME_PTR 1294static FRAME_PTR
1307some_mouse_moved (void) 1295some_mouse_moved (void)
@@ -1329,9 +1317,9 @@ some_mouse_moved (void)
1329 sans error-handling encapsulation. */ 1317 sans error-handling encapsulation. */
1330 1318
1331static int read_key_sequence (Lisp_Object *, int, Lisp_Object, 1319static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
1332 int, int, int); 1320 bool, bool, bool);
1333void safe_run_hooks (Lisp_Object); 1321void safe_run_hooks (Lisp_Object);
1334static void adjust_point_for_property (ptrdiff_t, int); 1322static void adjust_point_for_property (ptrdiff_t, bool);
1335 1323
1336/* Cancel hourglass from protect_unwind. 1324/* Cancel hourglass from protect_unwind.
1337 ARG is not used. */ 1325 ARG is not used. */
@@ -1359,10 +1347,7 @@ command_loop_1 (void)
1359 int i; 1347 int i;
1360 EMACS_INT prev_modiff = 0; 1348 EMACS_INT prev_modiff = 0;
1361 struct buffer *prev_buffer = NULL; 1349 struct buffer *prev_buffer = NULL;
1362#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1350 bool already_adjusted = 0;
1363 int was_locked = single_kboard;
1364#endif
1365 int already_adjusted = 0;
1366 1351
1367 kset_prefix_arg (current_kboard, Qnil); 1352 kset_prefix_arg (current_kboard, Qnil);
1368 kset_last_prefix_arg (current_kboard, Qnil); 1353 kset_last_prefix_arg (current_kboard, Qnil);
@@ -1731,10 +1716,6 @@ command_loop_1 (void)
1731 if (!NILP (KVAR (current_kboard, defining_kbd_macro)) 1716 if (!NILP (KVAR (current_kboard, defining_kbd_macro))
1732 && NILP (KVAR (current_kboard, Vprefix_arg))) 1717 && NILP (KVAR (current_kboard, Vprefix_arg)))
1733 finalize_kbd_macro_chars (); 1718 finalize_kbd_macro_chars ();
1734#if 0 /* This shouldn't be necessary anymore. --lorentey */
1735 if (!was_locked)
1736 any_kboard_state ();
1737#endif
1738 } 1719 }
1739} 1720}
1740 1721
@@ -1744,7 +1725,7 @@ command_loop_1 (void)
1744 LAST_PT is the last position of point. */ 1725 LAST_PT is the last position of point. */
1745 1726
1746static void 1727static void
1747adjust_point_for_property (ptrdiff_t last_pt, int modified) 1728adjust_point_for_property (ptrdiff_t last_pt, bool modified)
1748{ 1729{
1749 ptrdiff_t beg, end; 1730 ptrdiff_t beg, end;
1750 Lisp_Object val, overlay, tmp; 1731 Lisp_Object val, overlay, tmp;
@@ -1752,7 +1733,7 @@ adjust_point_for_property (ptrdiff_t last_pt, int modified)
1752 suppress the point adjustment for automatic composition so that a 1733 suppress the point adjustment for automatic composition so that a
1753 user can keep inserting another character at point or keep 1734 user can keep inserting another character at point or keep
1754 deleting characters around point. */ 1735 deleting characters around point. */
1755 int check_composition = ! modified, check_display = 1, check_invisible = 1; 1736 bool check_composition = ! modified, check_display = 1, check_invisible = 1;
1756 ptrdiff_t orig_pt = PT; 1737 ptrdiff_t orig_pt = PT;
1757 1738
1758 /* FIXME: cycling is probably not necessary because these properties 1739 /* FIXME: cycling is probably not necessary because these properties
@@ -1791,7 +1772,8 @@ adjust_point_for_property (ptrdiff_t last_pt, int modified)
1791 check_display = 0; 1772 check_display = 0;
1792 if (check_invisible && PT > BEGV && PT < ZV) 1773 if (check_invisible && PT > BEGV && PT < ZV)
1793 { 1774 {
1794 int inv, ellipsis = 0; 1775 int inv;
1776 bool ellipsis = 0;
1795 beg = end = PT; 1777 beg = end = PT;
1796 1778
1797 /* Find boundaries `beg' and `end' of the invisible area, if any. */ 1779 /* Find boundaries `beg' and `end' of the invisible area, if any. */
@@ -1920,7 +1902,7 @@ safe_run_hooks_error (Lisp_Object error_data)
1920 if (SYMBOLP (hook)) 1902 if (SYMBOLP (hook))
1921 { 1903 {
1922 Lisp_Object val; 1904 Lisp_Object val;
1923 int found = 0; 1905 bool found = 0;
1924 Lisp_Object newval = Qnil; 1906 Lisp_Object newval = Qnil;
1925 for (val = find_symbol_value (hook); CONSP (val); val = XCDR (val)) 1907 for (val = find_symbol_value (hook); CONSP (val); val = XCDR (val))
1926 if (EQ (fun, XCAR (val))) 1908 if (EQ (fun, XCAR (val)))
@@ -2050,9 +2032,9 @@ start_polling (void)
2050#endif 2032#endif
2051} 2033}
2052 2034
2053/* Nonzero if we are using polling to handle input asynchronously. */ 2035/* True if we are using polling to handle input asynchronously. */
2054 2036
2055int 2037bool
2056input_polling_used (void) 2038input_polling_used (void)
2057{ 2039{
2058#ifdef POLL_FOR_INPUT 2040#ifdef POLL_FOR_INPUT
@@ -2228,7 +2210,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
2228 2210
2229/* Input of single characters from keyboard */ 2211/* Input of single characters from keyboard */
2230 2212
2231static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, int *used_mouse_menu, 2213static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, bool *used_mouse_menu,
2232 EMACS_TIME *end_time); 2214 EMACS_TIME *end_time);
2233static void record_char (Lisp_Object c); 2215static void record_char (Lisp_Object c);
2234 2216
@@ -2265,9 +2247,9 @@ do { if (polling_stopped_here) start_polling (); \
2265 not to run input methods, but in other respects to act as if 2247 not to run input methods, but in other respects to act as if
2266 not reading a key sequence. 2248 not reading a key sequence.
2267 2249
2268 If USED_MOUSE_MENU is non-null, then we set *USED_MOUSE_MENU to 1 2250 If USED_MOUSE_MENU is non-null, then set *USED_MOUSE_MENU to true
2269 if we used a mouse menu to read the input, or zero otherwise. If 2251 if we used a mouse menu to read the input, or false otherwise. If
2270 USED_MOUSE_MENU is null, we don't dereference it. 2252 USED_MOUSE_MENU is null, don't dereference it.
2271 2253
2272 Value is -2 when we find input on another keyboard. A second call 2254 Value is -2 when we find input on another keyboard. A second call
2273 to read_char will read it. 2255 to read_char will read it.
@@ -2281,7 +2263,7 @@ do { if (polling_stopped_here) start_polling (); \
2281Lisp_Object 2263Lisp_Object
2282read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, 2264read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2283 Lisp_Object prev_event, 2265 Lisp_Object prev_event,
2284 int *used_mouse_menu, EMACS_TIME *end_time) 2266 bool *used_mouse_menu, EMACS_TIME *end_time)
2285{ 2267{
2286 Lisp_Object c; 2268 Lisp_Object c;
2287 ptrdiff_t jmpcount; 2269 ptrdiff_t jmpcount;
@@ -2290,9 +2272,9 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2290 Lisp_Object tem, save; 2272 Lisp_Object tem, save;
2291 volatile Lisp_Object previous_echo_area_message; 2273 volatile Lisp_Object previous_echo_area_message;
2292 volatile Lisp_Object also_record; 2274 volatile Lisp_Object also_record;
2293 volatile int reread; 2275 volatile bool reread;
2294 struct gcpro gcpro1, gcpro2; 2276 struct gcpro gcpro1, gcpro2;
2295 int volatile polling_stopped_here = 0; 2277 bool volatile polling_stopped_here = 0;
2296 struct kboard *orig_kboard = current_kboard; 2278 struct kboard *orig_kboard = current_kboard;
2297 2279
2298 also_record = Qnil; 2280 also_record = Qnil;
@@ -2328,7 +2310,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2328 2310
2329 if (CONSP (Vunread_command_events)) 2311 if (CONSP (Vunread_command_events))
2330 { 2312 {
2331 int was_disabled = 0; 2313 bool was_disabled = 0;
2332 2314
2333 c = XCAR (Vunread_command_events); 2315 c = XCAR (Vunread_command_events);
2334 Vunread_command_events = XCDR (Vunread_command_events); 2316 Vunread_command_events = XCDR (Vunread_command_events);
@@ -2430,7 +2412,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2430 /* if redisplay was requested */ 2412 /* if redisplay was requested */
2431 if (commandflag >= 0) 2413 if (commandflag >= 0)
2432 { 2414 {
2433 int echo_current = EQ (echo_message_buffer, echo_area_buffer[0]); 2415 bool echo_current = EQ (echo_message_buffer, echo_area_buffer[0]);
2434 2416
2435 /* If there is pending input, process any events which are not 2417 /* If there is pending input, process any events which are not
2436 user-visible, such as X selection_request events. */ 2418 user-visible, such as X selection_request events. */
@@ -2862,12 +2844,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2862 if (!NILP (tem)) 2844 if (!NILP (tem))
2863 { 2845 {
2864 struct buffer *prev_buffer = current_buffer; 2846 struct buffer *prev_buffer = current_buffer;
2865#if 0 /* This shouldn't be necessary anymore. --lorentey */
2866 int was_locked = single_kboard;
2867 ptrdiff_t count = SPECPDL_INDEX ();
2868 record_single_kboard_state ();
2869#endif
2870
2871 last_input_event = c; 2847 last_input_event = c;
2872 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt); 2848 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_event), Qt);
2873 2849
@@ -2878,13 +2854,6 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2878 example banishing the mouse under mouse-avoidance-mode. */ 2854 example banishing the mouse under mouse-avoidance-mode. */
2879 timer_resume_idle (); 2855 timer_resume_idle ();
2880 2856
2881#if 0 /* This shouldn't be necessary anymore. --lorentey */
2882 /* Resume allowing input from any kboard, if that was true before. */
2883 if (!was_locked)
2884 any_kboard_state ();
2885 unbind_to (count, Qnil);
2886#endif
2887
2888 if (current_buffer != prev_buffer) 2857 if (current_buffer != prev_buffer)
2889 { 2858 {
2890 /* The command may have changed the keymaps. Pretend there 2859 /* The command may have changed the keymaps. Pretend there
@@ -2992,15 +2961,15 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2992 { 2961 {
2993 Lisp_Object keys; 2962 Lisp_Object keys;
2994 ptrdiff_t key_count; 2963 ptrdiff_t key_count;
2995 int key_count_reset; 2964 bool key_count_reset;
2996 struct gcpro gcpro1; 2965 struct gcpro gcpro1;
2997 ptrdiff_t count = SPECPDL_INDEX (); 2966 ptrdiff_t count = SPECPDL_INDEX ();
2998 2967
2999 /* Save the echo status. */ 2968 /* Save the echo status. */
3000 int saved_immediate_echo = current_kboard->immediate_echo; 2969 bool saved_immediate_echo = current_kboard->immediate_echo;
3001 struct kboard *saved_ok_to_echo = ok_to_echo_at_next_pause; 2970 struct kboard *saved_ok_to_echo = ok_to_echo_at_next_pause;
3002 Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string); 2971 Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string);
3003 int saved_echo_after_prompt = current_kboard->echo_after_prompt; 2972 ptrdiff_t saved_echo_after_prompt = current_kboard->echo_after_prompt;
3004 2973
3005#if 0 2974#if 0
3006 if (before_command_restore_flag) 2975 if (before_command_restore_flag)
@@ -3201,9 +3170,9 @@ record_menu_key (Lisp_Object c)
3201 num_input_events++; 3170 num_input_events++;
3202} 3171}
3203 3172
3204/* Return 1 if should recognize C as "the help character". */ 3173/* Return true if should recognize C as "the help character". */
3205 3174
3206static int 3175static bool
3207help_char_p (Lisp_Object c) 3176help_char_p (Lisp_Object c)
3208{ 3177{
3209 Lisp_Object tail; 3178 Lisp_Object tail;
@@ -3375,7 +3344,7 @@ restore_getcjmp (sys_jmp_buf temp)
3375 3344
3376/* Return true if there are any events in the queue that read-char 3345/* Return true if there are any events in the queue that read-char
3377 would return. If this returns false, a read-char would block. */ 3346 would return. If this returns false, a read-char would block. */
3378static int 3347static bool
3379readable_events (int flags) 3348readable_events (int flags)
3380{ 3349{
3381 if (flags & READABLE_EVENTS_DO_TIMERS_NOW) 3350 if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
@@ -3714,15 +3683,14 @@ discard_mouse_events (void)
3714} 3683}
3715 3684
3716 3685
3717/* Return non-zero if there are any real events waiting in the event 3686/* Return true if there are any real events waiting in the event
3718 buffer, not counting `NO_EVENT's. 3687 buffer, not counting `NO_EVENT's.
3719 3688
3720 If DISCARD is non-zero, discard NO_EVENT events at the front of 3689 Discard NO_EVENT events at the front of the input queue, possibly
3721 the input queue, possibly leaving the input queue empty if there 3690 leaving the input queue empty if there are no real input events. */
3722 are no real input events. */
3723 3691
3724int 3692bool
3725kbd_buffer_events_waiting (int discard) 3693kbd_buffer_events_waiting (void)
3726{ 3694{
3727 struct input_event *sp; 3695 struct input_event *sp;
3728 3696
@@ -3734,9 +3702,7 @@ kbd_buffer_events_waiting (int discard)
3734 sp = kbd_buffer; 3702 sp = kbd_buffer;
3735 } 3703 }
3736 3704
3737 if (discard) 3705 kbd_fetch_ptr = sp;
3738 kbd_fetch_ptr = sp;
3739
3740 return sp != kbd_store_ptr && sp->kind != NO_EVENT; 3706 return sp != kbd_store_ptr && sp->kind != NO_EVENT;
3741} 3707}
3742 3708
@@ -3758,7 +3724,7 @@ clear_event (struct input_event *event)
3758 3724
3759static Lisp_Object 3725static Lisp_Object
3760kbd_buffer_get_event (KBOARD **kbp, 3726kbd_buffer_get_event (KBOARD **kbp,
3761 int *used_mouse_menu, 3727 bool *used_mouse_menu,
3762 EMACS_TIME *end_time) 3728 EMACS_TIME *end_time)
3763{ 3729{
3764 Lisp_Object obj; 3730 Lisp_Object obj;
@@ -3766,8 +3732,8 @@ kbd_buffer_get_event (KBOARD **kbp,
3766#ifdef subprocesses 3732#ifdef subprocesses
3767 if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4) 3733 if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4)
3768 { 3734 {
3769 /* Start reading input again, we have processed enough so we can 3735 /* Start reading input again because we have processed enough to
3770 accept new events again. */ 3736 be able to accept new events again. */
3771 unhold_keyboard_input (); 3737 unhold_keyboard_input ();
3772 start_polling (); 3738 start_polling ();
3773 } 3739 }
@@ -3947,7 +3913,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3947 x_activate_menubar (XFRAME (event->frame_or_window)); 3913 x_activate_menubar (XFRAME (event->frame_or_window));
3948 } 3914 }
3949#endif 3915#endif
3950#if defined (WINDOWSNT) 3916#ifdef HAVE_NTGUI
3951 else if (event->kind == LANGUAGE_CHANGE_EVENT) 3917 else if (event->kind == LANGUAGE_CHANGE_EVENT)
3952 { 3918 {
3953 /* Make an event (language-change (FRAME CODEPAGE LANGUAGE-ID)). */ 3919 /* Make an event (language-change (FRAME CODEPAGE LANGUAGE-ID)). */
@@ -4203,14 +4169,14 @@ process_special_events (void)
4203 are ripe, and return, without reading any user-visible events. */ 4169 are ripe, and return, without reading any user-visible events. */
4204 4170
4205void 4171void
4206swallow_events (int do_display) 4172swallow_events (bool do_display)
4207{ 4173{
4208 int old_timers_run; 4174 unsigned old_timers_run;
4209 4175
4210 process_special_events (); 4176 process_special_events ();
4211 4177
4212 old_timers_run = timers_run; 4178 old_timers_run = timers_run;
4213 get_input_pending (&input_pending, READABLE_EVENTS_DO_TIMERS_NOW); 4179 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
4214 4180
4215 if (timers_run != old_timers_run && do_display) 4181 if (timers_run != old_timers_run && do_display)
4216 redisplay_preserve_echo_area (7); 4182 redisplay_preserve_echo_area (7);
@@ -4337,7 +4303,7 @@ timer_check_2 (Lisp_Object timers, Lisp_Object idle_timers)
4337 EMACS_TIME difference; 4303 EMACS_TIME difference;
4338 EMACS_TIME timer_difference = invalid_emacs_time (); 4304 EMACS_TIME timer_difference = invalid_emacs_time ();
4339 EMACS_TIME idle_timer_difference = invalid_emacs_time (); 4305 EMACS_TIME idle_timer_difference = invalid_emacs_time ();
4340 int ripe, timer_ripe = 0, idle_timer_ripe = 0; 4306 bool ripe, timer_ripe = 0, idle_timer_ripe = 0;
4341 4307
4342 /* Set TIMER and TIMER_DIFFERENCE 4308 /* Set TIMER and TIMER_DIFFERENCE
4343 based on the next ordinary timer. 4309 based on the next ordinary timer.
@@ -5417,7 +5383,7 @@ make_lispy_event (struct input_event *event)
5417 (sizeof (lispy_function_keys) 5383 (sizeof (lispy_function_keys)
5418 / sizeof (lispy_function_keys[0]))); 5384 / sizeof (lispy_function_keys[0])));
5419 5385
5420#ifdef WINDOWSNT 5386#ifdef HAVE_NTGUI
5421 case MULTIMEDIA_KEY_EVENT: 5387 case MULTIMEDIA_KEY_EVENT:
5422 if (event->code < (sizeof (lispy_multimedia_keys) 5388 if (event->code < (sizeof (lispy_multimedia_keys)
5423 / sizeof (lispy_multimedia_keys[0])) 5389 / sizeof (lispy_multimedia_keys[0]))
@@ -5441,7 +5407,7 @@ make_lispy_event (struct input_event *event)
5441#endif 5407#endif
5442 { 5408 {
5443 int button = event->code; 5409 int button = event->code;
5444 int is_double; 5410 bool is_double;
5445 Lisp_Object position; 5411 Lisp_Object position;
5446 Lisp_Object *start_pos_ptr; 5412 Lisp_Object *start_pos_ptr;
5447 Lisp_Object start_pos; 5413 Lisp_Object start_pos;
@@ -5722,7 +5688,7 @@ make_lispy_event (struct input_event *event)
5722 struct frame *fr; 5688 struct frame *fr;
5723 int fuzz; 5689 int fuzz;
5724 int symbol_num; 5690 int symbol_num;
5725 int is_double; 5691 bool is_double;
5726 5692
5727 if (WINDOWP (event->frame_or_window)) 5693 if (WINDOWP (event->frame_or_window))
5728 fr = XFRAME (XWINDOW (event->frame_or_window)->frame); 5694 fr = XFRAME (XWINDOW (event->frame_or_window)->frame);
@@ -6664,11 +6630,11 @@ parse_solitary_modifier (Lisp_Object symbol)
6664 return 0; 6630 return 0;
6665} 6631}
6666 6632
6667/* Return 1 if EVENT is a list whose elements are all integers or symbols. 6633/* Return true if EVENT is a list whose elements are all integers or symbols.
6668 Such a list is not valid as an event, 6634 Such a list is not valid as an event,
6669 but it can be a Lucid-style event type list. */ 6635 but it can be a Lucid-style event type list. */
6670 6636
6671int 6637bool
6672lucid_event_type_list_p (Lisp_Object object) 6638lucid_event_type_list_p (Lisp_Object object)
6673{ 6639{
6674 Lisp_Object tail; 6640 Lisp_Object tail;
@@ -6693,8 +6659,10 @@ lucid_event_type_list_p (Lisp_Object object)
6693 return NILP (tail); 6659 return NILP (tail);
6694} 6660}
6695 6661
6696/* Store into *addr a value nonzero if terminal input chars are available. 6662/* Return true if terminal input chars are available.
6697 Serves the purpose of ioctl (0, FIONREAD, addr) 6663 Also, store the return value into INPUT_PENDING.
6664
6665 Serves the purpose of ioctl (0, FIONREAD, ...)
6698 but works even if FIONREAD does not exist. 6666 but works even if FIONREAD does not exist.
6699 (In fact, this may actually read some input.) 6667 (In fact, this may actually read some input.)
6700 6668
@@ -6705,19 +6673,21 @@ lucid_event_type_list_p (Lisp_Object object)
6705 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse 6673 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse
6706 movements and toolkit scroll bar thumb drags. */ 6674 movements and toolkit scroll bar thumb drags. */
6707 6675
6708static void 6676static bool
6709get_input_pending (int *addr, int flags) 6677get_input_pending (int flags)
6710{ 6678{
6711 /* First of all, have we already counted some input? */ 6679 /* First of all, have we already counted some input? */
6712 *addr = (!NILP (Vquit_flag) || readable_events (flags)); 6680 input_pending = (!NILP (Vquit_flag) || readable_events (flags));
6713 6681
6714 /* If input is being read as it arrives, and we have none, there is none. */ 6682 /* If input is being read as it arrives, and we have none, there is none. */
6715 if (*addr > 0 || (interrupt_input && ! interrupts_deferred)) 6683 if (!input_pending && (!interrupt_input || interrupts_deferred))
6716 return; 6684 {
6685 /* Try to read some input and see how much we get. */
6686 gobble_input ();
6687 input_pending = (!NILP (Vquit_flag) || readable_events (flags));
6688 }
6717 6689
6718 /* Try to read some input and see how much we get. */ 6690 return input_pending;
6719 gobble_input ();
6720 *addr = (!NILP (Vquit_flag) || readable_events (flags));
6721} 6691}
6722 6692
6723/* Put a BUFFER_SWITCH_EVENT in the buffer 6693/* Put a BUFFER_SWITCH_EVENT in the buffer
@@ -6767,7 +6737,7 @@ int
6767gobble_input (void) 6737gobble_input (void)
6768{ 6738{
6769 int nread = 0; 6739 int nread = 0;
6770 int err = 0; 6740 bool err = 0;
6771 struct terminal *t; 6741 struct terminal *t;
6772 6742
6773 /* Store pending user signal events, if any. */ 6743 /* Store pending user signal events, if any. */
@@ -7337,9 +7307,9 @@ static const char* separator_names[] = {
7337 0, 7307 0,
7338}; 7308};
7339 7309
7340/* Return non-zero if LABEL specifies a separator. */ 7310/* Return true if LABEL specifies a separator. */
7341 7311
7342int 7312bool
7343menu_separator_name_p (const char *label) 7313menu_separator_name_p (const char *label)
7344{ 7314{
7345 if (!label) 7315 if (!label)
@@ -7514,6 +7484,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
7514{ 7484{
7515 struct gcpro gcpro1; 7485 struct gcpro gcpro1;
7516 int i; 7486 int i;
7487 bool parsed;
7517 Lisp_Object tem; 7488 Lisp_Object tem;
7518 7489
7519 if (EQ (item, Qundefined)) 7490 if (EQ (item, Qundefined))
@@ -7545,9 +7516,9 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
7545 parse_menu_item, so that if it turns out it wasn't a menu item, 7516 parse_menu_item, so that if it turns out it wasn't a menu item,
7546 it still correctly hides any further menu item. */ 7517 it still correctly hides any further menu item. */
7547 GCPRO1 (key); 7518 GCPRO1 (key);
7548 i = parse_menu_item (item, 1); 7519 parsed = parse_menu_item (item, 1);
7549 UNGCPRO; 7520 UNGCPRO;
7550 if (!i) 7521 if (!parsed)
7551 return; 7522 return;
7552 7523
7553 item = AREF (item_properties, ITEM_PROPERTY_DEF); 7524 item = AREF (item_properties, ITEM_PROPERTY_DEF);
@@ -7623,7 +7594,7 @@ menu_item_eval_property (Lisp_Object sexpr)
7623 parse_menu_item returns true if the item is a menu item and false 7594 parse_menu_item returns true if the item is a menu item and false
7624 otherwise. */ 7595 otherwise. */
7625 7596
7626int 7597bool
7627parse_menu_item (Lisp_Object item, int inmenubar) 7598parse_menu_item (Lisp_Object item, int inmenubar)
7628{ 7599{
7629 Lisp_Object def, tem, item_string, start; 7600 Lisp_Object def, tem, item_string, start;
@@ -7923,7 +7894,7 @@ static Lisp_Object QCrtl;
7923 7894
7924static void init_tool_bar_items (Lisp_Object); 7895static void init_tool_bar_items (Lisp_Object);
7925static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*); 7896static void process_tool_bar_item (Lisp_Object, Lisp_Object, Lisp_Object, void*);
7926static int parse_tool_bar_item (Lisp_Object, Lisp_Object); 7897static bool parse_tool_bar_item (Lisp_Object, Lisp_Object);
7927static void append_tool_bar_item (void); 7898static void append_tool_bar_item (void);
7928 7899
7929 7900
@@ -8056,7 +8027,7 @@ set_prop (ptrdiff_t idx, Lisp_Object val)
8056 8027
8057 8028
8058/* Parse a tool bar item specification ITEM for key KEY and return the 8029/* Parse a tool bar item specification ITEM for key KEY and return the
8059 result in tool_bar_item_properties. Value is zero if ITEM is 8030 result in tool_bar_item_properties. Value is false if ITEM is
8060 invalid. 8031 invalid.
8061 8032
8062 ITEM is a list `(menu-item CAPTION BINDING PROPS...)'. 8033 ITEM is a list `(menu-item CAPTION BINDING PROPS...)'.
@@ -8101,12 +8072,13 @@ set_prop (ptrdiff_t idx, Lisp_Object val)
8101 8072
8102 A text label to show with the tool bar button if labels are enabled. */ 8073 A text label to show with the tool bar button if labels are enabled. */
8103 8074
8104static int 8075static bool
8105parse_tool_bar_item (Lisp_Object key, Lisp_Object item) 8076parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8106{ 8077{
8107 Lisp_Object filter = Qnil; 8078 Lisp_Object filter = Qnil;
8108 Lisp_Object caption; 8079 Lisp_Object caption;
8109 int i, have_label = 0; 8080 int i;
8081 bool have_label = 0;
8110 8082
8111 /* Definition looks like `(menu-item CAPTION BINDING PROPS...)'. 8083 /* Definition looks like `(menu-item CAPTION BINDING PROPS...)'.
8112 Rule out items that aren't lists, don't start with 8084 Rule out items that aren't lists, don't start with
@@ -8363,9 +8335,9 @@ append_tool_bar_item (void)
8363 PREV_EVENT is the previous input event, or nil if we are reading 8335 PREV_EVENT is the previous input event, or nil if we are reading
8364 the first event of a key sequence. 8336 the first event of a key sequence.
8365 8337
8366 If USED_MOUSE_MENU is non-null, then we set *USED_MOUSE_MENU to 1 8338 If USED_MOUSE_MENU is non-null, set *USED_MOUSE_MENU to true
8367 if we used a mouse menu to read the input, or zero otherwise. If 8339 if we used a mouse menu to read the input, or false otherwise. If
8368 USED_MOUSE_MENU is null, we don't dereference it. 8340 USED_MOUSE_MENU is null, don't dereference it.
8369 8341
8370 The prompting is done based on the prompt-string of the map 8342 The prompting is done based on the prompt-string of the map
8371 and the strings associated with various map elements. 8343 and the strings associated with various map elements.
@@ -8378,7 +8350,7 @@ append_tool_bar_item (void)
8378 8350
8379static Lisp_Object 8351static Lisp_Object
8380read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, 8352read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8381 Lisp_Object prev_event, int *used_mouse_menu) 8353 Lisp_Object prev_event, bool *used_mouse_menu)
8382{ 8354{
8383#ifdef HAVE_MENUS 8355#ifdef HAVE_MENUS
8384 ptrdiff_t mapno; 8356 ptrdiff_t mapno;
@@ -8472,7 +8444,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8472 /* FIXME: Use the minibuffer's frame width. */ 8444 /* FIXME: Use the minibuffer's frame width. */
8473 ptrdiff_t width = FRAME_COLS (SELECTED_FRAME ()) - 4; 8445 ptrdiff_t width = FRAME_COLS (SELECTED_FRAME ()) - 4;
8474 ptrdiff_t idx = -1; 8446 ptrdiff_t idx = -1;
8475 int nobindings = 1; 8447 bool nobindings = 1;
8476 Lisp_Object rest, vector; 8448 Lisp_Object rest, vector;
8477 char *menu; 8449 char *menu;
8478 8450
@@ -8520,7 +8492,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8520 /* Present the documented bindings, a line at a time. */ 8492 /* Present the documented bindings, a line at a time. */
8521 while (1) 8493 while (1)
8522 { 8494 {
8523 int notfirst = 0; 8495 bool notfirst = 0;
8524 ptrdiff_t i = nlength; 8496 ptrdiff_t i = nlength;
8525 Lisp_Object obj; 8497 Lisp_Object obj;
8526 Lisp_Object orig_defn_macro; 8498 Lisp_Object orig_defn_macro;
@@ -8576,8 +8548,8 @@ read_char_minibuf_menu_prompt (int commandflag,
8576 /* Ignore the element if it has no prompt string. */ 8548 /* Ignore the element if it has no prompt string. */
8577 if (INTEGERP (event) && parse_menu_item (elt, -1)) 8549 if (INTEGERP (event) && parse_menu_item (elt, -1))
8578 { 8550 {
8579 /* 1 if the char to type matches the string. */ 8551 /* True if the char to type matches the string. */
8580 int char_matches; 8552 bool char_matches;
8581 Lisp_Object upcased_event, downcased_event; 8553 Lisp_Object upcased_event, downcased_event;
8582 Lisp_Object desc = Qnil; 8554 Lisp_Object desc = Qnil;
8583 Lisp_Object s 8555 Lisp_Object s
@@ -8629,7 +8601,7 @@ read_char_minibuf_menu_prompt (int commandflag,
8629 i += 2; 8601 i += 2;
8630 } 8602 }
8631 notfirst = 1; 8603 notfirst = 1;
8632 nobindings = 0 ; 8604 nobindings = 0;
8633 8605
8634 /* If the char to type doesn't match the string's 8606 /* If the char to type doesn't match the string's
8635 first char, explicitly show what char to type. */ 8607 first char, explicitly show what char to type. */
@@ -8763,14 +8735,14 @@ typedef struct keyremap
8763 8735
8764/* Lookup KEY in MAP. 8736/* Lookup KEY in MAP.
8765 MAP is a keymap mapping keys to key vectors or functions. 8737 MAP is a keymap mapping keys to key vectors or functions.
8766 If the mapping is a function and DO_FUNCTION is non-zero, then 8738 If the mapping is a function and DO_FUNCALL is true,
8767 the function is called with PROMPT as parameter and its return 8739 the function is called with PROMPT as parameter and its return
8768 value is used as the return value of this function (after checking 8740 value is used as the return value of this function (after checking
8769 that it is indeed a vector). */ 8741 that it is indeed a vector). */
8770 8742
8771static Lisp_Object 8743static Lisp_Object
8772access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt, 8744access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8773 int do_funcall) 8745 bool do_funcall)
8774{ 8746{
8775 Lisp_Object next; 8747 Lisp_Object next;
8776 8748
@@ -8809,15 +8781,15 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8809 BUFSIZE is its maximum size. 8781 BUFSIZE is its maximum size.
8810 FKEY is a pointer to the keyremap structure to use. 8782 FKEY is a pointer to the keyremap structure to use.
8811 INPUT is the index of the last element in KEYBUF. 8783 INPUT is the index of the last element in KEYBUF.
8812 DOIT if non-zero says that the remapping can actually take place. 8784 DOIT if true says that the remapping can actually take place.
8813 DIFF is used to return the number of keys added/removed by the remapping. 8785 DIFF is used to return the number of keys added/removed by the remapping.
8814 PARENT is the root of the keymap. 8786 PARENT is the root of the keymap.
8815 PROMPT is the prompt to use if the remapping happens through a function. 8787 PROMPT is the prompt to use if the remapping happens through a function.
8816 The return value is non-zero if the remapping actually took place. */ 8788 Return true if the remapping actually took place. */
8817 8789
8818static int 8790static bool
8819keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, 8791keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8820 int input, int doit, int *diff, Lisp_Object prompt) 8792 int input, bool doit, int *diff, Lisp_Object prompt)
8821{ 8793{
8822 Lisp_Object next, key; 8794 Lisp_Object next, key;
8823 8795
@@ -8871,7 +8843,7 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8871 return 0; 8843 return 0;
8872} 8844}
8873 8845
8874static int 8846static bool
8875test_undefined (Lisp_Object binding) 8847test_undefined (Lisp_Object binding)
8876{ 8848{
8877 return (EQ (binding, Qundefined) 8849 return (EQ (binding, Qundefined)
@@ -8913,13 +8885,13 @@ test_undefined (Lisp_Object binding)
8913 off the switch-frame event until later; the next call to 8885 off the switch-frame event until later; the next call to
8914 read_char will return it. 8886 read_char will return it.
8915 8887
8916 If FIX_CURRENT_BUFFER is nonzero, we restore current_buffer 8888 If FIX_CURRENT_BUFFER, we restore current_buffer
8917 from the selected window's buffer. */ 8889 from the selected window's buffer. */
8918 8890
8919static int 8891static int
8920read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, 8892read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8921 int dont_downcase_last, int can_return_switch_frame, 8893 bool dont_downcase_last, bool can_return_switch_frame,
8922 int fix_current_buffer) 8894 bool fix_current_buffer)
8923{ 8895{
8924 Lisp_Object from_string; 8896 Lisp_Object from_string;
8925 ptrdiff_t count = SPECPDL_INDEX (); 8897 ptrdiff_t count = SPECPDL_INDEX ();
@@ -8952,7 +8924,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8952 key sequence. */ 8924 key sequence. */
8953 Lisp_Object orig_keymap; 8925 Lisp_Object orig_keymap;
8954 8926
8955 /* 1 if we have already considered switching to the local-map property 8927 /* Positive if we have already considered switching to the local-map property
8956 of the place where a mouse click occurred. */ 8928 of the place where a mouse click occurred. */
8957 int localized_local_map = 0; 8929 int localized_local_map = 0;
8958 8930
@@ -8992,10 +8964,10 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8992 /* Likewise, for key_translation_map and input-decode-map. */ 8964 /* Likewise, for key_translation_map and input-decode-map. */
8993 keyremap keytran, indec; 8965 keyremap keytran, indec;
8994 8966
8995 /* Non-zero if we are trying to map a key by changing an upper-case 8967 /* True if we are trying to map a key by changing an upper-case
8996 letter to lower case, or a shifted function key to an unshifted 8968 letter to lower case, or a shifted function key to an unshifted
8997 one. */ 8969 one. */
8998 int shift_translated = 0; 8970 bool shift_translated = 0;
8999 8971
9000 /* If we receive a `switch-frame' or `select-window' event in the middle of 8972 /* If we receive a `switch-frame' or `select-window' event in the middle of
9001 a key sequence, we put it off for later. 8973 a key sequence, we put it off for later.
@@ -9011,7 +8983,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9011 int original_uppercase_position = -1; 8983 int original_uppercase_position = -1;
9012 8984
9013 /* Gets around Microsoft compiler limitations. */ 8985 /* Gets around Microsoft compiler limitations. */
9014 int dummyflag = 0; 8986 bool dummyflag = 0;
9015 8987
9016 struct buffer *starting_buffer; 8988 struct buffer *starting_buffer;
9017 8989
@@ -9173,7 +9145,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9173 : (/* indec.start < t || fkey.start < t || */ keytran.start < t)) 9145 : (/* indec.start < t || fkey.start < t || */ keytran.start < t))
9174 { 9146 {
9175 Lisp_Object key; 9147 Lisp_Object key;
9176 int used_mouse_menu = 0; 9148 bool used_mouse_menu = 0;
9177 9149
9178 /* Where the last real key started. If we need to throw away a 9150 /* Where the last real key started. If we need to throw away a
9179 key that has expanded into more than one element of keybuf 9151 key that has expanded into more than one element of keybuf
@@ -9267,7 +9239,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9267 return. Any better way to fix this? -- cyd */ 9239 return. Any better way to fix this? -- cyd */
9268 || (interrupted_kboard != current_kboard)) 9240 || (interrupted_kboard != current_kboard))
9269 { 9241 {
9270 int found = 0; 9242 bool found = 0;
9271 struct kboard *k; 9243 struct kboard *k;
9272 9244
9273 for (k = all_kboards; k; k = k->next_kboard) 9245 for (k = all_kboards; k; k = k->next_kboard)
@@ -9821,7 +9793,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9821 while (indec.end < t) 9793 while (indec.end < t)
9822 { 9794 {
9823 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9795 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9824 int done, diff; 9796 bool done;
9797 int diff;
9825 9798
9826 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); 9799 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
9827 done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input), 9800 done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input),
@@ -9855,7 +9828,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9855 while (fkey.end < indec.start) 9828 while (fkey.end < indec.start)
9856 { 9829 {
9857 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9830 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9858 int done, diff; 9831 bool done;
9832 int diff;
9859 9833
9860 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); 9834 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
9861 done = keyremap_step (keybuf, bufsize, &fkey, 9835 done = keyremap_step (keybuf, bufsize, &fkey,
@@ -9884,7 +9858,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9884 while (keytran.end < fkey.start) 9858 while (keytran.end < fkey.start)
9885 { 9859 {
9886 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9860 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9887 int done, diff; 9861 bool done;
9862 int diff;
9888 9863
9889 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); 9864 GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
9890 done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input), 9865 done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input),
@@ -10270,38 +10245,32 @@ a special event, so ignore the prefix argument and don't clear it. */)
10270 10245
10271 10246
10272 10247
10273/* Return nonzero if input events are pending. */ 10248/* Return true if input events are pending. */
10274 10249
10275int 10250bool
10276detect_input_pending (void) 10251detect_input_pending (void)
10277{ 10252{
10278 if (!input_pending) 10253 return input_pending || get_input_pending (0);
10279 get_input_pending (&input_pending, 0);
10280
10281 return input_pending;
10282} 10254}
10283 10255
10284/* Return nonzero if input events other than mouse movements are 10256/* Return true if input events other than mouse movements are
10285 pending. */ 10257 pending. */
10286 10258
10287int 10259bool
10288detect_input_pending_ignore_squeezables (void) 10260detect_input_pending_ignore_squeezables (void)
10289{ 10261{
10290 if (!input_pending) 10262 return input_pending || get_input_pending (READABLE_EVENTS_IGNORE_SQUEEZABLES);
10291 get_input_pending (&input_pending, READABLE_EVENTS_IGNORE_SQUEEZABLES);
10292
10293 return input_pending;
10294} 10263}
10295 10264
10296/* Return nonzero if input events are pending, and run any pending timers. */ 10265/* Return true if input events are pending, and run any pending timers. */
10297 10266
10298int 10267bool
10299detect_input_pending_run_timers (int do_display) 10268detect_input_pending_run_timers (bool do_display)
10300{ 10269{
10301 int old_timers_run = timers_run; 10270 unsigned old_timers_run = timers_run;
10302 10271
10303 if (!input_pending) 10272 if (!input_pending)
10304 get_input_pending (&input_pending, READABLE_EVENTS_DO_TIMERS_NOW); 10273 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
10305 10274
10306 if (old_timers_run != timers_run && do_display) 10275 if (old_timers_run != timers_run && do_display)
10307 { 10276 {
@@ -10332,13 +10301,13 @@ clear_input_pending (void)
10332 input_pending = 0; 10301 input_pending = 0;
10333} 10302}
10334 10303
10335/* Return nonzero if there are pending requeued events. 10304/* Return true if there are pending requeued events.
10336 This isn't used yet. The hope is to make wait_reading_process_output 10305 This isn't used yet. The hope is to make wait_reading_process_output
10337 call it, and return if it runs Lisp code that unreads something. 10306 call it, and return if it runs Lisp code that unreads something.
10338 The problem is, kbd_buffer_get_event needs to be fixed to know what 10307 The problem is, kbd_buffer_get_event needs to be fixed to know what
10339 to do in that case. It isn't trivial. */ 10308 to do in that case. It isn't trivial. */
10340 10309
10341int 10310bool
10342requeued_events_pending_p (void) 10311requeued_events_pending_p (void)
10343{ 10312{
10344 return (!NILP (Vunread_command_events)); 10313 return (!NILP (Vunread_command_events));
@@ -10359,10 +10328,9 @@ if there is a doubt, the value is t. */)
10359 /* Process non-user-visible events (Bug#10195). */ 10328 /* Process non-user-visible events (Bug#10195). */
10360 process_special_events (); 10329 process_special_events ();
10361 10330
10362 get_input_pending (&input_pending, 10331 return (get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW
10363 READABLE_EVENTS_DO_TIMERS_NOW 10332 | READABLE_EVENTS_FILTER_EVENTS)
10364 | READABLE_EVENTS_FILTER_EVENTS); 10333 ? Qt : Qnil);
10365 return input_pending > 0 ? Qt : Qnil;
10366} 10334}
10367 10335
10368DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, 10336DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0,
@@ -10868,7 +10836,7 @@ handle_interrupt (bool in_signal_handler)
10868/* Handle a C-g by making read_char return C-g. */ 10836/* Handle a C-g by making read_char return C-g. */
10869 10837
10870static void 10838static void
10871quit_throw_to_read_char (int from_signal) 10839quit_throw_to_read_char (bool from_signal)
10872{ 10840{
10873 /* When not called from a signal handler it is safe to call 10841 /* When not called from a signal handler it is safe to call
10874 Lisp. */ 10842 Lisp. */
@@ -10898,7 +10866,7 @@ otherwise Emacs uses CBREAK mode.
10898See also `current-input-mode'. */) 10866See also `current-input-mode'. */)
10899 (Lisp_Object interrupt) 10867 (Lisp_Object interrupt)
10900{ 10868{
10901 int new_interrupt_input; 10869 bool new_interrupt_input;
10902#ifdef USABLE_SIGIO 10870#ifdef USABLE_SIGIO
10903#ifdef HAVE_X_WINDOWS 10871#ifdef HAVE_X_WINDOWS
10904 if (x_display_list != NULL) 10872 if (x_display_list != NULL)
@@ -11394,7 +11362,7 @@ syms_of_keyboard (void)
11394 DEFSYM (Qconfig_changed_event, "config-changed-event"); 11362 DEFSYM (Qconfig_changed_event, "config-changed-event");
11395 DEFSYM (Qmenu_enable, "menu-enable"); 11363 DEFSYM (Qmenu_enable, "menu-enable");
11396 11364
11397#if defined (WINDOWSNT) 11365#ifdef HAVE_NTGUI
11398 DEFSYM (Qlanguage_change, "language-change"); 11366 DEFSYM (Qlanguage_change, "language-change");
11399#endif 11367#endif
11400 11368
diff --git a/src/keyboard.h b/src/keyboard.h
index bc35bba4ecc..e57c8cc7193 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -169,12 +169,12 @@ struct kboard
169 reading from this KBOARD again until more input arrives. */ 169 reading from this KBOARD again until more input arrives. */
170 char kbd_queue_has_data; 170 char kbd_queue_has_data;
171 171
172 /* Nonzero means echo each character as typed. */ 172 /* True means echo each character as typed. */
173 char immediate_echo; 173 unsigned immediate_echo : 1;
174 174
175 /* If we have echoed a prompt string specified by the user, 175 /* If we have echoed a prompt string specified by the user,
176 this is its length in characters. Otherwise this is -1. */ 176 this is its length in characters. Otherwise this is -1. */
177 char echo_after_prompt; 177 ptrdiff_t echo_after_prompt;
178 }; 178 };
179 179
180KEYBOARD_INLINE void 180KEYBOARD_INLINE void
@@ -463,14 +463,14 @@ extern Lisp_Object Qhelp_echo;
463extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line; 463extern Lisp_Object Qmode_line, Qvertical_line, Qheader_line;
464 464
465/* True while doing kbd input. */ 465/* True while doing kbd input. */
466extern int waiting_for_input; 466extern bool waiting_for_input;
467 467
468/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt 468/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
469 happens. */ 469 happens. */
470extern EMACS_TIME *input_available_clear_time; 470extern EMACS_TIME *input_available_clear_time;
471 471
472#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS 472#if defined HAVE_WINDOW_SYSTEM && !defined USE_GTK && !defined HAVE_NS
473extern int ignore_mouse_drag_p; 473extern bool ignore_mouse_drag_p;
474#endif 474#endif
475 475
476/* The primary selection. */ 476/* The primary selection. */
@@ -482,7 +482,7 @@ struct input_event;
482extern Lisp_Object parse_modifiers (Lisp_Object); 482extern Lisp_Object parse_modifiers (Lisp_Object);
483extern Lisp_Object reorder_modifiers (Lisp_Object); 483extern Lisp_Object reorder_modifiers (Lisp_Object);
484extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object, 484extern Lisp_Object read_char (int, ptrdiff_t, Lisp_Object *, Lisp_Object,
485 int *, EMACS_TIME *); 485 bool *, EMACS_TIME *);
486extern int parse_solitary_modifier (Lisp_Object symbol); 486extern int parse_solitary_modifier (Lisp_Object symbol);
487 487
488 488
@@ -506,10 +506,10 @@ extern Time last_event_timestamp;
506 506
507extern int quit_char; 507extern int quit_char;
508 508
509extern int timers_run; 509extern unsigned int timers_run;
510 510
511extern int menu_separator_name_p (const char *); 511extern bool menu_separator_name_p (const char *);
512extern int parse_menu_item (Lisp_Object, int); 512extern bool parse_menu_item (Lisp_Object, int);
513 513
514extern void init_kboard (KBOARD *); 514extern void init_kboard (KBOARD *);
515extern void delete_kboard (KBOARD *); 515extern void delete_kboard (KBOARD *);
@@ -524,15 +524,15 @@ extern void start_polling (void);
524extern void stop_polling (void); 524extern void stop_polling (void);
525extern void set_poll_suppress_count (int); 525extern void set_poll_suppress_count (int);
526extern int gobble_input (void); 526extern int gobble_input (void);
527extern int input_polling_used (void); 527extern bool input_polling_used (void);
528extern void clear_input_pending (void); 528extern void clear_input_pending (void);
529extern int requeued_events_pending_p (void); 529extern bool requeued_events_pending_p (void);
530extern void bind_polling_period (int); 530extern void bind_polling_period (int);
531extern int make_ctrl_char (int) ATTRIBUTE_CONST; 531extern int make_ctrl_char (int) ATTRIBUTE_CONST;
532extern void stuff_buffered_input (Lisp_Object); 532extern void stuff_buffered_input (Lisp_Object);
533extern void clear_waiting_for_input (void); 533extern void clear_waiting_for_input (void);
534extern void swallow_events (int); 534extern void swallow_events (bool);
535extern int lucid_event_type_list_p (Lisp_Object); 535extern bool lucid_event_type_list_p (Lisp_Object);
536extern void kbd_buffer_store_event (struct input_event *); 536extern void kbd_buffer_store_event (struct input_event *);
537extern void kbd_buffer_store_event_hold (struct input_event *, 537extern void kbd_buffer_store_event_hold (struct input_event *,
538 struct input_event *); 538 struct input_event *);
@@ -544,14 +544,14 @@ extern void gen_help_event (Lisp_Object, Lisp_Object, Lisp_Object,
544 Lisp_Object, ptrdiff_t); 544 Lisp_Object, ptrdiff_t);
545extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object); 545extern void kbd_buffer_store_help_event (Lisp_Object, Lisp_Object);
546extern Lisp_Object menu_item_eval_property (Lisp_Object); 546extern Lisp_Object menu_item_eval_property (Lisp_Object);
547extern int kbd_buffer_events_waiting (int); 547extern bool kbd_buffer_events_waiting (void);
548extern void add_user_signal (int, const char *); 548extern void add_user_signal (int, const char *);
549 549
550extern int tty_read_avail_input (struct terminal *, struct input_event *); 550extern int tty_read_avail_input (struct terminal *, struct input_event *);
551extern EMACS_TIME timer_check (void); 551extern EMACS_TIME timer_check (void);
552extern void mark_kboards (void); 552extern void mark_kboards (void);
553 553
554#ifdef WINDOWSNT 554#ifdef HAVE_NTGUI
555extern const char *const lispy_function_keys[]; 555extern const char *const lispy_function_keys[];
556#endif 556#endif
557 557
diff --git a/src/keymap.c b/src/keymap.c
index 6ea142651bf..fbdd31e0de3 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -99,12 +99,12 @@ static void describe_command (Lisp_Object, Lisp_Object);
99static void describe_translation (Lisp_Object, Lisp_Object); 99static void describe_translation (Lisp_Object, Lisp_Object);
100static void describe_map (Lisp_Object, Lisp_Object, 100static void describe_map (Lisp_Object, Lisp_Object,
101 void (*) (Lisp_Object, Lisp_Object), 101 void (*) (Lisp_Object, Lisp_Object),
102 int, Lisp_Object, Lisp_Object*, int, int); 102 bool, Lisp_Object, Lisp_Object*, bool, bool);
103static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object, 103static void describe_vector (Lisp_Object, Lisp_Object, Lisp_Object,
104 void (*) (Lisp_Object, Lisp_Object), int, 104 void (*) (Lisp_Object, Lisp_Object), bool,
105 Lisp_Object, Lisp_Object, int, int); 105 Lisp_Object, Lisp_Object, bool, bool);
106static void silly_event_symbol_error (Lisp_Object); 106static void silly_event_symbol_error (Lisp_Object);
107static Lisp_Object get_keyelt (Lisp_Object, int); 107static Lisp_Object get_keyelt (Lisp_Object, bool);
108 108
109/* Keymap object support - constructors and predicates. */ 109/* Keymap object support - constructors and predicates. */
110 110
@@ -207,15 +207,12 @@ when reading a key-sequence to be looked-up in this keymap. */)
207/* Check that OBJECT is a keymap (after dereferencing through any 207/* Check that OBJECT is a keymap (after dereferencing through any
208 symbols). If it is, return it. 208 symbols). If it is, return it.
209 209
210 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value 210 If AUTOLOAD and if OBJECT is a symbol whose function value
211 is an autoload form, do the autoload and try again. 211 is an autoload form, do the autoload and try again.
212 If AUTOLOAD is nonzero, callers must assume GC is possible. 212 If AUTOLOAD, callers must assume GC is possible.
213
214 If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR
215 is zero as well), return Qt.
216 213
217 ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap. 214 ERROR_IF_NOT_KEYMAP controls how we respond if OBJECT isn't a keymap.
218 If ERROR_IF_NOT_KEYMAP is non-zero, signal an error; otherwise, 215 If ERROR_IF_NOT_KEYMAP, signal an error; otherwise,
219 just return Qnil. 216 just return Qnil.
220 217
221 Note that most of the time, we don't want to pursue autoloads. 218 Note that most of the time, we don't want to pursue autoloads.
@@ -224,11 +221,11 @@ when reading a key-sequence to be looked-up in this keymap. */)
224 but it seems to me that only read_key_sequence, Flookup_key, and 221 but it seems to me that only read_key_sequence, Flookup_key, and
225 Fdefine_key should cause keymaps to be autoloaded. 222 Fdefine_key should cause keymaps to be autoloaded.
226 223
227 This function can GC when AUTOLOAD is non-zero, because it calls 224 This function can GC when AUTOLOAD is true, because it calls
228 Fautoload_do_load which can GC. */ 225 Fautoload_do_load which can GC. */
229 226
230Lisp_Object 227Lisp_Object
231get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload) 228get_keymap (Lisp_Object object, bool error_if_not_keymap, bool autoload)
232{ 229{
233 Lisp_Object tem; 230 Lisp_Object tem;
234 231
@@ -280,7 +277,7 @@ get_keymap (Lisp_Object object, int error_if_not_keymap, int autoload)
280 We assume that KEYMAP is a valid keymap. */ 277 We assume that KEYMAP is a valid keymap. */
281 278
282static Lisp_Object 279static Lisp_Object
283keymap_parent (Lisp_Object keymap, int autoload) 280keymap_parent (Lisp_Object keymap, bool autoload)
284{ 281{
285 Lisp_Object list; 282 Lisp_Object list;
286 283
@@ -307,7 +304,7 @@ If KEYMAP has no parent, return nil. */)
307} 304}
308 305
309/* Check whether MAP is one of MAPS parents. */ 306/* Check whether MAP is one of MAPS parents. */
310static int 307static bool
311keymap_memberp (Lisp_Object map, Lisp_Object maps) 308keymap_memberp (Lisp_Object map, Lisp_Object maps)
312{ 309{
313 if (NILP (map)) return 0; 310 if (NILP (map)) return 0;
@@ -365,19 +362,20 @@ Return PARENT. PARENT should be nil or another keymap. */)
365 362
366 MAP must be a keymap or a list of keymaps. 363 MAP must be a keymap or a list of keymaps.
367 364
368 If T_OK is non-zero, bindings for Qt are treated as default 365 If T_OK, bindings for Qt are treated as default
369 bindings; any key left unmentioned by other tables and bindings is 366 bindings; any key left unmentioned by other tables and bindings is
370 given the binding of Qt. 367 given the binding of Qt.
371 368
372 If T_OK is zero, bindings for Qt are not treated specially. 369 If not T_OK, bindings for Qt are not treated specially.
373 370
374 If NOINHERIT, don't accept a subkeymap found in an inherited keymap. 371 If NOINHERIT, don't accept a subkeymap found in an inherited keymap.
375 372
376 Returns Qunbound if no binding was found (and returns Qnil if a nil 373 Return Qunbound if no binding was found (and return Qnil if a nil
377 binding was found). */ 374 binding was found). */
378 375
379static Lisp_Object 376static Lisp_Object
380access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int autoload) 377access_keymap_1 (Lisp_Object map, Lisp_Object idx,
378 bool t_ok, bool noinherit, bool autoload)
381{ 379{
382 /* If idx is a list (some sort of mouse click, perhaps?), 380 /* If idx is a list (some sort of mouse click, perhaps?),
383 the index we want to use is the car of the list, which 381 the index we want to use is the car of the list, which
@@ -547,7 +545,7 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int
547 545
548Lisp_Object 546Lisp_Object
549access_keymap (Lisp_Object map, Lisp_Object idx, 547access_keymap (Lisp_Object map, Lisp_Object idx,
550 int t_ok, int noinherit, int autoload) 548 bool t_ok, bool noinherit, bool autoload)
551{ 549{
552 Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload); 550 Lisp_Object val = access_keymap_1 (map, idx, t_ok, noinherit, autoload);
553 return EQ (val, Qunbound) ? Qnil : val; 551 return EQ (val, Qunbound) ? Qnil : val;
@@ -630,9 +628,10 @@ map_keymap_call (Lisp_Object key, Lisp_Object val, Lisp_Object fun, void *dummy)
630} 628}
631 629
632/* Same as map_keymap_internal, but traverses parent keymaps as well. 630/* Same as map_keymap_internal, but traverses parent keymaps as well.
633 A non-zero AUTOLOAD indicates that autoloaded keymaps should be loaded. */ 631 AUTOLOAD indicates that autoloaded keymaps should be loaded. */
634void 632void
635map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args, void *data, int autoload) 633map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object args,
634 void *data, bool autoload)
636{ 635{
637 struct gcpro gcpro1; 636 struct gcpro gcpro1;
638 GCPRO1 (args); 637 GCPRO1 (args);
@@ -711,13 +710,13 @@ usage: (map-keymap FUNCTION KEYMAP) */)
711 Also if OBJECT has a menu string as the first element, 710 Also if OBJECT has a menu string as the first element,
712 remove that. Also remove a menu help string as second element. 711 remove that. Also remove a menu help string as second element.
713 712
714 If AUTOLOAD is nonzero, load autoloadable keymaps 713 If AUTOLOAD, load autoloadable keymaps
715 that are referred to with indirection. 714 that are referred to with indirection.
716 715
717 This can GC because menu_item_eval_property calls Feval. */ 716 This can GC because menu_item_eval_property calls Feval. */
718 717
719static Lisp_Object 718static Lisp_Object
720get_keyelt (Lisp_Object object, int autoload) 719get_keyelt (Lisp_Object object, bool autoload)
721{ 720{
722 while (1) 721 while (1)
723 { 722 {
@@ -1114,10 +1113,10 @@ binding is altered. If there is no binding for KEY, the new pair
1114binding KEY to DEF is added at the front of KEYMAP. */) 1113binding KEY to DEF is added at the front of KEYMAP. */)
1115 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def) 1114 (Lisp_Object keymap, Lisp_Object key, Lisp_Object def)
1116{ 1115{
1117 register ptrdiff_t idx; 1116 ptrdiff_t idx;
1118 register Lisp_Object c; 1117 Lisp_Object c;
1119 register Lisp_Object cmd; 1118 Lisp_Object cmd;
1120 int metized = 0; 1119 bool metized = 0;
1121 int meta_bit; 1120 int meta_bit;
1122 ptrdiff_t length; 1121 ptrdiff_t length;
1123 struct gcpro gcpro1, gcpro2, gcpro3; 1122 struct gcpro gcpro1, gcpro2, gcpro3;
@@ -1271,11 +1270,11 @@ third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will
1271recognize the default bindings, just as `read-key-sequence' does. */) 1270recognize the default bindings, just as `read-key-sequence' does. */)
1272 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default) 1271 (Lisp_Object keymap, Lisp_Object key, Lisp_Object accept_default)
1273{ 1272{
1274 register ptrdiff_t idx; 1273 ptrdiff_t idx;
1275 register Lisp_Object cmd; 1274 Lisp_Object cmd;
1276 register Lisp_Object c; 1275 Lisp_Object c;
1277 ptrdiff_t length; 1276 ptrdiff_t length;
1278 int t_ok = !NILP (accept_default); 1277 bool t_ok = !NILP (accept_default);
1279 struct gcpro gcpro1, gcpro2; 1278 struct gcpro gcpro1, gcpro2;
1280 1279
1281 GCPRO2 (keymap, key); 1280 GCPRO2 (keymap, key);
@@ -1887,7 +1886,7 @@ DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_
1887struct accessible_keymaps_data { 1886struct accessible_keymaps_data {
1888 Lisp_Object maps, tail, thisseq; 1887 Lisp_Object maps, tail, thisseq;
1889 /* Does the current sequence end in the meta-prefix-char? */ 1888 /* Does the current sequence end in the meta-prefix-char? */
1890 int is_metized; 1889 bool is_metized;
1891}; 1890};
1892 1891
1893static void 1892static void
@@ -1898,7 +1897,7 @@ accessible_keymaps_1 (Lisp_Object key, Lisp_Object cmd, Lisp_Object args, void *
1898 Lisp_Object maps = d->maps; 1897 Lisp_Object maps = d->maps;
1899 Lisp_Object tail = d->tail; 1898 Lisp_Object tail = d->tail;
1900 Lisp_Object thisseq = d->thisseq; 1899 Lisp_Object thisseq = d->thisseq;
1901 int is_metized = d->is_metized && INTEGERP (key); 1900 bool is_metized = d->is_metized && INTEGERP (key);
1902 Lisp_Object tem; 1901 Lisp_Object tem;
1903 1902
1904 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0); 1903 cmd = get_keymap (get_keyelt (cmd, 0), 0, 0);
@@ -2060,7 +2059,7 @@ The `kbd' macro is an approximate inverse of this. */)
2060 Lisp_Object sep = build_string (" "); 2059 Lisp_Object sep = build_string (" ");
2061 Lisp_Object key; 2060 Lisp_Object key;
2062 Lisp_Object result; 2061 Lisp_Object result;
2063 int add_meta = 0; 2062 bool add_meta = 0;
2064 USE_SAFE_ALLOCA; 2063 USE_SAFE_ALLOCA;
2065 2064
2066 if (!NILP (prefix)) 2065 if (!NILP (prefix))
@@ -2155,9 +2154,10 @@ The `kbd' macro is an approximate inverse of this. */)
2155 2154
2156 2155
2157char * 2156char *
2158push_key_description (EMACS_INT ch, char *p, int force_multibyte) 2157push_key_description (EMACS_INT ch, char *p)
2159{ 2158{
2160 int c, c2, tab_as_ci; 2159 int c, c2;
2160 bool tab_as_ci;
2161 2161
2162 /* Clear all the meaningless bits above the meta bit. */ 2162 /* Clear all the meaningless bits above the meta bit. */
2163 c = ch & (meta_modifier | ~ - meta_modifier); 2163 c = ch & (meta_modifier | ~ - meta_modifier);
@@ -2256,21 +2256,12 @@ push_key_description (EMACS_INT ch, char *p, int force_multibyte)
2256 *p++ = 'P'; 2256 *p++ = 'P';
2257 *p++ = 'C'; 2257 *p++ = 'C';
2258 } 2258 }
2259 else if (c < 128 2259 else if (c < 128)
2260 || (NILP (BVAR (current_buffer, enable_multibyte_characters)) 2260 *p++ = c;
2261 && SINGLE_BYTE_CHAR_P (c)
2262 && !force_multibyte))
2263 {
2264 *p++ = c;
2265 }
2266 else 2261 else
2267 { 2262 {
2268 /* Now we are sure that C is a valid character code. */ 2263 /* Now we are sure that C is a valid character code. */
2269 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) 2264 p += CHAR_STRING (c, (unsigned char *) p);
2270 && ! force_multibyte)
2271 *p++ = multibyte_char_to_unibyte (c);
2272 else
2273 p += CHAR_STRING (c, (unsigned char *) p);
2274 } 2265 }
2275 2266
2276 return p; 2267 return p;
@@ -2299,9 +2290,8 @@ around function keys and event symbols. */)
2299 2290
2300 if (INTEGERP (key)) /* Normal character. */ 2291 if (INTEGERP (key)) /* Normal character. */
2301 { 2292 {
2302 char tem[KEY_DESCRIPTION_SIZE], *p; 2293 char tem[KEY_DESCRIPTION_SIZE];
2303 2294 char *p = push_key_description (XINT (key), tem);
2304 p = push_key_description (XINT (key), tem, 1);
2305 *p = 0; 2295 *p = 0;
2306 return make_specified_string (tem, -1, p - tem, 1); 2296 return make_specified_string (tem, -1, p - tem, 1);
2307 } 2297 }
@@ -2429,7 +2419,7 @@ static void where_is_internal_1 (Lisp_Object key, Lisp_Object binding,
2429 2419
2430static Lisp_Object 2420static Lisp_Object
2431shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag, 2421shadow_lookup (Lisp_Object shadow, Lisp_Object key, Lisp_Object flag,
2432 int remap) 2422 bool remap)
2433{ 2423{
2434 Lisp_Object tail, value; 2424 Lisp_Object tail, value;
2435 2425
@@ -2461,7 +2451,7 @@ static Lisp_Object Vmouse_events;
2461 2451
2462struct where_is_internal_data { 2452struct where_is_internal_data {
2463 Lisp_Object definition, this, last; 2453 Lisp_Object definition, this, last;
2464 int last_is_meta, noindirect; 2454 bool last_is_meta, noindirect;
2465 Lisp_Object sequences; 2455 Lisp_Object sequences;
2466}; 2456};
2467 2457
@@ -2474,7 +2464,7 @@ struct where_is_internal_data {
2474 2464
2475static Lisp_Object 2465static Lisp_Object
2476where_is_internal (Lisp_Object definition, Lisp_Object keymaps, 2466where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2477 int noindirect, int nomenus) 2467 bool noindirect, bool nomenus)
2478{ 2468{
2479 Lisp_Object maps = Qnil; 2469 Lisp_Object maps = Qnil;
2480 Lisp_Object found; 2470 Lisp_Object found;
@@ -2523,7 +2513,7 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2523 [M-CHAR] sequences, check if last character of the sequence 2513 [M-CHAR] sequences, check if last character of the sequence
2524 is the meta-prefix char. */ 2514 is the meta-prefix char. */
2525 Lisp_Object last; 2515 Lisp_Object last;
2526 int last_is_meta; 2516 bool last_is_meta;
2527 2517
2528 this = Fcar (XCAR (maps)); 2518 this = Fcar (XCAR (maps));
2529 map = Fcdr (XCAR (maps)); 2519 map = Fcdr (XCAR (maps));
@@ -2606,7 +2596,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2606 /* Actually relevant bindings. */ 2596 /* Actually relevant bindings. */
2607 Lisp_Object found = Qnil; 2597 Lisp_Object found = Qnil;
2608 /* 1 means ignore all menu bindings entirely. */ 2598 /* 1 means ignore all menu bindings entirely. */
2609 int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii); 2599 bool nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii);
2610 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 2600 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
2611 /* List of sequences found via remapping. Keep them in a separate 2601 /* List of sequences found via remapping. Keep them in a separate
2612 variable, so as to push them later, since we prefer 2602 variable, so as to push them later, since we prefer
@@ -2615,7 +2605,7 @@ The optional 5th arg NO-REMAP alters how command remapping is handled:
2615 /* Whether or not we're handling remapped sequences. This is needed 2605 /* Whether or not we're handling remapped sequences. This is needed
2616 because remapping is not done recursively by Fcommand_remapping: you 2606 because remapping is not done recursively by Fcommand_remapping: you
2617 can't remap a remapped command. */ 2607 can't remap a remapped command. */
2618 int remapped = 0; 2608 bool remapped = 0;
2619 Lisp_Object tem = Qnil; 2609 Lisp_Object tem = Qnil;
2620 2610
2621 /* Refresh the C version of the modifier preference. */ 2611 /* Refresh the C version of the modifier preference. */
@@ -2767,10 +2757,10 @@ where_is_internal_1 (Lisp_Object key, Lisp_Object binding, Lisp_Object args, voi
2767{ 2757{
2768 struct where_is_internal_data *d = data; /* Cast! */ 2758 struct where_is_internal_data *d = data; /* Cast! */
2769 Lisp_Object definition = d->definition; 2759 Lisp_Object definition = d->definition;
2770 int noindirect = d->noindirect; 2760 bool noindirect = d->noindirect;
2771 Lisp_Object this = d->this; 2761 Lisp_Object this = d->this;
2772 Lisp_Object last = d->last; 2762 Lisp_Object last = d->last;
2773 int last_is_meta = d->last_is_meta; 2763 bool last_is_meta = d->last_is_meta;
2774 Lisp_Object sequence; 2764 Lisp_Object sequence;
2775 2765
2776 /* Search through indirections unless that's not wanted. */ 2766 /* Search through indirections unless that's not wanted. */
@@ -2821,8 +2811,8 @@ The optional argument MENUS, if non-nil, says to mention menu bindings.
2821 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus) 2811 (Lisp_Object buffer, Lisp_Object prefix, Lisp_Object menus)
2822{ 2812{
2823 Lisp_Object outbuf, shadow; 2813 Lisp_Object outbuf, shadow;
2824 int nomenu = NILP (menus); 2814 bool nomenu = NILP (menus);
2825 register Lisp_Object start1; 2815 Lisp_Object start1;
2826 struct gcpro gcpro1; 2816 struct gcpro gcpro1;
2827 2817
2828 const char *alternate_heading 2818 const char *alternate_heading
@@ -2857,10 +2847,10 @@ You type Translation\n\
2857 alternate_heading = 0; 2847 alternate_heading = 0;
2858 } 2848 }
2859 2849
2860 bufend = push_key_description (translate[c], buf, 1); 2850 bufend = push_key_description (translate[c], buf);
2861 insert (buf, bufend - buf); 2851 insert (buf, bufend - buf);
2862 Findent_to (make_number (16), make_number (1)); 2852 Findent_to (make_number (16), make_number (1));
2863 bufend = push_key_description (c, buf, 1); 2853 bufend = push_key_description (c, buf);
2864 insert (buf, bufend - buf); 2854 insert (buf, bufend - buf);
2865 2855
2866 insert ("\n", 1); 2856 insert ("\n", 1);
@@ -2977,34 +2967,34 @@ You type Translation\n\
2977 2967
2978/* Insert a description of the key bindings in STARTMAP, 2968/* Insert a description of the key bindings in STARTMAP,
2979 followed by those of all maps reachable through STARTMAP. 2969 followed by those of all maps reachable through STARTMAP.
2980 If PARTIAL is nonzero, omit certain "uninteresting" commands 2970 If PARTIAL, omit certain "uninteresting" commands
2981 (such as `undefined'). 2971 (such as `undefined').
2982 If SHADOW is non-nil, it is a list of maps; 2972 If SHADOW is non-nil, it is a list of maps;
2983 don't mention keys which would be shadowed by any of them. 2973 don't mention keys which would be shadowed by any of them.
2984 PREFIX, if non-nil, says mention only keys that start with PREFIX. 2974 PREFIX, if non-nil, says mention only keys that start with PREFIX.
2985 TITLE, if not 0, is a string to insert at the beginning. 2975 TITLE, if not 0, is a string to insert at the beginning.
2986 TITLE should not end with a colon or a newline; we supply that. 2976 TITLE should not end with a colon or a newline; we supply that.
2987 If NOMENU is not 0, then omit menu-bar commands. 2977 If NOMENU, then omit menu-bar commands.
2988 2978
2989 If TRANSL is nonzero, the definitions are actually key translations 2979 If TRANSL, the definitions are actually key translations
2990 so print strings and vectors differently. 2980 so print strings and vectors differently.
2991 2981
2992 If ALWAYS_TITLE is nonzero, print the title even if there are no maps 2982 If ALWAYS_TITLE, print the title even if there are no maps
2993 to look through. 2983 to look through.
2994 2984
2995 If MENTION_SHADOW is nonzero, then when something is shadowed by SHADOW, 2985 If MENTION_SHADOW, then when something is shadowed by SHADOW,
2996 don't omit it; instead, mention it but say it is shadowed. 2986 don't omit it; instead, mention it but say it is shadowed.
2997 2987
2998 Any inserted text ends in two newlines (used by `help-make-xrefs'). */ 2988 Any inserted text ends in two newlines (used by `help-make-xrefs'). */
2999 2989
3000void 2990void
3001describe_map_tree (Lisp_Object startmap, int partial, Lisp_Object shadow, 2991describe_map_tree (Lisp_Object startmap, bool partial, Lisp_Object shadow,
3002 Lisp_Object prefix, const char *title, int nomenu, int transl, 2992 Lisp_Object prefix, const char *title, bool nomenu,
3003 int always_title, int mention_shadow) 2993 bool transl, bool always_title, bool mention_shadow)
3004{ 2994{
3005 Lisp_Object maps, orig_maps, seen, sub_shadows; 2995 Lisp_Object maps, orig_maps, seen, sub_shadows;
3006 struct gcpro gcpro1, gcpro2, gcpro3; 2996 struct gcpro gcpro1, gcpro2, gcpro3;
3007 int something = 0; 2997 bool something = 0;
3008 const char *key_heading 2998 const char *key_heading
3009 = "\ 2999 = "\
3010key binding\n\ 3000key binding\n\
@@ -3179,7 +3169,12 @@ describe_translation (Lisp_Object definition, Lisp_Object args)
3179 into an array of `struct describe_map_elt', 3169 into an array of `struct describe_map_elt',
3180 then sorts them by the events. */ 3170 then sorts them by the events. */
3181 3171
3182struct describe_map_elt { Lisp_Object event; Lisp_Object definition; int shadowed; }; 3172struct describe_map_elt
3173{
3174 Lisp_Object event;
3175 Lisp_Object definition;
3176 bool shadowed;
3177};
3183 3178
3184/* qsort comparison function for sorting `struct describe_map_elt' by 3179/* qsort comparison function for sorting `struct describe_map_elt' by
3185 the event field. */ 3180 the event field. */
@@ -3209,14 +3204,14 @@ describe_map_compare (const void *aa, const void *bb)
3209static void 3204static void
3210describe_map (Lisp_Object map, Lisp_Object prefix, 3205describe_map (Lisp_Object map, Lisp_Object prefix,
3211 void (*elt_describer) (Lisp_Object, Lisp_Object), 3206 void (*elt_describer) (Lisp_Object, Lisp_Object),
3212 int partial, Lisp_Object shadow, 3207 bool partial, Lisp_Object shadow,
3213 Lisp_Object *seen, int nomenu, int mention_shadow) 3208 Lisp_Object *seen, bool nomenu, bool mention_shadow)
3214{ 3209{
3215 Lisp_Object tail, definition, event; 3210 Lisp_Object tail, definition, event;
3216 Lisp_Object tem; 3211 Lisp_Object tem;
3217 Lisp_Object suppress; 3212 Lisp_Object suppress;
3218 Lisp_Object kludge; 3213 Lisp_Object kludge;
3219 int first = 1; 3214 bool first = 1;
3220 struct gcpro gcpro1, gcpro2, gcpro3; 3215 struct gcpro gcpro1, gcpro2, gcpro3;
3221 3216
3222 /* These accumulate the values from sparse keymap bindings, 3217 /* These accumulate the values from sparse keymap bindings,
@@ -3258,7 +3253,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3258 1, mention_shadow); 3253 1, mention_shadow);
3259 else if (CONSP (XCAR (tail))) 3254 else if (CONSP (XCAR (tail)))
3260 { 3255 {
3261 int this_shadowed = 0; 3256 bool this_shadowed = 0;
3262 3257
3263 event = XCAR (XCAR (tail)); 3258 event = XCAR (XCAR (tail));
3264 3259
@@ -3428,7 +3423,7 @@ DESCRIBER is the output function used; nil means use `princ'. */)
3428 of bytes that lead to the character set or portion of a character 3423 of bytes that lead to the character set or portion of a character
3429 set described by this chartable. 3424 set described by this chartable.
3430 3425
3431 If PARTIAL is nonzero, it means do not mention suppressed commands 3426 If PARTIAL, it means do not mention suppressed commands
3432 (that assumes the vector is in a keymap). 3427 (that assumes the vector is in a keymap).
3433 3428
3434 SHADOW is a list of keymaps that shadow this map. 3429 SHADOW is a list of keymaps that shadow this map.
@@ -3448,8 +3443,8 @@ DESCRIBER is the output function used; nil means use `princ'. */)
3448static void 3443static void
3449describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, 3444describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3450 void (*elt_describer) (Lisp_Object, Lisp_Object), 3445 void (*elt_describer) (Lisp_Object, Lisp_Object),
3451 int partial, Lisp_Object shadow, Lisp_Object entire_map, 3446 bool partial, Lisp_Object shadow, Lisp_Object entire_map,
3452 int keymap_p, int mention_shadow) 3447 bool keymap_p, bool mention_shadow)
3453{ 3448{
3454 Lisp_Object definition; 3449 Lisp_Object definition;
3455 Lisp_Object tem2; 3450 Lisp_Object tem2;
@@ -3457,7 +3452,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3457 int i; 3452 int i;
3458 Lisp_Object suppress; 3453 Lisp_Object suppress;
3459 Lisp_Object kludge; 3454 Lisp_Object kludge;
3460 int first = 1; 3455 bool first = 1;
3461 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 3456 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3462 /* Range of elements to be handled. */ 3457 /* Range of elements to be handled. */
3463 int from, to, stop; 3458 int from, to, stop;
@@ -3497,7 +3492,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3497 3492
3498 for (i = from; ; i++) 3493 for (i = from; ; i++)
3499 { 3494 {
3500 int this_shadowed = 0; 3495 bool this_shadowed = 0;
3501 int range_beg, range_end; 3496 int range_beg, range_end;
3502 Lisp_Object val; 3497 Lisp_Object val;
3503 3498
diff --git a/src/keymap.h b/src/keymap.h
index 5ed70c67b85..c704ee0b050 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -34,11 +34,11 @@ extern Lisp_Object Qkeymap, Qmenu_bar;
34extern Lisp_Object Qremap; 34extern Lisp_Object Qremap;
35extern Lisp_Object Qmenu_item; 35extern Lisp_Object Qmenu_item;
36extern Lisp_Object current_global_map; 36extern Lisp_Object current_global_map;
37extern char *push_key_description (EMACS_INT, char *, int); 37extern char *push_key_description (EMACS_INT, char *);
38extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, int, int, int); 38extern Lisp_Object access_keymap (Lisp_Object, Lisp_Object, bool, bool, bool);
39extern Lisp_Object get_keymap (Lisp_Object, int, int); 39extern Lisp_Object get_keymap (Lisp_Object, bool, bool);
40extern void describe_map_tree (Lisp_Object, int, Lisp_Object, Lisp_Object, 40extern void describe_map_tree (Lisp_Object, bool, Lisp_Object, Lisp_Object,
41 const char *, int, int, int, int); 41 const char *, bool, bool, bool, bool);
42extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **); 42extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **);
43extern void initial_define_key (Lisp_Object, int, const char *); 43extern void initial_define_key (Lisp_Object, int, const char *);
44extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); 44extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
@@ -47,7 +47,8 @@ extern void keys_of_keymap (void);
47 47
48typedef void (*map_keymap_function_t) 48typedef void (*map_keymap_function_t)
49 (Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data); 49 (Lisp_Object key, Lisp_Object val, Lisp_Object args, void* data);
50extern void map_keymap (Lisp_Object map, map_keymap_function_t fun, Lisp_Object largs, void* cargs, int autoload); 50extern void map_keymap (Lisp_Object, map_keymap_function_t, Lisp_Object,
51 void *, bool);
51extern void map_keymap_canonical (Lisp_Object map, 52extern void map_keymap_canonical (Lisp_Object map,
52 map_keymap_function_t fun, 53 map_keymap_function_t fun,
53 Lisp_Object args, void *data); 54 Lisp_Object args, void *data);
diff --git a/src/lisp.h b/src/lisp.h
index 2a647e593a8..1de9ec74d9f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -345,15 +345,11 @@ static ptrdiff_t const PSEUDOVECTOR_FLAG
345 = PSEUDOVECTOR_FLAG; 345 = PSEUDOVECTOR_FLAG;
346 346
347/* In a pseudovector, the size field actually contains a word with one 347/* In a pseudovector, the size field actually contains a word with one
348 PSEUDOVECTOR_FLAG bit set, and exactly one of the following bits to 348 PSEUDOVECTOR_FLAG bit set, and one of the following values extracted
349 indicate the actual type. 349 with PVEC_TYPE_MASK to indicate the actual type. */
350 We use a bitset, even tho only one of the bits can be set at any
351 particular time just so as to be able to use micro-optimizations such as
352 testing membership of a particular subset of pseudovectors in Fequal.
353 It is not crucial, but there are plenty of bits here, so why not do it? */
354enum pvec_type 350enum pvec_type
355{ 351{
356 PVEC_NORMAL_VECTOR = 0, /* Unused! */ 352 PVEC_NORMAL_VECTOR,
357 PVEC_FREE, 353 PVEC_FREE,
358 PVEC_PROCESS, 354 PVEC_PROCESS,
359 PVEC_FRAME, 355 PVEC_FRAME,
@@ -3202,9 +3198,9 @@ extern ptrdiff_t fast_string_match_ignore_case (Lisp_Object, Lisp_Object);
3202extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t, 3198extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t,
3203 ptrdiff_t, ptrdiff_t, Lisp_Object); 3199 ptrdiff_t, ptrdiff_t, Lisp_Object);
3204extern ptrdiff_t scan_buffer (int, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3200extern ptrdiff_t scan_buffer (int, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3205 ptrdiff_t *, int); 3201 ptrdiff_t *, bool);
3206extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3202extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3207 EMACS_INT, int); 3203 EMACS_INT, bool);
3208extern ptrdiff_t find_next_newline (ptrdiff_t, int); 3204extern ptrdiff_t find_next_newline (ptrdiff_t, int);
3209extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t); 3205extern ptrdiff_t find_next_newline_no_quit (ptrdiff_t, ptrdiff_t);
3210extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t); 3206extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t);
@@ -3247,7 +3243,7 @@ extern Lisp_Object Qdisabled, QCfilter;
3247extern Lisp_Object Qup, Qdown, Qbottom; 3243extern Lisp_Object Qup, Qdown, Qbottom;
3248extern Lisp_Object Qtop; 3244extern Lisp_Object Qtop;
3249extern Lisp_Object last_undo_boundary; 3245extern Lisp_Object last_undo_boundary;
3250extern int input_pending; 3246extern bool input_pending;
3251extern Lisp_Object menu_bar_items (Lisp_Object); 3247extern Lisp_Object menu_bar_items (Lisp_Object);
3252extern Lisp_Object tool_bar_items (Lisp_Object, int *); 3248extern Lisp_Object tool_bar_items (Lisp_Object, int *);
3253extern void discard_mouse_events (void); 3249extern void discard_mouse_events (void);
@@ -3255,9 +3251,9 @@ extern void discard_mouse_events (void);
3255void handle_input_available_signal (int); 3251void handle_input_available_signal (int);
3256#endif 3252#endif
3257extern Lisp_Object pending_funcalls; 3253extern Lisp_Object pending_funcalls;
3258extern int detect_input_pending (void); 3254extern bool detect_input_pending (void);
3259extern int detect_input_pending_ignore_squeezables (void); 3255extern bool detect_input_pending_ignore_squeezables (void);
3260extern int detect_input_pending_run_timers (int); 3256extern bool detect_input_pending_run_timers (bool);
3261extern void safe_run_hooks (Lisp_Object); 3257extern void safe_run_hooks (Lisp_Object);
3262extern void cmd_error_internal (Lisp_Object, const char *); 3258extern void cmd_error_internal (Lisp_Object, const char *);
3263extern Lisp_Object command_loop_1 (void); 3259extern Lisp_Object command_loop_1 (void);
@@ -3336,7 +3332,7 @@ extern bool running_asynch_code;
3336extern Lisp_Object QCtype, Qlocal; 3332extern Lisp_Object QCtype, Qlocal;
3337extern Lisp_Object Qprocessp; 3333extern Lisp_Object Qprocessp;
3338extern void kill_buffer_processes (Lisp_Object); 3334extern void kill_buffer_processes (Lisp_Object);
3339extern int wait_reading_process_output (intmax_t, int, int, int, 3335extern int wait_reading_process_output (intmax_t, int, int, bool,
3340 Lisp_Object, 3336 Lisp_Object,
3341 struct Lisp_Process *, 3337 struct Lisp_Process *,
3342 int); 3338 int);
@@ -3563,7 +3559,8 @@ extern char *emacs_root_dir (void);
3563 Used during startup to detect startup of dumped Emacs. */ 3559 Used during startup to detect startup of dumped Emacs. */
3564extern bool initialized; 3560extern bool initialized;
3565 3561
3566extern int immediate_quit; /* Nonzero means ^G can quit instantly. */ 3562/* True means ^G can quit instantly. */
3563extern bool immediate_quit;
3567 3564
3568extern void *xmalloc (size_t); 3565extern void *xmalloc (size_t);
3569extern void *xzalloc (size_t); 3566extern void *xzalloc (size_t);
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index c6fbf59fb5a..40a075dbf3c 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -27,7 +27,7 @@ EMACSLOADPATH=$(CURDIR)/../lisp
27# Size in MBs of the static heap in temacs.exe. 27# Size in MBs of the static heap in temacs.exe.
28HEAPSIZE = $(EMACS_HEAPSIZE) 28HEAPSIZE = $(EMACS_HEAPSIZE)
29 29
30LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc -DHAVE_NTGUI=1 $(EMACS_EXTRA_C_FLAGS) 30LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc $(EMACS_EXTRA_C_FLAGS)
31 31
32SRC = . 32SRC = .
33EMACS = $(BLD)/emacs.exe 33EMACS = $(BLD)/emacs.exe
@@ -207,7 +207,7 @@ make-buildobj-SH:
207GLOBAL_SOURCES = dosfns.c msdos.c \ 207GLOBAL_SOURCES = dosfns.c msdos.c \
208 xterm.c xfns.c xmenu.c xselect.c xrdb.c xsmfns.c fringe.c image.c \ 208 xterm.c xfns.c xmenu.c xselect.c xrdb.c xsmfns.c fringe.c image.c \
209 fontset.c menu.c dbusbind.c \ 209 fontset.c menu.c dbusbind.c \
210 w32.c w32console.c w32fns.c w32heap.c w32inevt.c \ 210 w32.c w32console.c w32fns.c w32heap.c w32inevt.c cygw32.c \
211 w32menu.c w32proc.c w32reg.c w32select.c w32term.c w32xfns.c \ 211 w32menu.c w32proc.c w32reg.c w32select.c w32term.c w32xfns.c \
212 font.c w32font.c w32uniscribe.c \ 212 font.c w32font.c w32uniscribe.c \
213 dispnew.c frame.c scroll.c xdisp.c window.c bidi.c \ 213 dispnew.c frame.c scroll.c xdisp.c window.c bidi.c \
@@ -423,10 +423,11 @@ DISPEXTERN_H = $(SRC)/dispextern.h \
423 $(W32GUI_H) 423 $(W32GUI_H)
424FILEMODE_H = $(GNU_LIB)/filemode.h \ 424FILEMODE_H = $(GNU_LIB)/filemode.h \
425 $(NT_INC)/sys/stat.h 425 $(NT_INC)/sys/stat.h
426FONT_H = $(SRC)/font.h \
427 $(CCL_H)
428FRAME_H = $(SRC)/frame.h \ 426FRAME_H = $(SRC)/frame.h \
429 $(DISPEXTERN_H) 427 $(DISPEXTERN_H)
428FONT_H = $(SRC)/font.h \
429 $(CCL_H) \
430 $(FRAME_H)
430FTOASTR_H = $(GNU_LIB)/ftoastr.h \ 431FTOASTR_H = $(GNU_LIB)/ftoastr.h \
431 $(GNU_LIB)/intprops.h 432 $(GNU_LIB)/intprops.h
432GRP_H = $(NT_INC)/grp.h \ 433GRP_H = $(NT_INC)/grp.h \
@@ -476,6 +477,8 @@ TERMHOOKS_H = $(SRC)/termhooks.h \
476W32FONT_H = $(SRC)/w32font.h \ 477W32FONT_H = $(SRC)/w32font.h \
477 $(FONT_H) 478 $(FONT_H)
478W32TERM_H = $(SRC)/w32term.h \ 479W32TERM_H = $(SRC)/w32term.h \
480 $(ATIMER_H) \
481 $(FRAME_H) \
479 $(W32GUI_H) 482 $(W32GUI_H)
480WINDOW_H = $(SRC)/window.h \ 483WINDOW_H = $(SRC)/window.h \
481 $(DISPEXTERN_H) 484 $(DISPEXTERN_H)
@@ -732,7 +735,6 @@ $(BLD)/dispnew.$(O) : \
732 $(SRC)/disptab.h \ 735 $(SRC)/disptab.h \
733 $(SRC)/indent.h \ 736 $(SRC)/indent.h \
734 $(SRC)/termchar.h \ 737 $(SRC)/termchar.h \
735 $(SRC)/termopts.h \
736 $(NT_INC)/unistd.h \ 738 $(NT_INC)/unistd.h \
737 $(BUFFER_H) \ 739 $(BUFFER_H) \
738 $(CHARACTER_H) \ 740 $(CHARACTER_H) \
@@ -796,6 +798,7 @@ $(BLD)/emacs.$(O) : \
796 $(SRC)/unexec.h \ 798 $(SRC)/unexec.h \
797 $(SRC)/w32.h \ 799 $(SRC)/w32.h \
798 $(SRC)/w32heap.h \ 800 $(SRC)/w32heap.h \
801 $(SRC)/w32select.h \
799 $(NT_INC)/sys/file.h \ 802 $(NT_INC)/sys/file.h \
800 $(NT_INC)/unistd.h \ 803 $(NT_INC)/unistd.h \
801 $(GNU_LIB)/ignore-value.h \ 804 $(GNU_LIB)/ignore-value.h \
@@ -811,6 +814,7 @@ $(BLD)/emacs.$(O) : \
811 $(SYSSIGNAL_H) \ 814 $(SYSSIGNAL_H) \
812 $(SYSTTY_H) \ 815 $(SYSTTY_H) \
813 $(TERMHOOKS_H) \ 816 $(TERMHOOKS_H) \
817 $(W32FONT_H) \
814 $(W32TERM_H) \ 818 $(W32TERM_H) \
815 $(WINDOW_H) 819 $(WINDOW_H)
816 820
@@ -1010,7 +1014,6 @@ $(BLD)/indent.$(O) : \
1010 $(SRC)/indent.h \ 1014 $(SRC)/indent.h \
1011 $(SRC)/region-cache.h \ 1015 $(SRC)/region-cache.h \
1012 $(SRC)/termchar.h \ 1016 $(SRC)/termchar.h \
1013 $(SRC)/termopts.h \
1014 $(BUFFER_H) \ 1017 $(BUFFER_H) \
1015 $(CHARACTER_H) \ 1018 $(CHARACTER_H) \
1016 $(CONFIG_H) \ 1019 $(CONFIG_H) \
@@ -1167,6 +1170,7 @@ $(BLD)/w32.$(O) : \
1167 $(SRC)/w32.c \ 1170 $(SRC)/w32.c \
1168 $(SRC)/ndir.h \ 1171 $(SRC)/ndir.h \
1169 $(SRC)/w32.h \ 1172 $(SRC)/w32.h \
1173 $(SRC)/w32common.h \
1170 $(SRC)/w32heap.h \ 1174 $(SRC)/w32heap.h \
1171 $(NT_INC)/pwd.h \ 1175 $(NT_INC)/pwd.h \
1172 $(NT_INC)/sys/file.h \ 1176 $(NT_INC)/sys/file.h \
@@ -1184,6 +1188,7 @@ $(BLD)/w32.$(O) : \
1184 1188
1185$(BLD)/w32heap.$(O) : \ 1189$(BLD)/w32heap.$(O) : \
1186 $(SRC)/w32heap.c \ 1190 $(SRC)/w32heap.c \
1191 $(SRC)/w32common.h \
1187 $(SRC)/w32heap.h \ 1192 $(SRC)/w32heap.h \
1188 $(CONFIG_H) \ 1193 $(CONFIG_H) \
1189 $(LISP_H) 1194 $(LISP_H)
@@ -1207,6 +1212,7 @@ $(BLD)/w32proc.$(O) : \
1207 $(SRC)/w32proc.c \ 1212 $(SRC)/w32proc.c \
1208 $(SRC)/syswait.h \ 1213 $(SRC)/syswait.h \
1209 $(SRC)/w32.h \ 1214 $(SRC)/w32.h \
1215 $(SRC)/w32common.h \
1210 $(SRC)/w32heap.h \ 1216 $(SRC)/w32heap.h \
1211 $(NT_INC)/nl_types.h \ 1217 $(NT_INC)/nl_types.h \
1212 $(NT_INC)/sys/file.h \ 1218 $(NT_INC)/sys/file.h \
@@ -1224,7 +1230,7 @@ $(BLD)/w32console.$(O) : \
1224 $(SRC)/w32console.c \ 1230 $(SRC)/w32console.c \
1225 $(SRC)/disptab.h \ 1231 $(SRC)/disptab.h \
1226 $(SRC)/termchar.h \ 1232 $(SRC)/termchar.h \
1227 $(SRC)/w32heap.h \ 1233 $(SRC)/w32common.h \
1228 $(SRC)/w32inevt.h \ 1234 $(SRC)/w32inevt.h \
1229 $(CHARACTER_H) \ 1235 $(CHARACTER_H) \
1230 $(CODING_H) \ 1236 $(CODING_H) \
@@ -1233,6 +1239,7 @@ $(BLD)/w32console.$(O) : \
1233 $(FRAME_H) \ 1239 $(FRAME_H) \
1234 $(LISP_H) \ 1240 $(LISP_H) \
1235 $(TERMHOOKS_H) \ 1241 $(TERMHOOKS_H) \
1242 $(W32TERM_H) \
1236 $(WINDOW_H) 1243 $(WINDOW_H)
1237 1244
1238$(BLD)/print.$(O) : \ 1245$(BLD)/print.$(O) : \
@@ -1403,7 +1410,6 @@ $(BLD)/term.$(O) : \
1403 $(SRC)/disptab.h \ 1410 $(SRC)/disptab.h \
1404 $(SRC)/keymap.h \ 1411 $(SRC)/keymap.h \
1405 $(SRC)/termchar.h \ 1412 $(SRC)/termchar.h \
1406 $(SRC)/termopts.h \
1407 $(SRC)/tparam.h \ 1413 $(SRC)/tparam.h \
1408 $(NT_INC)/sys/file.h \ 1414 $(NT_INC)/sys/file.h \
1409 $(NT_INC)/sys/time.h \ 1415 $(NT_INC)/sys/time.h \
@@ -1461,6 +1467,7 @@ $(BLD)/undo.$(O) : \
1461$(BLD)/unexw32.$(O) : \ 1467$(BLD)/unexw32.$(O) : \
1462 $(SRC)/unexw32.c \ 1468 $(SRC)/unexw32.c \
1463 $(SRC)/unexec.h \ 1469 $(SRC)/unexec.h \
1470 $(SRC)/w32common.h \
1464 $(SRC)/w32heap.h \ 1471 $(SRC)/w32heap.h \
1465 $(CONFIG_H) 1472 $(CONFIG_H)
1466 1473
@@ -1547,6 +1554,7 @@ $(BLD)/w32fns.$(O) : \
1547 $(SRC)/epaths.h \ 1554 $(SRC)/epaths.h \
1548 $(SRC)/fontset.h \ 1555 $(SRC)/fontset.h \
1549 $(SRC)/w32.h \ 1556 $(SRC)/w32.h \
1557 $(SRC)/w32common.h \
1550 $(SRC)/w32heap.h \ 1558 $(SRC)/w32heap.h \
1551 $(BUFFER_H) \ 1559 $(BUFFER_H) \
1552 $(CCL_H) \ 1560 $(CCL_H) \
@@ -1570,7 +1578,7 @@ $(BLD)/w32menu.$(O) : \
1570 $(SRC)/w32menu.c \ 1578 $(SRC)/w32menu.c \
1571 $(SRC)/blockinput.h \ 1579 $(SRC)/blockinput.h \
1572 $(SRC)/keymap.h \ 1580 $(SRC)/keymap.h \
1573 $(SRC)/w32heap.h \ 1581 $(SRC)/w32common.h \
1574 $(BUFFER_H) \ 1582 $(BUFFER_H) \
1575 $(CHARACTER_H) \ 1583 $(CHARACTER_H) \
1576 $(CHARSET_H) \ 1584 $(CHARSET_H) \
@@ -1620,7 +1628,7 @@ $(BLD)/w32select.$(O) : \
1620 $(SRC)/w32select.c \ 1628 $(SRC)/w32select.c \
1621 $(SRC)/blockinput.h \ 1629 $(SRC)/blockinput.h \
1622 $(SRC)/composite.h \ 1630 $(SRC)/composite.h \
1623 $(SRC)/w32heap.h \ 1631 $(SRC)/w32common.h \
1624 $(CHARSET_H) \ 1632 $(CHARSET_H) \
1625 $(CODING_H) \ 1633 $(CODING_H) \
1626 $(CONFIG_H) \ 1634 $(CONFIG_H) \
diff --git a/src/marker.c b/src/marker.c
index e01647bdb2a..2e2aba579db 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -29,7 +29,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29static ptrdiff_t cached_charpos; 29static ptrdiff_t cached_charpos;
30static ptrdiff_t cached_bytepos; 30static ptrdiff_t cached_bytepos;
31static struct buffer *cached_buffer; 31static struct buffer *cached_buffer;
32static int cached_modiff; 32static EMACS_INT cached_modiff;
33 33
34/* Juanma Barranquero <lekktu@gmail.com> reported ~3x increased 34/* Juanma Barranquero <lekktu@gmail.com> reported ~3x increased
35 bootstrap time when byte_char_debug_check is enabled; so this 35 bootstrap time when byte_char_debug_check is enabled; so this
diff --git a/src/menu.c b/src/menu.c
index 5374aa9157a..6e052dc65a9 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -40,7 +40,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40#endif /* HAVE_WINDOW_SYSTEM */ 40#endif /* HAVE_WINDOW_SYSTEM */
41 41
42#ifdef HAVE_NTGUI 42#ifdef HAVE_NTGUI
43# ifdef NTGUI_UNICODE
44# define unicode_append_menu AppendMenuW
45# else /* !NTGUI_UNICODE */
43extern AppendMenuW_Proc unicode_append_menu; 46extern AppendMenuW_Proc unicode_append_menu;
47# endif /* NTGUI_UNICODE */
44extern HMENU current_popup_menu; 48extern HMENU current_popup_menu;
45#endif /* HAVE_NTGUI */ 49#endif /* HAVE_NTGUI */
46 50
@@ -327,7 +331,7 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk
327{ 331{
328 Lisp_Object map, item_string, enabled; 332 Lisp_Object map, item_string, enabled;
329 struct gcpro gcpro1, gcpro2; 333 struct gcpro gcpro1, gcpro2;
330 int res; 334 bool res;
331 struct skp *skp = skp_v; 335 struct skp *skp = skp_v;
332 336
333 /* Parse the menu item and leave the result in item_properties. */ 337 /* Parse the menu item and leave the result in item_properties. */
diff --git a/src/nsfont.m b/src/nsfont.m
index b13c96aa6ed..a820b60ac58 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -53,6 +53,7 @@ extern float ns_antialias_threshold;
53extern int ns_tmp_flags; 53extern int ns_tmp_flags;
54extern struct nsfont_info *ns_tmp_font; 54extern struct nsfont_info *ns_tmp_font;
55 55
56
56/* font glyph and metrics caching functions, implemented at end */ 57/* font glyph and metrics caching functions, implemented at end */
57static void ns_uni_to_glyphs (struct nsfont_info *font_info, 58static void ns_uni_to_glyphs (struct nsfont_info *font_info,
58 unsigned char block); 59 unsigned char block);
@@ -799,8 +800,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
799 { 800 {
800 if (NSFONT_TRACE) 801 if (NSFONT_TRACE)
801 fprintf(stderr, "*** nsfont_open CACHE HIT!\n"); 802 fprintf(stderr, "*** nsfont_open CACHE HIT!\n");
802 /* FIXME: Cast from (unsigned long) to Lisp_Object. */ 803 XHASH (font_object) = [cached unsignedLongLongValue];
803 XHASH (font_object) = [cached unsignedLongValue];
804 return font_object; 804 return font_object;
805 } 805 }
806 else 806 else
@@ -808,9 +808,12 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
808 font_object = font_make_object (VECSIZE (struct nsfont_info), 808 font_object = font_make_object (VECSIZE (struct nsfont_info),
809 font_entity, pixel_size); 809 font_entity, pixel_size);
810 if (!synthItal) 810 if (!synthItal)
811 [fontCache setObject: [NSNumber numberWithUnsignedLong: 811 {
812 (unsigned long) XHASH (font_object)] 812 [fontCache setObject: [NSNumber
813 forKey: nsfont]; 813 numberWithUnsignedLongLong:
814 (unsigned long long) XHASH (font_object)]
815 forKey: nsfont];
816 }
814 } 817 }
815 818
816 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); 819 font_info = (struct nsfont_info *) XFONT_OBJECT (font_object);
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 9af732c6c45..a5983c70cdb 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -128,8 +128,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
128 static EmacsMenu *last_submenu = nil; 128 static EmacsMenu *last_submenu = nil;
129 BOOL needsSet = NO; 129 BOOL needsSet = NO;
130 const char *submenuTitle = [[submenu title] UTF8String]; 130 const char *submenuTitle = [[submenu title] UTF8String];
131 extern int waiting_for_input; 131 bool owfi;
132 int owfi;
133 Lisp_Object items; 132 Lisp_Object items;
134 widget_value *wv, *first_wv, *prev_wv = 0; 133 widget_value *wv, *first_wv, *prev_wv = 0;
135 int i; 134 int i;
diff --git a/src/nsterm.m b/src/nsterm.m
index 6b739befeeb..1d935fc76de 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -55,7 +55,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
55#include "ccl.h" 55#include "ccl.h"
56 56
57#include "termhooks.h" 57#include "termhooks.h"
58#include "termopts.h"
59#include "termchar.h" 58#include "termchar.h"
60 59
61#include "window.h" 60#include "window.h"
@@ -1315,7 +1314,7 @@ static void
1315ns_fullscreen_hook (FRAME_PTR f) 1314ns_fullscreen_hook (FRAME_PTR f)
1316{ 1315{
1317 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); 1316 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1318 1317
1319 if (! f->async_visible) return; 1318 if (! f->async_visible) return;
1320#ifndef NEW_STYLE_FS 1319#ifndef NEW_STYLE_FS
1321 if (f->want_fullscreen == FULLSCREEN_BOTH) 1320 if (f->want_fullscreen == FULLSCREEN_BOTH)
@@ -5942,7 +5941,7 @@ not_in_argv (NSString *arg)
5942 [w setBackgroundColor: col]; 5941 [w setBackgroundColor: col];
5943 if ([col alphaComponent] != 1.0) 5942 if ([col alphaComponent] != 1.0)
5944 [w setOpaque: NO]; 5943 [w setOpaque: NO];
5945 5944
5946 f->border_width = bwidth; 5945 f->border_width = bwidth;
5947 FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height; 5946 FRAME_NS_TITLEBAR_HEIGHT (f) = tibar_height;
5948 FRAME_TOOLBAR_HEIGHT (f) = tobar_height; 5947 FRAME_TOOLBAR_HEIGHT (f) = tobar_height;
@@ -5995,7 +5994,7 @@ not_in_argv (NSString *arg)
5995 } 5994 }
5996 break; 5995 break;
5997 } 5996 }
5998 5997
5999 emacsframe->want_fullscreen = FULLSCREEN_NONE; 5998 emacsframe->want_fullscreen = FULLSCREEN_NONE;
6000 } 5999 }
6001 6000
diff --git a/src/process.c b/src/process.c
index 92bea0d3a27..2cbce9d28ea 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4302,7 +4302,7 @@ wait_reading_process_output_1 (void)
4302 -1 meaning caller will actually read the input, so don't throw to 4302 -1 meaning caller will actually read the input, so don't throw to
4303 the quit handler, or 4303 the quit handler, or
4304 4304
4305 DO_DISPLAY != 0 means redisplay should be done to show subprocess 4305 DO_DISPLAY means redisplay should be done to show subprocess
4306 output that arrives. 4306 output that arrives.
4307 4307
4308 If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil 4308 If WAIT_FOR_CELL is a cons cell, wait until its car is non-nil
@@ -4322,7 +4322,7 @@ wait_reading_process_output_1 (void)
4322 4322
4323int 4323int
4324wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, 4324wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4325 int do_display, 4325 bool do_display,
4326 Lisp_Object wait_for_cell, 4326 Lisp_Object wait_for_cell,
4327 struct Lisp_Process *wait_proc, int just_wait_proc) 4327 struct Lisp_Process *wait_proc, int just_wait_proc)
4328{ 4328{
@@ -4419,7 +4419,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4419 4419
4420 do 4420 do
4421 { 4421 {
4422 int old_timers_run = timers_run; 4422 unsigned old_timers_run = timers_run;
4423 struct buffer *old_buffer = current_buffer; 4423 struct buffer *old_buffer = current_buffer;
4424 Lisp_Object old_window = selected_window; 4424 Lisp_Object old_window = selected_window;
4425 4425
@@ -4646,6 +4646,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4646 process_output_skip = 0; 4646 process_output_skip = 0;
4647 } 4647 }
4648#endif 4648#endif
4649
4649#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 4650#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
4650 nfds = xg_select 4651 nfds = xg_select
4651#elif defined (HAVE_NS) 4652#elif defined (HAVE_NS)
@@ -4752,7 +4753,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4752 4753
4753 if (read_kbd != 0) 4754 if (read_kbd != 0)
4754 { 4755 {
4755 int old_timers_run = timers_run; 4756 unsigned old_timers_run = timers_run;
4756 struct buffer *old_buffer = current_buffer; 4757 struct buffer *old_buffer = current_buffer;
4757 Lisp_Object old_window = selected_window; 4758 Lisp_Object old_window = selected_window;
4758 int leave = 0; 4759 int leave = 0;
@@ -6820,14 +6821,14 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
6820 see full version for other parameters. We know that wait_proc will 6821 see full version for other parameters. We know that wait_proc will
6821 always be NULL, since `subprocesses' isn't defined. 6822 always be NULL, since `subprocesses' isn't defined.
6822 6823
6823 DO_DISPLAY != 0 means redisplay should be done to show subprocess 6824 DO_DISPLAY means redisplay should be done to show subprocess
6824 output that arrives. 6825 output that arrives.
6825 6826
6826 Return true if we received input from any process. */ 6827 Return true if we received input from any process. */
6827 6828
6828int 6829int
6829wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, 6830wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6830 int do_display, 6831 bool do_display,
6831 Lisp_Object wait_for_cell, 6832 Lisp_Object wait_for_cell,
6832 struct Lisp_Process *wait_proc, int just_wait_proc) 6833 struct Lisp_Process *wait_proc, int just_wait_proc)
6833{ 6834{
@@ -6903,7 +6904,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6903 6904
6904 do 6905 do
6905 { 6906 {
6906 int old_timers_run = timers_run; 6907 unsigned old_timers_run = timers_run;
6907 timer_delay = timer_check (); 6908 timer_delay = timer_check ();
6908 if (timers_run != old_timers_run && do_display) 6909 if (timers_run != old_timers_run && do_display)
6909 /* We must retry, since a timer may have requeued itself 6910 /* We must retry, since a timer may have requeued itself
diff --git a/src/ralloc.c b/src/ralloc.c
index e4a8fe9c6da..11897411930 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -327,10 +327,11 @@ relinquish (void)
327 327
328 if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess) 328 if ((char *)last_heap->end - (char *)last_heap->bloc_start <= excess)
329 { 329 {
330 /* This heap should have no blocs in it. */ 330 /* This heap should have no blocs in it. If it does, we
331 cannot return it to the system. */
331 if (last_heap->first_bloc != NIL_BLOC 332 if (last_heap->first_bloc != NIL_BLOC
332 || last_heap->last_bloc != NIL_BLOC) 333 || last_heap->last_bloc != NIL_BLOC)
333 emacs_abort (); 334 return;
334 335
335 /* Return the last heap, with its header, to the system. */ 336 /* Return the last heap, with its header, to the system. */
336 excess = (char *)last_heap->end - (char *)last_heap->start; 337 excess = (char *)last_heap->end - (char *)last_heap->start;
diff --git a/src/regex.c b/src/regex.c
index 17562043df1..7443eff3977 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1834,7 +1834,6 @@ typedef struct
1834/* Explicit quit checking is needed for Emacs, which uses polling to 1834/* Explicit quit checking is needed for Emacs, which uses polling to
1835 process input events. */ 1835 process input events. */
1836#ifdef emacs 1836#ifdef emacs
1837extern int immediate_quit;
1838# define IMMEDIATE_QUIT_CHECK \ 1837# define IMMEDIATE_QUIT_CHECK \
1839 do { \ 1838 do { \
1840 if (immediate_quit) QUIT; \ 1839 if (immediate_quit) QUIT; \
diff --git a/src/search.c b/src/search.c
index 7c084c62e28..aacdbe33eef 100644
--- a/src/search.c
+++ b/src/search.c
@@ -636,12 +636,12 @@ newline_cache_on_off (struct buffer *buf)
636 If we don't find COUNT instances before reaching END, set *SHORTAGE 636 If we don't find COUNT instances before reaching END, set *SHORTAGE
637 to the number of TARGETs left unfound, and return END. 637 to the number of TARGETs left unfound, and return END.
638 638
639 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 639 If ALLOW_QUIT, set immediate_quit. That's good to do
640 except when inside redisplay. */ 640 except when inside redisplay. */
641 641
642ptrdiff_t 642ptrdiff_t
643scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end, 643scan_buffer (int target, ptrdiff_t start, ptrdiff_t end,
644 ptrdiff_t count, ptrdiff_t *shortage, int allow_quit) 644 ptrdiff_t count, ptrdiff_t *shortage, bool allow_quit)
645{ 645{
646 struct region_cache *newline_cache; 646 struct region_cache *newline_cache;
647 int direction; 647 int direction;
@@ -837,23 +837,23 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
837 the number of line boundaries left unfound, and position at 837 the number of line boundaries left unfound, and position at
838 the limit we bumped up against. 838 the limit we bumped up against.
839 839
840 If ALLOW_QUIT is non-zero, set immediate_quit. That's good to do 840 If ALLOW_QUIT, set immediate_quit. That's good to do
841 except in special cases. */ 841 except in special cases. */
842 842
843EMACS_INT 843EMACS_INT
844scan_newline (ptrdiff_t start, ptrdiff_t start_byte, 844scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
845 ptrdiff_t limit, ptrdiff_t limit_byte, 845 ptrdiff_t limit, ptrdiff_t limit_byte,
846 register EMACS_INT count, int allow_quit) 846 EMACS_INT count, bool allow_quit)
847{ 847{
848 int direction = ((count > 0) ? 1 : -1); 848 int direction = ((count > 0) ? 1 : -1);
849 849
850 register unsigned char *cursor; 850 unsigned char *cursor;
851 unsigned char *base; 851 unsigned char *base;
852 852
853 ptrdiff_t ceiling; 853 ptrdiff_t ceiling;
854 register unsigned char *ceiling_addr; 854 unsigned char *ceiling_addr;
855 855
856 int old_immediate_quit = immediate_quit; 856 bool old_immediate_quit = immediate_quit;
857 857
858 /* The code that follows is like scan_buffer 858 /* The code that follows is like scan_buffer
859 but checks for either newline or carriage return. */ 859 but checks for either newline or carriage return. */
diff --git a/src/term.c b/src/term.c
index 189fb783cbc..acce9c0548c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28 28
29#include "lisp.h" 29#include "lisp.h"
30#include "termchar.h" 30#include "termchar.h"
31#include "termopts.h"
32#include "tparam.h" 31#include "tparam.h"
33#include "character.h" 32#include "character.h"
34#include "buffer.h" 33#include "buffer.h"
diff --git a/src/termhooks.h b/src/termhooks.h
index f35bd929af1..c33c2dd1587 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -107,9 +107,9 @@ enum event_kind
107 HORIZ_WHEEL_EVENT, /* A wheel event generated by a second 107 HORIZ_WHEEL_EVENT, /* A wheel event generated by a second
108 horizontal wheel that is present on some 108 horizontal wheel that is present on some
109 mice. See WHEEL_EVENT. */ 109 mice. See WHEEL_EVENT. */
110#if defined (WINDOWSNT) 110#ifdef HAVE_NTGUI
111 LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is 111 LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is
112 generated on WINDOWSNT or Mac OS 112 generated when HAVE_NTGUI or on Mac OS
113 when the keyboard layout or input 113 when the keyboard layout or input
114 language is changed by the 114 language is changed by the
115 user. */ 115 user. */
@@ -188,7 +188,7 @@ enum event_kind
188 188
189 , CONFIG_CHANGED_EVENT 189 , CONFIG_CHANGED_EVENT
190 190
191#ifdef WINDOWSNT 191#ifdef HAVE_NTGUI
192 /* Generated when an APPCOMMAND event is received, in response to 192 /* Generated when an APPCOMMAND event is received, in response to
193 Multimedia or Internet buttons on some keyboards. 193 Multimedia or Internet buttons on some keyboards.
194 Such keys are available as normal function keys on X through the 194 Such keys are available as normal function keys on X through the
diff --git a/src/termopts.h b/src/termopts.h
index 7bf71aeefe7..05fa0a52eee 100644
--- a/src/termopts.h
+++ b/src/termopts.h
@@ -17,15 +17,8 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19 19
20/* Nonzero means use ^S/^Q as cretinous flow control. */
21extern int flow_control;
22
23/* Nonzero means use interrupt-driven input. */ 20/* Nonzero means use interrupt-driven input. */
24extern int interrupt_input; 21extern bool interrupt_input;
25 22
26/* Nonzero while interrupts are temporarily deferred during redisplay. */ 23/* Nonzero while interrupts are temporarily deferred during redisplay. */
27extern int interrupts_deferred; 24extern bool interrupts_deferred;
28
29/* Terminal has meta key */
30extern int meta_key;
31
diff --git a/src/unexcw.c b/src/unexcw.c
index 96c4b4a9aec..8c5d574530d 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22#include "unexec.h" 22#include "unexec.h"
23#include "w32common.h"
23 24
24#include <lisp.h> 25#include <lisp.h>
25#include <stdio.h> 26#include <stdio.h>
diff --git a/src/unexw32.c b/src/unexw32.c
index 3eefc9ce058..82671d0f120 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include <config.h> 23#include <config.h>
24#include "unexec.h" 24#include "unexec.h"
25#include "w32common.h"
25 26
26#include <stdio.h> 27#include <stdio.h>
27#include <fcntl.h> 28#include <fcntl.h>
@@ -83,7 +84,7 @@ DWORD_PTR extra_bss_size_static = 0;
83PIMAGE_SECTION_HEADER heap_section; 84PIMAGE_SECTION_HEADER heap_section;
84 85
85#ifdef HAVE_NTGUI 86#ifdef HAVE_NTGUI
86HINSTANCE hinst = NULL; 87extern HINSTANCE hinst;
87HINSTANCE hprevinst = NULL; 88HINSTANCE hprevinst = NULL;
88LPSTR lpCmdLine = ""; 89LPSTR lpCmdLine = "";
89int nCmdShow = 0; 90int nCmdShow = 0;
diff --git a/src/w32.c b/src/w32.c
index f17c06ea807..b50cd13517d 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -31,13 +31,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31#include <sys/file.h> 31#include <sys/file.h>
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/utime.h> 33#include <sys/utime.h>
34#include <mbstring.h> /* for _mbspbrk */
35#include <math.h> 34#include <math.h>
36#include <time.h> 35#include <time.h>
37 36
38/* must include CRT headers *before* config.h */ 37/* must include CRT headers *before* config.h */
39 38
40#include <config.h> 39#include <config.h>
40#include <mbstring.h> /* for _mbspbrk */
41 41
42#undef access 42#undef access
43#undef chdir 43#undef chdir
@@ -173,6 +173,7 @@ typedef struct _REPARSE_DATA_BUFFER {
173 173
174#include "w32.h" 174#include "w32.h"
175#include "ndir.h" 175#include "ndir.h"
176#include "w32common.h"
176#include "w32heap.h" 177#include "w32heap.h"
177#include "systime.h" 178#include "systime.h"
178#include "dispextern.h" /* for xstrcasecmp */ 179#include "dispextern.h" /* for xstrcasecmp */
@@ -866,23 +867,6 @@ create_symbolic_link (LPTSTR lpSymlinkFilename,
866 return retval; 867 return retval;
867} 868}
868 869
869/* Equivalent of strerror for W32 error codes. */
870char *
871w32_strerror (int error_no)
872{
873 static char buf[500];
874
875 if (error_no == 0)
876 error_no = GetLastError ();
877
878 buf[0] = '\0';
879 if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL,
880 error_no,
881 0, /* choose most suitable language */
882 buf, sizeof (buf), NULL))
883 sprintf (buf, "w32 error %u", error_no);
884 return buf;
885}
886 870
887/* Return 1 if P is a valid pointer to an object of size SIZE. Return 871/* Return 1 if P is a valid pointer to an object of size SIZE. Return
888 0 if P is NOT a valid pointer. Return -1 if we cannot validate P. 872 0 if P is NOT a valid pointer. Return -1 if we cannot validate P.
diff --git a/src/w32.h b/src/w32.h
index 2e2315e245d..c4cfdf5fedd 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -19,6 +19,12 @@ GNU General Public License for more details.
19You should have received a copy of the GNU General Public License 19You should have received a copy of the GNU General Public License
20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#ifdef CYGWIN
23#error "w32.h is not compatible with Cygwin"
24#endif
25
26#include <windows.h>
27
22 28
23/* File descriptor set emulation. */ 29/* File descriptor set emulation. */
24 30
@@ -130,17 +136,6 @@ extern LPBYTE w32_get_resource (char * key, LPDWORD type);
130extern void init_ntproc (int); 136extern void init_ntproc (int);
131extern void term_ntproc (int); 137extern void term_ntproc (int);
132extern void globals_of_w32 (void); 138extern void globals_of_w32 (void);
133extern void syms_of_w32term (void);
134extern void syms_of_w32fns (void);
135extern void globals_of_w32fns (void);
136extern void syms_of_w32select (void);
137extern void globals_of_w32select (void);
138extern void term_w32select (void);
139extern void syms_of_w32menu (void);
140extern void globals_of_w32menu (void);
141extern void syms_of_fontset (void);
142extern void syms_of_w32font (void);
143extern void check_windows_init_file (void);
144 139
145extern void term_timers (void); 140extern void term_timers (void);
146extern void init_timers (void); 141extern void init_timers (void);
diff --git a/src/w32common.h b/src/w32common.h
new file mode 100644
index 00000000000..50724e5553c
--- /dev/null
+++ b/src/w32common.h
@@ -0,0 +1,53 @@
1/* Common functions for Microsoft Windows builds of Emacs
2 Copyright (C) 2012 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef W32COMMON_H
22#define W32COMMON_H
23
24#include <windows.h>
25
26#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
27#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
28
29#define get_page_size() sysinfo_cache.dwPageSize
30#define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
31#define get_processor_type() sysinfo_cache.dwProcessorType
32#define get_w32_major_version() w32_major_version
33#define get_w32_minor_version() w32_minor_version
34
35extern SYSTEM_INFO sysinfo_cache;
36extern OSVERSIONINFO osinfo_cache;
37extern unsigned long syspage_mask;
38
39extern int w32_major_version;
40extern int w32_minor_version;
41extern int w32_build_number;
42
43enum {
44 OS_9X = 1,
45 OS_NT
46};
47
48extern int os_subtype;
49
50/* Cache system info, e.g., the NT page size. */
51extern void cache_system_info (void);
52
53#endif /* W32COMMON_H */
diff --git a/src/w32console.c b/src/w32console.c
index b22b09af2f2..f0574689bf1 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -36,7 +36,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
36#include "termhooks.h" 36#include "termhooks.h"
37#include "termchar.h" 37#include "termchar.h"
38#include "dispextern.h" 38#include "dispextern.h"
39#include "w32heap.h" /* for os_subtype */ 39#include "w32term.h"
40#include "w32common.h" /* for os_subtype */
40#include "w32inevt.h" 41#include "w32inevt.h"
41 42
42/* from window.c */ 43/* from window.c */
@@ -430,53 +431,6 @@ w32con_delete_glyphs (struct frame *f, int n)
430 scroll_line (f, n, LEFT); 431 scroll_line (f, n, LEFT);
431} 432}
432 433
433static unsigned int sound_type = 0xFFFFFFFF;
434#define MB_EMACS_SILENT (0xFFFFFFFF - 1)
435
436void
437w32_sys_ring_bell (struct frame *f)
438{
439 if (sound_type == 0xFFFFFFFF)
440 {
441 Beep (666, 100);
442 }
443 else if (sound_type == MB_EMACS_SILENT)
444 {
445 /* Do nothing. */
446 }
447 else
448 MessageBeep (sound_type);
449}
450
451DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0,
452 doc: /* Set the sound generated when the bell is rung.
453SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent
454to use the corresponding system sound for the bell. The 'silent sound
455prevents Emacs from making any sound at all.
456SOUND is nil to use the normal beep. */)
457 (Lisp_Object sound)
458{
459 CHECK_SYMBOL (sound);
460
461 if (NILP (sound))
462 sound_type = 0xFFFFFFFF;
463 else if (EQ (sound, intern ("asterisk")))
464 sound_type = MB_ICONASTERISK;
465 else if (EQ (sound, intern ("exclamation")))
466 sound_type = MB_ICONEXCLAMATION;
467 else if (EQ (sound, intern ("hand")))
468 sound_type = MB_ICONHAND;
469 else if (EQ (sound, intern ("question")))
470 sound_type = MB_ICONQUESTION;
471 else if (EQ (sound, intern ("ok")))
472 sound_type = MB_OK;
473 else if (EQ (sound, intern ("silent")))
474 sound_type = MB_EMACS_SILENT;
475 else
476 sound_type = 0xFFFFFFFF;
477
478 return sound;
479}
480 434
481static void 435static void
482w32con_reset_terminal_modes (struct terminal *t) 436w32con_reset_terminal_modes (struct terminal *t)
@@ -850,5 +804,4 @@ scroll-back buffer. */);
850 defsubr (&Sset_screen_color); 804 defsubr (&Sset_screen_color);
851 defsubr (&Sget_screen_color); 805 defsubr (&Sget_screen_color);
852 defsubr (&Sset_cursor_size); 806 defsubr (&Sset_cursor_size);
853 defsubr (&Sset_message_beep);
854} 807}
diff --git a/src/w32fns.c b/src/w32fns.c
index 6d5d6822354..28a689ddc6c 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -44,8 +44,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include "fontset.h" 44#include "fontset.h"
45#include "systime.h" 45#include "systime.h"
46#include "termhooks.h" 46#include "termhooks.h"
47
48#include "w32common.h"
49
50#ifdef WINDOWSNT
47#include "w32heap.h" 51#include "w32heap.h"
52#endif /* WINDOWSNT */
53
54#if CYGWIN
55#include "cygw32.h"
56#else
48#include "w32.h" 57#include "w32.h"
58#endif
49 59
50#include "bitmaps/gray.xbm" 60#include "bitmaps/gray.xbm"
51 61
@@ -58,9 +68,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
58 68
59#include <dlgs.h> 69#include <dlgs.h>
60#include <imm.h> 70#include <imm.h>
61#define FILE_NAME_TEXT_FIELD edt1
62#define FILE_NAME_COMBO_BOX cmb13
63#define FILE_NAME_LIST lst1
64 71
65#include "font.h" 72#include "font.h"
66#include "w32font.h" 73#include "w32font.h"
@@ -78,6 +85,7 @@ extern int w32_console_toggle_lock_key (int, Lisp_Object);
78extern void w32_menu_display_help (HWND, HMENU, UINT, UINT); 85extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
79extern void w32_free_menu_strings (HWND); 86extern void w32_free_menu_strings (HWND);
80extern const char *map_w32_filename (const char *, const char **); 87extern const char *map_w32_filename (const char *, const char **);
88extern char * w32_strerror (int error_no);
81 89
82/* If non-NULL, a handle to a frame where to display the hourglass cursor. */ 90/* If non-NULL, a handle to a frame where to display the hourglass cursor. */
83static HWND hourglass_hwnd = NULL; 91static HWND hourglass_hwnd = NULL;
@@ -161,7 +169,11 @@ ImmSetCompositionWindow_Proc set_ime_composition_window_fn = NULL;
161MonitorFromPoint_Proc monitor_from_point_fn = NULL; 169MonitorFromPoint_Proc monitor_from_point_fn = NULL;
162GetMonitorInfo_Proc get_monitor_info_fn = NULL; 170GetMonitorInfo_Proc get_monitor_info_fn = NULL;
163 171
172#ifdef NTGUI_UNICODE
173#define unicode_append_menu AppendMenuW
174#else /* !NTGUI_UNICODE */
164extern AppendMenuW_Proc unicode_append_menu; 175extern AppendMenuW_Proc unicode_append_menu;
176#endif /* NTGUI_UNICODE */
165 177
166/* Flag to selectively ignore WM_IME_CHAR messages. */ 178/* Flag to selectively ignore WM_IME_CHAR messages. */
167static int ignore_ime_char = 0; 179static int ignore_ime_char = 0;
@@ -198,6 +210,33 @@ extern int uniscribe_available;
198static void w32_show_hourglass (struct frame *); 210static void w32_show_hourglass (struct frame *);
199static void w32_hide_hourglass (void); 211static void w32_hide_hourglass (void);
200 212
213#ifdef WINDOWSNT
214/* From w32inevet.c */
215extern int faked_key;
216#endif /* WINDOWSNT */
217
218/* This gives us the page size and the size of the allocation unit on NT. */
219SYSTEM_INFO sysinfo_cache;
220
221/* This gives us version, build, and platform identification. */
222OSVERSIONINFO osinfo_cache;
223
224unsigned long syspage_mask = 0;
225
226/* The major and minor versions of NT. */
227int w32_major_version;
228int w32_minor_version;
229int w32_build_number;
230
231/* Distinguish between Windows NT and Windows 95. */
232int os_subtype;
233
234#ifdef HAVE_NTGUI
235HINSTANCE hinst = NULL;
236#endif
237
238static unsigned int sound_type = 0xFFFFFFFF;
239#define MB_EMACS_SILENT (0xFFFFFFFF - 1)
201 240
202 241
203/* Error if we are not connected to MS-Windows. */ 242/* Error if we are not connected to MS-Windows. */
@@ -662,7 +701,7 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
662} 701}
663 702
664static Lisp_Object 703static Lisp_Object
665w32_color_map_lookup (char *colorname) 704w32_color_map_lookup (const char *colorname)
666{ 705{
667 Lisp_Object tail, ret = Qnil; 706 Lisp_Object tail, ret = Qnil;
668 707
@@ -741,7 +780,7 @@ add_system_logical_colors_to_map (Lisp_Object *system_colors)
741 780
742 781
743static Lisp_Object 782static Lisp_Object
744x_to_w32_color (char * colorname) 783x_to_w32_color (const char * colorname)
745{ 784{
746 register Lisp_Object ret = Qnil; 785 register Lisp_Object ret = Qnil;
747 786
@@ -750,11 +789,10 @@ x_to_w32_color (char * colorname)
750 if (colorname[0] == '#') 789 if (colorname[0] == '#')
751 { 790 {
752 /* Could be an old-style RGB Device specification. */ 791 /* Could be an old-style RGB Device specification. */
753 char *color; 792 int size = strlen (colorname + 1);
754 int size; 793 char *color = alloca (size + 1);
755 color = colorname + 1;
756 794
757 size = strlen (color); 795 strcpy (color, colorname + 1);
758 if (size == 3 || size == 6 || size == 9 || size == 12) 796 if (size == 3 || size == 6 || size == 9 || size == 12)
759 { 797 {
760 UINT colorval; 798 UINT colorval;
@@ -808,7 +846,7 @@ x_to_w32_color (char * colorname)
808 } 846 }
809 else if (strnicmp (colorname, "rgb:", 4) == 0) 847 else if (strnicmp (colorname, "rgb:", 4) == 0)
810 { 848 {
811 char *color; 849 const char *color;
812 UINT colorval; 850 UINT colorval;
813 int i, pos; 851 int i, pos;
814 pos = 0; 852 pos = 0;
@@ -864,7 +902,7 @@ x_to_w32_color (char * colorname)
864 else if (strnicmp (colorname, "rgbi:", 5) == 0) 902 else if (strnicmp (colorname, "rgbi:", 5) == 0)
865 { 903 {
866 /* This is an RGB Intensity specification. */ 904 /* This is an RGB Intensity specification. */
867 char *color; 905 const char *color;
868 UINT colorval; 906 UINT colorval;
869 int i, pos; 907 int i, pos;
870 pos = 0; 908 pos = 0;
@@ -1068,7 +1106,7 @@ gamma_correct (struct frame *f, COLORREF *color)
1068 If ALLOC is nonzero, allocate a new colormap cell. */ 1106 If ALLOC is nonzero, allocate a new colormap cell. */
1069 1107
1070int 1108int
1071w32_defined_color (FRAME_PTR f, char *color, XColor *color_def, int alloc) 1109w32_defined_color (FRAME_PTR f, const char *color, XColor *color_def, int alloc)
1072{ 1110{
1073 register Lisp_Object tem; 1111 register Lisp_Object tem;
1074 COLORREF w32_color_ref; 1112 COLORREF w32_color_ref;
@@ -1843,10 +1881,7 @@ w32_createwindow (struct frame *f)
1843 1881
1844 /* Do first time app init */ 1882 /* Do first time app init */
1845 1883
1846 if (!hprevinst) 1884 w32_init_class (hinst);
1847 {
1848 w32_init_class (hinst);
1849 }
1850 1885
1851 if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition) 1886 if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition)
1852 { 1887 {
@@ -2246,6 +2281,84 @@ unregister_hot_keys (HWND hwnd)
2246 } 2281 }
2247} 2282}
2248 2283
2284#if EMACSDEBUG
2285const char*
2286w32_name_of_message (UINT msg)
2287{
2288 unsigned i;
2289 static char buf[64];
2290 static const struct {
2291 UINT msg;
2292 const char* name;
2293 } msgnames[] = {
2294#define M(msg) { msg, # msg }
2295 M (WM_PAINT),
2296 M (WM_TIMER),
2297 M (WM_USER),
2298 M (WM_MOUSEMOVE),
2299 M (WM_LBUTTONUP),
2300 M (WM_KEYDOWN),
2301 M (WM_EMACS_KILL),
2302 M (WM_EMACS_CREATEWINDOW),
2303 M (WM_EMACS_DONE),
2304 M (WM_EMACS_CREATESCROLLBAR),
2305 M (WM_EMACS_SHOWWINDOW),
2306 M (WM_EMACS_SETWINDOWPOS),
2307 M (WM_EMACS_DESTROYWINDOW),
2308 M (WM_EMACS_TRACKPOPUPMENU),
2309 M (WM_EMACS_SETFOCUS),
2310 M (WM_EMACS_SETFOREGROUND),
2311 M (WM_EMACS_SETLOCALE),
2312 M (WM_EMACS_SETKEYBOARDLAYOUT),
2313 M (WM_EMACS_REGISTER_HOT_KEY),
2314 M (WM_EMACS_UNREGISTER_HOT_KEY),
2315 M (WM_EMACS_TOGGLE_LOCK_KEY),
2316 M (WM_EMACS_TRACK_CARET),
2317 M (WM_EMACS_DESTROY_CARET),
2318 M (WM_EMACS_SHOW_CARET),
2319 M (WM_EMACS_HIDE_CARET),
2320 M (WM_EMACS_SETCURSOR),
2321 M (WM_EMACS_PAINT),
2322 M (WM_CHAR),
2323#undef M
2324 { 0, 0 }
2325 };
2326
2327 for (i = 0; msgnames[i].name; ++i)
2328 if (msgnames[i].msg == msg)
2329 return msgnames[i].name;
2330
2331 sprintf (buf, "message 0x%04x", (unsigned)msg);
2332 return buf;
2333}
2334#endif /* EMACSDEBUG */
2335
2336/* Here's an overview of how Emacs input works on MS-Windows.
2337
2338 System messages are read and processed by w32_msg_pump below. This
2339 function runs in a separate thread. It handles a small number of
2340 custom WM_EMACS_* messages (posted by the main thread, look for
2341 PostMessage calls), and dispatches the rest to w32_wnd_proc, which
2342 is the main window procedure for the entire Emacs application.
2343
2344 w32_wnd_proc also runs in the same separate input thread. It
2345 handles some messages, mostly those that need GDI calls, by itself.
2346 For the others, it calls my_post_msg, which inserts the messages
2347 into the input queue serviced by w32_read_socket.
2348
2349 w32_read_socket runs in the main (a.k.a. "Lisp") thread, and is
2350 called synchronously from keyboard.c when it is known or suspected
2351 that some input is available. w32_read_socket either handles
2352 messages immediately, or converts them into Emacs input events and
2353 stuffs them into kbd_buffer, where kbd_buffer_get_event can get at
2354 them and process them when read_char and its callers require
2355 input.
2356
2357 Under Cygwin with the W32 toolkit, the use of /dev/windows with
2358 select(2) takes the place of w32_read_socket.
2359
2360 */
2361
2249/* Main message dispatch loop. */ 2362/* Main message dispatch loop. */
2250 2363
2251static void 2364static void
@@ -2259,6 +2372,10 @@ w32_msg_pump (deferred_msg * msg_buf)
2259 2372
2260 while ((w32_unicode_gui ? GetMessageW : GetMessageA) (&msg, NULL, 0, 0)) 2373 while ((w32_unicode_gui ? GetMessageW : GetMessageA) (&msg, NULL, 0, 0))
2261 { 2374 {
2375
2376 /* DebPrint (("w32_msg_pump: %s time:%u\n", */
2377 /* w32_name_of_message (msg.message), msg.time)); */
2378
2262 if (msg.hwnd == NULL) 2379 if (msg.hwnd == NULL)
2263 { 2380 {
2264 switch (msg.message) 2381 switch (msg.message)
@@ -2346,7 +2463,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2346 /* Broadcast messages make it here, so you need to be looking 2463 /* Broadcast messages make it here, so you need to be looking
2347 for something in particular for this to be useful. */ 2464 for something in particular for this to be useful. */
2348 default: 2465 default:
2349 DebPrint (("msg %x not expected by w32_msg_pump\n", msg.message)); 2466 DebPrint (("msg %x not expected by w32_msg_pump\n", msg.message));
2350#endif 2467#endif
2351 } 2468 }
2352 } 2469 }
@@ -4525,22 +4642,14 @@ If omitted or nil, that stands for the selected frame's display. */)
4525 (Lisp_Object display) 4642 (Lisp_Object display)
4526{ 4643{
4527 struct w32_display_info *dpyinfo = check_x_display_info (display); 4644 struct w32_display_info *dpyinfo = check_x_display_info (display);
4528 HDC hdc;
4529 int cap; 4645 int cap;
4530 4646
4531 hdc = GetDC (dpyinfo->root_window); 4647 /* Don't use NCOLORS: it returns incorrect results under remote
4532 if (dpyinfo->has_palette) 4648 * desktop. We force 24+ bit depths to 24-bit, both to prevent an
4533 cap = GetDeviceCaps (hdc, SIZEPALETTE); 4649 * overflow and because probably is more meaningful on Windows
4534 else 4650 * anyway. */
4535 cap = GetDeviceCaps (hdc, NUMCOLORS);
4536
4537 /* We force 24+ bit depths to 24-bit, both to prevent an overflow
4538 and because probably is more meaningful on Windows anyway */
4539 if (cap < 0)
4540 cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24);
4541
4542 ReleaseDC (dpyinfo->root_window, hdc);
4543 4651
4652 cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24);
4544 return make_number (cap); 4653 return make_number (cap);
4545} 4654}
4546 4655
@@ -4682,6 +4791,37 @@ If omitted or nil, that stands for the selected frame's display. */)
4682{ 4791{
4683 return Qnil; 4792 return Qnil;
4684} 4793}
4794
4795DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0,
4796 doc: /* Set the sound generated when the bell is rung.
4797SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent
4798to use the corresponding system sound for the bell. The 'silent sound
4799prevents Emacs from making any sound at all.
4800SOUND is nil to use the normal beep. */)
4801 (Lisp_Object sound)
4802{
4803 CHECK_SYMBOL (sound);
4804
4805 if (NILP (sound))
4806 sound_type = 0xFFFFFFFF;
4807 else if (EQ (sound, intern ("asterisk")))
4808 sound_type = MB_ICONASTERISK;
4809 else if (EQ (sound, intern ("exclamation")))
4810 sound_type = MB_ICONEXCLAMATION;
4811 else if (EQ (sound, intern ("hand")))
4812 sound_type = MB_ICONHAND;
4813 else if (EQ (sound, intern ("question")))
4814 sound_type = MB_ICONQUESTION;
4815 else if (EQ (sound, intern ("ok")))
4816 sound_type = MB_OK;
4817 else if (EQ (sound, intern ("silent")))
4818 sound_type = MB_EMACS_SILENT;
4819 else
4820 sound_type = 0xFFFFFFFF;
4821
4822 return sound;
4823}
4824
4685 4825
4686int 4826int
4687x_pixel_width (register struct frame *f) 4827x_pixel_width (register struct frame *f)
@@ -4763,12 +4903,21 @@ terminate Emacs if we can't open the connection.
4763 unsigned char *xrm_option; 4903 unsigned char *xrm_option;
4764 struct w32_display_info *dpyinfo; 4904 struct w32_display_info *dpyinfo;
4765 4905
4906 CHECK_STRING (display);
4907
4908 /* Signal an error in order to encourage correct use from callers.
4909 * If we ever support multiple window systems in the same Emacs,
4910 * we'll need callers to be precise about what window system they
4911 * want. */
4912
4913 if (strcmp (SSDATA (display), "w32") != 0)
4914 error ("The name of the display in this Emacs must be \"w32\"");
4915
4766 /* If initialization has already been done, return now to avoid 4916 /* If initialization has already been done, return now to avoid
4767 overwriting critical parts of one_w32_display_info. */ 4917 overwriting critical parts of one_w32_display_info. */
4768 if (w32_in_use) 4918 if (w32_in_use)
4769 return Qnil; 4919 return Qnil;
4770 4920
4771 CHECK_STRING (display);
4772 if (! NILP (xrm_string)) 4921 if (! NILP (xrm_string))
4773 CHECK_STRING (xrm_string); 4922 CHECK_STRING (xrm_string);
4774 4923
@@ -5839,6 +5988,18 @@ Value is t if tooltip was open, nil otherwise. */)
5839 File selection dialog 5988 File selection dialog
5840 ***********************************************************************/ 5989 ***********************************************************************/
5841 5990
5991#define FILE_NAME_TEXT_FIELD edt1
5992#define FILE_NAME_COMBO_BOX cmb13
5993#define FILE_NAME_LIST lst1
5994
5995#ifdef NTGUI_UNICODE
5996#define GUISTR(x) (L ## x)
5997typedef wchar_t guichar_t;
5998#else /* !NTGUI_UNICODE */
5999#define GUISTR(x) x
6000typedef char guichar_t;
6001#endif /* NTGUI_UNICODE */
6002
5842/* Callback for altering the behavior of the Open File dialog. 6003/* Callback for altering the behavior of the Open File dialog.
5843 Makes the Filename text field contain "Current Directory" and be 6004 Makes the Filename text field contain "Current Directory" and be
5844 read-only when "Directories" is selected in the filter. This 6005 read-only when "Directories" is selected in the filter. This
@@ -5849,7 +6010,11 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5849{ 6010{
5850 if (msg == WM_NOTIFY) 6011 if (msg == WM_NOTIFY)
5851 { 6012 {
5852 OFNOTIFY * notify = (OFNOTIFY *)lParam; 6013#ifdef NTGUI_UNICODE
6014 OFNOTIFYW * notify = (OFNOTIFYW *)lParam;
6015#else /* !NTGUI_UNICODE */
6016 OFNOTIFYA * notify = (OFNOTIFYA *)lParam;
6017#endif /* NTGUI_UNICODE */
5853 /* Detect when the Filter dropdown is changed. */ 6018 /* Detect when the Filter dropdown is changed. */
5854 if (notify->hdr.code == CDN_TYPECHANGE 6019 if (notify->hdr.code == CDN_TYPECHANGE
5855 || notify->hdr.code == CDN_INITDONE) 6020 || notify->hdr.code == CDN_INITDONE)
@@ -5877,7 +6042,7 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5877 if (notify->lpOFN->nFilterIndex == 2) 6042 if (notify->lpOFN->nFilterIndex == 2)
5878 { 6043 {
5879 CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD, 6044 CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD,
5880 "Current Directory"); 6045 GUISTR ("Current Directory"));
5881 EnableWindow (edit_control, FALSE); 6046 EnableWindow (edit_control, FALSE);
5882 /* Note that at least on Windows 7, the above call to EnableWindow 6047 /* Note that at least on Windows 7, the above call to EnableWindow
5883 disables the window that would ordinarily have focus. If we 6048 disables the window that would ordinarily have focus. If we
@@ -5893,7 +6058,8 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5893 /* Don't override default filename on init done. */ 6058 /* Don't override default filename on init done. */
5894 if (notify->hdr.code == CDN_TYPECHANGE) 6059 if (notify->hdr.code == CDN_TYPECHANGE)
5895 CommDlg_OpenSave_SetControlText (dialog, 6060 CommDlg_OpenSave_SetControlText (dialog,
5896 FILE_NAME_TEXT_FIELD, ""); 6061 FILE_NAME_TEXT_FIELD,
6062 GUISTR (""));
5897 EnableWindow (edit_control, TRUE); 6063 EnableWindow (edit_control, TRUE);
5898 } 6064 }
5899 } 6065 }
@@ -5901,19 +6067,6 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5901 return 0; 6067 return 0;
5902} 6068}
5903 6069
5904/* Since we compile with _WIN32_WINNT set to 0x0400 (for NT4 compatibility)
5905 we end up with the old file dialogs. Define a big enough struct for the
5906 new dialog to trick GetOpenFileName into giving us the new dialogs on
5907 Windows 2000 and XP. */
5908typedef struct
5909{
5910 OPENFILENAME real_details;
5911 void * pReserved;
5912 DWORD dwReserved;
5913 DWORD FlagsEx;
5914} NEWOPENFILENAME;
5915
5916
5917DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, 6070DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
5918 doc: /* Read file name, prompting with PROMPT in directory DIR. 6071 doc: /* Read file name, prompting with PROMPT in directory DIR.
5919Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file 6072Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
@@ -5925,134 +6078,205 @@ Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
5925Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) 6078Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5926 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) 6079 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
5927{ 6080{
6081 /* Filter index: 1: All Files, 2: Directories only */
6082 static const guichar_t filter[] =
6083 GUISTR ("All Files (*.*)\0*.*\0Directories\0*|*\0");
6084
6085 Lisp_Object filename = default_filename;
5928 struct frame *f = SELECTED_FRAME (); 6086 struct frame *f = SELECTED_FRAME ();
5929 Lisp_Object file = Qnil; 6087 BOOL file_opened = FALSE;
5930 ptrdiff_t count = SPECPDL_INDEX (); 6088 Lisp_Object orig_dir = dir;
6089 Lisp_Object orig_prompt = prompt;
6090
6091 /* If we compile with _WIN32_WINNT set to 0x0400 (for NT4
6092 compatibility) we end up with the old file dialogs. Define a big
6093 enough struct for the new dialog to trick GetOpenFileName into
6094 giving us the new dialogs on newer versions of Windows. */
6095 struct {
6096#ifdef NTGUI_UNICODE
6097 OPENFILENAMEW details;
6098#else /* !NTGUI_UNICODE */
6099 OPENFILENAMEA details;
6100#endif /* NTGUI_UNICODE */
6101
6102#if _WIN32_WINNT < 0x500 /* < win2k */
6103 PVOID pvReserved;
6104 DWORD dwReserved;
6105 DWORD FlagsEx;
6106#endif /* < win2k */
6107 } new_file_details;
6108
6109#ifdef NTGUI_UNICODE
6110 wchar_t filename_buf[32*1024 + 1]; // NT kernel maximum
6111 OPENFILENAMEW * file_details = &new_file_details.details;
6112#else /* not NTGUI_UNICODE */
6113 char filename_buf[MAX_PATH + 1];
6114 OPENFILENAMEA * file_details = &new_file_details.details;
6115#endif /* NTGUI_UNICODE */
6116
5931 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 6117 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
5932 char filename[MAX_PATH + 1]; 6118 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, filename);
5933 char init_dir[MAX_PATH + 1];
5934 int default_filter_index = 1; /* 1: All Files, 2: Directories only */
5935
5936 GCPRO6 (prompt, dir, default_filename, mustmatch, only_dir_p, file);
5937 CHECK_STRING (prompt);
5938 CHECK_STRING (dir);
5939
5940 /* Create the dialog with PROMPT as title, using DIR as initial
5941 directory and using "*" as pattern. */
5942 dir = Fexpand_file_name (dir, Qnil);
5943 strncpy (init_dir, SDATA (ENCODE_FILE (dir)), MAX_PATH);
5944 init_dir[MAX_PATH] = '\0';
5945 unixtodos_filename (init_dir);
5946
5947 if (STRINGP (default_filename))
5948 {
5949 char *file_name_only;
5950 char *full_path_name = SDATA (ENCODE_FILE (default_filename));
5951 6119
5952 unixtodos_filename (full_path_name); 6120 {
6121 struct gcpro gcpro1, gcpro2;
6122 GCPRO2 (orig_dir, orig_prompt); /* There is no GCPRON, N>6. */
5953 6123
5954 file_name_only = strrchr (full_path_name, '\\'); 6124 /* Note: under NTGUI_UNICODE, we do _NOT_ use ENCODE_FILE: the
5955 if (!file_name_only) 6125 system file encoding expected by the platform APIs (e.g. Cygwin's
5956 file_name_only = full_path_name; 6126 POSIX implementation) may not be the same as the encoding expected
5957 else 6127 by the Windows "ANSI" APIs! */
5958 file_name_only++;
5959 6128
5960 strncpy (filename, file_name_only, MAX_PATH); 6129 CHECK_STRING (prompt);
5961 filename[MAX_PATH] = '\0'; 6130 CHECK_STRING (dir);
5962 }
5963 else
5964 filename[0] = '\0';
5965 6131
5966 /* The code in file_dialog_callback that attempts to set the text 6132 dir = Fexpand_file_name (dir, Qnil);
5967 of the file name edit window when handling the CDN_INITDONE
5968 WM_NOTIFY message does not work. Setting filename to "Current
5969 Directory" in the only_dir_p case here does work however. */
5970 if (filename[0] == 0 && ! NILP (only_dir_p))
5971 strcpy (filename, "Current Directory");
5972 6133
5973 { 6134 if (STRINGP (filename))
5974 NEWOPENFILENAME new_file_details; 6135 filename = Ffile_name_nondirectory (filename);
5975 BOOL file_opened = FALSE; 6136 else
5976 OPENFILENAME * file_details = &new_file_details.real_details; 6137 filename = empty_unibyte_string;
5977 6138
5978 /* Prevent redisplay. */ 6139#ifdef CYGWIN
5979 specbind (Qinhibit_redisplay, Qt); 6140 dir = Fcygwin_convert_path_to_windows (dir, Qt);
5980 block_input (); 6141 if (SCHARS (filename) > 0)
6142 filename = Fcygwin_convert_path_to_windows (filename, Qnil);
6143#endif
5981 6144
6145 CHECK_STRING (dir);
6146 CHECK_STRING (filename);
6147
6148 /* The code in file_dialog_callback that attempts to set the text
6149 of the file name edit window when handling the CDN_INITDONE
6150 WM_NOTIFY message does not work. Setting filename to "Current
6151 Directory" in the only_dir_p case here does work however. */
6152 if (SCHARS (filename) == 0 && ! NILP (only_dir_p))
6153 filename = build_string ("Current Directory");
6154
6155 /* Convert the values we've computed so far to system form. */
6156#ifdef NTGUI_UNICODE
6157 to_unicode (prompt, &prompt);
6158 to_unicode (dir, &dir);
6159 to_unicode (filename, &filename);
6160#else /* !NTGUI_UNICODE */
6161 prompt = ENCODE_FILE (prompt);
6162 dir = ENCODE_FILE (dir);
6163 filename = ENCODE_FILE (filename);
6164
6165 /* We modify these in-place, so make copies for safety. */
6166 dir = Fcopy_sequence (dir);
6167 unixtodos_filename (SDATA (dir));
6168 filename = Fcopy_sequence (filename);
6169 unixtodos_filename (SDATA (filename));
6170#endif /* NTGUI_UNICODE */
6171
6172 /* Fill in the structure for the call to GetOpenFileName below.
6173 For NTGUI_UNICODE builds (which run only on NT), we just use
6174 the actual size of the structure. For non-NTGUI_UNICODE
6175 builds, we tell the OS we're using an old version of the
6176 structure if the OS isn't new enough to support the newer
6177 version. */
5982 memset (&new_file_details, 0, sizeof (new_file_details)); 6178 memset (&new_file_details, 0, sizeof (new_file_details));
5983 /* Apparently NT4 crashes if you give it an unexpected size. 6179
5984 I'm not sure about Windows 9x, so play it safe. */
5985 if (w32_major_version > 4 && w32_major_version < 95) 6180 if (w32_major_version > 4 && w32_major_version < 95)
5986 file_details->lStructSize = sizeof (NEWOPENFILENAME); 6181 file_details->lStructSize = sizeof (new_file_details);
5987 else 6182 else
5988 file_details->lStructSize = sizeof (OPENFILENAME); 6183 file_details->lStructSize = sizeof (*file_details);
6184
6185 /* Set up the inout parameter for the selected file name. */
6186 if (SBYTES (filename) + 1 > sizeof (filename_buf))
6187 report_file_error ("filename too long", default_filename);
6188
6189 memcpy (filename_buf, SDATA (filename), SBYTES (filename) + 1);
6190 file_details->lpstrFile = filename_buf;
6191 file_details->nMaxFile = sizeof (filename_buf) / sizeof (*filename_buf);
5989 6192
5990 file_details->hwndOwner = FRAME_W32_WINDOW (f); 6193 file_details->hwndOwner = FRAME_W32_WINDOW (f);
5991 /* Undocumented Bug in Common File Dialog: 6194 /* Undocumented Bug in Common File Dialog:
5992 If a filter is not specified, shell links are not resolved. */ 6195 If a filter is not specified, shell links are not resolved. */
5993 file_details->lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0"; 6196 file_details->lpstrFilter = filter;
5994 file_details->lpstrFile = filename; 6197 file_details->lpstrInitialDir = (guichar_t*) SDATA (dir);
5995 file_details->nMaxFile = sizeof (filename); 6198 file_details->lpstrTitle = (guichar_t*) SDATA (prompt);
5996 file_details->lpstrInitialDir = init_dir; 6199 file_details->nFilterIndex = NILP (only_dir_p) ? 1 : 2;
5997 file_details->lpstrTitle = SDATA (prompt);
5998
5999 if (! NILP (only_dir_p))
6000 default_filter_index = 2;
6001
6002 file_details->nFilterIndex = default_filter_index;
6003
6004 file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR 6200 file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR
6005 | OFN_EXPLORER | OFN_ENABLEHOOK); 6201 | OFN_EXPLORER | OFN_ENABLEHOOK);
6202
6006 if (!NILP (mustmatch)) 6203 if (!NILP (mustmatch))
6007 { 6204 {
6008 /* Require that the path to the parent directory exists. */ 6205 /* Require that the path to the parent directory exists. */
6009 file_details->Flags |= OFN_PATHMUSTEXIST; 6206 file_details->Flags |= OFN_PATHMUSTEXIST;
6010 /* If we are looking for a file, require that it exists. */ 6207 /* If we are looking for a file, require that it exists. */
6011 if (NILP (only_dir_p)) 6208 if (NILP (only_dir_p))
6012 file_details->Flags |= OFN_FILEMUSTEXIST; 6209 file_details->Flags |= OFN_FILEMUSTEXIST;
6013 } 6210 }
6014 6211
6015 file_details->lpfnHook = (LPOFNHOOKPROC) file_dialog_callback; 6212 {
6016 6213 int count = SPECPDL_INDEX ();
6017 file_opened = GetOpenFileName (file_details); 6214 /* Prevent redisplay. */
6215 specbind (Qinhibit_redisplay, Qt);
6216 block_input ();
6217 file_details->lpfnHook = file_dialog_callback;
6018 6218
6019 unblock_input (); 6219#ifdef NTGUI_UNICODE
6220 file_opened = GetOpenFileNameW (file_details);
6221#else /* !NTGUI_UNICODE */
6222 file_opened = GetOpenFileNameA (file_details);
6223#endif /* NTGUI_UNICODE */
6224 unblock_input ();
6225 unbind_to (count, Qnil);
6226 }
6020 6227
6021 if (file_opened) 6228 if (file_opened)
6022 { 6229 {
6023 dostounix_filename (filename); 6230 /* Get an Emacs string from the value Windows gave us. */
6024 6231#ifdef NTGUI_UNICODE
6025 if (file_details->nFilterIndex == 2) 6232 filename = from_unicode (
6026 { 6233 make_unibyte_string (
6027 /* "Directories" selected - strip dummy file name. */ 6234 (char*) filename_buf,
6028 char * last = strrchr (filename, '/'); 6235 /* we get one of the two final 0 bytes for free. */
6029 *last = '\0'; 6236 1 + sizeof (wchar_t) * wcslen (filename_buf)));
6030 } 6237#else /* !NTGUI_UNICODE */
6031 6238 dostounix_filename (filename_buf);
6032 file = DECODE_FILE (build_string (filename)); 6239 filename = DECODE_FILE (build_string (filename_buf));
6240#endif /* NTGUI_UNICODE */
6241
6242#ifdef CYGWIN
6243 filename = Fcygwin_convert_path_from_windows (filename, Qt);
6244#endif /* CYGWIN */
6245
6246 /* Strip the dummy filename off the end of the string if we
6247 added it to select a directory. */
6248 if (file_details->nFilterIndex == 2)
6249 {
6250 filename = Ffile_name_directory (filename);
6251 }
6033 } 6252 }
6034 /* User canceled the dialog without making a selection. */ 6253 /* User canceled the dialog without making a selection. */
6035 else if (!CommDlgExtendedError ()) 6254 else if (!CommDlgExtendedError ())
6036 file = Qnil; 6255 filename = Qnil;
6037 /* An error occurred, fallback on reading from the mini-buffer. */ 6256 /* An error occurred, fallback on reading from the mini-buffer. */
6038 else 6257 else
6039 file = Fcompleting_read (prompt, intern ("read-file-name-internal"), 6258 filename = Fcompleting_read (
6040 dir, mustmatch, dir, Qfile_name_history, 6259 orig_prompt,
6041 default_filename, Qnil); 6260 intern ("read-file-name-internal"),
6261 orig_dir,
6262 mustmatch,
6263 orig_dir,
6264 Qfile_name_history,
6265 default_filename,
6266 Qnil);
6042 6267
6043 file = unbind_to (count, file); 6268 UNGCPRO;
6044 } 6269 }
6045 6270
6046 UNGCPRO;
6047
6048 /* Make "Cancel" equivalent to C-g. */ 6271 /* Make "Cancel" equivalent to C-g. */
6049 if (NILP (file)) 6272 if (NILP (filename))
6050 Fsignal (Qquit, Qnil); 6273 Fsignal (Qquit, Qnil);
6051 6274
6052 return unbind_to (count, file); 6275 RETURN_UNGCPRO (filename);
6053} 6276}
6054 6277
6055 6278
6279#ifdef WINDOWSNT
6056/* Moving files to the system recycle bin. 6280/* Moving files to the system recycle bin.
6057 Used by `move-file-to-trash' instead of the default moving to ~/.Trash */ 6281 Used by `move-file-to-trash' instead of the default moving to ~/.Trash */
6058DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash, 6282DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
@@ -6106,6 +6330,8 @@ DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
6106 return Qnil; 6330 return Qnil;
6107} 6331}
6108 6332
6333#endif /* WINDOWSNT */
6334
6109 6335
6110/*********************************************************************** 6336/***********************************************************************
6111 w32 specialized functions 6337 w32 specialized functions
@@ -6523,7 +6749,7 @@ The following %-sequences are provided:
6523 else 6749 else
6524 { 6750 {
6525 char buffer[16]; 6751 char buffer[16];
6526 _snprintf (buffer, 16, "%d", system_status.BatteryLifePercent); 6752 snprintf (buffer, 16, "%d", system_status.BatteryLifePercent);
6527 load_percentage = build_string (buffer); 6753 load_percentage = build_string (buffer);
6528 } 6754 }
6529 6755
@@ -6534,18 +6760,18 @@ The following %-sequences are provided:
6534 long m; 6760 long m;
6535 float h; 6761 float h;
6536 char buffer[16]; 6762 char buffer[16];
6537 _snprintf (buffer, 16, "%ld", seconds_left); 6763 snprintf (buffer, 16, "%ld", seconds_left);
6538 seconds = build_string (buffer); 6764 seconds = build_string (buffer);
6539 6765
6540 m = seconds_left / 60; 6766 m = seconds_left / 60;
6541 _snprintf (buffer, 16, "%ld", m); 6767 snprintf (buffer, 16, "%ld", m);
6542 minutes = build_string (buffer); 6768 minutes = build_string (buffer);
6543 6769
6544 h = seconds_left / 3600.0; 6770 h = seconds_left / 3600.0;
6545 _snprintf (buffer, 16, "%3.1f", h); 6771 snprintf (buffer, 16, "%3.1f", h);
6546 hours = build_string (buffer); 6772 hours = build_string (buffer);
6547 6773
6548 _snprintf (buffer, 16, "%ld:%02ld", m / 60, m % 60); 6774 snprintf (buffer, 16, "%ld:%02ld", m / 60, m % 60);
6549 remain = build_string (buffer); 6775 remain = build_string (buffer);
6550 } 6776 }
6551 6777
@@ -6707,10 +6933,10 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
6707 { 6933 {
6708 /* a remote printer */ 6934 /* a remote printer */
6709 if (*ppi2->pServerName == '\\') 6935 if (*ppi2->pServerName == '\\')
6710 _snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName, 6936 snprintf (pname_buf, sizeof (pname_buf), "%s\\%s", ppi2->pServerName,
6711 ppi2->pShareName); 6937 ppi2->pShareName);
6712 else 6938 else
6713 _snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName, 6939 snprintf (pname_buf, sizeof (pname_buf), "\\\\%s\\%s", ppi2->pServerName,
6714 ppi2->pShareName); 6940 ppi2->pShareName);
6715 pname_buf[sizeof (pname_buf) - 1] = '\0'; 6941 pname_buf[sizeof (pname_buf) - 1] = '\0';
6716 } 6942 }
@@ -6729,6 +6955,294 @@ DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
6729 return build_string (pname_buf); 6955 return build_string (pname_buf);
6730} 6956}
6731 6957
6958
6959/* Equivalent of strerror for W32 error codes. */
6960char *
6961w32_strerror (int error_no)
6962{
6963 static char buf[500];
6964 DWORD ret;
6965
6966 if (error_no == 0)
6967 error_no = GetLastError ();
6968
6969 ret = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
6970 FORMAT_MESSAGE_IGNORE_INSERTS,
6971 NULL,
6972 error_no,
6973 0, /* choose most suitable language */
6974 buf, sizeof (buf), NULL);
6975
6976 while (ret > 0 && (buf[ret - 1] == '\n' ||
6977 buf[ret - 1] == '\r' ))
6978 --ret;
6979 buf[ret] = '\0';
6980 if (!ret)
6981 sprintf (buf, "w32 error %u", error_no);
6982
6983 return buf;
6984}
6985
6986/* For convenience when debugging. (You cannot call GetLastError
6987 directly from GDB: it will crash, because it uses the __stdcall
6988 calling convention, not the _cdecl convention assumed by GDB.) */
6989DWORD
6990w32_last_error (void)
6991{
6992 return GetLastError ();
6993}
6994
6995/* Cache information describing the NT system for later use. */
6996void
6997cache_system_info (void)
6998{
6999 union
7000 {
7001 struct info
7002 {
7003 char major;
7004 char minor;
7005 short platform;
7006 } info;
7007 DWORD data;
7008 } version;
7009
7010 /* Cache the version of the operating system. */
7011 version.data = GetVersion ();
7012 w32_major_version = version.info.major;
7013 w32_minor_version = version.info.minor;
7014
7015 if (version.info.platform & 0x8000)
7016 os_subtype = OS_9X;
7017 else
7018 os_subtype = OS_NT;
7019
7020 /* Cache page size, allocation unit, processor type, etc. */
7021 GetSystemInfo (&sysinfo_cache);
7022 syspage_mask = sysinfo_cache.dwPageSize - 1;
7023
7024 /* Cache os info. */
7025 osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
7026 GetVersionEx (&osinfo_cache);
7027
7028 w32_build_number = osinfo_cache.dwBuildNumber;
7029 if (os_subtype == OS_9X)
7030 w32_build_number &= 0xffff;
7031
7032 w32_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
7033}
7034
7035#ifdef EMACSDEBUG
7036void
7037_DebPrint (const char *fmt, ...)
7038{
7039 char buf[1024];
7040 va_list args;
7041
7042 va_start (args, fmt);
7043 vsprintf (buf, fmt, args);
7044 va_end (args);
7045#if CYGWIN
7046 fprintf (stderr, "%s", buf);
7047#endif
7048 OutputDebugString (buf);
7049}
7050#endif
7051
7052int
7053w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state)
7054{
7055 int cur_state = (GetKeyState (vk_code) & 1);
7056
7057 if (NILP (new_state)
7058 || (NUMBERP (new_state)
7059 && ((XUINT (new_state)) & 1) != cur_state))
7060 {
7061#ifdef WINDOWSNT
7062 faked_key = vk_code;
7063#endif /* WINDOWSNT */
7064
7065 keybd_event ((BYTE) vk_code,
7066 (BYTE) MapVirtualKey (vk_code, 0),
7067 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
7068 keybd_event ((BYTE) vk_code,
7069 (BYTE) MapVirtualKey (vk_code, 0),
7070 KEYEVENTF_EXTENDEDKEY | 0, 0);
7071 keybd_event ((BYTE) vk_code,
7072 (BYTE) MapVirtualKey (vk_code, 0),
7073 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
7074 cur_state = !cur_state;
7075 }
7076
7077 return cur_state;
7078}
7079
7080/* Translate console modifiers to emacs modifiers.
7081 German keyboard support (Kai Morgan Zeise 2/18/95). */
7082int
7083w32_kbd_mods_to_emacs (DWORD mods, WORD key)
7084{
7085 int retval = 0;
7086
7087 /* If we recognize right-alt and left-ctrl as AltGr, and it has been
7088 pressed, first remove those modifiers. */
7089 if (!NILP (Vw32_recognize_altgr)
7090 && (mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
7091 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
7092 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED);
7093
7094 if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED))
7095 retval = ((NILP (Vw32_alt_is_meta)) ? alt_modifier : meta_modifier);
7096
7097 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
7098 {
7099 retval |= ctrl_modifier;
7100 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
7101 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
7102 retval |= meta_modifier;
7103 }
7104
7105 if (mods & LEFT_WIN_PRESSED)
7106 retval |= w32_key_to_modifier (VK_LWIN);
7107 if (mods & RIGHT_WIN_PRESSED)
7108 retval |= w32_key_to_modifier (VK_RWIN);
7109 if (mods & APPS_PRESSED)
7110 retval |= w32_key_to_modifier (VK_APPS);
7111 if (mods & SCROLLLOCK_ON)
7112 retval |= w32_key_to_modifier (VK_SCROLL);
7113
7114 /* Just in case someone wanted the original behavior, make it
7115 optional by setting w32-capslock-is-shiftlock to t. */
7116 if (NILP (Vw32_capslock_is_shiftlock)
7117 /* Keys that should _not_ be affected by CapsLock. */
7118 && ( (key == VK_BACK)
7119 || (key == VK_TAB)
7120 || (key == VK_CLEAR)
7121 || (key == VK_RETURN)
7122 || (key == VK_ESCAPE)
7123 || ((key >= VK_SPACE) && (key <= VK_HELP))
7124 || ((key >= VK_NUMPAD0) && (key <= VK_F24))
7125 || ((key >= VK_NUMPAD_CLEAR) && (key <= VK_NUMPAD_DELETE))
7126 ))
7127 {
7128 /* Only consider shift state. */
7129 if ((mods & SHIFT_PRESSED) != 0)
7130 retval |= shift_modifier;
7131 }
7132 else
7133 {
7134 /* Ignore CapsLock state if not enabled. */
7135 if (NILP (Vw32_enable_caps_lock))
7136 mods &= ~CAPSLOCK_ON;
7137 if ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) != 0)
7138 retval |= shift_modifier;
7139 }
7140
7141 return retval;
7142}
7143
7144/* The return code indicates key code size. cpID is the codepage to
7145 use for translation to Unicode; -1 means use the current console
7146 input codepage. */
7147int
7148w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId)
7149{
7150 unsigned int key_code = event->wVirtualKeyCode;
7151 unsigned int mods = event->dwControlKeyState;
7152 BYTE keystate[256];
7153 static BYTE ansi_code[4];
7154 static int isdead = 0;
7155
7156 if (isdead == 2)
7157 {
7158 event->uChar.AsciiChar = ansi_code[2];
7159 isdead = 0;
7160 return 1;
7161 }
7162 if (event->uChar.AsciiChar != 0)
7163 return 1;
7164
7165 memset (keystate, 0, sizeof (keystate));
7166 keystate[key_code] = 0x80;
7167 if (mods & SHIFT_PRESSED)
7168 keystate[VK_SHIFT] = 0x80;
7169 if (mods & CAPSLOCK_ON)
7170 keystate[VK_CAPITAL] = 1;
7171 /* If we recognize right-alt and left-ctrl as AltGr, set the key
7172 states accordingly before invoking ToAscii. */
7173 if (!NILP (Vw32_recognize_altgr)
7174 && (mods & LEFT_CTRL_PRESSED) && (mods & RIGHT_ALT_PRESSED))
7175 {
7176 keystate[VK_CONTROL] = 0x80;
7177 keystate[VK_LCONTROL] = 0x80;
7178 keystate[VK_MENU] = 0x80;
7179 keystate[VK_RMENU] = 0x80;
7180 }
7181
7182#if 0
7183 /* Because of an OS bug, ToAscii corrupts the stack when called to
7184 convert a dead key in console mode on NT4. Unfortunately, trying
7185 to check for dead keys using MapVirtualKey doesn't work either -
7186 these functions apparently use internal information about keyboard
7187 layout which doesn't get properly updated in console programs when
7188 changing layout (though apparently it gets partly updated,
7189 otherwise ToAscii wouldn't crash). */
7190 if (is_dead_key (event->wVirtualKeyCode))
7191 return 0;
7192#endif
7193
7194 /* On NT, call ToUnicode instead and then convert to the current
7195 console input codepage. */
7196 if (os_subtype == OS_NT)
7197 {
7198 WCHAR buf[128];
7199
7200 isdead = ToUnicode (event->wVirtualKeyCode, event->wVirtualScanCode,
7201 keystate, buf, 128, 0);
7202 if (isdead > 0)
7203 {
7204 /* When we are called from the GUI message processing code,
7205 we are passed the current keyboard codepage, a positive
7206 number, to use below. */
7207 if (cpId == -1)
7208 cpId = GetConsoleCP ();
7209
7210 event->uChar.UnicodeChar = buf[isdead - 1];
7211 isdead = WideCharToMultiByte (cpId, 0, buf, isdead,
7212 ansi_code, 4, NULL, NULL);
7213 }
7214 else
7215 isdead = 0;
7216 }
7217 else
7218 {
7219 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode,
7220 keystate, (LPWORD) ansi_code, 0);
7221 }
7222
7223 if (isdead == 0)
7224 return 0;
7225 event->uChar.AsciiChar = ansi_code[0];
7226 return isdead;
7227}
7228
7229
7230void
7231w32_sys_ring_bell (struct frame *f)
7232{
7233 if (sound_type == 0xFFFFFFFF)
7234 {
7235 Beep (666, 100);
7236 }
7237 else if (sound_type == MB_EMACS_SILENT)
7238 {
7239 /* Do nothing. */
7240 }
7241 else
7242 MessageBeep (sound_type);
7243}
7244
7245
6732/*********************************************************************** 7246/***********************************************************************
6733 Initialization 7247 Initialization
6734 ***********************************************************************/ 7248 ***********************************************************************/
@@ -7095,6 +7609,7 @@ only be necessary if the default setting causes problems. */);
7095 7609
7096 defsubr (&Sfile_system_info); 7610 defsubr (&Sfile_system_info);
7097 defsubr (&Sdefault_printer_name); 7611 defsubr (&Sdefault_printer_name);
7612 defsubr (&Sset_message_beep);
7098 7613
7099 check_window_system_func = check_w32; 7614 check_window_system_func = check_w32;
7100 7615
@@ -7111,7 +7626,9 @@ only be necessary if the default setting causes problems. */);
7111 staticpro (&last_show_tip_args); 7626 staticpro (&last_show_tip_args);
7112 7627
7113 defsubr (&Sx_file_dialog); 7628 defsubr (&Sx_file_dialog);
7629#ifdef WINDOWSNT
7114 defsubr (&Ssystem_move_file_to_trash); 7630 defsubr (&Ssystem_move_file_to_trash);
7631#endif
7115} 7632}
7116 7633
7117 7634
@@ -7193,9 +7710,3 @@ emacs_abort (void)
7193 } 7710 }
7194} 7711}
7195 7712
7196/* For convenience when debugging. */
7197int
7198w32_last_error (void)
7199{
7200 return GetLastError ();
7201}
diff --git a/src/w32font.c b/src/w32font.c
index 833b7cdfb25..d7d25d89939 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -18,6 +18,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20#include <windows.h> 20#include <windows.h>
21#include <stdio.h>
21#include <math.h> 22#include <math.h>
22#include <ctype.h> 23#include <ctype.h>
23#include <commdlg.h> 24#include <commdlg.h>
@@ -1434,6 +1435,9 @@ w32font_coverage_ok (FONTSIGNATURE * coverage, BYTE charset)
1434 return 1; 1435 return 1;
1435} 1436}
1436 1437
1438#ifndef WINDOWSNT
1439#define _strlwr strlwr
1440#endif /* !WINDOWSNT */
1437 1441
1438static int 1442static int
1439check_face_name (LOGFONT *font, char *full_name) 1443check_face_name (LOGFONT *font, char *full_name)
diff --git a/src/w32heap.c b/src/w32heap.c
index 8b9b19ea35d..311e1064434 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -23,65 +23,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include <config.h> 23#include <config.h>
24#include <stdio.h> 24#include <stdio.h>
25 25
26#include "w32common.h"
26#include "w32heap.h" 27#include "w32heap.h"
27#include "lisp.h" /* for VALMASK */ 28#include "lisp.h" /* for VALMASK */
28 29
29#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL))) 30#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL)))
30 31
31/* This gives us the page size and the size of the allocation unit on NT. */
32SYSTEM_INFO sysinfo_cache;
33
34/* This gives us version, build, and platform identification. */
35OSVERSIONINFO osinfo_cache;
36
37size_t syspage_mask = 0;
38
39/* The major and minor versions of NT. */
40int w32_major_version;
41int w32_minor_version;
42int w32_build_number;
43
44/* Distinguish between Windows NT and Windows 95. */
45int os_subtype;
46
47/* Cache information describing the NT system for later use. */
48void
49cache_system_info (void)
50{
51 union
52 {
53 struct info
54 {
55 char major;
56 char minor;
57 short platform;
58 } info;
59 DWORD data;
60 } version;
61
62 /* Cache the version of the operating system. */
63 version.data = GetVersion ();
64 w32_major_version = version.info.major;
65 w32_minor_version = version.info.minor;
66
67 if (version.info.platform & 0x8000)
68 os_subtype = OS_9X;
69 else
70 os_subtype = OS_NT;
71
72 /* Cache page size, allocation unit, processor type, etc. */
73 GetSystemInfo (&sysinfo_cache);
74 syspage_mask = sysinfo_cache.dwPageSize - 1;
75
76 /* Cache os info. */
77 osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
78 GetVersionEx (&osinfo_cache);
79
80 w32_build_number = osinfo_cache.dwBuildNumber;
81 if (os_subtype == OS_9X)
82 w32_build_number &= 0xffff;
83}
84
85/* Emulate getpagesize. */ 32/* Emulate getpagesize. */
86int 33int
87getpagesize (void) 34getpagesize (void)
diff --git a/src/w32heap.h b/src/w32heap.h
index aae4845b4cc..1630864875f 100644
--- a/src/w32heap.h
+++ b/src/w32heap.h
@@ -24,9 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 24
25#include <windows.h> 25#include <windows.h>
26 26
27#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
28#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
29
30/* 27/*
31 * Heap related stuff. 28 * Heap related stuff.
32 */ 29 */
@@ -34,28 +31,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
34#define get_committed_heap_size() (get_data_end () - get_data_start ()) 31#define get_committed_heap_size() (get_data_end () - get_data_start ())
35#define get_heap_start() get_data_start () 32#define get_heap_start() get_data_start ()
36#define get_heap_end() get_data_end () 33#define get_heap_end() get_data_end ()
37#define get_page_size() sysinfo_cache.dwPageSize
38#define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
39#define get_processor_type() sysinfo_cache.dwProcessorType
40#define get_w32_major_version() w32_major_version
41#define get_w32_minor_version() w32_minor_version
42 34
43extern unsigned char *get_data_start (void); 35extern unsigned char *get_data_start (void);
44extern unsigned char *get_data_end (void); 36extern unsigned char *get_data_end (void);
45extern size_t reserved_heap_size; 37extern size_t reserved_heap_size;
46extern SYSTEM_INFO sysinfo_cache;
47extern OSVERSIONINFO osinfo_cache;
48extern BOOL using_dynamic_heap; 38extern BOOL using_dynamic_heap;
49extern int w32_major_version;
50extern int w32_minor_version;
51extern int w32_build_number;
52
53enum {
54 OS_9X = 1,
55 OS_NT
56};
57
58extern int os_subtype;
59 39
60/* Emulation of Unix sbrk(). */ 40/* Emulation of Unix sbrk(). */
61extern void *sbrk (ptrdiff_t size); 41extern void *sbrk (ptrdiff_t size);
@@ -66,9 +46,6 @@ extern void init_heap (void);
66/* Round the heap to this size. */ 46/* Round the heap to this size. */
67extern void round_heap (size_t size); 47extern void round_heap (size_t size);
68 48
69/* Cache system info, e.g., the NT page size. */
70extern void cache_system_info (void);
71
72/* ----------------------------------------------------------------- */ 49/* ----------------------------------------------------------------- */
73/* Useful routines for manipulating memory-mapped files. */ 50/* Useful routines for manipulating memory-mapped files. */
74 51
diff --git a/src/w32inevt.c b/src/w32inevt.c
index ebb95dcace5..c322d3a0b44 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -70,6 +70,9 @@ w32_read_console_input (HANDLE h, INPUT_RECORD *rec, DWORD recsize,
70 : ReadConsoleInputA (h, rec, recsize, waiting)); 70 : ReadConsoleInputA (h, rec, recsize, waiting));
71} 71}
72 72
73/* Set by w32_console_toggle_lock_key. */
74int faked_key;
75
73static int 76static int
74fill_queue (BOOL block) 77fill_queue (BOOL block)
75{ 78{
@@ -110,67 +113,7 @@ get_frame (void)
110 113
111/* Translate console modifiers to emacs modifiers. 114/* Translate console modifiers to emacs modifiers.
112 German keyboard support (Kai Morgan Zeise 2/18/95). */ 115 German keyboard support (Kai Morgan Zeise 2/18/95). */
113int
114w32_kbd_mods_to_emacs (DWORD mods, WORD key)
115{
116 int retval = 0;
117
118 /* If we recognize right-alt and left-ctrl as AltGr, and it has been
119 pressed, first remove those modifiers. */
120 if (!NILP (Vw32_recognize_altgr)
121 && (mods & (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
122 == (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED))
123 mods &= ~ (RIGHT_ALT_PRESSED | LEFT_CTRL_PRESSED);
124 116
125 if (mods & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED))
126 retval = ((NILP (Vw32_alt_is_meta)) ? alt_modifier : meta_modifier);
127
128 if (mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
129 {
130 retval |= ctrl_modifier;
131 if ((mods & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
132 == (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED))
133 retval |= meta_modifier;
134 }
135
136 if (mods & LEFT_WIN_PRESSED)
137 retval |= w32_key_to_modifier (VK_LWIN);
138 if (mods & RIGHT_WIN_PRESSED)
139 retval |= w32_key_to_modifier (VK_RWIN);
140 if (mods & APPS_PRESSED)
141 retval |= w32_key_to_modifier (VK_APPS);
142 if (mods & SCROLLLOCK_ON)
143 retval |= w32_key_to_modifier (VK_SCROLL);
144
145 /* Just in case someone wanted the original behavior, make it
146 optional by setting w32-capslock-is-shiftlock to t. */
147 if (NILP (Vw32_capslock_is_shiftlock)
148 /* Keys that should _not_ be affected by CapsLock. */
149 && ( (key == VK_BACK)
150 || (key == VK_TAB)
151 || (key == VK_CLEAR)
152 || (key == VK_RETURN)
153 || (key == VK_ESCAPE)
154 || ((key >= VK_SPACE) && (key <= VK_HELP))
155 || ((key >= VK_NUMPAD0) && (key <= VK_F24))
156 || ((key >= VK_NUMPAD_CLEAR) && (key <= VK_NUMPAD_DELETE))
157 ))
158 {
159 /* Only consider shift state. */
160 if ((mods & SHIFT_PRESSED) != 0)
161 retval |= shift_modifier;
162 }
163 else
164 {
165 /* Ignore CapsLock state if not enabled. */
166 if (NILP (Vw32_enable_caps_lock))
167 mods &= ~CAPSLOCK_ON;
168 if ((mods & (SHIFT_PRESSED | CAPSLOCK_ON)) != 0)
169 retval |= shift_modifier;
170 }
171
172 return retval;
173}
174 117
175#if 0 118#if 0
176/* Return nonzero if the virtual key is a dead key. */ 119/* Return nonzero if the virtual key is a dead key. */
@@ -187,90 +130,7 @@ is_dead_key (int wparam)
187/* The return code indicates key code size. cpID is the codepage to 130/* The return code indicates key code size. cpID is the codepage to
188 use for translation to Unicode; -1 means use the current console 131 use for translation to Unicode; -1 means use the current console
189 input codepage. */ 132 input codepage. */
190int
191w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId)
192{
193 unsigned int key_code = event->wVirtualKeyCode;
194 unsigned int mods = event->dwControlKeyState;
195 BYTE keystate[256];
196 static BYTE ansi_code[4];
197 static int isdead = 0;
198 133
199 if (isdead == 2)
200 {
201 event->uChar.AsciiChar = ansi_code[2];
202 isdead = 0;
203 return 1;
204 }
205 if (event->uChar.AsciiChar != 0)
206 return 1;
207
208 memset (keystate, 0, sizeof (keystate));
209 keystate[key_code] = 0x80;
210 if (mods & SHIFT_PRESSED)
211 keystate[VK_SHIFT] = 0x80;
212 if (mods & CAPSLOCK_ON)
213 keystate[VK_CAPITAL] = 1;
214 /* If we recognize right-alt and left-ctrl as AltGr, set the key
215 states accordingly before invoking ToAscii. */
216 if (!NILP (Vw32_recognize_altgr)
217 && (mods & LEFT_CTRL_PRESSED) && (mods & RIGHT_ALT_PRESSED))
218 {
219 keystate[VK_CONTROL] = 0x80;
220 keystate[VK_LCONTROL] = 0x80;
221 keystate[VK_MENU] = 0x80;
222 keystate[VK_RMENU] = 0x80;
223 }
224
225#if 0
226 /* Because of an OS bug, ToAscii corrupts the stack when called to
227 convert a dead key in console mode on NT4. Unfortunately, trying
228 to check for dead keys using MapVirtualKey doesn't work either -
229 these functions apparently use internal information about keyboard
230 layout which doesn't get properly updated in console programs when
231 changing layout (though apparently it gets partly updated,
232 otherwise ToAscii wouldn't crash). */
233 if (is_dead_key (event->wVirtualKeyCode))
234 return 0;
235#endif
236
237 /* On NT, call ToUnicode instead and then convert to the current
238 console input codepage. */
239 if (os_subtype == OS_NT)
240 {
241 WCHAR buf[128];
242
243 isdead = ToUnicode (event->wVirtualKeyCode, event->wVirtualScanCode,
244 keystate, buf, 128, 0);
245 if (isdead > 0)
246 {
247 /* When we are called from the GUI message processing code,
248 we are passed the current keyboard codepage, a positive
249 number, to use below. */
250 if (cpId == -1)
251 cpId = GetConsoleCP ();
252
253 event->uChar.UnicodeChar = buf[isdead - 1];
254 isdead = WideCharToMultiByte (cpId, 0, buf, isdead,
255 ansi_code, 4, NULL, NULL);
256 }
257 else
258 isdead = 0;
259 }
260 else
261 {
262 isdead = ToAscii (event->wVirtualKeyCode, event->wVirtualScanCode,
263 keystate, (LPWORD) ansi_code, 0);
264 }
265
266 if (isdead == 0)
267 return 0;
268 event->uChar.AsciiChar = ansi_code[0];
269 return isdead;
270}
271
272
273static int faked_key = 0;
274 134
275/* return code -1 means that event_queue_ptr won't be incremented. 135/* return code -1 means that event_queue_ptr won't be incremented.
276 In other word, this event makes two key codes. (by himi) */ 136 In other word, this event makes two key codes. (by himi) */
@@ -531,32 +391,6 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
531 return 1; 391 return 1;
532} 392}
533 393
534int
535w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state)
536{
537 int cur_state = (GetKeyState (vk_code) & 1);
538
539 if (NILP (new_state)
540 || (NUMBERP (new_state)
541 && ((XUINT (new_state)) & 1) != cur_state))
542 {
543 faked_key = vk_code;
544
545 keybd_event ((BYTE) vk_code,
546 (BYTE) MapVirtualKey (vk_code, 0),
547 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
548 keybd_event ((BYTE) vk_code,
549 (BYTE) MapVirtualKey (vk_code, 0),
550 KEYEVENTF_EXTENDEDKEY | 0, 0);
551 keybd_event ((BYTE) vk_code,
552 (BYTE) MapVirtualKey (vk_code, 0),
553 KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
554 cur_state = !cur_state;
555 }
556
557 return cur_state;
558}
559
560/* Mouse position hook. */ 394/* Mouse position hook. */
561void 395void
562w32_console_mouse_position (FRAME_PTR *f, 396w32_console_mouse_position (FRAME_PTR *f,
diff --git a/src/w32menu.c b/src/w32menu.c
index 0a10f1f0893..36bf9574fdc 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22#include <signal.h> 22#include <signal.h>
23#include <stdio.h> 23#include <stdio.h>
24#include <mbstring.h> 24#include <setjmp.h>
25 25
26#include "lisp.h" 26#include "lisp.h"
27#include "keyboard.h" 27#include "keyboard.h"
@@ -40,6 +40,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40 if this is not done before the other system files. */ 40 if this is not done before the other system files. */
41#include "w32term.h" 41#include "w32term.h"
42 42
43/* Cygwin does not support the multibyte string functions declared in
44 * mbstring.h below --- but that's okay: because Cygwin is
45 * UNICODE-only, we don't need to use these functions anyway. */
46
47#ifndef NTGUI_UNICODE
48#include <mbstring.h>
49#endif /* !NTGUI_UNICODE */
50
43/* Load sys/types.h if not already loaded. 51/* Load sys/types.h if not already loaded.
44 In some systems loading it twice is suicidal. */ 52 In some systems loading it twice is suicidal. */
45#ifndef makedev 53#ifndef makedev
@@ -48,7 +56,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48 56
49#include "dispextern.h" 57#include "dispextern.h"
50 58
51#include "w32heap.h" /* for osinfo_cache */ 59#include "w32common.h" /* for osinfo_cache */
52 60
53#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */ 61#undef HAVE_DIALOGS /* TODO: Implement native dialogs. */
54 62
@@ -78,10 +86,17 @@ typedef int (WINAPI * MessageBoxW_Proc) (
78 IN WCHAR *caption, 86 IN WCHAR *caption,
79 IN UINT type); 87 IN UINT type);
80 88
89#ifdef NTGUI_UNICODE
90#define get_menu_item_info GetMenuItemInfoA
91#define set_menu_item_info SetMenuItemInfoA
92#define unicode_append_menu AppendMenuW
93#define unicode_message_box MessageBoxW
94#else /* !NTGUI_UNICODE */
81GetMenuItemInfoA_Proc get_menu_item_info = NULL; 95GetMenuItemInfoA_Proc get_menu_item_info = NULL;
82SetMenuItemInfoA_Proc set_menu_item_info = NULL; 96SetMenuItemInfoA_Proc set_menu_item_info = NULL;
83AppendMenuW_Proc unicode_append_menu = NULL; 97AppendMenuW_Proc unicode_append_menu = NULL;
84MessageBoxW_Proc unicode_message_box = NULL; 98MessageBoxW_Proc unicode_message_box = NULL;
99#endif /* NTGUI_UNICODE */
85 100
86Lisp_Object Qdebug_on_next_call; 101Lisp_Object Qdebug_on_next_call;
87 102
@@ -98,6 +113,7 @@ static void utf8to16 (unsigned char *, int, WCHAR *);
98static int fill_in_menu (HMENU, widget_value *); 113static int fill_in_menu (HMENU, widget_value *);
99 114
100void w32_free_menu_strings (HWND); 115void w32_free_menu_strings (HWND);
116
101 117
102 118
103/* This is set nonzero after the user activates the menu bar, and set 119/* This is set nonzero after the user activates the menu bar, and set
@@ -1405,6 +1421,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1405 nlen++; 1421 nlen++;
1406 } 1422 }
1407 } 1423 }
1424#ifndef NTGUI_UNICODE
1408 else 1425 else
1409 { 1426 {
1410 /* If encoded with the system codepage, use multibyte string 1427 /* If encoded with the system codepage, use multibyte string
@@ -1415,6 +1432,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1415 nlen++; 1432 nlen++;
1416 } 1433 }
1417 } 1434 }
1435#endif /* !NTGUI_UNICODE */
1418 1436
1419 if (nlen > orig_len) 1437 if (nlen > orig_len)
1420 { 1438 {
@@ -1429,6 +1447,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1429 *q++ = *p; 1447 *q++ = *p;
1430 *q++ = *p++; 1448 *q++ = *p++;
1431 } 1449 }
1450#ifndef NTGUI_UNICODE
1432 else 1451 else
1433 { 1452 {
1434 if (_mbsnextc (p) == '&') 1453 if (_mbsnextc (p) == '&')
@@ -1440,6 +1459,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1440 p = _mbsinc (p); 1459 p = _mbsinc (p);
1441 q = _mbsinc (q); 1460 q = _mbsinc (q);
1442 } 1461 }
1462#endif /* !NTGUI_UNICODE */
1443 } 1463 }
1444 *q = '\0'; 1464 *q = '\0';
1445 } 1465 }
@@ -1486,6 +1506,8 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1486 item != NULL ? (UINT_PTR) item 1506 item != NULL ? (UINT_PTR) item
1487 : (UINT_PTR) wv->call_data, 1507 : (UINT_PTR) wv->call_data,
1488 utf16_string); 1508 utf16_string);
1509
1510#ifndef NTGUI_UNICODE /* Fallback does not apply when always UNICODE */
1489 if (!return_value) 1511 if (!return_value)
1490 { 1512 {
1491 /* On W9x/ME, Unicode menus are not supported, though AppendMenuW 1513 /* On W9x/ME, Unicode menus are not supported, though AppendMenuW
@@ -1504,6 +1526,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1504 if (osinfo_cache.dwPlatformId != VER_PLATFORM_WIN32_NT) 1526 if (osinfo_cache.dwPlatformId != VER_PLATFORM_WIN32_NT)
1505 unicode_append_menu = NULL; 1527 unicode_append_menu = NULL;
1506 } 1528 }
1529#endif /* NTGUI_UNICODE */
1507 1530
1508 if (unicode_append_menu && (fuFlags & MF_OWNERDRAW)) 1531 if (unicode_append_menu && (fuFlags & MF_OWNERDRAW))
1509 local_free (out_string); 1532 local_free (out_string);
@@ -1723,10 +1746,12 @@ syms_of_w32menu (void)
1723void 1746void
1724globals_of_w32menu (void) 1747globals_of_w32menu (void)
1725{ 1748{
1749#ifndef NTGUI_UNICODE
1726 /* See if Get/SetMenuItemInfo functions are available. */ 1750 /* See if Get/SetMenuItemInfo functions are available. */
1727 HMODULE user32 = GetModuleHandle ("user32.dll"); 1751 HMODULE user32 = GetModuleHandle ("user32.dll");
1728 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); 1752 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
1729 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); 1753 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
1730 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW"); 1754 unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
1731 unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW"); 1755 unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW");
1756#endif /* !NTGUI_UNICODE */
1732} 1757}
diff --git a/src/w32proc.c b/src/w32proc.c
index d032b21c59e..7e8183b0e82 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -51,6 +51,7 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
51 51
52#include "lisp.h" 52#include "lisp.h"
53#include "w32.h" 53#include "w32.h"
54#include "w32common.h"
54#include "w32heap.h" 55#include "w32heap.h"
55#include "systime.h" 56#include "systime.h"
56#include "syswait.h" 57#include "syswait.h"
@@ -67,20 +68,6 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
67 68
68Lisp_Object Qhigh, Qlow; 69Lisp_Object Qhigh, Qlow;
69 70
70#ifdef EMACSDEBUG
71void
72_DebPrint (const char *fmt, ...)
73{
74 char buf[1024];
75 va_list args;
76
77 va_start (args, fmt);
78 vsprintf (buf, fmt, args);
79 va_end (args);
80 OutputDebugString (buf);
81}
82#endif
83
84typedef void (_CALLBACK_ *signal_handler) (int); 71typedef void (_CALLBACK_ *signal_handler) (int);
85 72
86/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ 73/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */
diff --git a/src/w32select.c b/src/w32select.c
index 66f9f7ab041..1b10c74cfe9 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -75,12 +75,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
75#include <config.h> 75#include <config.h>
76#include "lisp.h" 76#include "lisp.h"
77#include "w32term.h" /* for all of the w32 includes */ 77#include "w32term.h" /* for all of the w32 includes */
78#include "w32heap.h" /* os_subtype */ 78#include "w32common.h" /* os_subtype */
79#include "keyboard.h"
79#include "blockinput.h" 80#include "blockinput.h"
80#include "charset.h" 81#include "charset.h"
81#include "coding.h" 82#include "coding.h"
82#include "composite.h" 83#include "composite.h"
83 84
85#ifdef CYGWIN
86#include <string.h>
87#include <stdio.h>
88#define _memccpy memccpy
89#endif
84 90
85static HGLOBAL convert_to_handle_as_ascii (void); 91static HGLOBAL convert_to_handle_as_ascii (void);
86static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system); 92static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system);
@@ -388,7 +394,6 @@ run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
388 with global variables and calling strange looking functions. Is 394 with global variables and calling strange looking functions. Is
389 this really the right way to run Lisp callbacks? */ 395 this really the right way to run Lisp callbacks? */
390 396
391 extern int waiting_for_input; /* from keyboard.c */
392 int owfi; 397 int owfi;
393 398
394 block_input (); 399 block_input ();
diff --git a/src/w32select.h b/src/w32select.h
new file mode 100644
index 00000000000..4f4de59f7fe
--- /dev/null
+++ b/src/w32select.h
@@ -0,0 +1,28 @@
1/* Selection processing for Emacs on the Microsoft W32 API.
2
3Copyright (C) 1993-1994, 2001-2012 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 3 of the License, or
10(at your option) any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20#ifndef W32SELECT_H
21#define W32SELECT_H
22#include <windows.h>
23
24extern void syms_of_w32select (void);
25extern void globals_of_w32select (void);
26extern void term_w32select (void);
27
28#endif
diff --git a/src/w32term.c b/src/w32term.c
index 1cc8bd2adef..4cc0b860947 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -51,7 +51,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
51#include "atimer.h" 51#include "atimer.h"
52#include "keymap.h" 52#include "keymap.h"
53 53
54#ifdef WINDOWSNT
54#include "w32heap.h" 55#include "w32heap.h"
56#endif
57
58#ifndef WINDOWSNT
59#include <io.h> /* for get_osfhandle */
60#endif
61
55#include <shellapi.h> 62#include <shellapi.h>
56 63
57#include "font.h" 64#include "font.h"
@@ -121,7 +128,7 @@ typedef struct tagGLYPHSET
121 WCRANGE ranges[1]; 128 WCRANGE ranges[1];
122} GLYPHSET; 129} GLYPHSET;
123 130
124#endif 131#endif /* compiling for pre-Win2k */
125 132
126/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */ 133/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
127BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD); 134BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
@@ -190,6 +197,10 @@ static int volatile input_signal_count;
190static int input_signal_count; 197static int input_signal_count;
191#endif 198#endif
192 199
200#ifdef CYGWIN
201int w32_message_fd = -1;
202#endif /* CYGWIN */
203
193static void x_update_window_end (struct window *, int, int); 204static void x_update_window_end (struct window *, int, int);
194static void w32_handle_tool_bar_click (struct frame *, 205static void w32_handle_tool_bar_click (struct frame *,
195 struct input_event *); 206 struct input_event *);
@@ -4138,6 +4149,9 @@ static char dbcs_lead = 0;
4138 This routine is called by the SIGIO handler. 4149 This routine is called by the SIGIO handler.
4139 We return as soon as there are no more events to be read. 4150 We return as soon as there are no more events to be read.
4140 4151
4152 For an overview of how Emacs input works on MS-Windows, see the
4153 commentary before w32_msg_pump in w32fns.c.
4154
4141 We return the number of characters stored into the buffer, 4155 We return the number of characters stored into the buffer,
4142 thus pretending to be `read'. 4156 thus pretending to be `read'.
4143 4157
@@ -4160,18 +4174,26 @@ w32_read_socket (struct terminal *terminal,
4160 struct frame *f; 4174 struct frame *f;
4161 struct w32_display_info *dpyinfo = &one_w32_display_info; 4175 struct w32_display_info *dpyinfo = &one_w32_display_info;
4162 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 4176 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
4177 static char buf[1];
4163 4178
4164 block_input (); 4179 block_input ();
4165 4180
4166 /* So people can tell when we have read the available input. */ 4181 /* So people can tell when we have read the available input. */
4167 input_signal_count++; 4182 input_signal_count++;
4168 4183
4184 /* Process any incoming thread messages. */
4185 drain_message_queue ();
4186
4169 /* TODO: ghostscript integration. */ 4187 /* TODO: ghostscript integration. */
4170 while (get_next_msg (&msg, FALSE)) 4188 while (get_next_msg (&msg, FALSE))
4171 { 4189 {
4172 struct input_event inev; 4190 struct input_event inev;
4173 int do_help = 0; 4191 int do_help = 0;
4174 4192
4193 /* DebPrint (("w32_read_socket: %s time:%u\n", */
4194 /* w32_name_of_message (msg.msg.message), */
4195 /* msg.msg.time)); */
4196
4175 EVENT_INIT (inev); 4197 EVENT_INIT (inev);
4176 inev.kind = NO_EVENT; 4198 inev.kind = NO_EVENT;
4177 inev.arg = Qnil; 4199 inev.arg = Qnil;
@@ -6304,8 +6326,15 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
6304 w32_defined_color (0, "black", &color, 1); 6326 w32_defined_color (0, "black", &color, 1);
6305 } 6327 }
6306 6328
6307 /* Add the default keyboard. */ 6329#ifdef WINDOWSNT
6330 /* Add the default keyboard. When !WINDOWSNT, we're using the
6331 standard Emacs console handling machinery and don't need an
6332 explicit FD here. */
6308 add_keyboard_wait_descriptor (0); 6333 add_keyboard_wait_descriptor (0);
6334#elif CYGWIN
6335 /* /dev/windows wakes us up when we have a thread message pending. */
6336 add_keyboard_wait_descriptor (w32_message_fd);
6337#endif
6309 6338
6310 /* Create Fringe Bitmaps and store them for later use. 6339 /* Create Fringe Bitmaps and store them for later use.
6311 6340
@@ -6316,15 +6345,6 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
6316 the bitmaps. */ 6345 the bitmaps. */
6317 w32_init_fringe (terminal->rif); 6346 w32_init_fringe (terminal->rif);
6318 6347
6319#ifdef F_SETOWN
6320 fcntl (connection, F_SETOWN, getpid ());
6321#endif /* ! defined (F_SETOWN) */
6322
6323#ifdef SIGIO
6324 if (interrupt_input)
6325 init_sigio (connection);
6326#endif /* ! defined (SIGIO) */
6327
6328 unblock_input (); 6348 unblock_input ();
6329 6349
6330 return dpyinfo; 6350 return dpyinfo;
@@ -6374,6 +6394,7 @@ x_delete_display (struct w32_display_info *dpyinfo)
6374 6394
6375 w32_reset_fringes (); 6395 w32_reset_fringes ();
6376} 6396}
6397
6377 6398
6378/* Set up use of W32. */ 6399/* Set up use of W32. */
6379 6400
@@ -6411,6 +6432,11 @@ w32_initialize (void)
6411 set_user_model (L"GNU.Emacs"); 6432 set_user_model (L"GNU.Emacs");
6412 } 6433 }
6413 6434
6435#ifdef CYGWIN
6436 if ((w32_message_fd = open ("/dev/windows", O_RDWR | O_CLOEXEC)) == -1)
6437 fatal ("opening /dev/windows: %s", strerror (errno));
6438#endif /* CYGWIN */
6439
6414 /* Initialize w32_use_visible_system_caret based on whether a screen 6440 /* Initialize w32_use_visible_system_caret based on whether a screen
6415 reader is in use. */ 6441 reader is in use. */
6416 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0, 6442 if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
@@ -6571,4 +6597,6 @@ With MS Windows or Nextstep, the value is t. */);
6571 6597
6572 staticpro (&last_mouse_motion_frame); 6598 staticpro (&last_mouse_motion_frame);
6573 last_mouse_motion_frame = Qnil; 6599 last_mouse_motion_frame = Qnil;
6600
6601 Fprovide (intern_c_string ("w32"), Qnil);
6574} 6602}
diff --git a/src/w32term.h b/src/w32term.h
index fcaccc4d624..83f9e7b98dc 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19/* Added by Kevin Gallo */ 19/* Added by Kevin Gallo */
20 20
21#include "w32gui.h" 21#include "w32gui.h"
22#include "frame.h"
23#include "atimer.h"
22 24
23 25
24#define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0) 26#define BLACK_PIX_DEFAULT(f) PALETTERGB(0,0,0)
@@ -195,11 +197,45 @@ Lisp_Object display_x_get_resource (struct w32_display_info *,
195 Lisp_Object, Lisp_Object, 197 Lisp_Object, Lisp_Object,
196 Lisp_Object, Lisp_Object); 198 Lisp_Object, Lisp_Object);
197 199
200extern void x_focus_on_frame (struct frame *f);
201
202/* also defined in xterm.h XXX: factor out to common header */
203
198extern struct w32_display_info *w32_term_init (Lisp_Object, 204extern struct w32_display_info *w32_term_init (Lisp_Object,
199 char *, char *); 205 char *, char *);
200 206extern void check_w32 (void);
207extern int w32_defined_color (FRAME_PTR f, const char *color,
208 XColor *color_def, int alloc);
209extern void x_set_window_size (struct frame *f, int change_grav,
210 int cols, int rows);
201extern int x_display_pixel_height (struct w32_display_info *); 211extern int x_display_pixel_height (struct w32_display_info *);
202extern int x_display_pixel_width (struct w32_display_info *); 212extern int x_display_pixel_width (struct w32_display_info *);
213extern void x_sync (struct frame *);
214extern Lisp_Object x_get_focus_frame (struct frame *);
215extern void x_set_mouse_position (struct frame *f, int h, int v);
216extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
217extern void x_make_frame_visible (struct frame *f);
218extern void x_make_frame_invisible (struct frame *f);
219extern void x_iconify_frame (struct frame *f);
220extern int x_char_width (struct frame *f);
221extern int x_char_height (struct frame *f);
222extern int x_pixel_width (struct frame *f);
223extern int x_pixel_height (struct frame *f);
224extern void x_set_frame_alpha (struct frame *f);
225extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
226extern void x_set_tool_bar_lines (struct frame *f,
227 Lisp_Object value,
228 Lisp_Object oldval);
229extern void x_activate_menubar (struct frame *);
230extern int x_bitmap_icon (struct frame *, Lisp_Object);
231extern void initialize_frame_menubar (struct frame *);
232extern void x_free_frame_resources (struct frame *);
233extern void x_real_positions (struct frame *, int *, int *);
234
235/* w32inevt.c */
236extern int w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId);
237extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
238
203 239
204extern Lisp_Object x_get_focus_frame (struct frame *); 240extern Lisp_Object x_get_focus_frame (struct frame *);
205 241
@@ -584,7 +620,8 @@ do { \
584#define WM_EMACS_SETCURSOR (WM_EMACS_START + 19) 620#define WM_EMACS_SETCURSOR (WM_EMACS_START + 19)
585#define WM_EMACS_PAINT (WM_EMACS_START + 20) 621#define WM_EMACS_PAINT (WM_EMACS_START + 20)
586#define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 21) 622#define WM_EMACS_BRINGTOTOP (WM_EMACS_START + 21)
587#define WM_EMACS_END (WM_EMACS_START + 22) 623#define WM_EMACS_INPUT_READY (WM_EMACS_START + 22)
624#define WM_EMACS_END (WM_EMACS_START + 23)
588 625
589#define WND_FONTWIDTH_INDEX (0) 626#define WND_FONTWIDTH_INDEX (0)
590#define WND_LINEHEIGHT_INDEX (4) 627#define WND_LINEHEIGHT_INDEX (4)
@@ -606,6 +643,8 @@ typedef struct W32Msg {
606 RECT rect; 643 RECT rect;
607} W32Msg; 644} W32Msg;
608 645
646extern BOOL prepend_msg (W32Msg *lpmsg);
647
609/* Structure for recording message when input thread must return a 648/* Structure for recording message when input thread must return a
610 result that depends on lisp thread to compute. Lisp thread can 649 result that depends on lisp thread to compute. Lisp thread can
611 complete deferred messages out of order. */ 650 complete deferred messages out of order. */
@@ -709,3 +748,19 @@ extern HWND w32_system_caret_hwnd;
709extern int w32_system_caret_height; 748extern int w32_system_caret_height;
710extern int w32_system_caret_x; 749extern int w32_system_caret_x;
711extern int w32_system_caret_y; 750extern int w32_system_caret_y;
751
752#if EMACSDEBUG
753extern const char*
754w32_name_of_message (UINT msg);
755#endif /* EMACSDEBUG */
756
757extern void syms_of_w32term (void);
758extern void syms_of_w32menu (void);
759extern void syms_of_w32fns (void);
760
761extern void globals_of_w32menu (void);
762extern void globals_of_w32fns (void);
763
764#ifdef CYGWIN
765extern int w32_message_fd;
766#endif /* CYGWIN */
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 018dd14cb80..cb452571665 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19#include <config.h> 19#include <config.h>
20#include <signal.h> 20#include <signal.h>
21#include <stdio.h> 21#include <stdio.h>
22
22#include "lisp.h" 23#include "lisp.h"
23#include "keyboard.h" 24#include "keyboard.h"
24#include "frame.h" 25#include "frame.h"
@@ -32,7 +33,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#define myfree(lp) GlobalFreePtr (lp) 33#define myfree(lp) GlobalFreePtr (lp)
33 34
34CRITICAL_SECTION critsect; 35CRITICAL_SECTION critsect;
36
37#ifdef WINDOWSNT
35extern HANDLE keyboard_handle; 38extern HANDLE keyboard_handle;
39#endif /* WINDOWSNT */
40
36HANDLE input_available = NULL; 41HANDLE input_available = NULL;
37HANDLE interrupt_handle = NULL; 42HANDLE interrupt_handle = NULL;
38 43
@@ -43,7 +48,11 @@ init_crit (void)
43 48
44 /* For safety, input_available should only be reset by get_next_msg 49 /* For safety, input_available should only be reset by get_next_msg
45 when the input queue is empty, so make it a manual reset event. */ 50 when the input queue is empty, so make it a manual reset event. */
46 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL); 51 input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
52
53#ifdef WINDOWSNT
54 keyboard_handle = input_available;
55#endif /* WINDOWSNT */
47 56
48 /* interrupt_handle is signaled when quit (C-g) is detected, so that 57 /* interrupt_handle is signaled when quit (C-g) is detected, so that
49 blocking system calls can be interrupted. We make it a manual 58 blocking system calls can be interrupted. We make it a manual
@@ -240,6 +249,22 @@ get_next_msg (W32Msg * lpmsg, BOOL bWait)
240 return (bRet); 249 return (bRet);
241} 250}
242 251
252extern char * w32_strerror (int error_no);
253
254/* Tell the main thread that we have input available; if the main
255 thread is blocked in select(), we wake it up here. */
256static void
257notify_msg_ready (void)
258{
259 SetEvent (input_available);
260
261#ifdef CYGWIN
262 /* Wakes up the main thread, which is blocked select()ing for /dev/windows,
263 among other files. */
264 (void) PostThreadMessage (dwMainThreadId, WM_EMACS_INPUT_READY, 0, 0);
265#endif /* CYGWIN */
266}
267
243BOOL 268BOOL
244post_msg (W32Msg * lpmsg) 269post_msg (W32Msg * lpmsg)
245{ 270{
@@ -263,8 +288,7 @@ post_msg (W32Msg * lpmsg)
263 } 288 }
264 289
265 lpTail = lpNew; 290 lpTail = lpNew;
266 SetEvent (input_available); 291 notify_msg_ready ();
267
268 leave_crit (); 292 leave_crit ();
269 293
270 return (TRUE); 294 return (TRUE);
@@ -285,7 +309,7 @@ prepend_msg (W32Msg *lpmsg)
285 nQueue++; 309 nQueue++;
286 lpNew->lpNext = lpHead; 310 lpNew->lpNext = lpHead;
287 lpHead = lpNew; 311 lpHead = lpNew;
288 312 notify_msg_ready ();
289 leave_crit (); 313 leave_crit ();
290 314
291 return (TRUE); 315 return (TRUE);
diff --git a/src/window.c b/src/window.c
index 3b974616e38..61d2a8b073f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -43,7 +43,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
43#ifdef HAVE_X_WINDOWS 43#ifdef HAVE_X_WINDOWS
44#include "xterm.h" 44#include "xterm.h"
45#endif /* HAVE_X_WINDOWS */ 45#endif /* HAVE_X_WINDOWS */
46#ifdef WINDOWSNT 46#ifdef HAVE_NTGUI
47#include "w32term.h" 47#include "w32term.h"
48#endif 48#endif
49#ifdef MSDOS 49#ifdef MSDOS
diff --git a/src/xdisp.c b/src/xdisp.c
index 635e7ecd0b2..1e61a74068b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -302,7 +302,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
302#ifdef HAVE_X_WINDOWS 302#ifdef HAVE_X_WINDOWS
303#include "xterm.h" 303#include "xterm.h"
304#endif 304#endif
305#ifdef WINDOWSNT 305#ifdef HAVE_NTGUI
306#include "w32term.h" 306#include "w32term.h"
307#endif 307#endif
308#ifdef HAVE_NS 308#ifdef HAVE_NS
@@ -29379,9 +29379,10 @@ start_hourglass (void)
29379 else 29379 else
29380 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0); 29380 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0);
29381 29381
29382#ifdef WINDOWSNT 29382#ifdef HAVE_NTGUI
29383 extern void w32_note_current_window (void);
29383 w32_note_current_window (); 29384 w32_note_current_window ();
29384#endif 29385#endif /* HAVE_NTGUI */
29385 29386
29386 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 29387 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
29387 show_hourglass, NULL); 29388 show_hourglass, NULL);
diff --git a/src/xfaces.c b/src/xfaces.c
index f861dde2d15..3e6e9dc8ec0 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -227,13 +227,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
227#ifdef HAVE_WINDOW_SYSTEM 227#ifdef HAVE_WINDOW_SYSTEM
228#include TERM_HEADER 228#include TERM_HEADER
229#include "fontset.h" 229#include "fontset.h"
230#ifdef WINDOWSNT 230#ifdef HAVE_NTGUI
231#undef FRAME_X_DISPLAY_INFO 231#undef FRAME_X_DISPLAY_INFO
232#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO 232#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
233#define x_display_info w32_display_info 233#define x_display_info w32_display_info
234#define check_x check_w32 234#define check_x check_w32
235#define GCGraphicsExposures 0 235#define GCGraphicsExposures 0
236#endif /* WINDOWSNT */ 236#endif /* HAVE_NTGUI */
237 237
238#ifdef HAVE_NS 238#ifdef HAVE_NS
239#undef FRAME_X_DISPLAY_INFO 239#undef FRAME_X_DISPLAY_INFO
@@ -625,7 +625,7 @@ x_free_gc (struct frame *f, GC gc)
625 625
626#endif /* HAVE_X_WINDOWS */ 626#endif /* HAVE_X_WINDOWS */
627 627
628#ifdef WINDOWSNT 628#ifdef HAVE_NTGUI
629/* W32 emulation of GCs */ 629/* W32 emulation of GCs */
630 630
631static GC 631static GC
@@ -649,7 +649,7 @@ x_free_gc (struct frame *f, GC gc)
649 xfree (gc); 649 xfree (gc);
650} 650}
651 651
652#endif /* WINDOWSNT */ 652#endif /* HAVE_NTGUI */
653 653
654#ifdef HAVE_NS 654#ifdef HAVE_NS
655/* NS emulation of GCs */ 655/* NS emulation of GCs */
@@ -719,7 +719,7 @@ init_frame_faces (struct frame *f)
719#ifdef HAVE_X_WINDOWS 719#ifdef HAVE_X_WINDOWS
720 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f)) 720 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f))
721#endif 721#endif
722#ifdef WINDOWSNT 722#ifdef HAVE_NTGUI
723 if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f)) 723 if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f))
724#endif 724#endif
725#ifdef HAVE_NS 725#ifdef HAVE_NS
@@ -1098,7 +1098,7 @@ defined_color (struct frame *f, const char *color_name, XColor *color_def,
1098 else if (FRAME_X_P (f)) 1098 else if (FRAME_X_P (f))
1099 return x_defined_color (f, color_name, color_def, alloc); 1099 return x_defined_color (f, color_name, color_def, alloc);
1100#endif 1100#endif
1101#ifdef WINDOWSNT 1101#ifdef HAVE_NTGUI
1102 else if (FRAME_W32_P (f)) 1102 else if (FRAME_W32_P (f))
1103 return w32_defined_color (f, color_name, color_def, alloc); 1103 return w32_defined_color (f, color_name, color_def, alloc);
1104#endif 1104#endif
@@ -3245,7 +3245,7 @@ FRAME 0 means change the face on all frames, and change the default
3245 param = Qbackground_color; 3245 param = Qbackground_color;
3246 } 3246 }
3247#ifdef HAVE_WINDOW_SYSTEM 3247#ifdef HAVE_WINDOW_SYSTEM
3248#ifndef WINDOWSNT 3248#ifndef HAVE_NTGUI
3249 else if (EQ (face, Qscroll_bar)) 3249 else if (EQ (face, Qscroll_bar))
3250 { 3250 {
3251 /* Changing the colors of `scroll-bar' sets frame parameters 3251 /* Changing the colors of `scroll-bar' sets frame parameters
@@ -3255,7 +3255,7 @@ FRAME 0 means change the face on all frames, and change the default
3255 else if (EQ (attr, QCbackground)) 3255 else if (EQ (attr, QCbackground))
3256 param = Qscroll_bar_background; 3256 param = Qscroll_bar_background;
3257 } 3257 }
3258#endif /* not WINDOWSNT */ 3258#endif /* not HAVE_NTGUI */
3259 else if (EQ (face, Qborder)) 3259 else if (EQ (face, Qborder))
3260 { 3260 {
3261 /* Changing background color of `border' sets frame parameter 3261 /* Changing background color of `border' sets frame parameter
@@ -6362,7 +6362,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6362 if (num >= 0 && name[num] == '\n') 6362 if (num >= 0 && name[num] == '\n')
6363 name[num] = 0; 6363 name[num] = 0;
6364 cmap = Fcons (Fcons (build_string (name), 6364 cmap = Fcons (Fcons (build_string (name),
6365#ifdef WINDOWSNT 6365#ifdef HAVE_NTGUI
6366 make_number (RGB (red, green, blue))), 6366 make_number (RGB (red, green, blue))),
6367#else 6367#else
6368 make_number ((red << 16) | (green << 8) | blue)), 6368 make_number ((red << 16) | (green << 8) | blue)),
diff --git a/src/xsettings.c b/src/xsettings.c
index 7c68ff295cf..d23070791d8 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -29,7 +29,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include "keyboard.h" 29#include "keyboard.h"
30#include "blockinput.h" 30#include "blockinput.h"
31#include "termhooks.h" 31#include "termhooks.h"
32#include "termopts.h"
33 32
34#include <X11/Xproto.h> 33#include <X11/Xproto.h>
35 34
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 8067899f931..289aac8492b 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -35,7 +35,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35#include "sysselect.h" 35#include "sysselect.h"
36#include "frame.h" 36#include "frame.h"
37#include "termhooks.h" 37#include "termhooks.h"
38#include "termopts.h"
39#include "xterm.h" 38#include "xterm.h"
40#include "process.h" 39#include "process.h"
41#include "keyboard.h" 40#include "keyboard.h"